$end = $start + 1000; $sum = $end; $file_name = "/home/pzr/download/2016-05-04-audio/{$start}-{$end}"; $this->logger("start ", $file_name); $data = $this->read_file_json($file_name); $this->read_json($data); $this->write_url_json($start, $end); $this->logger('ended ', $file_name); } } public function logger($key, $value, $line = false) { @error_log("\n {$key} : " . $value, 3, '/tmp/tourism.log'); if ($line) { @error_log("\n------------------------------------------------------\n", 3, '/tmp/tourism.log'); } } public function write_url_json($start, $end) { $imgPath = $this->imgPath . "img{$start}-{$end}.json"; $mp3Path = $this->mp3Path . "mp3{$start}-{$end}.json"; $this->logger("{$start}-{$end} :", count($this->picArray)); $this->logger("{$start}-{$end} :", count($this->mp3Array)); file_put_contents($imgPath, json_encode($this->picArray)); file_put_contents($mp3Path, json_encode($this->mp3Array)); } } $mp3Path = '/home/pzr/download/2016-05-08/'; $imgPath = '/home/pzr/download/2016-05-08/'; $tourism = new tourism($mp3Path, $imgPath); $tourism->start();
public function start_all() { $sum = 0; for ($i = 0; $i < 1; $i++) { $this->picArray = array(); $this->mp3Array = array(); $start = $sum; $end = $start + 1000; $sum = $end; $this->start_one($start, $end); } } public function start_one($start, $end) { $now = time(); $this->logger("start {$start}-{$end}: ", $now); $data = $this->read_file($start, $end); $this->write_url($data); $this->logger("ended {$start}-{$end}: ", time() - $now); } } /** * $readPath , * $basePath='/home/pzr/tour' , * $type = 'img', * $logPath='/tmp/tourism.log' ) * @var unknown */ $readPath = '/home/pzr/download/2016-05-08/'; $tourism = new tourism($readPath); $tourism->start_one(0, 1000);