api.stargazer.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php
  2. define('BILLING_CONFIG', 'config/billing.ini');
  3. $billing_config = parse_ini_file(BILLING_CONFIG);
  4. include($billing_config['baseconf'] . '/handlers.php');
  5. /**
  6. * Low level billing operations wrapper
  7. * Class just calls ultra low handlers
  8. */
  9. class ApiBilling {
  10. /**
  11. * Creates some stargazer user
  12. *
  13. * @param string $login
  14. *
  15. * @return void
  16. */
  17. function createuser($login) {
  18. $login = trim($login);
  19. billing_createuser($login);
  20. }
  21. /**
  22. * Adds cash to stargazer user account
  23. *
  24. * @param string $login
  25. * @param float $cash
  26. *
  27. * @return void
  28. */
  29. function addcash($login, $cash) {
  30. $login = trim($login);
  31. $cash = trim($cash);
  32. billing_addcash($login, $cash);
  33. }
  34. /**
  35. * Sets user account cash to some value
  36. *
  37. * @param string $login
  38. * @param float $cash
  39. *
  40. * @return void
  41. */
  42. function setcash($login, $cash) {
  43. $login = trim($login);
  44. $cash = trim($cash);
  45. billing_setcash($login, $cash);
  46. }
  47. /**
  48. * Sets credit for some user account
  49. *
  50. * @param string $login
  51. * @param float $credit
  52. */
  53. function setcredit($login, $credit) {
  54. $login = trim($login);
  55. $credit = trim($credit);
  56. billing_setcredit($login, $credit);
  57. }
  58. /**
  59. * Sets credit expiration date
  60. *
  61. * @param string $login
  62. * @param string $creditexpire
  63. *
  64. * @return void
  65. */
  66. function setcreditexpire($login, $creditexpire) {
  67. $login = trim($login);
  68. $creditexpire = trim($creditexpire);
  69. billing_setcreditexpire($login, $creditexpire);
  70. }
  71. /**
  72. * Performs stargazer user reinit
  73. *
  74. * @param string $login
  75. *
  76. * @return void
  77. */
  78. function resetuser($login) {
  79. $login = trim($login);
  80. billing_resetuser($login);
  81. }
  82. /**
  83. * Sets AlwaysOnline flag to existing user
  84. *
  85. * @param string $login
  86. * @param int $state
  87. *
  88. * @return void
  89. */
  90. function setao($login, $state) {
  91. $login = trim($login);
  92. $state = trim($state);
  93. billing_setao($login, $state);
  94. }
  95. /**
  96. * Sets DisabledDetailStat flag to existing user
  97. *
  98. * @param string $login
  99. * @param int $state
  100. *
  101. * @return void
  102. */
  103. function setdstat($login, $state) {
  104. $login = trim($login);
  105. $state = trim($state);
  106. billing_setdstat($login, $state);
  107. }
  108. /**
  109. * Sets IP for some staragazer user login
  110. *
  111. * @param string $login
  112. * @param string $ip
  113. *
  114. * @return void
  115. */
  116. function setip($login, $ip) {
  117. $login = trim($login);
  118. $ip = trim($ip);
  119. billing_setip($login, $ip);
  120. }
  121. /**
  122. * Sets password for existing user
  123. *
  124. * @param string $login
  125. * @param string $password
  126. *
  127. * @return void
  128. */
  129. function setpassword($login, $password) {
  130. $login = trim($login);
  131. $password = trim($password);
  132. billing_setpassword($login, $password);
  133. }
  134. /**
  135. * Changes tariff right now for some user
  136. *
  137. * @param string $login
  138. * @param string $tariff
  139. *
  140. * @return void
  141. */
  142. function settariff($login, $tariff) {
  143. $login = trim($login);
  144. $tariff = trim($tariff);
  145. billing_settariff($login, $tariff);
  146. }
  147. /**
  148. * Sets TariffChange for next month
  149. *
  150. * @param string $login
  151. * @param string $tariff
  152. *
  153. * @return void
  154. */
  155. function settariffnm($login, $tariff) {
  156. $login = trim($login);
  157. $tariff = trim($tariff);
  158. billing_settariffnm($login, $tariff);
  159. }
  160. /**
  161. * Sets Down flag to existing user
  162. *
  163. * @param string $login
  164. * @param int $state
  165. *
  166. * @return void
  167. */
  168. function setdown($login, $state) {
  169. $login = trim($login);
  170. $state = trim($state);
  171. billing_setdown($login, $state);
  172. }
  173. /**
  174. * Sets Passive aka Frozen flag to existing user
  175. *
  176. * @param string $login
  177. * @param int $state
  178. *
  179. * @return void
  180. */
  181. function setpassive($login, $state) {
  182. $login = trim($login);
  183. $state = trim($state);
  184. billing_setpassive($login, $state);
  185. }
  186. /**
  187. * Deletes existing stargazer user
  188. *
  189. * @param string $login
  190. *
  191. * @return void
  192. */
  193. function deleteuser($login) {
  194. $login = trim($login);
  195. billing_deleteuser($login);
  196. }
  197. /**
  198. * Creates new stargazer tariff
  199. *
  200. * @param string $tariff
  201. *
  202. * @return void
  203. */
  204. function createtariff($tariff) {
  205. $tariff = trim($tariff);
  206. billing_createtariff($tariff);
  207. }
  208. /**
  209. * Deletes existing stargazer tariff
  210. *
  211. * @param string $tariff
  212. *
  213. * @return void
  214. */
  215. function deletetariff($tariff) {
  216. $tariff = trim($tariff);
  217. billing_deletetariff($tariff);
  218. }
  219. /**
  220. * Changes existing stargazer tariff options
  221. *
  222. * @param string $tariff
  223. * @param array $options
  224. *
  225. * @return void
  226. */
  227. function edittariff($tariff, $options) {
  228. $tariff = trim($tariff);
  229. billing_edittariff($tariff, $options);
  230. }
  231. }
  232. ?>