setting.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Statistics\Modules;
  3. function setting()
  4. {
  5. $act = isset($_GET['act'])? $_GET['act'] : 'home';
  6. $err_msg = $notice_msg = $suc_msg = $ip_list_str = '';
  7. switch($act)
  8. {
  9. case 'save':
  10. if(empty($_POST['detect_port']))
  11. {
  12. $err_msg = "探测端口不能为空";
  13. break;
  14. }
  15. $detect_port = (int)$_POST['detect_port'];
  16. if($detect_port<0 || $detect_port > 65535)
  17. {
  18. $err_msg = "探测端口不合法";
  19. break;
  20. }
  21. $suc_msg = "保存成功";
  22. \Statistics\Config\Config::$ProviderPort = $detect_port;
  23. saveDetectPortToCache();
  24. break;
  25. default:
  26. $detect_port = \Statistics\Config\Config::$ProviderPort;
  27. }
  28. include ST_ROOT . '/Views/header.tpl.php';
  29. include ST_ROOT . '/Views/setting.tpl.php';
  30. include ST_ROOT . '/Views/footer.tpl.php';
  31. }
  32. function saveDetectPortToCache()
  33. {
  34. foreach(glob(ST_ROOT . '/Config/Cache/*detect_port.cache.php') as $php_file)
  35. {
  36. unlink($php_file);
  37. }
  38. file_put_contents(ST_ROOT . '/Config/Cache/'.time().'.detect_port.cache.php', "<?php\n\\Statistics\\Config\\Config::\$ProviderPort=".var_export(\Statistics\Config\Config::$ProviderPort,true).';');
  39. }