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


PHP Files::get_mime_type方法代码示例

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


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

示例1: layout

 /**
  * list images
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the anchor for this image
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url to view the image
         $url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')';
         } else {
             $label = $item['image_name'];
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['create_address'] . ' (' . $item['create_name'] . ')';
         if ($item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         }
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // url for enclosure
         $type = Files::get_mime_type($item['image_name']);
         $extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />';
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:layout_images_as_feed.php

示例2: render_embed

 /**
  * embed an interactive object
  *
  * The id designates the target file.
  * It can also include width and height of the target canvas, as in: '12, 100%, 250px'
  *
  * @param string id of the target file
  * @return string the rendered string
  **/
 public static function render_embed($id)
 {
     global $context;
     // split parameters
     $attributes = preg_split("/\\s*,\\s*/", $id, 4);
     $id = $attributes[0];
     // get the file
     if (!($item = Files::get($id))) {
         $output = '[embed=' . $id . ']';
         return $output;
     }
     // stream in a separate page
     if (isset($attributes[1]) && preg_match('/window/i', $attributes[1])) {
         if (!isset($attributes[2])) {
             $attributes[2] = i18n::s('Play in a separate window');
         }
         $output = '<a href="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'stream', $item['file_name']) . '" onclick="window.open(this.href); return false;" class="button"><span>' . $attributes[2] . '</span></a>';
         return $output;
     }
     // file extension
     $extension = strtolower(substr($item['file_name'], -3));
     // set a default size
     if (!isset($attributes[1])) {
         if (!strcmp($extension, 'gan')) {
             $attributes[1] = '98%';
         } elseif (!strcmp($extension, 'mm') && isset($context['skins_freemind_canvas_width'])) {
             $attributes[1] = $context['skins_freemind_canvas_width'];
         } else {
             $attributes[1] = 480;
         }
     }
     if (!isset($attributes[2])) {
         if (!strcmp($extension, 'gan')) {
             $attributes[2] = '300px';
         } elseif (!strcmp($extension, 'mm') && isset($context['skins_freemind_canvas_height'])) {
             $attributes[2] = $context['skins_freemind_canvas_height'];
         } else {
             $attributes[2] = 360;
         }
     }
     // object attributes
     $width = $attributes[1];
     $height = $attributes[2];
     $flashvars = '';
     if (isset($attributes[3])) {
         $flashvars = $attributes[3];
     }
     // rendering depends on file extension
     switch ($extension) {
         // stream a video
         case '3gp':
         case 'flv':
         case 'm4v':
         case 'mov':
         case 'mp4':
             // a flash player to stream a flash video
             $flvplayer_url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/player_flv_maxi.swf';
             // file is elsewhere
             if (isset($item['file_href']) && $item['file_href']) {
                 $url = $item['file_href'];
             } else {
                 $url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
             }
             // pass parameters to the player
             if ($flashvars) {
                 $flashvars = str_replace('autostart=true', 'autoplay=1', $flashvars) . '&';
             }
             $flashvars .= 'width=' . $width . '&height=' . $height;
             // if there is a static image for this video, use it
             if (isset($item['icon_url']) && $item['icon_url']) {
                 $flashvars .= '&startimage=' . urlencode($item['icon_url']);
             }
             // if there is a subtitle file for this video, use it
             if (isset($item['file_name']) && ($srt = 'files/' . str_replace(':', '/', $item['anchor']) . '/' . str_replace('.' . $extension, '.srt', $item['file_name'])) && file_exists($context['path_to_root'] . $srt)) {
                 $flashvars .= '&srt=1&srturl=' . urlencode($context['url_to_home'] . $context['url_to_root'] . $srt);
             }
             // if there is a logo file in the skin, use it
             Skin::define_img_href('FLV_IMG_HREF', 'codes/flvplayer_logo.png', '');
             if (FLV_IMG_HREF) {
                 $flashvars .= '&top1=' . urlencode(FLV_IMG_HREF . '|10|10');
             }
             // rely on Flash
             if (Surfer::has_flash()) {
                 // the full object is built in Javascript --see parameters at http://flv-player.net/players/maxi/documentation/
                 $output = '<div id="flv_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
                 Page::insert_script('var flashvars = { flv:"' . $url . '", ' . str_replace(array('&', '='), array('", ', ':"'), $flashvars) . '", autoload:0, margin:1, showiconplay:1, playeralpha:50, iconplaybgalpha:30, showfullscreen:1, showloading:"always", ondoubleclick:"fullscreen" }' . "\n" . 'var params = { allowfullscreen: "true", allowscriptaccess: "always" }' . "\n" . 'var attributes = { id: "file_' . $item['id'] . '", name: "file_' . $item['id'] . '"}' . "\n" . 'swfobject.embedSWF("' . $flvplayer_url . '", "flv_' . $item['id'] . '", "' . $width . '", "' . $height . '", "9", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", flashvars, params);' . "\n");
                 // native support
             } else {
                 // <video> is HTML5, <object> is legacy
                 $output = '<video width="' . $width . '" height="' . $height . '" autoplay="" controls="" src="' . $url . '" >' . "\n" . '	<object width="' . $width . '" height="' . $height . '" data="' . $url . '" type="' . Files::get_mime_type($item['file_name']) . '">' . "\n" . '		<param value="' . $url . '" name="movie" />' . "\n" . '		<param value="true" name="allowFullScreen" />' . "\n" . '		<param value="always" name="allowscriptaccess" />' . "\n" . '		<a href="' . $url . '">No video playback capabilities, please download the file</a>' . "\n" . '	</object>' . "\n" . '</video>' . "\n";
             }
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:code_embed.php

示例3: substr

     if ($name = implode(' - ', $name)) {
         Safe::header("icy-name: " . utf8::to_iso8859(utf8::transcode($name)));
     }
     // genre
     if ($value = implode(', ', @$data['comments_html']['genre'])) {
         Safe::header("icy-genre: " . utf8::to_iso8859(utf8::transcode($value)));
     }
     // audio bitrate
     if ($value = @$data['audio']['bitrate']) {
         Safe::header("icy-br: " . substr($value, 0, -3));
     }
     // this server
     Safe::header("icy-url: " . $context['url_to_home'] . $context['url_to_root']);
 }
 // serve the right type
 Safe::header('Content-Type: ' . Files::get_mime_type($item['file_name']));
 // suggest a name for the saved file
 $file_name = utf8::to_ascii($item['file_name']);
 Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
 // we accepted (limited) range requests
 Safe::header('Accept-Ranges: bytes');
 // provide only a slice of the file
 if (isset($_SERVER['HTTP_RANGE']) && !strncmp('bytes=', $_SERVER['HTTP_RANGE'], 6)) {
     // maybe several ranges
     $range = substr($_SERVER['HTTP_RANGE'], 6);
     // process only the first range, if several are specified
     if ($position = strpos($range, ',')) {
         $range = substr($range, 0, $position);
     }
     // beginning and end of the range
     list($offset, $end) = explode('-', $range);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:fetch.php

示例4: interact

 /**
  * integrate some player for the file, if any
  *
  * @param array the file to look at
  * @param int width for video player
  * @param int height of video player
  * @return string tags to be put in the HTML flow, or an empty string
  */
 public static function interact($item, $width = 320, $height = 240, $flashvars = '', $with_icon = TRUE)
 {
     global $context;
     static $counter;
     if (!isset($counter)) {
         $counter = 1;
     } else {
         $counter++;
     }
     // display explicit title, if any
     $title = '';
     if ($item['title']) {
         $title = '<p>' . Skin::strip($item['title']) . '</p>';
     }
     // several ways to play flash
     switch (strtolower(substr($item['file_name'], -3))) {
         // audio file handled by dewplayer
         case 'mp3':
             // only if the player is available
             if (file_exists($context['path_to_root'] . 'included/browser/dewplayer.swf')) {
                 // the player
                 $dewplayer_url = $context['url_to_root'] . 'included/browser/dewplayer.swf';
                 // the mp3 file
                 if (isset($item['file_href']) && $item['file_href']) {
                     $mp3_url = $item['file_href'];
                 } else {
                     $mp3_url = $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
                 }
                 $flashvars = 'son=' . $mp3_url;
                 // combine the two in a single object
                 $output = '<div id="interact_' . $counter . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n" . $title;
                 Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($mp3_url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $dewplayer_url . '", "interact_' . $counter . '", "200", "20", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
                 return $output;
             }
             // native flash
         // native flash
         case 'swf':
             // where to get the file
             if (isset($item['file_href']) && $item['file_href']) {
                 $url = $item['file_href'];
             } else {
                 $url = $context['url_to_home'] . $context['url_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . rawurlencode($item['file_name']);
             }
             $output = '<div id="interact_' . $counter . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div><br />' . "\n" . $title;
             Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.allowfullscreen = "true";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "interact_' . $counter . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
             return $output;
             // stream a video
         // stream a video
         case '3gp':
         case 'flv':
         case 'm4v':
         case 'mov':
         case 'mp4':
             // a flash player to stream a flash video
             $flvplayer_url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/player_flv_maxi.swf';
             // file is elsewhere
             if (isset($item['file_href']) && $item['file_href']) {
                 $url = $item['file_href'];
             } else {
                 $url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
             }
             // pass parameters to the player
             if ($flashvars) {
                 $flashvars = str_replace('autostart=true', 'autoplay=1', $flashvars) . '&';
             }
             $flashvars .= 'width=' . $width . '&height=' . $height;
             // rely on Flash
             if (Surfer::has_flash()) {
                 // the full object is built in Javascript --see parameters at http://flv-player.net/players/maxi/documentation/
                 $output = '<div id="interact_' . $counter . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n" . $title;
                 Page::insert_script('var flashvars = { flv:"' . $url . '", ' . str_replace(array('&', '='), array('", ', ':"'), $flashvars) . '", autoload:0, margin:1, showiconplay:1, playeralpha:50, iconplaybgalpha:30, showloading:"always", ondoubleclick:"fullscreen" }' . "\n" . 'var params = { allowfullscreen: "true", allowscriptaccess: "always" }' . "\n" . 'var attributes = { id: "interact_' . $counter . '", name: "file_' . $item['id'] . '"}' . "\n" . 'swfobject.embedSWF("' . $flvplayer_url . '", "interact_' . $counter . '", "' . $width . '", "' . $height . '", "9", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", flashvars, params);' . "\n");
                 // native support
             } else {
                 $output = '<object width="' . $width . '" height="' . $height . '" data="' . $url . '" type="' . Files::get_mime_type($item['file_name']) . '">' . "\n" . '	<param value="' . $url . '" name="movie" />' . "\n" . '	<param value="true" name="allowFullScreen" />' . "\n" . '	<param value="always" name="allowscriptaccess" />' . "\n" . '	<a href="' . $url . '">No video playback capabilities, please download the file</a>' . "\n" . '</object>' . "\n" . $title;
             }
             return $output;
     }
     if (!$with_icon) {
         return '';
     }
     // this is a reasonably large image
     if (Files::is_image($item['file_name']) && ($image_information = Safe::GetImageSize($context['path_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . $item['file_name'])) && $image_information[0] <= 600) {
         // provide a direct link to it!
         $src = $context['url_to_home'] . $context['url_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . rawurlencode($item['file_name']);
         $icon = '<img src="' . $src . '" width="' . $image_information[0] . '" height="' . $image_information[1] . '" alt="" style="padding: 3px"/>' . BR;
         return Skin::build_link(Files::get_download_url($item), $icon, 'basic') . $title;
     }
     // explicit icon
     if ($item['thumbnail_url']) {
         $icon = $item['thumbnail_url'];
     } else {
         $icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:files.php

示例5: post


//.........这里部分代码省略.........
         $body .= M_EOL . M_EOL . '--' . $boundary . '-internal--';
     }
     // a mix of things
     if (count($attachments)) {
         // encoding is irrelevant if there are multiple parts
         if (!strncmp($content_type, 'multipart/', 10)) {
             $content_encoding = '';
         } else {
             $content_encoding = M_EOL . 'Content-Transfer-Encoding: ' . $content_encoding;
         }
         // identify the main part of the overall message
         $content_start = 'mainpart';
         // the current body becomes the first part of a larger message
         $body = 'This is a multi-part message in MIME format.' . M_EOL . M_EOL . '--' . $boundary . '-external' . M_EOL . 'Content-Type: ' . $content_type . $content_encoding . M_EOL . 'Content-ID: <' . $content_start . '>' . M_EOL . M_EOL . $body;
         // message parts should be considered as an aggregate whole --see RFC 2387
         $content_type = 'multipart/related; type="multipart/alternative"; boundary="' . $boundary . '-external"';
         $content_encoding = '';
         // process every file
         foreach ($attachments as $name => $content) {
             // read external file content
             if (preg_match('/^[0-9]+$/', $name)) {
                 // only a file name has been provided
                 $name = $content;
                 // read file content from the file system
                 if (!($content = Safe::file_get_contents($name))) {
                     continue;
                 }
             }
             // file name is the file type
             if (preg_match('/name="(.+)?"/', $name, $matches)) {
                 $type = $name;
                 $name = $matches[1];
             } else {
                 $type = Files::get_mime_type($name);
             }
             // a unique id for for this file
             $cid = sprintf('%u@%s', crc32($name), $context['host_name']);
             // set a name that avoids problems
             $basename = utf8::to_ascii(basename($name));
             // headers for one file
             $body .= M_EOL . M_EOL . '--' . $boundary . '-external' . M_EOL . 'Content-Type: ' . $type . M_EOL . 'Content-Disposition: inline; filename="' . str_replace('"', '', $basename) . '"' . M_EOL . 'Content-ID: <' . $cid . '>';
             // transfer textual entities as they are
             if (!strncmp($type, 'text/', 5)) {
                 $body .= M_EOL . 'Content-Transfer-Encoding: quoted-printable' . M_EOL . M_EOL . quoted_printable_encode($content);
                 // encode everything else
             } else {
                 $body .= M_EOL . 'Content-Transfer-Encoding: base64' . M_EOL . M_EOL . chunk_split(base64_encode($content), 76, M_EOL);
             }
         }
         // the closing boundary
         $body .= M_EOL . M_EOL . '--' . $boundary . '-external--';
     }
     // Content-Type: header
     if ($content_type && !preg_match('/^Content-Type: /im', $headers)) {
         $headers .= M_EOL . 'Content-Type: ' . $content_type;
     }
     // Content-Transfer-Encoding: header
     if (!isset($boundary) && $content_encoding && !preg_match('/^Content-Transfer-Encoding: /im', $headers)) {
         $headers .= M_EOL . 'Content-Transfer-Encoding: ' . $content_encoding;
     }
     // Start: header
     if (isset($boundary) && isset($content_start) && $content_start && !preg_match('/^Start: /im', $headers)) {
         $headers .= M_EOL . 'Start: ' . $content_start;
     }
     // X-Mailer: header --helps to avoid spam filters
     if (!preg_match('/^X-Mailer: /im', $headers)) {
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:mailer.php


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