index.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. if (cfr('TARIFFSPEED')) {
  3. $altCfg = $ubillingConfig->getAlter();
  4. if (isset($_GET['tariff'])) {
  5. // show speed editor and create speed if need
  6. $tariff = mysql_real_escape_string($_GET['tariff']);
  7. $existingspeeds = zb_TariffGetAllSpeeds();
  8. if (!isset($existingspeeds[$tariff]['speeddown'])) {
  9. if ($altCfg['BURST_ENABLED']) {
  10. zb_TariffCreateSpeed($tariff, 0, 0, 0, 0, 0, 0);
  11. } else {
  12. zb_TariffCreateSpeed($tariff, 0, 0);
  13. }
  14. $existingspeeds = zb_TariffGetAllSpeeds();
  15. }
  16. $fieldnames = array('fieldname1' => __('Down speed Kbit/s'), 'fieldname2' => __('Up speed Kbit/s'));
  17. $fieldkeys = array('fieldkey1' => 'newspeeddown', 'fieldkey2' => 'newspeedup');
  18. $olddata[1] = $existingspeeds[$tariff]['speeddown'];
  19. $olddata[2] = $existingspeeds[$tariff]['speedup'];
  20. if ($altCfg['BURST_ENABLED']) {
  21. $fieldnames['fieldname3'] = (__('Burst Download speed'));
  22. $fieldnames['fieldname4'] = (__('Burst Upload speed'));
  23. $fieldnames['fieldname5'] = (__('Burst Download Time speed'));
  24. $fieldnames['fieldname6'] = (__('Burst Upload Time speed'));
  25. $fieldkeys['fieldkey3'] = ('newburstdownload');
  26. $fieldkeys['fieldkey4'] = ('newburstupload');
  27. $fieldkeys['fieldkey5'] = ('newbursttimedownload');
  28. $fieldkeys['fieldkey6'] = ('newburstimetupload');
  29. $olddata[3] = $existingspeeds[$tariff]['burstdownload'];
  30. $olddata[4] = $existingspeeds[$tariff]['burstupload'];
  31. $olddata[5] = $existingspeeds[$tariff]['bursttimedownload'];
  32. $olddata[6] = $existingspeeds[$tariff]['burstimetupload'];
  33. show_window(__('Edit speed') . ' ' . $tariff, web_EditorSixStringDataForm($fieldnames, $fieldkeys, $olddata));
  34. } else {
  35. show_window(__('Edit speed') . ' ' . $tariff, web_EditorTwoStringDataForm($fieldnames, $fieldkeys, $olddata));
  36. }
  37. show_window('', wf_BackLink("?module=tariffspeeds", 'Back', true));
  38. // if all ok save speed
  39. if ((isset($_POST['newspeeddown'])) AND ( isset($_POST['newspeedup']))) {
  40. zb_TariffDeleteSpeed($tariff);
  41. $newSpeedDown = trim($_POST['newspeeddown']);
  42. $newSpeedUp = trim($_POST['newspeedup']);
  43. $newBurstDown = isset($_POST['newburstdownload']) ? trim($_POST['newburstdownload']) : '';
  44. $newBurstUp = isset($_POST['newburstupload']) ? trim($_POST['newburstupload']) : '';
  45. $newBurstTimeDown = isset($_POST['newbursttimedownload']) ? trim($_POST['newbursttimedownload']) : '';
  46. $newBurstTimeUp = isset($_POST['newburstimetupload']) ? trim($_POST['newburstimetupload']) : '';
  47. zb_TariffCreateSpeed($tariff, $newSpeedDown, $newSpeedUp, $newBurstDown, $newBurstUp, $newBurstTimeDown, $newBurstTimeUp, $newBurstTimeUp);
  48. rcms_redirect("?module=tariffspeeds&tariff=" . $tariff);
  49. }
  50. } else {
  51. //deleting speed
  52. if (wf_CheckGet(array('deletespeed'))) {
  53. zb_TariffDeleteSpeed($_GET['deletespeed']);
  54. rcms_redirect("?module=tariffspeeds");
  55. }
  56. show_window(__('Tariff speeds'), web_TariffSpeedLister());
  57. show_window('', wf_BackLink('?module=tariffs'));
  58. }
  59. } else {
  60. show_error(__('You cant control this module'));
  61. }
  62. ?>