refill_config.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. class refill_configControl extends SystemControl
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. }
  8. public function indexOp()
  9. {
  10. if (chksubmit()) {
  11. foreach ($_POST as $key => $value) {
  12. $cache[$key] = $value;
  13. }
  14. wcache('config', ['data' => serialize($_POST)], 'refill-');
  15. showMessage('编辑成功');
  16. } else {
  17. $config = rcache('config', 'refill-');
  18. if (empty($config)) {
  19. $config = [];
  20. } else {
  21. $config = unserialize($config['data']);
  22. }
  23. Tpl::output('config', $config);
  24. Tpl::showpage('refill.config');
  25. }
  26. }
  27. public function interceptOp()
  28. {
  29. $qualitys = [refill\Quality::Normal => '普充',
  30. refill\Quality::Quick => '快充',
  31. refill\Quality::CardKey => '卡密',
  32. refill\Quality::ThirdShop => '三方',
  33. refill\Quality::SlowTwentyFour => '慢24'];
  34. $card_types = [mtopcard\ChinaMobileCard => '移动',
  35. mtopcard\ChinaUnicomCard => '联通',
  36. mtopcard\ChinaTelecomCard => '电信'];
  37. $province_list = mtopcard\ProvinceList;
  38. $province_list[-1] = '全国';
  39. ksort($province_list);
  40. if (chksubmit())
  41. {
  42. $intercept = [];
  43. foreach ($qualitys as $quality_key => $quality_txt)
  44. {
  45. foreach ($card_types as $card_type_key => $card_type_text)
  46. {
  47. $key = $quality_key . '-' . $card_type_key;
  48. foreach ($province_list as $province_key => $province_text)
  49. {
  50. $data_key = $key . '-' . $province_key;
  51. if (array_key_exists($data_key, $_POST)) {
  52. $intercept[$key][$province_key] = intval($_POST[$data_key]);
  53. }
  54. }
  55. }
  56. }
  57. $intercept = serialize($intercept);
  58. Log::record("intercept={$intercept}",Log::DEBUG);
  59. wkcache('refill-intercept',$intercept);
  60. showMessage('编辑成功');
  61. }
  62. else
  63. {
  64. $intercept = rkcache('refill-intercept');
  65. if (empty($intercept)) {
  66. $intercept = [];
  67. } else {
  68. $intercept = unserialize($intercept);
  69. }
  70. Tpl::output('quality_txt', $qualitys);
  71. Tpl::output('card_type_text', $card_types);
  72. Tpl::output('province_list', $province_list);
  73. Tpl::output('intercept', $intercept);
  74. Tpl::showpage('refill.intercept');
  75. }
  76. }
  77. }