index.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. if (cfr('TARIFFS')) {
  3. //basic check for availability of any existing traffic classes
  4. $dirs = getAllDirs();
  5. if (empty($dirs)) {
  6. $alert = wf_tag('script', false, '', 'type="text/javascript"');
  7. $alert .= 'alert("' . __('Error') . ': ' . __('No traffic classes available, now you will be redirected to the module with which you can add traffic classes') . '");';
  8. $alert .= wf_tag('script', true);
  9. print($alert);
  10. ubRouting::nav('?module=rules');
  11. die();
  12. }
  13. //new stargazer tariff creation
  14. if (ubRouting::checkPost('options') AND ubRouting::get('action') == 'new') {
  15. $newTariffOptions = ubRouting::post('options');
  16. if (isset($newTariffOptions['TARIFF'])) {
  17. $newTariffName = $newTariffOptions['TARIFF'];
  18. $newTariffName = zb_TariffNameFilter($newTariffName);
  19. //check for tariff fee valid money format
  20. if (zb_checkMoney($newTariffOptions['Fee'])) {
  21. if (!empty($newTariffName)) {
  22. $currentTariffData = zb_TariffGetData($newTariffName);
  23. if (empty($currentTariffData)) {
  24. //The same tariff doesnt exists
  25. $billing->createtariff($newTariffName); //just creating empty tariff
  26. $billing->edittariff($newTariffName, $newTariffOptions); //and set options property to it
  27. log_register('TARIFF CREATE `' . $newTariffName . '`');
  28. ubRouting::nav('?module=tariffs&action=edit&tariffname=' . $newTariffName);
  29. } else {
  30. log_register('TARIFF CREATE `' . $newTariffName . '` FAIL ALREADY EXIST');
  31. }
  32. }
  33. } else {
  34. log_register('TARIFF CREATE `' . $newTariffName . '` FAIL FEE `' . $newTariffOptions['Fee'] . '`');
  35. }
  36. }
  37. }
  38. if (ubRouting::checkGet('action')) {
  39. $tariffName = ubRouting::get('tariffname');
  40. if ($tariffName) {
  41. //existing tariff deletion
  42. if (ubRouting::get('action') == 'delete') {
  43. if (!zb_TariffProtected($tariffName)) { // is tariff is not used by any users?
  44. $billing->deletetariff($tariffName); //tariff deletion here
  45. log_register("TARIFF DELETE `" . $tariffName . "`");
  46. $lousy = new LousyTariffs();
  47. $lousy->flush($tariffName);
  48. zb_TariffDeleteSpeed($tariffName);
  49. $dshaper = new DynamicShaper();
  50. $dshaper->flushTariff($tariffName);
  51. $stealthTariffs = new StealthTariffs();
  52. $stealthTariffs->flush($tariffName);
  53. ubRouting::nav('?module=tariffs');
  54. } else {
  55. log_register("TARIFF DELETE TRY USED `" . $tariffName . "`");
  56. show_error(__('Tariff is used by some users'));
  57. show_window('', wf_BackLink('?module=tariffs', '', true));
  58. }
  59. }
  60. //existing tariff editing here
  61. if (ubRouting::get('action') == 'edit') {
  62. $tariffOptions = ubRouting::post('options');
  63. if (!empty($tariffOptions)) {
  64. if (zb_checkMoney($tariffOptions['Fee'])) {
  65. $billing->edittariff($tariffName, $tariffOptions); //pushing new tariff options to stargazer
  66. log_register('TARIFF CHANGE `' . $tariffName . '`');
  67. ubRouting::nav('?module=tariffs&action=edit&tariffname=' . $tariffName);
  68. } else {
  69. log_register('TARIFF CHANGE `' . $tariffName . '` FAIL FEE `' . $tariffOptions['Fee'] . '`');
  70. }
  71. }
  72. //rendering tariff editing form
  73. show_window(__('Edit Tariff'), web_TariffEditForm($tariffName));
  74. show_window('', wf_BackLink('?module=tariffs'));
  75. }
  76. }
  77. //new tariff creation form rendering
  78. if (ubRouting::get('action') == 'new') {
  79. show_window(__('Create new tariff'), web_TariffCreateForm());
  80. show_window('', wf_BackLink("?module=tariffs"));
  81. }
  82. }
  83. ///just available tariffs list rendering
  84. if (!ubRouting::checkGet('action')) {
  85. show_window(__('Available tariffs'), web_TariffLister());
  86. }
  87. } else {
  88. show_error(__('You cant control this module'));
  89. }