コード例 #1
0
 public static function clean($f3, $filename)
 {
     $total_filesize = R::getCell('select sum(filesize) as total_filesize from cache');
     $cache_total_filesize_limit = $f3->get("UPLOAD.cache_total_size_limit");
     $cache_total_filesize_limit = PFH_File_helper::convert_filesize_in_bytes($cache_total_filesize_limit);
     if ($total_filesize > $cache_total_filesize_limit) {
         $caches = R::find("cache", "ORDER BY datetime");
         $count = count($caches);
         // 只有一個不刪除
         //if ($count < 2) {
         //    return;
         //}
         foreach ($caches as $key => $cache) {
             //不刪除最後一個
             //if ($key > $count - 1) {
             //    return;
             //}
             if ($cache->path === $filename) {
                 continue;
             }
             //throw new Exception("$key $cache->path");
             //echo $cache->path . "<br />";
             if (is_file($cache->path)) {
                 unlink($cache->path);
             }
             $total_filesize = $total_filesize - $cache->filesize;
             R::trash($cache);
             if ($total_filesize < $cache_total_filesize_limit) {
                 break;
             }
         }
     }
 }
コード例 #2
0
 function get_file($f3)
 {
     $hash_id = $f3->get("PARAMS.hash_id");
     $id = Base56::decode($hash_id);
     $file = PFH_File_model::get($id);
     $filename = $file->filename;
     $filetype = $file->filetype;
     $md5 = $file->md5;
     //$filepath = PFH_MD5::get_file_path($f3, $md5);
     //$filepath = PFH_ZIP::read($f3, $md5);
     //$filepath = PFH_MD5::get_file_path($f3, $md5);
     $filepath = PFH_Archive::read($f3, $md5, $filename);
     $action = "download";
     PFH_Log_model::create_log($f3, $file, $action);
     $force_download = FALSE;
     PFH_File_helper::download_contents($filepath, $filetype, $filename, $force_download);
 }
コード例 #3
0
ファイル: File_host.php プロジェクト: rivalinx/php-file-host
 private function _validate_file_size($f3, $file, $filesize = NULL)
 {
     // 檢查檔案
     if (is_null($filesize)) {
         // 沒設定不用檢查
         if ($f3->exists("UPLOAD.filesize") === FALSE || $f3->get("UPLOAD.filesize") < 1) {
             return TRUE;
         }
         $filesize = $f3->get("UPLOAD.filesize");
     }
     $filesize = PFH_File_helper::convert_filesize_in_bytes($filesize);
     if ($file['size'] > $filesize) {
         $message = "Your file size " . $file['size'] . " is too large. This type's size limitation is " . $filesize;
         $f3->set($this->session_error_key, $message);
         throw new Exception($message);
         return FALSE;
     } else {
         return TRUE;
     }
 }