<?php
class cronControl extends skymvc{
	
	public function __construct(){
		parent::__construct();
		session_write_close();
		$this->loadModel(array("cron"));
	}
	
	public function onDefault(){
		$data=$this->cron->selectRow(array("order"=>"next_time asc","where"=>" next_time<".time()));
		if(!empty($data)){
			$data['last_time']=time();
			$data['next_time']=time()+$data['minute']*60;
			$this->cron->update($data,"id=".$data['id']);
			if(strpos($data['url'],"http")===false){
				$fun="on".trim($data['url']);
				self::$fun();
			}else
				file_get_contents($data['url']);
			} 
	}
		 
	
	/*删除产品临时文件*/
	public function onProduct_temp(){
		$this->loadModel("product");
		//删除超过1小时的临时产品
		$this->product->delete("is_temp=1 AND dateline<".(time()-3600));
	}
	/*获取商品*/
	public function onproduct_Get(){
		file_get_contents("http://".$_SERVER['HTTP_HOST']."/index.php?m=tao&a=get");	
	}
	/*分享*/
	public function onShare(){
		file_get_contents("http://".$_SERVER['HTTP_HOST']."/index.php?m=weibo&a=share");
	}
	/*采集*/
	public function onRandStole(){
		file_get_contents("http://".$_SERVER['HTTP_HOST']."/index.php?m=tao&a=RandStole");
	}

	
	
	
}

?>