public function doSqlUpdate()
 {
     $now = time();
     $updateRecord = M('System_info')->order('lastsqlupdate DESC')->find();
     $key = $this->key;
     $url = ((((($this->server_url . '?act=sql&getFile=1&key=') . $key) . '&lastversion=') . $updateRecord['lastsqlupdate']) . '&domain=') .$this->topdomain;
     $remoteStr = @Saivi_getcontents($url);
     $rt = json_decode($remoteStr, 1);
     if (intval($rt['success']) < 1) {
         if (intval($rt['success']) == 0) {
             $this->success('升级完成', U('System/main'));
         } else {
             $this->error($rt['msg'], U('System/main'));
         }
     } else {
         $Model = new Model();
         error_reporting(0);
         @mysql_query(str_replace('{tableprefix}', C('DB_PREFIX'), $rt['sql']));
         if ($rt['time']) {
             M('System_info')->where(array('lastsqlupdate' => $updateRecord['lastsqlupdate']))->save(array('lastsqlupdate' => $rt['time']));
         }
         if (!isset($_GET['ignore'])) {
             $this->success('进入下一步:' . $rt['msg'], U('System/doSqlUpdate'));
         } else {
             $this->success('进入下一步:' . $rt['msg'], U('System/doSqlUpdate', array('ignore' => 1)));
         }
     }
 }
Example #2
0
	public function doSqlUpdate(){
		//
		$now=time();
		$updateRecord=M('System_info')->order('lastsqlupdate DESC')->find();
		$key=$this->key;
		$url=$this->server_url.'sqlserver.php?key='.$key.'&excute=1&lastsqlupdate='.$updateRecord['lastsqlupdate'].'&domain='.$this->topdomain.'&dirtype='.$this->dirtype;
		$remoteStr=Saivi_getcontents($url);
		//
		$rt=json_decode($remoteStr,1);
		if (intval($rt['success'])<1){
			if (intval($rt['success'])==0){
				$this->success('升级完成',U('System/main'));
			}else {
				$this->error($rt['msg'],U('System/main'));
			}
		}else {
			$Model = new Model();
			error_reporting(0);
			@mysql_query(str_replace('{tableprefix}',C('DB_PREFIX'),$rt['sql']));
			//record to database
			if ($rt['time']){
				M('System_info')->where(array('lastsqlupdate'=>$updateRecord['lastsqlupdate']))->save(array('lastsqlupdate'=>$rt['time']));
			}
			if (!isset($_GET['ignore'])){
				$this->success('进入下一步(不要关闭,耐心等待完成,跳是正常的):'.$rt['msg'],U('System/doSqlUpdate'));
			}else {
				$this->success('进入下一步(不要关闭,耐心等待完成,跳是正常的):'.$rt['msg'],U('System/doSqlUpdate',array('ignore'=>1)));
			}
		}
	}