Ejemplo n.º 1
1
 public function process(FileInfo $path)
 {
     if (mb_strlen($path->getPathname()) < 5) {
         throw new DirectoryCleanerException('For security reasons, path must be at least 5 chars long', DirectoryCleanerException::SecurityLimitation);
     }
     if (!$path->exists()) {
         return;
     }
     $worker = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path->getPathname(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($worker as $entry) {
         if ($entry->isDir() && !$entry->isLink()) {
             rmdir($entry->getPathname());
         } else {
             unlink($entry->getPathname());
         }
     }
     rmdir($path);
 }
Ejemplo n.º 2
1
 public function process(FileInfo $path)
 {
     if (mb_strlen($path->getPathname()) < 5) {
         throw new DirectoryCleanerException('For security reasons, path must be at least 5 chars long', DirectoryCleanerException::SecurityLimitation);
     }
     if (!file_exists($path)) {
         return;
     }
     $worker = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path->getPathname()));
     foreach ($worker as $x) {
         if ($x->getFilename() == "." || $x->getFilename() == "..") {
             continue;
         }
         if ($x->isDir()) {
             $this->clearDirectory(new FileInfo($x->getPathname()));
         }
         unlink($x->getPathname());
     }
 }
Ejemplo n.º 3
0
 /**
  * @param	Huxtable\Core\FileInfo	$source
  */
 public function __construct(FileInfo $source)
 {
     if (!$source->exists()) {
         throw new \Exception("Data source not found '{$source}'");
     }
     $this->source = $source;
 }
Ejemplo n.º 4
0
 /**
  * Constructor
  *
  * @param string $filename
  * @param string $mode
  * @param bool $useIncludePath
  * @param null|resource $context
  */
 public function __construct($filename, $mode = "r", $useIncludePath = false, $context = null)
 {
     $this->filename = $filename;
     $args = func_get_args();
     count($args) < 2 ? $args[] = $mode : '';
     $this->resource = call_user_func_array('fopen', $args);
     parent::__construct($filename);
 }
Ejemplo n.º 5
0
 private function fileExecutor($filePath, $type, $actionType)
 {
     if ($actionType === $this->ACTION_PROCESS) {
         $fileinfo = new FileInfo($filePath);
         $fileinfoNode = $fileinfo->getXMLNode();
         if ($this->GENERATE_FILE_QUEUE && is_file($fileinfo->absoluteName)) {
             $queue_entry = $fileinfo->absoluteName . ' ' . $fileinfo->md5 . PHP_EOL;
             file_put_contents2($this->tmpQueueFilename, $queue_entry, 'a');
         }
         $this->dom->documentElement->appendChild($this->dom->importNode($fileinfoNode, true));
         $this->filesFound++;
     } else {
         if ($actionType === $this->ACTION_SKIP) {
             // TODO: Do something with skipped item
             // fputs($file_handle, "* SKIPPED *************************************** " . $file_path);
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Constructs a new `FileInfo` instance.
  *
  * @param string $file Path to file.
  */
 public function __construct($file)
 {
     if (!is_string($file)) {
         throw new InvalidArgumentException('FileInfo expects a string.');
     }
     // cache loaded media types
     if (self::$mediaTypes === null) {
         self::$mediaTypes = $this->loadMediaTypes();
     }
     $this->file = $file;
 }
Ejemplo n.º 7
0
 public function getFileInfos()
 {
     return $this->hasMany(FileInfo::className(), ['file_formats_id' => 'id']);
 }
Ejemplo n.º 8
0
function getFileData($_XML_DATA){
	$_file_data = array();

	//file data is assumed to be stored in $_XML_DATA[0]['child'][2]
	for($i = 0; $i < count($_XML_DATA[0]['child'][2]['child']); $i++){
		$file_info = new FileInfo;

		$file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][0]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][0]['content']);
		$file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][1]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][1]['content']);
		$file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][2]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][2]['content']);
		$file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][3]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][3]['content']);

		$_file_data[$i] = $file_info;
	}

	return $_file_data;
}
Ejemplo n.º 9
0
 public function getFileInfo()
 {
     return $this->hasOne(FileInfo::className(), ['id' => ['files_info_id']]);
 }
