Ejemplo n.º 1
0
 public function archive()
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     /*$chk = array("bool" => true, "func" => $this->traceID.": archive");
     		$dirArray = array();
     		$myDirectory;
     		$num = 1;
     		//----------------------------------------------------------
     		$myDirectory = opendir($this->newVideoRelPath);
     		//----------------------------------------------------------
     		$this->move($this->newVideoRelPath, $this->newVideoRelPath, " ", "_");
     		//----------------------------------------------------------
     		$this->move($this->newThumbRelPath, $this->newThumbRelPath, " ", "_");
     		//----------------------------------------------------------
     		while($entryName = readdir($myDirectory)) {
     			if (stristr($entryName, '.mp4')) {
     				$num ++;
     				$hash = $this->getHash("videos", $num);
     				array_push($dirArray, array(
     				'title' => $entryName, 
     				'orig_title' => $entryName, 
     				'hash' => $hash,
     				'mp4' => $this->str_lreplace(".mp4", "_".$hash.".mp4", $entryName),
     				'thumbnail_url' => $thumbnail_url = $this->str_lreplace(".mp4", "_".$hash.".png", $entryName)
     				));
     				rename($this->newVideoRelPath.$entryName, $this->newVideoRelPath.$this->str_lreplace(".mp4", "_".$hash.".mp4", $entryName));
     				rename($this->newThumbRelPath.$this->str_lreplace(".mp4", ".png", $entryName), $this->newThumbRelPath.$thumbnail_url);
     			}
     		}
     		$chk = $this->_insertContents($dirArray);*/
     $chk = array("bool" => true, "func" => $this->traceID . ": archive");
     $dirArray = array();
     $myDirectory;
     $num = 1;
     //----------------------------------------------------------
     //----------------------------------------------------------
     //$this->move($this->newVideoRelPath, $this->newVideoRelPath, " ", "_");
     //----------------------------------------------------------
     //$this->move($this->newThumbRelPath, $this->newThumbRelPath, " ", "_");
     //----------------------------------------------------------
     $videoOrganizer = new VideoOrganizer();
     //----------------------------------------------------------
     $this->videos = array();
     $myDirectory = opendir($this->newVideoRelPath);
     while ($entryName = readdir($myDirectory)) {
         array_push($this->videos, $entryName);
     }
     closedir($myDirectory);
     //----------------------------------------------------------
     $this->thumbs = array();
     $myDirectory = opendir($this->newThumbRelPath);
     while ($entryName = readdir($myDirectory)) {
         array_push($this->thumbs, $entryName);
     }
     closedir($myDirectory);
     //----------------------------------------------------------
     foreach ($this->videos as $entryName) {
         if (stristr($entryName, '.mp4')) {
             $thumbnail_name = $this->str_lreplace(".mp4", ".png", $entryName);
             //$thumb = (file_exists($this->newThumbRelPath.$thumbnail_name)) ? $videoOrganizer->insertFile($thumbnail_name) : NULL;
             $thumb_name = $this->getThumb($this->getFileName($entryName));
             $thumb = file_exists($this->newThumbRelPath . $thumb_name) ? $videoOrganizer->insertFile($thumb_name) : NULL;
             //$thumb = (!is_null($thumb)) ? $videoOrganizer->insertFile($thumbnail_name) : NULL;
             $video = $videoOrganizer->insertFile($entryName);
             $arr = array('title' => $entryName, 'mp4' => $video['insert_id'], 'images_id' => is_null($thumb) ? $thumb : $thumb['insert_id']);
             //krumo(array($this->newVideoRelPath.$entryName, $this->videoRelPath.$entryName));
             //krumo(array($this->newThumbRelPath.$thumbnail_name, $this->thumbRelPath.$thumbnail_name));
             rename($this->newVideoRelPath . $entryName, $this->videoRelPath . $entryName);
             if (!is_null($thumb)) {
                 rename($this->newThumbRelPath . $thumb_name, $this->thumbRelPath . $thumb_name);
             }
             $chk = $videoOrganizer->toServerFromUpload($arr);
             krumo($chk);
         }
     }
     return $chk;
 }