<?php
/**
 *------Create thems Controller------
 *------SCWPHP  Version 1.0.0------
 *------Dev Model Jions------
 *------Create Time 2017-06-23 15:06:45------
 */
namespace App\Api\Controller;
use \BaseController\Controller;
// ini_set('display_errors', 1);

// error_reporting(E_ALL);
class Close extends Controller {

	//关闭网站
	public function CloseWeb() {
		$status = isset($_GET['status'])?intval($_GET['status']):-1;
		$token = isset($_GET['token'])?$_GET['token']:'';
		if($status<1 || empty($token)){
			return -5007;
		}
		if (!empty($token) && ($re = lm('SystemUser', 'commons')->checkToken($token)) < 1) {
			return $re;
		}
		try{
			if($status==1){
				\file_put_contents(ROOT_PATH."/Cache/system.lock",'');
			}else{
				if(\file_exists(ROOT_PATH."/Cache/system.lock")){
					unlink(ROOT_PATH."/Cache/system.lock");
				}
			}
		}catch(PDOException $e){
			return -5011;
		}
	}
}
