コード例 #1
0
ファイル: kfmFile.php プロジェクト: lxthien/batdongsan
 function kfmFile()
 {
     global $kfm;
     if (func_num_args() == 1) {
         $this->id = (int) func_get_arg(0);
         parent::__construct();
         $filedata = db_fetch_row("SELECT id,name,directory FROM " . KFM_DB_PREFIX . "files WHERE id=" . $this->id);
         $this->name = $filedata['name'];
         $this->parent = $filedata['directory'];
         $dir = kfmDirectory::getInstance($this->parent);
         $this->dir = $dir;
         $this->directory = $dir->path();
         $this->path = $this->directory . '/' . $filedata['name'];
         if (!$this->exists()) {
             //				$this->error(kfm_lang('File cannot be found')); // removed because it is causing false errors
             $this->delete();
             return false;
         }
         $this->writable = $this->isWritable();
         $this->ctime = filemtime($this->path) + $GLOBALS['kfm_server_hours_offset'] * 3600;
         $this->modified = strftime($kfm->setting('date_format') . ' ' . $kfm->setting('time_format'), filemtime($this->path));
         $mimetype = Mimetype::get($this->path);
         $pos = strpos($mimetype, ';');
         $this->mimetype = $pos === false ? $mimetype : substr($mimetype, 0, $pos);
         $this->type = trim(substr(strstr($this->mimetype, '/'), 1));
     }
 }
コード例 #2
0
ファイル: get.php プロジェクト: adammajchrzak/silesiamaps
// { headers
if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
    $name = preg_replace('/\\./', '%2e', $name, substr_count($name, '.') - 1);
}
@set_time_limit(0);
header('Cache-Control: max-age = 2592000');
header('Expires-Active: On');
header('Expires: Fri, 1 Jan 2500 01:01:01 GMT');
header('Pragma:');
$filesize = filesize($path);
header('Content-Length: ' . (string) filesize($path));
if (isset($_GET['forcedownload'])) {
    header('Content-Type: force/download');
    header('Content-Disposition: attachment; filename="' . $name . '"');
} else {
    header('Content-Type: ' . Mimetype::get($extension));
}
header('Content-Transfer-Encoding: binary');
// }
if ($file = fopen($path, 'rb')) {
    // send file
    while (!feof($file) && connection_status() == 0) {
        print fread($file, 1024 * 8);
        flush();
    }
    fclose($file);
}
if (file_exists('api/log_retrieved_file.php')) {
    require 'api/log_retrieved_file.php';
}
return connection_status() == 0 and !connection_aborted();