当前位置: 首页>>代码示例>>PHP>>正文


PHP files::getMimeType方法代码示例

本文整理汇总了PHP中files::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP files::getMimeType方法的具体用法?PHP files::getMimeType怎么用?PHP files::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在files的用法示例。


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

示例1: getFilesInfo

 /**
  * Retourne les informations des fichiers d'un article
  *
  * @return array
  */
 public function getFilesInfo()
 {
     $files = array();
     if (!$this->okt->diary->config->files['enable']) {
         return $files;
     }
     $files_array = array_filter((array) unserialize($this->files));
     $j = 1;
     for ($i = 1; $i <= $this->okt->diary->config->files['number']; $i++) {
         if (!isset($files_array[$i]) || empty($files_array[$i]['filename']) || !file_exists($this->okt->diary->upload_dir . 'files/' . $files_array[$i]['filename'])) {
             continue;
         }
         $mime_type = files::getMimeType($this->okt->diary->upload_dir . 'files/' . $files_array[$i]['filename']);
         $files[$j] = array_merge(stat($this->okt->diary->upload_dir . 'files/' . $files_array[$i]['filename']), array('url' => $this->okt->diary->upload_url . 'files/' . $files_array[$i]['filename'], 'filename' => $files_array[$i]['filename'], 'title' => $files_array[$i]['title'], 'mime' => $mime_type, 'type' => util::getMediaType($mime_type), 'ext' => pathinfo($this->okt->diary->upload_dir . 'files/' . $files_array[$i]['filename'], PATHINFO_EXTENSION)));
         $j++;
     }
     return $files;
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:23,代码来源:class.diary.recordset.php

示例2: getFilesInfo

 /**
  * Retourne les informations des fichiers d'une question
  *
  * @param string $imageslist
  * @return 	array
  */
 function getFilesInfo()
 {
     $files_infos = array();
     $files = unserialize($this->files);
     foreach ($files as $locale => $files) {
         $files_infos[$locale] = array();
         $i = 0;
         foreach ($files as $file) {
             $path = $this->okt->faq->upload_dir . $file;
             $url = $this->okt->faq->upload_url . $file;
             if (!file_exists($path)) {
                 continue;
             }
             $mime_type = files::getMimeType($path);
             $files_infos[$locale][$i] = array_merge(stat($path), array('filename' => $file, 'path' => $path, 'url' => $url, 'mime' => $mime_type, 'type' => util::getMediaType($mime_type), 'ext' => pathinfo($path, PATHINFO_EXTENSION)));
             $i++;
         }
     }
     return $files_infos;
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:26,代码来源:class.faq.recordset.php

示例3: newMediaObject

 private function newMediaObject($blog_id, $user, $pwd, $file)
 {
     if (empty($file['name'])) {
         throw new Exception('No file name');
     }
     if (empty($file['bits'])) {
         throw new Exception('No file content');
     }
     $file_name = $file['name'];
     $file_bits = base64_decode($file['bits']);
     $this->setUser($user, $pwd);
     $this->setBlog();
     $media = new dcMedia($this->core);
     $dir_name = path::clean(dirname($file_name));
     $file_name = basename($file_name);
     $dir_name = preg_replace('!^/!', '', $dir_name);
     if ($dir_name != '') {
         $dir = explode('/', $dir_name);
         $cwd = './';
         foreach ($dir as $v) {
             $v = files::tidyFileName($v);
             $cwd .= $v . '/';
             $media->makeDir($v);
             $media->chdir($cwd);
         }
     }
     $media_id = $media->uploadBits($file_name, $file_bits);
     $f = $media->getFile($media_id);
     return array('file' => $file_name, 'url' => $f->file_url, 'type' => files::getMimeType($file_name));
 }
开发者ID:nikrou,项目名称:dotclear,代码行数:30,代码来源:class.dc.xmlrpc.php

示例4: __construct

 /**
  * Constructor
  *
  * Creates an instance of fileItem object.
  *
  * @param string	$file		Absolute file or directory path
  * @param string	$root		File root path
  * @param string	$root_url		File root URL
  */
 public function __construct($file, $root, $root_url = '')
 {
     $file = path::real($file);
     $stat = stat($file);
     $path = path::info($file);
     $rel = preg_replace('/^' . preg_quote($root, '/') . '\\/?/', '', $file);
     $this->file = $file;
     $this->basename = $path['basename'];
     $this->dir = $path['dirname'];
     $this->relname = $rel;
     $this->file_url = str_replace('%2F', '/', rawurlencode($rel));
     $this->file_url = $root_url . $this->file_url;
     $this->dir_url = dirname($this->file_url);
     $this->extension = $path['extension'];
     $this->mtime = $stat[9];
     $this->size = $stat[7];
     $this->mode = $stat[2];
     $this->uid = $stat[4];
     $this->gid = $stat[5];
     $this->w = is_writable($file);
     $this->d = is_dir($file);
     $this->f = is_file($file);
     $this->x = file_exists($file . '/.');
     $this->del = files::isDeletable($file);
     $this->type = $this->d ? null : files::getMimeType($file);
     $this->type_prefix = preg_replace('/^(.+?)\\/.+$/', '$1', $this->type);
 }
开发者ID:HackerMajor,项目名称:root,代码行数:36,代码来源:class.filemanager.php

示例5: dirname

require dirname(__FILE__) . '/../inc/admin/prepend.php';
dcPage::check('admin');
# -- Loading themes --
$core->themes = new dcThemes($core);
$core->themes->loadModules($core->blog->themes_path, null);
# -- Page helper --
$list = new adminThemesList($core->themes, $core->blog->themes_path, $core->blog->settings->system->store_theme_url);
adminThemesList::$distributed_modules = explode(',', DC_DISTRIB_THEMES);
# -- Theme screenshot --
if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) {
    $f = path::real(empty($_GET['src']) ? $core->blog->themes_path . '/' . $_GET['shot'] . '/screenshot.jpg' : $core->blog->themes_path . '/' . $_GET['shot'] . '/' . path::clean($_GET['src']));
    if (!file_exists($f)) {
        $f = dirname(__FILE__) . '/images/noscreenshot.png';
    }
    http::cache(array_merge(array($f), get_included_files()));
    header('Content-Type: ' . files::getMimeType($f));
    header('Content-Length: ' . filesize($f));
    readfile($f);
    exit;
}
# -- Display module configuration page --
if ($list->setConfiguration($core->blog->settings->system->theme)) {
    # Get content before page headers
    include $list->includeConfiguration();
    # Gather content
    $list->getConfiguration();
    # Display page
    dcPage::open(__('Blog appearance'), dcPage::jsPageTabs() . dcPage::jsColorPicker() . $core->callBehavior('themesToolsHeaders', $core, true), dcPage::breadcrumb(array(html::escapeHTML($core->blog->name) => '', __('Blog appearance') => $list->getURL('', false), '<span class="page-title">' . __('Theme configuration') . '</span>' => '')));
    # Display previously gathered content
    $list->displayConfiguration();
    dcPage::helpBlock('core_blog_theme_conf');
开发者ID:nikrou,项目名称:dotclear,代码行数:31,代码来源:blog_theme.php

示例6: uploadImage

 /**
  * Upload an image in images folder
  *
  * @param  string $folder images folder
  * @param  string $f      selected image file (as $_FILES[<file input fieldname>])
  * @param  int    $width  check accurate width of uploaded image if <> 0
  *
  * @return string         full pathname of uploaded image
  */
 public static function uploadImage($folder, $f, $width = 0)
 {
     if (!self::canWriteImages($folder, true)) {
         throw new Exception(__('Unable to create images.'));
     }
     $name = $f['name'];
     $type = files::getMimeType($name);
     if ($type != 'image/jpeg' && $type != 'image/png') {
         throw new Exception(__('Invalid file type.'));
     }
     $dest = self::imagesPath($folder) . '/uploaded' . ($type == 'image/png' ? '.png' : '.jpg');
     if (@move_uploaded_file($f['tmp_name'], $dest) === false) {
         throw new Exception(__('An error occurred while writing the file.'));
     }
     if ($width) {
         $s = getimagesize($dest);
         if ($s[0] != $width) {
             throw new Exception(sprintf(__('Uploaded image is not %s pixels wide.'), $width));
         }
     }
     return $dest;
 }
开发者ID:nikrou,项目名称:dotclear,代码行数:31,代码来源:lib.themeconfig.php

示例7: removeFile

 /**
 Removes a file.
 
 @param	f		<b>fileItem</b>	fileItem object
 */
 public function removeFile($f)
 {
     if (!$this->core->auth->check('media,media_admin', $this->core->blog->id)) {
         throw new Exception(__('Permission denied.'));
     }
     $media_file = $this->relpwd ? path::clean($this->relpwd . '/' . $f) : path::clean($f);
     $strReq = 'DELETE FROM ' . $this->table . ' ' . "WHERE media_path = '" . $this->con->escape($this->path) . "' " . "AND media_file = '" . $this->con->escape($media_file) . "' ";
     if (!$this->core->auth->check('media_admin', $this->core->blog->id)) {
         $strReq .= "AND user_id = '" . $this->con->escape($this->core->auth->userID()) . "'";
     }
     $this->con->execute($strReq);
     if ($this->con->changes() == 0) {
         throw new Exception(__('File does not exist in the database.'));
     }
     parent::removeFile($f);
     $this->callFileHandler(files::getMimeType($media_file), 'remove', $f);
 }
开发者ID:HackerMajor,项目名称:root,代码行数:22,代码来源:class.dc.media.php

示例8: removeFile

 /**
 Removes a file.
 
 @param	f		<b>fileItem</b>	fileItem object
 */
 public function removeFile($f)
 {
     if (!$this->okt->checkPerm('media') && !$this->okt->checkPerm('media_admin')) {
         throw new Exception(__('Permission denied.'));
     }
     $media_file = $this->relpwd ? path::clean($this->relpwd . '/' . $f) : path::clean($f);
     $strReq = 'DELETE FROM ' . $this->t_media . ' ' . "WHERE media_path = '" . $this->db->escapeStr($this->path) . "' " . "AND media_file = '" . $this->db->escapeStr($media_file) . "' ";
     if (!$this->okt->checkPerm('media_admin')) {
         $strReq .= 'AND user_id = ' . (int) $this->okt->user->id . ' ';
     }
     $this->db->execute($strReq);
     if ($this->db->affectedRows() == 0) {
         throw new Exception(__('File does not exist in the database.'));
     }
     parent::removeFile($f);
     $this->callFileHandler(files::getMimeType($media_file), 'remove', $f);
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:22,代码来源:class.oktMedia.php

示例9: createImages

 public static function createImages(&$config, $uploaded)
 {
     $body_color = $config['body_bg_c'];
     $prelude_color = $config['prelude_c'];
     $gradient = $config['body_bg_g'];
     $comment_color = $config['post_comment_bg_c'];
     $comment_color_my = $config['post_commentmy_bg_c'];
     $top_image = $config['top_image'];
     $config['top_height'] = null;
     if ($top_image != 'custom' && !isset(self::$top_images[$top_image])) {
         $top_image = 'default';
     }
     if ($uploaded && !is_file($uploaded)) {
         $uploaded = null;
     }
     if (!self::canWriteImages(true)) {
         throw new Exception(__('Unable to create images.'));
     }
     $body_fill = array('light' => dirname(__FILE__) . '/../alpha-img/gradient-l.png', 'medium' => dirname(__FILE__) . '/../alpha-img/gradient-m.png', 'dark' => dirname(__FILE__) . '/../alpha-img/gradient-d.png');
     $body_g = isset($body_fill[$gradient]) ? $body_fill[$gradient] : false;
     if ($top_image == 'custom' && $uploaded) {
         $page_t = $uploaded;
     } else {
         $page_t = dirname(__FILE__) . '/../alpha-img/page-t/' . $top_image . '.png';
     }
     $body_bg = dirname(__FILE__) . '/../alpha-img/body-bg.png';
     $page_t_mask = dirname(__FILE__) . '/../alpha-img/page-t/image-mask.png';
     $page_b = dirname(__FILE__) . '/../alpha-img/page-b.png';
     $comment_t = dirname(__FILE__) . '/../alpha-img/comment-t.png';
     $comment_b = dirname(__FILE__) . '/../alpha-img/comment-b.png';
     $default_bg = '#e0e0e0';
     $default_prelude = '#ededed';
     self::dropImage(basename($body_bg));
     self::dropImage('page-t.png');
     self::dropImage(basename($page_b));
     self::dropImage(basename($comment_t));
     self::dropImage(basename($comment_b));
     $body_color = self::adjustColor($body_color);
     $prelude_color = self::adjustColor($prelude_color);
     $comment_color = self::adjustColor($comment_color);
     if ($top_image || $body_color || $gradient != 'light' || $prelude_color || $uploaded) {
         if (!$body_color) {
             $body_color = $default_bg;
         }
         $body_color = sscanf($body_color, '#%2X%2X%2X');
         # Create body gradient with color
         $d_body_bg = imagecreatetruecolor(50, 180);
         $fill = imagecolorallocate($d_body_bg, $body_color[0], $body_color[1], $body_color[2]);
         imagefill($d_body_bg, 0, 0, $fill);
         # User choosed a gradient
         if ($body_g) {
             $s_body_bg = imagecreatefrompng($body_g);
             imagealphablending($s_body_bg, true);
             imagecopy($d_body_bg, $s_body_bg, 0, 0, 0, 0, 50, 180);
             imagedestroy($s_body_bg);
         }
         if (!$prelude_color) {
             $prelude_color = $default_prelude;
         }
         $prelude_color = sscanf($prelude_color, '#%2X%2X%2X');
         $s_prelude = imagecreatetruecolor(50, 30);
         $fill = imagecolorallocate($s_prelude, $prelude_color[0], $prelude_color[1], $prelude_color[2]);
         imagefill($s_prelude, 0, 0, $fill);
         imagecopy($d_body_bg, $s_prelude, 0, 0, 0, 0, 50, 30);
         imagepng($d_body_bg, self::imagesPath() . '/' . basename($body_bg));
     }
     if ($top_image || $body_color || $gradient != 'light') {
         # Create top image from uploaded image
         $size = getimagesize($page_t);
         $size = $size[1];
         $type = files::getMimeType($page_t);
         $d_page_t = imagecreatetruecolor(800, $size);
         if ($type == 'image/png') {
             $s_page_t = @imagecreatefrompng($page_t);
         } else {
             $s_page_t = @imagecreatefromjpeg($page_t);
         }
         if (!$s_page_t) {
             throw new exception(__('Unable to open image.'));
         }
         $fill = imagecolorallocate($d_page_t, $body_color[0], $body_color[1], $body_color[2]);
         imagefill($d_page_t, 0, 0, $fill);
         if ($type == 'image/png') {
             # PNG, we only add body gradient and image
             imagealphablending($s_page_t, true);
             imagecopyresized($d_page_t, $d_body_bg, 0, 0, 0, 50, 800, 130, 50, 130);
             imagecopy($d_page_t, $s_page_t, 0, 0, 0, 0, 800, $size);
         } else {
             # JPEG, we add image and a frame with rounded corners
             imagecopy($d_page_t, $s_page_t, 0, 0, 0, 0, 800, $size);
             imagecopy($d_page_t, $d_body_bg, 0, 0, 0, 50, 8, 4);
             imagecopy($d_page_t, $d_body_bg, 0, 4, 0, 54, 4, 4);
             imagecopy($d_page_t, $d_body_bg, 792, 0, 0, 50, 8, 4);
             imagecopy($d_page_t, $d_body_bg, 796, 4, 0, 54, 4, 4);
             $mask = imagecreatefrompng($page_t_mask);
             imagealphablending($mask, true);
             imagecopy($d_page_t, $mask, 0, 0, 0, 0, 800, 11);
             imagedestroy($mask);
             $fill = imagecolorallocate($d_page_t, 255, 255, 255);
             imagefilledrectangle($d_page_t, 0, 11, 3, $size - 1, $fill);
//.........这里部分代码省略.........
开发者ID:HackerMajor,项目名称:root,代码行数:101,代码来源:class.blowup.config.php

示例10: mediaFireRecreateEvent

 /**
 Calls file handlers registered for recreate event
 
 @param	f	<b>fileItem</b>	fileItem object
 */
 public function mediaFireRecreateEvent($f)
 {
     $media_type = files::getMimeType($f->basename);
     $this->callFileHandler($media_type, 'recreate', null, $f->basename);
     // Args list to be completed as necessary (Franck)
 }
开发者ID:nikrou,项目名称:dotclear,代码行数:11,代码来源:class.dc.media.php


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