Ejemplo n.º 10
0
 public function update_archive_link_cache($args)
 {
     $blog_id = $args['blog_id'];
     $at = $args['archive_type'];
     $where = isset($args['where']) ? $args['where'] : '';
     if (isset($args['hi']) && isset($args['low'])) {
         $hi = $args['hi'];
         $low = $args['low'];
         $range = " and fileinfo_startdate between '{$low}' and '{$hi}'";
     }
     $sql = "\n            fileinfo_archive_type = '{$at}'\n            and fileinfo_blog_id = {$blog_id}\n            and templatemap_is_preferred = 1\n            {$range}\n            {$where}";
     $extras['join']['mt_templatemap'] = array('condition' => "templatemap_id = fileinfo_templatemap_id");
     require_once 'class.mt_fileinfo.php';
     $fileinfo = new FileInfo();
     $finfos = $fileinfo->Find($sql, false, false, $extras);
     if (!empty($finfos)) {
         $mt = MT::get_instance();
         foreach ($finfos as $finfo) {
             $date = $this->db2ts($finfo->fileinfo_startdate);
             if ($at == 'Page') {
                 $blog_url = $finfo->blog()->site_url();
             } else {
                 $blog_url = $finfo->blog()->archive_url();
                 $blog_url or $blog_url = $finfo->blog()->site_url();
             }
             $blog_url = preg_replace('!(https?://(?:[^/]+))/.*!', '$1', $blog_url);
             $url = $blog_url . $finfo->url;
             $url = _strip_index($url, array('blog_file_extension' => $finfo->blog()->blog_file_extension));
             $this->_archive_link_cache[$date . ';' . $at] = $url;
         }
     }
     return true;
 }
Ejemplo n.º 11
0
 /**
  * add Tree File
  *
  * @param FileInfo $file
  *
  * @return $this
  */
 public function addTreeFile(FileInfo $file)
 {
     $this->tree[$file->getHash()] = $file;
     return $this;
 }
Ejemplo n.º 12
0
 /**
  * Creates a FileInfo object from the given parsed header
  *
  * @param $header
  * @return FileInfo
  */
 protected function header2fileinfo($header)
 {
     $fileinfo = new FileInfo();
     $fileinfo->setPath($header['filename']);
     $fileinfo->setMode($header['perm']);
     $fileinfo->setUid($header['uid']);
     $fileinfo->setGid($header['gid']);
     $fileinfo->setSize($header['size']);
     $fileinfo->setMtime($header['mtime']);
     $fileinfo->setOwner($header['uname']);
     $fileinfo->setGroup($header['gname']);
     $fileinfo->setIsdir((bool) $header['typeflag']);
     return $fileinfo;
 }
Ejemplo n.º 13
0
 public static function HandleFileDeleteRequest($request)
 {
     $fileInfo = new FileInfo($request->data);
     return $fileInfo->Delete();
 }
Ejemplo n.º 14
0
function getFileData($_XML_DATA)
{
    $_file_data = array();
    if (isset($_XML_DATA[0]['child'][2]['child'])) {
        $num_files = count($_XML_DATA[0]['child'][2]['child']);
        //file data is assumed to be stored in $_XML_DATA[0]['child'][2]
        for ($i = 0; $i < $num_files; $i++) {
            $file_info = new FileInfo();
            // file slot name
            if (isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][0]['name']) && $_XML_DATA[0]['child'][2]['child'][$i]['child'][0]['name'] === 'slot' && isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][0]['content'])) {
                $file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][0]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][0]['content']);
            }
            // file name
            if (isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][1]['name']) && $_XML_DATA[0]['child'][2]['child'][$i]['child'][1]['name'] === 'name' && isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][1]['content'])) {
                $file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][1]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][1]['content']);
            }
            // file size
            if (isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][2]['name']) && $_XML_DATA[0]['child'][2]['child'][$i]['child'][2]['name'] === 'size' && isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][2]['content'])) {
                $file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][2]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][2]['content']);
            }
            // file type
            if (isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][3]['name']) && $_XML_DATA[0]['child'][2]['child'][$i]['child'][3]['name'] === 'type' && isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][3]['content'])) {
                $file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][3]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][3]['content']);
            }
            // file transfer status
            if (isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][4]['name']) && $_XML_DATA[0]['child'][2]['child'][$i]['child'][4]['name'] === 'status' && isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][4]['content'])) {
                $file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][4]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][4]['content']);
            }
            // file transfer status description
            if (isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][5]['name']) && $_XML_DATA[0]['child'][2]['child'][$i]['child'][5]['name'] === 'status_desc' && isset($_XML_DATA[0]['child'][2]['child'][$i]['child'][5]['content'])) {
                $file_info->setFileInfo($_XML_DATA[0]['child'][2]['child'][$i]['child'][5]['name'], $_XML_DATA[0]['child'][2]['child'][$i]['child'][5]['content']);
            }
            if (strlen($file_info->getFileInfo('slot')) > 0) {
                $_file_data[$file_info->slot] = $file_info;
            }
        }
    }
    return $_file_data;
}
Ejemplo n.º 15
0
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>FileInfoクラスを利用する</title>
</head>
<body>
<div>
<?php 
// FileInfoクラスの定義されたFileInfo.phpを読み込む
require_once './153_fileInfo.php';
$fileInfo = new FileInfo();
$fileInfo->readFile('./154_use_class.php');
echo '改行コードは「' . h($fileInfo->getRetCode()) . '」です。';
function h($string)
{
    return htmlspwcialchars($string, ENT_QUOTES, 'UTF-8');
}
?>
</div>
</body>
</html>
Ejemplo n.º 16
0
    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        include_once "/opt/nginx/html/laravel/vendor/SmartImage.class.php";
        try {
            $hash = $this->option('hash');
            $media = Media::where('hash', '=', $hash)->first();
            if ($media->files()->count() == 0) {
                echo "files";
                $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                $myvars = 'mode=info&hash=' . $hash;
                $ch = curl_init($url);
                $username = '******';
                $password = '******';
                curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                $torrent_info = json_decode($response, true);
                $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                $myvars = 'mode=fls&hash=' . $hash;
                $ch = curl_init($url);
                $username = '******';
                $password = '******';
                curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                $torrent_files = json_decode($response, true);
                $files = $torrent_files;
                if (!empty($files)) {
                    echo "not empty";
                    echo count($files);
                    $ignore_first_folder = true;
                    $id = 1;
                    $paths = array();
                    foreach ($files as $file) {
                        if ($torrent_info[3] != 0) {
                            $fd = parse_url(basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]));
                        } else {
                            $fd = parse_url(str_replace("#", "", $file[0]));
                        }
                        $path_parts = pathinfo($fd['path']);
                        $dirs = explode("/", $path_parts['dirname']);
                        for ($i = 0; $i <= count($dirs); $i++) {
                            if (isset($dirs[$i]) && $dirs[$i] != '.') {
                                $full_path = $this->fullpath($dirs, $i);
                                if (array_key_exists($full_path, $paths)) {
                                } else {
                                    $paths[$full_path]["id"] = $id;
                                    $paths[$full_path]["name"] = $dirs[$i];
                                    $prev_path = $this->fullpath($dirs, $i - 1);
                                    if (!isset($paths[$prev_path]["id"])) {
                                        $pv_p = 0;
                                    } else {
                                        $pv_p = $paths[$prev_path]["id"];
                                    }
                                    $new_folder = new MediaFlag();
                                    $new_folder->name = $dirs[$i];
                                    $new_folder->folder_id = $id;
                                    $new_folder->in = $pv_p;
                                    $new_folder->media_id = $media->id;
                                    $new_folder->save();
                                    $id++;
                                }
                            } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                                //echo $path_parts["basename"].' 0';
                                $new_file = new MediaLike();
                                if ($torrent_info[3] != 0) {
                                    $new_file->path = basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]);
                                } else {
                                    $new_file->path = str_replace("#", "", $file[0]);
                                }
                                $new_file->name = $path_parts["basename"];
                                $new_file->type = $this->getExt($new_file->path);
                                $new_file->in = 0;
                                $new_file->size = $file[3];
                                $new_file->media_id = $media->id;
                                //$like->user_id = Auth::user()->id;
                                $new_file->save();
                                $ignore_first_folder = false;
                            } else {
                                if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                                    $full_path = $this->fullpath($dirs, $i - 1);
                                    //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                                    $new_file = new MediaLike();
                                    if ($torrent_info[3] != 0) {
                                        $new_file->path = basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]);
                                    } else {
                                        $new_file->path = str_replace("#", "", $file[0]);
                                    }
                                    $new_file->type = $this->getExt($new_file->path);
                                    $new_file->name = $path_parts["basename"];
                                    $new_file->in = $paths[$full_path]["id"];
                                    $new_file->size = $file[3];
                                    $new_file->media_id = $media->id;
                                    //$like->user_id = Auth::user()->id;
                                    $new_file->save();
                                }
                            }
                        }
                    }
                    $media["ignore_first"] = $ignore_first_folder;
                    $media->save();
                }
            }
            $files_local = $media->getFiles();
            if (!empty($files_local)) {
                echo "pro";
                $media_id = $media->id;
                shell_exec('nohup php /opt/nginx/html/artisan check:files --media=' . $media_id . ' > /dev/null 2>&1 & echo $!');
                $max_file_id = null;
                $max_file_size = 0;
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        if ($file->size > $max_file_size) {
                            $max_file_size = $file->size;
                            $max_file_id = $file->id;
                        }
                    }
                }
                $media->max_file_id = $max_file_id;
                $media->save();
                $fast = false;
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        if ($file->type == "vid") {
                            $fast = $this->getFast($file->path);
                        }
                        if ($file->id == $max_file_id) {
                            $info = $this->makeThumbs($media->id, $file->id, $media->id . '/' . $file->path, $fast, 13);
                        } else {
                            $info = $this->makeThumbs($media->id, $file->id, $media->id . '/' . $file->path, $fast, 1);
                        }
                        if (!empty($info) && $info != null) {
                            $info_decode_all = json_decode($info, true);
                            $info_decode = $info_decode_all["data"];
                            $new_fileinfo = new FileInfo();
                            $new_fileinfo->file_id = $file->id;
                            $new_fileinfo->media_id = $media->id;
                            $new_fileinfo->video_duration = $info_decode["video_duration"];
                            $new_fileinfo->video_codec_name = $info_decode["video_codec_name"];
                            $new_fileinfo->video_width = $info_decode["video_width"];
                            $new_fileinfo->video_height = $info_decode["video_height"];
                            $new_fileinfo->video_height = $info_decode["video_height"];
                            $new_fileinfo->video_ratio = $info_decode["video_ratio"];
                            $new_fileinfo->video_fps = $info_decode["video_fps"];
                            $new_fileinfo->audio_codec_name = $info_decode["audio_codec_name"];
                            $new_fileinfo->audio_bit_rate = $info_decode["audio_bit_rate"];
                            $new_fileinfo->save();
                        }
                    } elseif ($file->type == "img") {
                        //$this->setimages($file->name ,$media->id . '/'. $file->path);
                        $file_path_thumb = '/opt/nginx/html/public/cache/thumbs/' . $file->id . '.jpg';
                        $full_path = '/home/mfs/Downloads/transmission/completed/' . $media->id . '/' . $file->path;
                        if (file_exists($file_path_thumb)) {
                            unlink($file_path_thumb);
                        }
                        try {
                            $img = new SmartImage($full_path);
                            $img->resize(130, 130, true);
                            $img->saveImage($file_path_thumb, 85);
                        } catch (Exception $e) {
                            $full_path = '/home/mfs/Downloads/transmission/image.png';
                            $img = new SmartImage($full_path);
                            $img->saveImage($file_path_thumb, 85);
                        }
                        //file_put_contents($file_path_thumb, $file_img_tmp);
                    }
                }
                sleep(10);
                $save_base_thumbs = "/opt/nginx/html/public/snaps/thumbs/";
                $save_base_big = "/opt/nginx/html/public/snaps/big/";
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        $snap_big_path = $save_base_big . $media->id;
                        if (!file_exists($snap_big_path)) {
                            mkdir($snap_big_path, 0775, true);
                        }
                        $snap_big_path_full = $snap_big_path . '/' . $file->id;
                        if (!file_exists($snap_big_path_full)) {
                            mkdir($snap_big_path_full, 0775, true);
                        }
                        $snap_thumb_path = $save_base_thumbs . $media->id;
                        if (!file_exists($snap_thumb_path)) {
                            mkdir($snap_thumb_path, 0775, true);
                        }
                        $snap_thumb_path_full = $snap_thumb_path . '/' . $file->id;
                        if (!file_exists($snap_thumb_path_full)) {
                            mkdir($snap_thumb_path_full, 0775, true);
                        }
                        if ($media->max_file_id != $file->id) {
                            $file_get = '/opt/nginx/html/laravel/public/snaps/' . $media->id . '/' . $file->id . '/1.jpg';
                            $snap_big_path_full_file = $snap_big_path_full . '/1.jpg';
                            $snap_thumb_path_full_file = $snap_thumb_path_full . '/1.jpg';
                            if (file_exists($snap_big_path_full_file)) {
                            } else {
                                try {
                                    $file_img = file_get_contents($file_get);
                                    file_put_contents($snap_big_path_full_file, $file_img);
                                    $img = new SmartImage($snap_big_path_full_file);
                                    $img->resize(130, 130, true);
                                    $img->saveImage($snap_thumb_path_full_file, 85);
                                } catch (Exception $e) {
                                    $img = new SmartImage('/opt/nginx/html/app/commands/1.png');
                                    $img->resize(130, 130, true);
                                    $img->saveImage($snap_thumb_path_full_file, 85);
                                }
                            }
                        } elseif ($media->max_file_id == $file->id) {
                            $frames = 13;
                            for ($k = 1; $k < $frames; $k++) {
                                $snap_big_path_full_file = $snap_big_path_full . '/' . $k . '.jpg';
                                $snap_thumb_path_full_file = $snap_thumb_path_full . '/' . $k . '.jpg';
                                $file_get = '/opt/nginx/html/laravel/public/snaps/' . $media->id . '/' . $file->id . '/' . $k . '.jpg';
                                if (file_exists($snap_big_path_full_file)) {
                                } else {
                                    try {
                                        $file_img = file_get_contents($file_get);
                                        file_put_contents($snap_big_path_full_file, $file_img);
                                        $img = new SmartImage($snap_big_path_full_file);
                                        $img->resize(130, 130, true);
                                        $img->saveImage($snap_thumb_path_full_file, 85);
                                    } catch (Exception $e) {
                                        $img = new SmartImage('/opt/nginx/html/app/commands/1.png');
                                        $img->resize(130, 130, true);
                                        $img->saveImage($snap_thumb_path_full_file, 85);
                                    }
                                }
                            }
                        }
                    }
                }
                while (MediaLike::where('media_id', '=', $media->id)->where('cksum', '=', '')->count() != 0) {
                    sleep(1);
                }
                $media["state"] = 'done';
                $media->save();
                $media_users = $media->usersMedia();
                foreach ($media_users as $media_user) {
                    try {
                        $user_this = User::where('id', '=', $media_user->user_id)->first();
                        if (isset($user_this->email) && $user_this->ea) {
                            require_once '/opt/nginx/html/vendor/php-aws-ses-master/src/ses.php';
                            $ses = new SimpleEmailService('AKIAJNUKDR6WQV2PJLEA', 'Q0p4SCDdHK5QddvUICYj/xMfoAbcxa7buuRYTJyY');
                            $m = new SimpleEmailServiceMessage();
                            $m->addTo($user_this->email);
                            $m->setFrom('DATAS Support <*****@*****.**>');
                            $m->setSubject('Your files are ready to download.');
                            $html = '<table class="yiv7962433916container" align="center" cellspacing="0" border="0" cellpadding="0" width="580" bgcolor="#FFFFFF" style="width:580px;background-color:#FFF;border-top:1px solid #DDD;border-bottom:1px solid #DDD;" id="yui_3_13_0_1_1397466773730_2821">
												<tbody id="yui_3_13_0_1_1397466773730_2820"><tr id="yui_3_13_0_1_1397466773730_2819">
													<td class="yiv7962433916title" style="padding-top:34px;padding-left:39px;padding-right:39px;text-align:left;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;" id="yui_3_13_0_1_1397466773730_2818">
														<h2 style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;font-size:30px;color:#262626;font-weight:normal;margin-top:0;margin-bottom:13px;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;letter-spacing:0;" id="yui_3_13_0_1_1397466773730_2817">Your file is ready!</h2>
														<h3 style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;font-size:16px;color:#3e434a;font-weight:normal;margin-top:0;margin-bottom:19px;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;line-height:25px;" id="yui_3_13_0_1_1397466773730_2824">The file <b>' . $media->title . '</b> has been downloaded and ready to Play, Download, Convert or Stream.</h3>
													</td>
												</tr>
												<tr id="yui_3_13_0_1_1397466773730_2831">
													<td class="yiv7962433916cta" align="left" style="background-color:#F1FAFE;font-size:14px;color:#1f1f1f;border-top-width:1px;border-top-style:solid;border-top-color:#DAE3EA;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#DAE3EA;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:20px;padding-bottom:20px;padding-right:39px;padding-left:39px;text-align:left;" id="yui_3_13_0_1_1397466773730_2830">
														<table cellspacing="0" border="0" cellpadding="0" width="500" align="left">
															<tbody><tr>
																<td width="24"></td>
																<td class="yiv7962433916link" align="left" style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;padding-left:9px;font-size:14px;"><strong><a rel="nofollow" style="color:#2b6cb5;font-family:Arial;font-size:12px;" target="_blank" href="https://okaydrive.com/torrent/' . $media_user->uni_id . '">Click here to go to your file</a></strong></td>
															</tr>
														</tbody></table>
													</td>
												</tr>
												<tr id="yui_3_13_0_1_1397466773730_2827">
													<td class="yiv7962433916footer" style="color:#797c80;font-size:12px;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;padding-top:23px;padding-left:39px;padding-right:13px;padding-bottom:23px;text-align:left;" id="yui_3_13_0_1_1397466773730_2826">
														<p style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:13px;padding-right:0;padding-left:0;line-height:20px;" id="yui_3_13_0_1_1397466773730_2832">
															You can login with <a rel="nofollow" style="font-weight:bold;text-decoration:none;color:inherit;cursor:default;">' . $user_this->username . '</a> at <a rel="nofollow" target="_blank" href="https://okaydrive.com" id="yui_3_13_0_1_1397466773730_2833">https://okaydrive.com</a>
														</p>
														<p style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:13px;padding-right:0;padding-left:0;line-height:20px;" id="yui_3_13_0_1_1397466773730_2825">Want some help with using our site? Simply reply to this email or email us - support@okaydrive.com. Email alerts are enabled by default, you may disable email alerts in your account settings.</p>
													</td>
												</tr>
												<tr>
											</tr></tbody></table>';
                            $m->setMessageFromString('', $html);
                            $ses->sendEmail($m);
                        }
                    } catch (Exception $e) {
                    }
                }
            }
        } catch (Exception $e) {
            file_put_contents('/home/mfs/l.log', $e);
        }
    }
Ejemplo n.º 17
0
         if ($row['orderStatus'] == ORDER_COMPLETED) {
             echo '<td>' . $row['timeCompleted'] . '</td>';
             echo '<td>' . round($row['timeExec'], 3) . 's</td>';
         } else {
             echo '<td>not done</td>';
             echo '<td>?</td>';
         }
         echo '<td>' . $row['orderType'] . '</td>';
         $creator = new User($row['creatorId']);
         echo '<td>' . $creator->render() . '</td>';
         //echo $row['orderParams'];
         echo '</tr>';
     }
     echo '</table>';
     echo FileInfo::render($fileId);
     $file = FileInfo::get($fileId);
     if ($file['fileType'] == FILETYPE_CLONE_CONVERTED) {
         echo 'This file is a converted version of the orginal file <a href="' . $_SERVER['PHP_SELF'] . '?id=' . $file['ownerId'] . '">' . $file['ownerId'] . '</a><br/>';
     }
     /*
         $list = $h->files->getFileList(FILETYPE_CLONE_CONVERTED, $fileId);
         if ($list) echo '<h1>Conversions based on this file</h1>';
         foreach ($list as $row) {
             echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$row['fileId'].'">'.$row['fileId'].'</a> '.formatDataSize($row['fileSize']).' '.$row['fileMime'].'<br/>';
         }
         echo '<br/>';
     */
     echo ahref('queue/show/' . $fileId, 'Create process (media conversion, or further processing)');
     break;
 default:
     echo 'No handler for view ' . $this->view;
Ejemplo n.º 18
0
 /**
  * Factory to build FileInfo from existing file or directory
  *
  * @param string $path path to a file on the local file system
  * @param string $as   optional path to use inside the archive
  * @throws FileInfoException
  * @return FileInfo
  */
 public static function fromPath($path, $as = '')
 {
     clearstatcache(false, $path);
     if (!file_exists($path)) {
         throw new FileInfoException("{$path} does not exist");
     }
     $stat = stat($path);
     $file = new FileInfo();
     $file->setPath($path);
     $file->setIsdir(is_dir($path));
     $file->setMode(fileperms($path));
     $file->setOwner(fileowner($path));
     $file->setGroup(filegroup($path));
     $file->setUid($stat['uid']);
     $file->setGid($stat['gid']);
     $file->setMtime($stat['mtime']);
     if ($as) {
         $file->setPath($as);
     }
     return $file;
 }
Ejemplo n.º 19
0
 /**
  * Create fileinfo object from header data
  *
  * @param $header
  * @return FileInfo
  */
 protected function header2fileinfo($header)
 {
     $fileinfo = new FileInfo();
     $fileinfo->setPath($header['filename']);
     $fileinfo->setSize($header['size']);
     $fileinfo->setCompressedSize($header['compressed_size']);
     $fileinfo->setMtime($header['mtime']);
     $fileinfo->setComment($header['comment']);
     $fileinfo->setIsdir($header['external'] == 0x41ff0010 || $header['external'] == 16);
     return $fileinfo;
 }
Ejemplo n.º 20
0
 /**
  * The pathname of the current entry
  *
  * @return string
  */
 public function key()
 {
     return $this->currentEntry ? $this->currentEntry->getPathname() : null;
 }
Ejemplo n.º 21
0
 /**
  * Constructor
  *
  * @param  string                    $key     The $_FILES[] key
  * @param  \Upload\StorageInterface  $storage The upload delegate instance
  * @throws \RuntimeException                  If file uploads are disabled in the php.ini file
  * @throws \InvalidArgumentException          If $_FILES[] does not contain key
  */
 public function __construct($key, StorageInterface $storage)
 {
     // Check if file uploads are allowed
     if (ini_get('file_uploads') == false) {
         throw new RuntimeException('File uploads are disabled in your PHP.ini file');
     }
     // Check if key exists
     if (isset($_FILES[$key]) === false) {
         throw new InvalidArgumentException("Cannot find uploaded file(s) identified by key: {$key}");
     }
     // Collect file info
     if (is_array($_FILES[$key]['tmp_name']) === true) {
         foreach ($_FILES[$key]['tmp_name'] as $index => $tmpName) {
             if ($_FILES[$key]['error'][$index] !== UPLOAD_ERR_OK) {
                 $this->errors[] = sprintf('%s: %s', $_FILES[$key]['name'][$index], static::$errorCodeMessages[$_FILES[$key]['error'][$index]]);
                 continue;
             }
             $this->objects[] = FileInfo::createFromFactory($_FILES[$key]['tmp_name'][$index], $_FILES[$key]['name'][$index]);
         }
     } else {
         if ($_FILES[$key]['error'] !== UPLOAD_ERR_OK) {
             $this->errors[] = sprintf('%s: %s', $_FILES[$key]['name'], static::$errorCodeMessages[$_FILES[$key]['error']]);
         }
         $this->objects[] = FileInfo::createFromFactory($_FILES[$key]['tmp_name'], $_FILES[$key]['name']);
     }
     $this->storage = $storage;
 }
Ejemplo n.º 22
0
/**
 * Takes some work orders from the process queue and performs them
 */
function processQueue()
{
    global $db, $config;
    //Only allows a few work orders being executed at once, so we can do this very often
    if (TaskQueue::getTaskQueueStatusCnt(ORDER_EXECUTING) >= $config['process']['process_limit']) {
        echo "TOO MUCH ACTIVE WORK, ABORTING\n";
        return;
    }
    $job = TaskQueue::getOldestEntry();
    if (!$job) {
        return;
    }
    //mark current job as "IN PROGRESS" so another process won't start on it aswell
    TaskQueue::markTask($job['entryId'], ORDER_EXECUTING);
    echo "\n\n-------------\n";
    switch ($job['orderType']) {
        case TASK_IMAGE_RECODE:
            echo 'IMAGE RECODE<br/>';
            if (!in_array($job['orderParams'], $h->files->image_mime_types)) {
                echo 'error: invalid mime type<br/>';
                $h->session->log('Process queue error - image conversion destination mimetype not supported: ' . $job['orderParams'], LOGLEVEL_ERROR);
                break;
            }
            $newId = $h->files->cloneFile($job['referId'], FILETYPE_CLONE_CONVERTED);
            $exec_start = microtime(true);
            $check = convertImage($h->files->findUploadPath($job['referId']), $h->files->findUploadPath($newId), $job['orderParams']);
            $exec_time = microtime(true) - $exec_start;
            echo 'Execution time: ' . shortTimePeriod($exec_time) . '<br/>';
            if (!$check) {
                $h->session->log('#' . $job['entryId'] . ': IMAGE CONVERT failed! format=' . $job['orderParams'], LOGLEVEL_ERROR);
                echo 'Error: Image convert failed!<br/>';
                break;
            }
            $h->files->updateFile($newId, $job['orderParams']);
            markQueueCompleted($job['entryId'], $exec_time);
            break;
        case TASK_AUDIO_RECODE:
            //Recodes source audio file into orderParams destination format
            $dst_audio_ok = array('ogg', 'wma', 'mp3');
            //FIXME: config item or $h->files->var
            if (!in_array($job['orderParams'], $dst_audio_ok)) {
                echo 'error: invalid mime type<br/>';
                $h->session->log('Process queue error - audio conversion destination mimetype not supported: ' . $job['orderParams'], LOGLEVEL_ERROR);
                break;
            }
            $file = $h->files->getFileInfo($job['referId']);
            if (!$file) {
                echo 'Error: no fileentry existed for fileId ' . $job['referId'];
                break;
            }
            $newId = $h->files->cloneFile($job['referId'], FILETYPE_CLONE_CONVERTED);
            echo 'Recoding source audio of "' . $file['fileName'] . '" (' . $file['fileMime'] . ') to format ' . $job['orderParams'] . " ...\n";
            switch ($job['orderParams']) {
                case 'application/x-ogg':
                    //FIXME hur anger ja dst-format utan filändelse? tvingas göra det i 2 steg nu
                    $dst_file = 'tmpfile.ogg';
                    $c = '/usr/local/bin/ffmpeg -i "' . $h->files->findUploadPath($job['referId']) . '" ' . $dst_file;
                    break;
                case 'audio/x-ms-wma':
                    $dst_file = 'tmpfile.wma';
                    $c = '/usr/local/bin/ffmpeg -i "' . $h->files->findUploadPath($job['referId']) . '" ' . $dst_file;
                    break;
                case 'audio/mpeg':
                case 'audio/x-mpeg':
                    //fixme: source & destination should not be able to be the same!
                    $dst_file = 'tmpfile.mp3';
                    $c = '/usr/local/bin/ffmpeg -i "' . $h->files->findUploadPath($job['referId']) . '" ' . $dst_file;
                    break;
                default:
                    die('unknown destination audio format: ' . $job['orderParams']);
            }
            echo 'Executing: ' . $c . "\n";
            $exec_time = exectime($c);
            echo 'Execution time: ' . shortTimePeriod($exec_time) . "\n";
            if (!file_exists($dst_file)) {
                echo '<b>FAILED - dst file ' . $dst_file . " dont exist!\n";
                break;
            }
            //FIXME: behöver inget rename-steg. kan skriva till rätt output fil i första steget
            rename($dst_file, $h->files->upload_dir . $newId);
            $h->files->updateFile($newId);
            markQueueCompleted($job['entryId'], $exec_time);
            break;
        case TASK_VIDEO_RECODE:
            echo "VIDEO RECODE:\n";
            $exec_start = microtime(true);
            if (convertVideo($job['referId'], $job['orderParams']) === false) {
                markQueue($job['entryId'], ORDER_FAILED);
            } else {
                markQueueCompleted($job['entryId'], microtime(true) - $exec_start);
            }
            break;
        case TASK_FETCH:
            echo "FETCH CONTENT\n";
            $fileName = basename($job['orderParams']);
            //extract filename part of url, used as "filename" in database
            $http = new HttpClient($job['orderParams']);
            $http->getHead();
            if ($http->getStatus() != 200) {
                // retry in 20 seconds if file is not yet ready
                retryQueueEntry($job['entryId'], 20);
                break;
            }
            $newFileId = FileList::createEntry(FILETYPE_PROCESS, 0, 0, $fileName);
            $c = 'wget ' . escapeshellarg($job['orderParams']) . ' -O ' . FileInfo::getUploadPath($newFileId);
            echo "\$ " . $c . "\n";
            $retval = 0;
            $exec_time = exectime($c, $retval);
            if (!$retval) {
                //TODO: process html document for media links if it is a html document
                TaskQueue::markTaskCompleted($job['entryId'], $exec_time, $newFileId);
                FileInfo::updateData($newFileId);
            } else {
                //wget failed somehow, delay work for 1 minute
                retryQueueEntry($job['entryId'], 60);
                $files->deleteFile($newFileId, 0, true);
                //remove failed local file entry
            }
            break;
        case TASK_CONVERT_TO_DEFAULT:
            echo "CONVERT TO DEFAULT\n";
            //referId is entryId of previous proccess queue order
            $params = unserialize($job['orderParams']);
            $prev_job = TaskQueue::getEntry($job['referId']);
            if ($prev_job['orderStatus'] != ORDER_COMPLETED) {
                retryQueueEntry($job['entryId'], 60);
                break;
            }
            $file = $files->getFileInfo($prev_job['referId']);
            $exec_start = microtime(true);
            $newId = false;
            switch ($file['mediaType']) {
                case MEDIATYPE_VIDEO:
                    $newId = convertVideo($prev_job['referId'], $h->files->default_video, !empty($params['callback']) ? false : true, !empty($params['watermark']) ? $params['watermark'] : '');
                    break;
                case MEDIATYPE_AUDIO:
                    $newId = convertAudio($prev_job['referId'], $h->files->default_audio);
                    break;
                default:
                    echo "UNKNOWN MEDIA TYPE " . $file['mediaType'] . ", MIME TYPE " . $file['fileMime'] . ", CANNOT CONVERT MEDIA!!!\n";
                    break;
            }
            if (!$newId) {
                markQueue($job['entryId'], ORDER_FAILED);
                return false;
            }
            markQueueCompleted($job['entryId'], microtime(true) - $exec_start);
            if (empty($params['callback'])) {
                break;
            }
            //'uri' isnt known before the new file is created so it is added at this point
            $uri = $config['core']['full_url'] . 'api/file.php?id=' . $newId;
            $params['callback'] .= (strpos($params['callback'], '?') !== false ? '&' : '?') . 'uri=' . urlencode($uri);
            $data = file_get_contents($params['callback']);
            echo "Performing callback: " . $params['callback'] . "\n\n";
            echo "Callback script returned:\n" . $data;
            storeCallbackData($job['entryId'], $data, $params);
            break;
        default:
            echo "Unknown ordertype: " . $job['orderType'] . "\n";
            d($job);
            die;
    }
}
Ejemplo n.º 23
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = FileInfo::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 24
0
 /**
  * (PHP 5 &gt;= 5.3.0 )<br/>
  * Get array of files, using the currently path
  * @return Boolean true if the reading was ok , false if has  errors.
  */
 public function readFolder()
 {
     $read = false;
     if (file_exists($this->rootPath)) {
         $read = true;
         $files = scandir($this->rootPath);
         natcasesort($files);
         if (count($files) > 0) {
             // All dirs
             foreach ($files as $file) {
                 //discard folders
                 if ($file == '.' || $file == '..') {
                     continue;
                 }
                 $path = $this->rootPath . "/" . $file;
                 if (is_dir($path)) {
                     $folderInfo = new FolderInfo();
                     $folderInfo->setName($file);
                     $folderInfo->setPath($path . "/");
                     $this->folderItemList->setItem($folderInfo);
                 }
             }
             $this->arrayAllFiles["folders"] = $this->folderItemList;
             // All files
             foreach ($files as $file) {
                 //dicart files
                 if ($file == '.' || $file == '..') {
                     continue;
                 }
                 $path = $this->rootPath . "/" . $file;
                 if (file_exists($path) && !is_dir($path)) {
                     $fileInfo = new FileInfo($path);
                     if (!$this->isFilterExtension($fileInfo->getExt())) {
                         $this->fileItemList->setItem($fileInfo);
                     }
                 }
             }
             $this->arrayAllFiles["files"] = $this->fileItemList;
         }
     }
     return $read;
 }
