• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_mimetype函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_mimetype函数的典型用法代码示例。如果您正苦于以下问题:PHP get_mimetype函数的具体用法?PHP get_mimetype怎么用?PHP get_mimetype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_mimetype函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_image

 function get_image()
 {
     $mime = get_mimetype($this->path);
     viscacha_header('Content-Type: ' . $mime['mime']);
     readfile($this->path);
     exit;
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:7,代码来源:class.thumbnail.php


示例2: kfmFile

 function kfmFile()
 {
     global $kfm;
     if (func_num_args() == 1) {
         $this->id = (int) func_get_arg(0);
         parent::kfmObject();
         $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->directory = $dir->path;
         $this->path = $dir->path . '/' . $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 = get_mimetype($this->path);
         $pos = strpos($mimetype, ';');
         $this->mimetype = $pos === false ? $mimetype : substr($mimetype, 0, $pos);
         $this->type = trim(substr(strstr($this->mimetype, '/'), 1));
     }
 }
开发者ID:blumine,项目名称:vunsy,代码行数:26,代码来源:file.class.php


示例3: get_file

 function get_file($file, $rev = "")
 {
     global $TPL;
     $f = realpath(wiki_module::get_wiki_path() . $file);
     if (path_under_path(dirname($f), wiki_module::get_wiki_path())) {
         $mt = get_mimetype($f);
         if (strtolower($mt) != "text/plain") {
             $s = "<h6>Download File</h6>";
             $s .= "<a href='" . $TPL["url_alloc_fileDownload"] . "file=" . urlencode($file) . "'>" . $file . "</a>";
             $TPL["str_html"] = $s;
             include_template("templates/fileGetM.tpl");
             exit;
         }
         // Get the regular revision ...
         $disk_file = file_get_contents($f) or $disk_file = "";
         $vcs = vcs::get();
         //$vcs->debug = true;
         // Get a particular revision
         if ($vcs) {
             $vcs_file = $vcs->cat($f, $rev);
         }
         if ($vcs && wiki_module::nuke_trailing_spaces_from_all_lines($disk_file) != wiki_module::nuke_trailing_spaces_from_all_lines($vcs_file)) {
             if (!$vcs_file) {
                 $TPL["msg"] = "<div class='message warn noprint' style='margin-top:0px; margin-bottom:10px; padding:10px;'>\n                          Warning: This file may not be under version control.\n                         </div>";
             } else {
                 $TPL["msg"] = "<div class='message warn noprint' style='margin-top:0px; margin-bottom:10px; padding:10px;'>\n                          Warning: This file may not be the latest version.\n                         </div>";
             }
         }
         if ($rev && $vcs_file) {
             $TPL["str"] = $vcs_file;
         } else {
             $TPL["str"] = $disk_file;
         }
         $wikiMarkup = config::get_config_item("wikiMarkup");
         $TPL["str_html"] = $wikiMarkup($TPL["str"]);
         $TPL["rev"] = urlencode($rev);
         include_template("templates/fileGetM.tpl");
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:39,代码来源:init.php


示例4: send_file_from_datadir

/** the designated file is sent to the visitor
 *
 * This transmits the file {$CFG->datadir}$file from
 * the data directory to the visitor's browser, suggesting
 * the name $name. The file is transmitted in chunks 
 * (see {@link readfile_chunked()}).
 *
 * Several different variations are possible.
 *
 *  - by specifying a Time To Live of 0 seconds, this routine
 *    tries hard to defeat any caching by proxies
 *
 *  - if the download flag is TRUE, this routine tries to
 *    prevent the visitor's browser to render the file in-line
 *    suggesting downloading instead
 *
 * Quirks
 *
 *  - There appears to be a problem with Internet Explorer and https://
 *    and caching which requires a specific workaround. We simply check
 *    for 'https:' or 'http'.
 *
 *  - Adobe Acrobat Reader has a bad track record of infecting
 *    user's computers with malware when PDF's are rendered in-line.
 *    Therefore we force download for that kind of files.
 *
 *  - It is not easy to determine the exact mime type of files
 *    without resorting to a complex shadow-filesystem or a metadata
 *    table in the database. Therefore we 'guess' the mime type, either
 *    based on the information provided by the fileinfo PHP-module, or
 *    simply based on the extension of $file (which is not very reliable,
 *    but we have to do _something_). See {@link get_mimetype()} for details.
 *
 * @param string $file name of the file to send relative to $CFG->datadir
 * @param string $name filename to suggest to the visitor/visitor's browser
 * @param string $mimetype the mime type of the file; if not specified we use an educated guess
 * @param int $ttl time to live (aka maximum age) in seconds, 0 implies file is not cacheable
 * @param bool $download if TRUE we try to force a download
 * @uses get_mimetype()
 */
function send_file_from_datadir($file, $name, $mimetype = '', $ttl = 86400, $download = FALSE)
{
    global $CFG;
    $path = $CFG->datadir . $file;
    $mtime = filemtime($path);
    $fsize = filesize($path);
    if (empty($mimetype)) {
        $mimetype = get_mimetype($path);
    }
    // Try to prevent inline rendering of PDF because of bugs in Adobe Reader
    $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
    if ($mimetype == 'application/pdf' || $ext == 'pdf') {
        $download = TRUE;
        $ttl = 0;
    }
    $headers = array();
    $headers['Last-Modified'] = rfc1123date($mtime);
    $headers['Content-Disposition'] = sprintf('%s; filename=%s', $download ? 'attachment' : 'inline', urlencode($name));
    $headers['Content-Type'] = $mimetype;
    $headers['Content-Length'] = $fsize;
    $headers['Accept-Ranges'] = 'none';
    if ($ttl > 0) {
        $headers['Cache-Control'] = sprintf('max-age=%d', $ttl);
        $headers['Expires'] = rfc1123date(time() + $ttl);
        $headers['Pragma'] = '';
    } else {
        if (strtolower(substr($CFG->www, 0, 6)) == 'https:') {
            $ttl = 10;
            $headers['Cache-Control'] = sprintf('max-age=%d', $ttl);
            $headers['Expires'] = rfc1123date(time() - 86400);
            // 24h in the past
            $headers['Pragma'] = '';
        } else {
            $headers['Cache-Control'] = 'private, must-revalidate, max-age=0';
            $headers['Expires'] = rfc1123date(time() - 86400);
            // 24h in the past
            $headers['Pragma'] = 'no-cache';
        }
    }
    foreach ($headers as $k => $v) {
        @header(trim($k . ': ' . $v));
    }
    $bytes = readfile_chunked($path);
    return $bytes;
}
开发者ID:BackupTheBerlios,项目名称:websiteatschool,代码行数:85,代码来源:main_file.php


示例5: add_attachment

 function add_attachment($file)
 {
     if (file_exists($file) && is_readable($file) && filesize($file)) {
         $mime_boundary = $this->get_mime_boundary();
         $this->add_header("MIME-Version", "1.0");
         $this->add_header("Content-Type", "multipart/mixed; boundary=\"" . $mime_boundary . "\"");
         $this->add_header("Content-Disposition", "inline");
         // Read the file to be attached ('rb' = read binary)
         $fh = fopen($file, 'rb');
         $data = fread($fh, filesize($file));
         fclose($fh);
         $mimetype = get_mimetype($file);
         // Base64 encode the file data
         $data = chunk_split(base64_encode($data));
         $name = basename($file);
         $this->body = $this->get_top_mime_header() . $this->body;
         $this->body .= "\n\n--" . $mime_boundary;
         $this->body .= "\nContent-Type: " . $mimetype . "; name=\"" . $name . "\"";
         $this->body .= "\nContent-Disposition: attachment; filename=\"" . $name . "\"";
         $this->body .= "\nContent-Transfer-Encoding: base64";
         $this->body .= "\n\n" . $data;
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:23,代码来源:email_send.inc.php


示例6: fopen

 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
// For use like get_attachment.php?entity=project&id=5&file=foo.bar
require_once "../alloc.php";
$file = $_GET["file"];
if (isset($_GET["id"]) && $file && !bad_filename($file)) {
    $entity = new $_GET["entity"]();
    $entity->set_id(sprintf("%d", $_GET["id"]));
    $entity->select();
    $file = ATTACHMENTS_DIR . $_GET["entity"] . "/" . $_GET["id"] . "/" . $file;
    if ($entity->has_attachment_permission($current_user)) {
        if (file_exists($file)) {
            $fp = fopen($file, "rb");
            $mimetype = get_mimetype($file);
            // Forge html for the whatsnew files
            if (basename(dirname(dirname($file))) == "whatsnew") {
                $forged_suffix = ".html";
                $mimetype = "text/html";
            }
            header('Content-Type: ' . $mimetype);
            header("Content-Length: " . filesize($file));
            header('Content-Disposition: inline; filename="' . basename($file) . $forged_suffix . '"');
            fpassthru($fp);
            exit;
        } else {
            echo "File not found.";
            exit;
        }
    } else {
开发者ID:cjbayliss,项目名称:alloc,代码行数:31,代码来源:get_attachment.php


示例7: display_items

        display_items('Archive For ' . get_list_name($_GET['id']), get_archive($_GET['id']), 'view-html', 'view-text', '');
        break;
    case 'information':
        display_information($_GET['id']);
        break;
    default:
        if (!check_logged_in()) {
            display_login_form($action);
        }
        break;
}
//all other actions require user to be logged in
if (check_logged_in()) {
    switch ($action) {
        case 'account-settings':
            display_account_form(get_email(), get_real_name(get_email()), get_mimetype(get_email()));
            break;
        case 'show-other-lists':
            display_items('Unsubscribed Lists', get_unsubscribed_lists(get_email()), 'information', 'show-archive', 'subscribe');
            break;
        case 'subscribe':
            subscribe(get_email(), $_GET['id']);
            display_items('Subscribed Lists', get_subscribed_lists(get_email()), 'information', 'show-archive', 'unsubscribe');
            break;
        case 'unsubscribe':
            unsubscribe(get_email(), $_GET['id']);
            display_items('Subscribed Lists', get_subscribed_lists(get_email()), 'information', 'show-archive', 'unsubscribe');
            break;
        case '':
        case 'show-my-lists':
            display_items('Subscribed Lists', get_subscribed_lists(get_email()), 'information', 'show-archive', 'unsubscribe');
开发者ID:kai-cn,项目名称:bookcode-php-mysql-web-development,代码行数:31,代码来源:index.php


示例8: upload

/**
 * 文件上传
 *
 * 返回的数组索引
 * mime_type 文件类型
 * size      文件大小(单位KB)
 * file_path 文件路径
 * width     宽度
 * height    高度
 * 可选值(仅在上传文件是图片且系统开启缩略图时起作用)
 * thum_file   缩略图的路径
 * thum_width  缩略图宽度
 * thum_height 缩略图高度
 * thum_size   缩略图大小(单位KB)
 *
 * @param string $fileName 文件名
 * @param string $errorNum 错误码:$_FILES['error']
 * @param string $tmpFile 上传后的临时文件
 * @param string $fileSize 文件大小 KB
 * @param array $type 允许上传的文件类型
 * @param boolean $isIcon 是否为上传头像
 * @param boolean $is_thumbnail 是否生成缩略图
 * @return array 文件数据 索引 
 * 
 */
function upload($fileName, $errorNum, $tmpFile, $fileSize, $type, $isIcon = false, $is_thumbnail = true)
{
    if ($errorNum == 1) {
        return '100';
        //文件大小超过系统限制
    } elseif ($errorNum > 1) {
        return '101';
        //上传文件失败
    }
    $extension = getFileSuffix($fileName);
    if (!in_array($extension, $type)) {
        return '102';
        //错误的文件类型
    }
    if ($fileSize > Option::getAttMaxSize()) {
        return '103';
        //文件大小超出emlog的限制
    }
    $file_info = array();
    $file_info['file_name'] = $fileName;
    $file_info['mime_type'] = get_mimetype($extension);
    $file_info['size'] = $fileSize;
    $file_info['width'] = 0;
    $file_info['height'] = 0;
    $uppath = Option::UPLOADFILE_PATH . gmdate('Ym') . '/';
    $fname = substr(md5($fileName), 0, 4) . time() . '.' . $extension;
    $attachpath = $uppath . $fname;
    $file_info['file_path'] = $attachpath;
    if (!is_dir(Option::UPLOADFILE_PATH)) {
        @umask(0);
        $ret = @mkdir(Option::UPLOADFILE_PATH, 0777);
        if ($ret === false) {
            return '104';
            //创建文件上传目录失败
        }
    }
    if (!is_dir($uppath)) {
        @umask(0);
        $ret = @mkdir($uppath, 0777);
        if ($ret === false) {
            return '105';
            //上传失败。文件上传目录(content/uploadfile)不可写
        }
    }
    doAction('attach_upload', $tmpFile);
    // 生成缩略图
    $thum = $uppath . 'thum-' . $fname;
    if ($is_thumbnail) {
        if ($isIcon && resizeImage($tmpFile, $thum, Option::ICON_MAX_W, Option::ICON_MAX_H)) {
            $file_info['thum_file'] = $thum;
            $file_info['thum_size'] = filesize($thum);
            $size = getimagesize($thum);
            if ($size) {
                $file_info['thum_width'] = $size[0];
                $file_info['thum_height'] = $size[1];
            }
            resizeImage($tmpFile, $uppath . 'thum52-' . $fname, 52, 52);
        } elseif (resizeImage($tmpFile, $thum, Option::get('att_imgmaxw'), Option::get('att_imgmaxh'))) {
            $file_info['thum_file'] = $thum;
            $file_info['thum_size'] = filesize($thum);
            $size = getimagesize($thum);
            if ($size) {
                $file_info['thum_width'] = $size[0];
                $file_info['thum_height'] = $size[1];
            }
        }
    }
    if (@is_uploaded_file($tmpFile)) {
        if (@(!move_uploaded_file($tmpFile, $attachpath))) {
            @unlink($tmpFile);
            return '105';
            //上传失败。文件上传目录(content/uploadfile)不可写
        }
        @chmod($attachpath, 0777);
    }
//.........这里部分代码省略.........
开发者ID:flyysr,项目名称:emlog,代码行数:101,代码来源:function.base.php


示例9: downloadFile

function downloadFile($fileName, $path)
{
    $file_path = @realpath($path) . '/' . $fileName;
    traceDebug($file_path);
    $file_mime = @get_mimetype($fileName);
    if (!$file_mime) {
        $file_mime = "application/octet-stream";
    }
    header("Content-Type: {$file_mime}");
    header("Content-Length: " . @filesize($file_path));
    $agent = $_SERVER["HTTP_USER_AGENT"];
    if (is_int(strpos($agent, "MSIE"))) {
        $fn = preg_replace('/[:\\x5c\\/*?"<>|]/', '_', $fileName);
        header("Content-Disposition: attachment; filename=" . rawurlencode($fn));
    } else {
        if (is_int(strpos($agent, "Gecko"))) {
            header("Content-Disposition: attachment; filename*=UTF-8''" . rawurlencode($fileName));
        } else {
            if (is_int(strpos($agent, "Opera"))) {
                $fn = preg_replace('/[:\\x5c\\/{?]/', '_', $fileName);
                header("Content-Disposition: attachment; filename*=UTF-8''" . rawurlencode($fn));
            } else {
                $fn = mb_convert_encoding($fileName, "US-ASCII", "UTF-8");
                $fn = (string) str_replace("\\", "\\\\", $fn);
                $fn = (string) str_replace("\"", "\\\"", $fn);
                header("Content-Disposition: attachment; filename=\"{$fn}\"");
            }
        }
    }
    @readfile($file_path);
}
开发者ID:thantalas,项目名称:slim-nne,代码行数:31,代码来源:commonlib.php


示例10: sanitise_filetype

 /** try to make sure that the extension of file $name makes sense or matches the actual filetype
  *
  * this checks or changes the $name of the file in line with the
  * mimetype of the actual file (as established by get_mimetype()).
  *
  * The reason to do this is to make it harder to 'smuggle in' files
  * with deceptive filenames/extensions. Quite often the extension is
  * used to determine the type of the file, even by browsers that should
  * know better. By uploading a malicious .PDF using an innocuous extension
  * like .TXT, a browser may be tricked into rendering that .PDF inline.
  * By changing the extension from .TXT to .PDF we can mitigate that risk,
  * at least a little bit. (People somehow trust an extension even though
  * they should know better and file(1) says so...)
  *
  * Strategy is as follows. If the mimetype based on the $name matches the
  * actual mimetype, we can simply allow the name provided.
  *
  * If there is a difference, we try to find an extension that maps to the
  * same mimetype as that of the actual file. IOW: we put more trust in the
  * mimetype of the actual file than we do in the mimetype suggested by the
  * extension.
  *
  * @param string $path full path to the actual file (from $_FILES[$i]['tmp_name'])
  * @param string $name the requested name of the file to examine (from $_FILES[$i]['name'])
  * @param string $type the suggested filetype of the file (from $_FILES[$i]['type'])
  * @return string the sanitised name and extension based on the file type
  */
 function sanitise_filetype($path, $name, $type)
 {
     // 0 -- initialise: isolate the $filename and $ext
     if (strpos($name, '.') === FALSE) {
         // not a single dot -> filename without extension
         $filename = $name;
         $extension = '';
     } else {
         $components = explode('.', $name);
         $extension = array_pop($components);
         $filename = implode('.', $components);
         unset($components);
     }
     // 1 -- does actual file mimetype agree with the file extension?
     $type_path = get_mediatype(get_mimetype($path, $name));
     $ext = utf8_strtolower($extension);
     $mimetypes = get_mimetypes_array();
     $type_name = isset($mimetypes[$ext]) ? get_mediatype($mimetypes[$ext]) : 'application/octet-stream';
     if (strcmp($type_path, $type_name) == 0) {
         return $name;
     }
     // 2 -- No, we change the extension based on the actual mimetype of the file
     // 2A - lookup the first extension matching type, or use '' (which implies application/octet-stream)
     $new_extension = array_search($type_path, $mimetypes);
     if ($new_extension === FALSE || is_null($new_extension)) {
         $new_extension = '';
         logger(sprintf('%s.%s(): mimetype \'%s\' not recognised; using \'%s\' instead', __CLASS__, __FUNCTION__, $type_path, $mimetypes[$new_extension]));
     }
     // 2B - avoid tricks with double extensions (eg. upload of "malware.exe.txt")
     if ($new_extension == '') {
         if ($type_name == 'application/octet-stream') {
             // preserve original extension and case because the original
             // extension will yield 'application/octet-stream' when served via file.php,
             // i.e. there is no need to lose the extension if it yields the same mimetype anyway
             $new_name = $name;
         } elseif (strpos($filename, '.') === FALSE) {
             // filename has no dot =>
             // no part of existing filename can be mistaken for an extension =>
             // don't add anything at all
             $new_name = $filename;
         } else {
             // bare $filename already contains an extension =>
             // add '.bin' to force 'application/octet-stream'
             $new_name = $filename . '.bin';
         }
     } else {
         $new_name = $filename . '.' . $new_extension;
     }
     logger(sprintf('%s.%s(): namechange %s -> %s (%s)', __CLASS__, __FUNCTION__, $name, $new_name, $type_path), WLOG_DEBUG);
     return $new_name;
 }
开发者ID:BackupTheBerlios,项目名称:websiteatschool,代码行数:78,代码来源:filemanager.class.php


示例11: getErrorMessage

 /**
  * Prefilled error messages.
  *
  * @param int $status The $status var from FileUploader::uploadTo()
  * @return string The proper error message.
  */
 public function getErrorMessage($status)
 {
     switch ($status) {
         case UPLOAD_ERR_OK:
             // You should avoid this. Is not an error!
             return _("Upload completato con successo.");
         case UPLOAD_ERR_NO_FILE:
             return _("Non è stato selezionato alcun file.");
         case UPLOAD_ERR_INI_SIZE:
             return _("Il file eccede i limiti di sistema.");
         case UPLOAD_ERR_FORM_SIZE:
             DEBUG && error(_("Non affidarti a UPLOAD_ERR_FORM_SIZE!"));
             return _("Il file eccede i limiti imposti.");
         case UPLOAD_EXTRA_ERR_OVERSIZE:
             return sprintf(_("Il file pesa %s. Non può superare %s."), human_filesize($_FILES[$this->fileEntry]['size']), human_filesize($this->args['max-filesize']));
         case UPLOAD_EXTRA_ERR_CANT_SAVE_FILE:
             return _("Impossibile salvare il file.");
         case UPLOAD_EXTRA_ERR_CANT_READ_MIMETYPE:
             return _("Il MIME del file non è validabile.");
         case UPLOAD_EXTRA_ERR_UNALLOWED_MIMETYPE:
             $mime = get_mimetype($_FILES[$this->fileEntry]['tmp_name']);
             return sprintf(_("Il file é di un <em>MIME type</em> non concesso: <em>%s</em>."), esc_html($mime));
         case UPLOAD_EXTRA_ERR_UNALLOWED_FILE:
             $mime = get_mimetype($_FILES[$this->fileEntry]['tmp_name']);
             $allowed_filetypes = $this->mimeTypes->getFiletypes($this->args['category'], $mime);
             return multi_text(count($allowed_filetypes), sprintf(_("Il file ha un'estensione non valida. Estensioni attese: <em>%s</em>."), esc_html(implode(', ', $allowed_filetypes))), sprintf(_("Il file ha un'estensione non valida. Estensione attesa: <em>%s</em>."), esc_html($allowed_filetypes[0])));
         case UPLOAD_EXTRA_ERR_FILENAME_TOO_SHORT:
             return _("Il file ha un nome troppo breve.");
         case UPLOAD_EXTRA_ERR_FILENAME_TOO_LONG:
             return _("Il file ha un nome troppo lungo.");
         case UPLOAD_EXTRA_ERR_GENERIC_ERROR:
             return _("Errore di caricamento.");
         default:
             DEBUG && error(sprintf(_("Stato di errore non previsto: '%d'"), $status));
             return _("Errore durante l'upload.");
     }
 }
开发者ID:valerio-bozzolan,项目名称:boz-php-another-php-framework,代码行数:43,代码来源:class-FileUploader.php


示例12: substr

        $ct['snd'] = 'audio/basic';
        $ct['midi'] = 'audio/midi';
        $ct['mid'] = 'audio/midi';
        $ct['m3u'] = 'audio/x-mpegurl';
        $ct['tiff'] = 'image/tiff';
        $ct['tif'] = 'image/tiff';
        $ct['rtf'] = 'text/rtf';
        $ct['wml'] = 'text/vnd.wap.wml';
        $ct['wmls'] = 'text/vnd.wap.wmlscript';
        $ct['xsl'] = 'text/xml';
        $ct['xml'] = 'text/xml';

        $extension = substr($file, strrpos($filename, '.')+1);

        if (!$type = $ct[strtolower($extension)]) {

            $type = 'text/html';
        }

        return $type;
    }

$mime = get_mimetype($filename);

header('Content-disposition: attachment; filename='.$filename);
header('Content-type: '.$mime);
readfile($fullname);



?>
开发者ID:rcroxyosox,项目名称:jobtracker,代码行数:31,代码来源:forcedownload.php


示例13: send_file

/**
 * @brief Send a file to the client (download file)
 *
 * @warning     This function must be called before there was any HTML output!
 *
 * @param string $filename      The full path to the filename
 * @param string $mimetype      @li The mime type of the file
 *                              @li if NULL, we will try to read the mimetype from the file
 */
function send_file($filename, $mimetype = NULL)
{
    $mtime = ($mtime = filemtime($filename)) ? $mtime : gmtime();
    if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") != false) {
        header("Content-Disposition: attachment; filename=" . urlencode(basename($filename)) . "; modification-date=" . date('r', $mtime) . ";");
    } else {
        header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\"; modification-date=\"" . date('r', $mtime) . "\";");
    }
    if ($mimetype == NULL) {
        $mimetype = get_mimetype($filename);
    }
    // lib.functions.php
    header("Content-Type: " . $mimetype);
    header("Content-Length:" . filesize($filename));
    if (in_array('mod_xsendfile', apache_get_modules())) {
        header('X-Sendfile: ' . $filename);
    } else {
        readfile($filename);
    }
    exit;
}
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:30,代码来源:lib.php


示例14: CSS_colourCode

function CSS_colourCode($code)
{
    if ($code[0] == '#') {
        $code = substr($code, 1, strlen($code) - 1);
    }
    if (strlen($code) == 3) {
        $chars = str_split($code);
        foreach ($chars as $k => $v) {
            $chars[$k] = $v . $v;
        }
        var_dump($chars);
        $code = join('', $chars);
    }
    return $code;
}
$mimetype = get_mimetype(preg_replace('/.*\\./', '', $file));
if ($mimetype == 'text/css') {
    $parsed = USERBASE . '/f/.files/css_' . str_replace('/', '|', $file);
    if (!file_exists($parsed) || filectime($parsed) < filectime($file)) {
        $f = file_get_contents($file);
        // { cool stuff
        preg_match_all('/\\.([a-z\\-]*)\\(([^\\)]*)\\);/', $f, $matches);
        for ($i = 0; $i < count($matches[0]); ++$i) {
            switch ($matches[1][$i]) {
                case 'linear-gradient':
                    // {
                    $colours = explode(', ', $matches[2][$i]);
                    foreach ($colours as $k => $v) {
                        $colours[$k] = CSS_colourCode($v);
                    }
                    $css = 'background:-moz-linear-gradient(top,#' . $colours[0] . ',#' . $colours[1] . ');' . 'background:-webkit-gradient(linear,left top,left bottom,from(#' . $colours[0] . '), to(#' . $colours[1] . '));' . 'filter: progid:DXImageTransform.Microsoft.gradient(startColor' . 'str=#FF' . $colours[0] . ', endColorstr=#FF' . $colours[1] . ');' . '-ms-filter: "progid:DXImageTransform.Microsoft.gradient(start' . 'Colorstr=#FF' . $colours[0] . ', endColorstr=#FF' . $colours[1] . ')";';
开发者ID:AmandaSyachri,项目名称:webworks-webme,代码行数:31,代码来源:get-skin-file.php


示例15: display_items

        break;
    case 'show-all-lists':
        display_items('All Lists', get_all_lists(), 'information', 'show-archive', 'modify');
        break;
    case 'show-archive':
        display_items('Archive For ' . get_list_name($_GET['id']), get_archive($_GET['id']), 'view-html', 'view-text', '');
        break;
    case 'information':
        display_information($_GET['id']);
        break;
}
//all other actions require user to be logged in
if (check_logged_in()) {
    switch ($action) {
        case 'account-settings':
            display_account_form(get_user(), get_real_name(get_user()), get_mimetype(get_user()));
            break;
        case 'show-other-lists':
            display_items('Unsubscribed Lists', get_unsubscribed_lists(get_user()), 'information', 'show-archive', 'subscribe');
            break;
        case 'subscribe':
            subscribe(get_user(), $_GET['id']);
            display_items('Subscribed Lists', get_subscribed_lists(get_user()), 'information', 'show-archive', 'subscribe');
            break;
        case 'unsubscribe':
            unsubscribe(get_user(), $_GET['id']);
            display_items('Subscribed Lists', get_subscribed_lists(get_user()), 'information', 'show-archive', 'unsubscribe');
            break;
            //case '':
        //case '':
        case 'show-my-lists':
开发者ID:jamaBHacker,项目名称:TrimartEmailBlasts,代码行数:31,代码来源:index.php


示例16: is_file_in_category

/**
 * Know if a file belongs to a certain category
 *
 * @param string $filepath The file path
 * @param string $category The category
 * @return mixed FALSE if not
 */
function is_file_in_category($filepath, $category)
{
    expect('mimeTypes');
    $mime = get_mimetype($filepath);
    return $GLOBALS['mimeTypes']->isMimetypeInCategory($mime, $category);
}
开发者ID:valerio-bozzolan,项目名称:boz-php-another-php-framework,代码行数:13,代码来源:functions.php


示例17: preg_replace

        $name = $file->name;
        $extension = $file->getExtension();
    }
}
// { 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:');
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: ' . get_mimetype($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);
}
return connection_status() == 0 and !connection_aborted();
开发者ID:blumine,项目名称:vunsy,代码行数:31,代码来源:get.php


示例18: plugin_qform_action

function plugin_qform_action()
{
    global $vars, $script;
    $id = $vars['id'];
    $path = $_SESSION['qform']['_FILES'][$id]['path'];
    $name = $_SESSION['qform']['_FILES'][$id]['name'];
    if ($path != '' && file_exists($path)) {
        $got = @getimagesize($path);
        if (!isset($got[2])) {
            $got[2] = FALSE;
        }
        switch ($got[2]) {
            case 1:
                $type = 'image/gif';
                break;
            case 2:
                $type = 'image/jpeg';
                break;
            case 3:
                $type = 'image/png';
                break;
            case 4:
                $type = 'application/x-shockwave-flash';
                break;
            default:
                $type = get_mimetype($name);
        }
        $file = htmlspecialchars($name);
        $size = filesize($path);
        pkwk_common_headers();
        header('Content-Disposition: inline; filename="' . $file . '"');
        header('Content-Length: ' . $size);
        header('Content-Type: ' . $type);
        @readfile($path);
    } else {
        echo 'No data';
    }
    exit;
}
开发者ID:big2men,项目名称:qhm,代码行数:39,代码来源:qform.inc.php


示例19: define

<?php

define('DIRECTORY_CACHE', '../cache');
define('MAX_WIDTH', 1200);
define('MAX_HEIGHT', 1600);
$src = get_query('src', '');
if ($src == '' || strlen($src) <= 3) {
    _error('no image specified');
}
$src = get_imgsrc($src);
$mime = get_mimetype($src);
if (!function_exists('imagecreatetruecolor')) {
    _error('GD lib error: the function imagecreatetruecolor does not exist');
}
if (function_exists('imagefilter') && defined('IMG_FILTER_NEGATE')) {
    $imgFilters = array(1 => array(IMG_FILTER_NEGATE, 0), 2 => array(IMG_FILTER_GRAYSCALE, 0), 3 => array(IMG_FILTER_BRIGHTNESS, 1), 4 => array(IMG_FILTER_CONTRAST, 1), 5 => array(IMG_FILTER_COLORIZE, 4), 6 => array(IMG_FILTER_EDGEDETECT, 0), 7 => array(IMG_FILTER_EMBOSS, 0), 8 => array(IMG_FILTER_GAUSSIAN_BLUR, 0), 9 => array(IMG_FILTER_SELECTIVE_BLUR, 0), 10 => array(IMG_FILTER_MEAN_REMOVAL, 0), 11 => array(IMG_FILTER_SMOOTH, 0));
}
$w = (int) abs(get_query('w', 0));
// width
$h = (int) abs(get_query('h', 0));
// height
$z = (int) get_query('z', 1);
// zoom
$q = (int) abs(get_query('q', 80));
// quality
$a = get_query('a', 'c');
// align
$f = get_query('f', '');
// filter
$s = (bool) get_query('s', 0);
// sharpen
开发者ID:Albirew,项目名称:wp-manga-project-manager,代码行数:31,代码来源:generate_thumbnail.php


示例20: error

 $my->p = $slog->Permissions($row['board']);
 $file = NULL;
 if ($db->num_rows($result) != 1) {
     echo $tpl->parse("header");
     error($lang->phrase('no_upload_found'));
 }
 if ($my->p['forum'] == 0 || $my->p['downloadfiles'] == 0) {
     echo $tpl->parse("header");
     errorLogin();
 }
 $uppath = 'uploads/topics/' . $row['file'];
 if (!file_exists($uppath)) {
     error(array($lang->phrase('no_upload_found')));
 }
 $db->query('UPDATE ' . $db->pre . 'uploads SET hits = hits+1 WHERE id = ' . $_GET['id'], __LINE__, __FILE__);
 $mime = get_mimetype($uppath);
 if ($config['tpcdownloadspeed'] > 0 && $mime['browser'] == 'attachment') {
     $rundeslimit = round($config['tpcdownloadspeed'] * 1024);
     viscacha_header('Cache-control: private');
     viscacha_header('Content-Type: ' . $mime['mime']);
     viscacha_header('Content-Length: ' . filesize($uppath));
     viscacha_header('Content-Disposition: ' . $mime['browser'] . '; filename="' . $row['file'] . '"');
     flush();
     $fd = fopen($uppath, "r");
     while (!feof($fd)) {
         echo fread($fd, $rundeslimit);
         flush();
         sleep(1);
     }
     fclose($fd);
 } else {
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:31,代码来源:attachments.php



注:本文中的get_mimetype函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_mimetype_description函数代码示例发布时间:2022-05-15
下一篇:
PHP get_mimes函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap