Example #1
0
function RegularControl($value = null)
{
    /*
    	サーバが重(混み)そうな時間帯は後回しにする。
    	PM 7:00 - AM 2:00 は処理しない。
    	※時刻は or なのに注意!
    */
    if (19 <= date("H") || date("H") <= 1) {
        return false;
    }
    $now = time();
    $fp = FileLock(CTRL_TIME_FILE, true);
    if (!$fp) {
        return false;
    }
    //$ctrltime	= file_get_contents(CTRL_TIME_FILE);
    $ctrltime = trim(fgets($fp, 1024));
    // 周期がまだなら終了
    if ($now < $ctrltime) {
        fclose($fp);
        unset($fp);
        return false;
    }
    // 管理の処理
    RecordManage(date("Y M d G:i:s", $now) . ": auto regular control by {$value}.");
    DeleteAbandonAccount();
    //その1 放棄ユーザの掃除
    // 定期管理が終わったら次の管理時刻を書き込んで終了する。
    WriteFileFP($fp, $now + CONTROL_PERIOD);
    fclose($fp);
    unset($fp);
}
Example #2
0
	function SaveCharData() {
		if(!file_exists($this->file))
			return false;
		$string	 = "MonsterNumber=".$this->MonsterNumber."\n";
		$string	.= "LastDefeated=".$this->LastDefeated."\n";
		$string	.= "HP=".$this->HP."\n";
		$string	.= "SP=".$this->SP."\n";

		WriteFileFP($this->fp,$string);
		fclose($this->fp);
		unset($this->fp);
	}
 function ItemSaveData()
 {
     if (!$this->DataChange) {
         fclose($this->fp);
         unset($this->fp);
         return false;
     }
     // アイテム オークションを保存する。
     $string = $this->ArticleNo . "\n";
     foreach ($this->Article as $val) {
         //if(strlen($val["end"]) != 10) continue;
         $string .= $val["No"] . "<>" . $val["end"] . "<>" . $val["price"] . "<>" . $val["exhibitor"] . "<>" . $val["item"] . "<>" . $val["amount"] . "<>" . $val["TotalBid"] . "<>" . $val["bidder"] . "<>" . $val["latest"] . "<>" . $val["comment"] . "<>" . $val["IP"] . "\n";
     }
     //print($string);
     if (file_exists(AUCTION_ITEM) && $this->fp) {
         WriteFileFP($this->fp, $string, true);
         fclose($this->fp);
         unset($this->fp);
     } else {
         WriteFile(AUCTION_ITEM, $string, true);
     }
     $this->SaveLog();
 }
Example #4
0
	function SaveCharData($id=false) {
		// モンスターは保存しない。
		//if($this->monster)	return false;

		if($id) {
			$dir	= USER.$id;
		} else {
			if(!$this->user) return false;
			$dir	= USER.$this->user;
		}
		// ユーザーが存在しない場合保存しない
		if(!file_exists($dir))
			return false;

		if(isset($this->file))
			$file	= $this->file;
		else
			$file	= $dir."/".$this->birth.".dat";

		if(file_exists($file) && $this->fp) {
			//sleep(10);//ファイルロック確認用
			WriteFileFP($this->fp,$this->DataSavingFormat());
			$this->fpclose();
		} else {
			WriteFile($file,$this->DataSavingFormat());
		}

	}
Example #5
0
 function SaveData()
 {
     $dir = USER . $this->id;
     $file = USER . $this->id . "/" . DATA;
     if (file_exists($this->file) && $this->fp) {
         //print("BBB");
         //ftruncate($this->fp,0);
         //rewind($this->fp);
         //$fp	= fopen($file,"w+");
         //flock($fp,LOCK_EX);
         //fputs($this->fp,$this->DataSavingFormat());
         WriteFileFP($this->fp, $this->DataSavingFormat());
         fclose($this->fp);
         unset($this->fp);
         //WriteFile("./user/1234/data2.dat",$this->DataSavingFormat());
         //WriteFile($file,$this->DataSavingFormat());
         //WriteFileFP($this->fp,$this->DataSavingFormat());
         //fclose($this->fp);
     } else {
         if (file_exists($file)) {
             WriteFile($file, $this->DataSavingFormat());
         }
     }
 }
Example #6
0
 function LoadUserName($id, $rank = false)
 {
     if (!$this->UserName["{$id}"]) {
         $User = new user($id);
         $Name = $User->Name();
         $Record = $User->RankRecordLoad();
         if ($Name !== false) {
             $this->UserName["{$id}"] = $Name;
             $this->UserRecord["{$id}"] = $Record;
         } else {
             $this->UserName["{$id}"] = "-";
             $this->DeleteRank($id);
             foreach ($this->Ranking as $rank => $val) {
                 foreach ($val as $key => $val2) {
                     $ranking .= $val2["id"] . "\n";
                 }
             }
             WriteFileFP($this->fp, $ranking);
         }
     }
     if ($rank) {
         return array($this->UserName["{$id}"], $this->UserRecord["{$id}"]);
     } else {
         return $this->UserName["{$id}"];
     }
 }