Ejemplo n.º 25
0
 /**
  * Рекурсивная функция для копирования директории со всеми
  * вложенными элементами.
  *
  * @param RecursiveDirectoryIterator $iterator
  * @param string $pathDestDir
  * @param integer $dirmode
  * @param integer $filemode
  * @throws System_FSException
  */
 private function coping(\RecursiveDirectoryIterator $iterator, $pathDestDir, $copyMode = CopyMode::SKIP_EXISTING, $dirmode = 0755, $filemode = 0644)
 {
     foreach ($iterator as $fileinfo) {
         $destDir = new FileInfo($pathDestDir . '/' . $fileinfo->getBasename());
         if ($iterator->hasChildren()) {
             if ($destDir->isLink() || $destDir->isFile()) {
                 throw new Exception\UnexpectedValueException();
             } elseif (!$destDir->isDir()) {
                 $destDir->controlDirectory()->create($dirmode);
             }
             $this->coping($iterator->getChildren(), $destDir->getRealPath(), $dirmode, $filemode);
         } elseif ($fileinfo->isLink()) {
             $fileinfo->openLink()->copyTo($destDir->getRealPath(), $copyMode);
         } elseif ($fileinfo->isFile()) {
             $fileinfo->openFile()->copyTo($destDir->getRealPath(), $copyMode);
         }
     }
 }