Close.php 901 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. *------Create thems Controller------
  4. *------SCWPHP Version 1.0.0------
  5. *------Dev Model Jions------
  6. *------Create Time 2017-06-23 15:06:45------
  7. */
  8. namespace App\Api\Controller;
  9. use \BaseController\Controller;
  10. // ini_set('display_errors', 1);
  11. // error_reporting(E_ALL);
  12. class Close extends Controller {
  13. //关闭网站
  14. public function CloseWeb() {
  15. $status = isset($_GET['status'])?intval($_GET['status']):-1;
  16. $token = isset($_GET['token'])?$_GET['token']:'';
  17. if($status<1 || empty($token)){
  18. return -5007;
  19. }
  20. if (!empty($token) && ($re = lm('SystemUser', 'commons')->checkToken($token)) < 1) {
  21. return $re;
  22. }
  23. try{
  24. if($status==1){
  25. \file_put_contents(ROOT_PATH."/Cache/system.lock",'');
  26. }else{
  27. if(\file_exists(ROOT_PATH."/Cache/system.lock")){
  28. unlink(ROOT_PATH."/Cache/system.lock");
  29. }
  30. }
  31. }catch(PDOException $e){
  32. return -5011;
  33. }
  34. }
  35. }