本文整理汇总了PHP中get_mime_type函数的典型用法代码示例。如果您正苦于以下问题:PHP get_mime_type函数的具体用法?PHP get_mime_type怎么用?PHP get_mime_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_mime_type函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render_field_value
/**
* Convert a field value to something renderable.
*
* @param array The field details
* @param mixed The raw value
* @return mixed Rendered field (tempcode or string)
*/
function render_field_value($field, $ev)
{
if (is_object($ev)) {
return $ev;
}
if ($ev == '') {
return '';
}
$original_filename = basename($ev);
$download_url = (url_is_local($ev) ? get_custom_base_url() . '/' : '') . $ev;
if (strpos($ev, '::') !== false) {
list($ev, $original_filename) = explode('::', $ev);
$keep = symbol_tempcode('KEEP');
$download_url = find_script('catalogue_file') . '?original_filename=' . urlencode($original_filename) . '&file=' . urlencode(basename($ev)) . $keep->evaluate();
}
$extension = get_file_extension($ev);
require_code('mime_types');
$mime_type = get_mime_type($extension);
if ((strpos($mime_type, 'video') !== false || strpos($mime_type, 'audio') !== false) && addon_installed('galleries')) {
// Video/Audio HTML
switch ($mime_type) {
case 'video/quicktime':
$tpl = 'GALLERY_VIDEO_QT';
break;
case 'audio/x-pn-realaudio':
$tpl = 'GALLERY_VIDEO_RM';
break;
default:
$tpl = 'GALLERY_VIDEO_GENERAL';
}
return do_template($tpl, array('URL' => url_is_local($ev) ? get_custom_base_url() . '/' . $ev : $ev, 'WIDTH' => get_option('default_video_width'), 'HEIGHT' => get_option('default_video_height'), 'MIME_TYPE' => $mime_type));
}
return hyperlink($download_url, $original_filename, true, true);
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:41,代码来源:upload.php
示例2: addImage
/**
* @param string $contentId unique id
* @param array $image 'data' or 'path' are required.
* 'data' => image data,
* 'path' => image path,
* 'mimetype' => mime type,
* 'encoding' => encoding('base64'(default) or 'quoted-printable')
*
* @return self
*/
public function addImage($contentId, $image)
{
if (is_array($image)) {
foreach ($image as $k => $v) {
if (($lk = strtolower($k)) !== $k) {
$image[$lk] = $v;
unset($image[$k]);
}
}
} else {
$image = array("path" => $image);
}
if (!isset($image["data"]) && !isset($image["path"])) {
$message = __METHOD__ . "() must set arg2[data](image data) or arg2[path](image path).";
throw new Sabel_Exception_InvalidArgument($message);
}
if (!isset($image["data"])) {
if (($image["data"] = @file_get_contents($image["path"])) === false) {
$message = __METHOD__ . "() failed to open stream: No such file or directory in '{$image['path']}'.";
throw new Sabel_Exception_FileNotFound($message);
}
}
if (!isset($image["encoding"])) {
$image["encoding"] = "base64";
}
if (!isset($image["mimetype"])) {
$mimetype = get_mime_type($image["data"]);
$image["mimetype"] = !$mimetype ? "application/octet-stream" : $mimetype;
}
$this->inlineImages[] = array("cid" => $contentId, "data" => $image["data"], "mimetype" => $image["mimetype"], "encoding" => $image["encoding"]);
return $this;
}
开发者ID:reoring,项目名称:sabel,代码行数:42,代码来源:Html.php
示例3: metaCreateForm
function metaCreateForm($metadata, $oldFilename, $real_filename)
{
// globals
global $course_code, $group_hidden_input;
// lang globals
global $langAddMetadata, $langWorkFile, $langTitle, $langTitleHelp, $langDescription, $langDescriptionHelp, $langAuthor, $langAuthorHelp, $langLanguage, $langGreek, $langEnglish, $langFrench, $langGerman, $langItalian, $langSpanish, $langLanguageHelp, $langLearningResourceType, $langLearningResourceTypeHelp, $langKeywords, $langKeywordsHelp, $langTopic, $langTopicHelp, $langSubTopic, $langSubTopicHelp, $langLevel, $langLevelHelp, $langTypicalAgeRange, $langTypicalAgeRangeHelp, $langComment, $langCommentHelp, $langCopyright, $langCopyrightHelp, $langIntentedEndUserRole, $langIntentedEndUserRoleHelp, $langOkComment, $langNotRequired;
// variable definitions
$metaTitle = "";
$metaLanguage = "";
$metaDescription = "";
$metaAuthors = "";
$metaKeywords = "";
$metaRights = "";
$metaLearningResourceTypes = "";
$metaIntendedEndUserRoles = "";
$metaLevels = "";
$metaTypicalAgeRanges = "";
$metaNotes = "";
$metaTopic = "";
$metaSubTopic = "";
if (file_exists($real_filename . ".xml")) {
$sxe = simplexml_load_file($real_filename . ".xml");
if ($sxe) {
$metaTitle = $sxe->general->title->string;
$metaLanguage = $sxe->general->language;
$metaDescription = $sxe->general->description->string;
$metaAuthors = $sxe->lifeCycle->contribute->entity;
$metaKeywords = $sxe->general->keyword;
$metaRights = $sxe->rights->description->string;
$metaLearningResourceTypes = $sxe->educational->learningResourceType;
$metaIntendedEndUserRoles = $sxe->educational->intendedEndUserRole;
$metaLevels = $sxe->educational->context;
$metaTypicalAgeRanges = $sxe->educational->typicalAgeRange;
$metaNotes = $sxe->educational->description->string;
$metaTopic = $sxe->classification->taxonPath->source->string;
$metaSubTopic = $sxe->classification->taxonPath->taxon->entry->string;
}
}
$checkMap['meta_learningresourcetype'] = metaBuildCheckMap($metaLearningResourceTypes, "meta_learningresourcetype");
$checkMap['meta_intendedenduserrole'] = metaBuildCheckMap($metaIntendedEndUserRoles, "meta_intendedenduserrole");
$checkMap['meta_level'] = metaBuildCheckMap($metaLevels, "meta_level");
$output = "\n\t<form method='post' action='index.php?course={$course_code}'>\n\t<fieldset>\n\t <input type='hidden' name='metadataPath' value='" . q($metadata) . "' />\n\t <input type='hidden' name='meta_filename' value='{$oldFilename}' />\n\t <input type='hidden' name='meta_mimetype' value='" . get_mime_type($oldFilename) . "' />\n\t {$group_hidden_input}\n\t <legend>{$langAddMetadata}</legend>\n\t <table class='tbl' width='100%'>\n\t <tr>\n\t <th>{$langWorkFile}:</th>\n\t <td>{$oldFilename}</td>\n\t </tr>";
$output .= metaTextAreaRow($langTitle, "meta_title", $metaTitle, $langTitleHelp) . metaTextAreaRow($langDescription, "meta_description", $metaDescription, $langDescriptionHelp, 4) . metaCommaTextAreaRow($langAuthor, "meta_author", $metaAuthors, $langAuthorHelp);
$cellLang = selection(array('el' => $langGreek, 'en' => $langEnglish, 'fr' => $langFrench, 'de' => $langGerman, 'it' => $langItalian, 'es' => $langSpanish), 'meta_language', $metaLanguage);
$output .= metaFormRow($langLanguage, $cellLang, $langLanguageHelp);
$resourceTypes = array("narrative text", "simulation", "photo", "experiment", "image", "microexperiment", "figure", "map", "diagram", "interactivemap", "graph", "exploration", "table", "interactivegame", "sound", "conceptualmap", "music", "index", "narration", "problem statement", "video", "self assessment", "animation", "questionnaire", "3danimation", "quiz", "slide", "exam", "presentation", "exercise", "lecture", "learningscenario", "textbook");
$output .= metaCheckBoxRow($langLearningResourceType, "meta_learningresourcetype", $resourceTypes, $checkMap, $langLearningResourceTypeHelp, true) . metaCommaTextAreaRow($langKeywords, "meta_keywords", $metaKeywords, $langKeywordsHelp, 2, "string") . metaInputTextRow($langTopic, "meta_topic", $metaTopic, $langTopicHelp) . metaInputTextRow($langSubTopic, "meta_subtopic", $metaSubTopic, $langSubTopicHelp);
$levels = array("nursery", "primary", "secondary", "highschool", "technical", "training", "higher education", "other");
$output .= metaCheckBoxRow($langLevel, "meta_level", $levels, $checkMap, $langLevelHelp) . metaCommaInputTextRow($langTypicalAgeRange, "meta_typicalagerange", $metaTypicalAgeRanges, $langTypicalAgeRangeHelp, "string") . metaTextAreaRow($langComment, "meta_notes", $metaNotes, $langCommentHelp, 4) . metaTextAreaRow($langCopyright, "meta_rights", $metaRights, $langCopyrightHelp);
$userRoles = array("teacher", "learner", "author", "manager", "other");
$output .= metaCheckBoxRow($langIntentedEndUserRole, "meta_intendedenduserrole", $userRoles, $checkMap, $langIntentedEndUserRoleHelp);
$output .= "<tr>\n\t <th> </th>\n\t <td class='right'><input class='btn btn-primary' type='submit' value='{$langOkComment}' /></td>\n\t </tr>\n\t <tr>\n\t <th> </th>\n\t <td class='right'>{$langNotRequired}</td>\n\t </tr>\n\t </table>\n\t</fieldset>\n\t</form>";
return $output;
}
开发者ID:kostastzo,项目名称:openeclass,代码行数:54,代码来源:doc_metadata.php
示例4: send_file_to_client
function send_file_to_client($real_filename, $filename, $disposition = null, $send_name = false, $delete = false)
{
if (!file_exists($real_filename)) {
return false;
}
$content_type = get_mime_type($filename);
if ($content_type == 'text/html') {
$charset = '; charset=' . html_charset($real_filename);
} elseif ($content_type == 'text/plain') {
$charset = '; charset=' . text_charset($real_filename);
} else {
$charset = '';
}
if ($send_name) {
if (preg_match('/[^\\x20-\\x7E]/', $filename) and strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
$filename = urlencode($filename);
}
// Add quotes to filename if it contains spaces
if (strpos($filename, ' ') !== false) {
$filename = '"' . $filename . '"';
}
$filenameattr = '; filename=' . $filename;
if (!isset($disposition)) {
$disposition = 'attachment';
}
} else {
$filenameattr = '';
}
header("Content-type: {$content_type}{$charset}");
if (isset($disposition)) {
header("Content-Disposition: {$disposition}{$filenameattr}");
}
header('Pragma:');
header('Cache-Control: public');
header('Content-length: ' . filesize($real_filename));
$mtime = filemtime($real_filename);
$mdate = gmdate('D, d M Y H:i:s', $mtime);
$etag = md5($real_filename . $mdate . $filename . filesize($real_filename));
header('Last-Modified: ' . $mdate . ' GMT');
header("Etag: {$etag}");
if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER) and strtotime(preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE'])) >= $mtime or array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER) and trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
header("HTTP/1.0 304 Not Modified");
} else {
stop_output_buffering();
if ($delete) {
register_shutdown_function('unlink', $real_filename);
}
readfile($real_filename);
}
return true;
}
开发者ID:kostastzo,项目名称:openeclass,代码行数:51,代码来源:forcedownload.php
示例5: getMediaType
public function getMediaType($filename)
{
$type = get_mime_type($filename);
switch ($type) {
case 'image/gif':
case 'image/jpeg':
case 'image/pjpeg':
case 'image/png':
return self::typePhoto;
case 'video/mpeg':
case 'video/mp4':
case 'video/ogg':
case 'video/quicktime':
case 'video/webm':
return self::typeVideo;
}
return false;
}
开发者ID:gg1977,项目名称:frontend,代码行数:18,代码来源:Media.php
示例6: get_part
function get_part($imap, $uid, $mimetype, $structure = false, $partNumber = false)
{
if (!$structure) {
//$imap_uid = imap_uid ($imap, $uid);
//echo "$uid->".$uid;
$structure = imap_fetchstructure($imap, $uid, FT_UID);
}
//echo "<br/>structure-><pre>".print_r($structure)."</pre>";
if ($structure) {
if ($mimetype == get_mime_type($structure)) {
if (!$partNumber) {
$partNumber = 1;
}
$text = imap_fetchbody($imap, $uid, $partNumber, FT_UID);
switch ($structure->encoding) {
case 3:
return imap_base64($text);
case 4:
return imap_qprint($text);
default:
return $text;
}
}
// multipart
if ($structure->type == 1) {
foreach ($structure->parts as $index => $subStruct) {
$prefix = "";
if ($partNumber) {
$prefix = $partNumber . ".";
}
$data = get_part($imap, $uid, $mimetype, $subStruct, $prefix . ($index + 1));
if ($data) {
return $data;
}
}
}
}
return false;
}
开发者ID:bhushansonar,项目名称:knewdog.com,代码行数:39,代码来源:list+-+Copy.php
示例7: load
/**
* Loads an image from a file path
*
* @param string $filename Full path to the file which will be manipulated
* @return ImageGD
*/
public function load($filename)
{
if ($this->image) {
imagedestroy($this->image);
$this->image = null;
}
$this->type = get_mime_type($filename);
if (preg_match('/png$/', $this->type)) {
$this->image = imagecreatefrompng($filename);
} elseif (preg_match('/gif$/', $this->type)) {
$this->image = @imagecreatefromgif($filename);
} else {
$this->image = @imagecreatefromjpeg($filename);
}
if (!$this->image) {
OPException::raise(new OPInvalidImageException('Could not create image with GD library'));
}
$this->filename = $filename;
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
return $this;
}
开发者ID:hfiguiere,项目名称:frontend,代码行数:28,代码来源:ImageGD.php
示例8: get_part
function get_part($imap, $uid, $mimetype, $structure = false, $partNumber = false)
{
if (!$structure) {
$structure = imap_fetchstructure($imap, $uid, FT_UID);
}
if ($structure) {
if ($mimetype == get_mime_type($structure)) {
if (!$partNumber) {
$partNumber = 1;
}
$text = imap_fetchbody($imap, $uid, $partNumber, FT_UID);
switch ($structure->encoding) {
case 3:
return imap_base64($text);
case 4:
return imap_qprint($text);
default:
return $text;
}
}
/*/ multipart */
if ($structure->type == 1) {
foreach ($structure->parts as $index => $subStruct) {
$prefix = "";
if ($partNumber) {
$prefix = $partNumber . ".";
}
$imap = '';
$data = get_part($imap, $uid, $mimetype, $subStruct, $prefix . ($index + 1));
if ($data) {
return $data;
}
}
}
}
return false;
}
开发者ID:linuxman,项目名称:uycodeka,代码行数:37,代码来源:GetBackup.php
示例9: getFile
public function getFile($file)
{
if (is_array($file)) {
foreach ($file as $filepath) {
if (file_exists($filepath)) {
$file = (string) $filepath;
break;
}
}
}
if (is_string($file) && file_exists($file)) {
$size = filesize($file);
$info = pathinfo($file);
$time = date('r', filemtime($file));
$mime = get_mime_type($info['extension']);
if ($size > 0) {
if ($mime !== false) {
$this->res->setStatus(200);
$this->res->addHeader('Content-Type', $mime);
$this->res->addHeader('Cache-Control', 'public, max-age=' . (time() + 1800));
$this->res->addHeader('Pragma', 'cache');
$this->res->addHeader('Content-Length', $size);
$this->res->addHeader('Content-Transfer-Encoding', 'binary');
$this->res->addHeader('Last-Modified', $time);
$this->res->write(file_get_contents($file));
} else {
$this->_error(403, 'The requested filetype "' . $info['extension'] . '" are not supported');
}
} else {
$this->_error(403, 'The requested file is empty (0 byte)');
}
} else {
$this->_error(404, 'The requested file was not found');
}
// end function
}
开发者ID:dlehmann,项目名称:DevCE,代码行数:36,代码来源:FileLoader.php
示例10: view
function view()
{
global $doc_root, $path_info, $url_info, $current_dir, $islinux, $filename, $passthru;
if (intval($passthru)) {
$file = $current_dir . $filename;
if (file_exists($file)) {
$is_denied = false;
foreach ($download_ext_filter as $key => $ext) {
if (eregi($ext, $filename)) {
$is_denied = true;
break;
}
}
if (!$is_denied) {
if ($fh = fopen("{$file}", "rb")) {
fclose($fh);
$ext = pathinfo($file, PATHINFO_EXTENSION);
$ctype = get_mime_type($ext);
if ($ctype == "application/octet-stream") {
$ctype = "text/plain";
}
header("Pragma: public");
header("Expires: 0");
header("Connection: close");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: " . $ctype);
header("Content-Disposition: inline; filename=\"" . pathinfo($file, PATHINFO_BASENAME) . "\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($file));
@readfile($file);
exit;
} else {
alert(et('ReadDenied') . ": " . $file);
}
} else {
alert(et('ReadDenied') . ": " . $file);
}
} else {
alert(et('FileNotFound') . ": " . $file);
}
echo "\r\n\t <script language=\"Javascript\" type=\"text/javascript\">\r\n\t <!--\r\n\t window.close();\r\n\t //-->\r\n\t </script>";
} else {
html_header();
echo "<body marginwidth=\"0\" marginheight=\"0\">";
$is_reachable_thru_webserver = stristr($current_dir, $doc_root) !== false;
if ($is_reachable_thru_webserver) {
$url = $url_info["scheme"] . "://" . $url_info["host"];
if (strlen($url_info["port"])) {
$url .= ":" . $url_info["port"];
}
// Malditas variaveis de sistema!! No windows doc_root é sempre em lowercase... cadê o str_ireplace() ??
$url .= str_replace($doc_root, "", "/" . $current_dir) . $filename;
} else {
$url = addslashes($path_info["basename"]) . "?action=4¤t_dir=" . addslashes($current_dir) . "&filename=" . addslashes($filename) . "&passthru=1";
}
echo "\r\n\t <script language=\"Javascript\" type=\"text/javascript\">\r\n\t <!--\r\n \twindow.moveTo((window.screen.width-800)/2,((window.screen.height-600)/2)-20);\r\n\t document.location.href='{$url}';\r\n\t //-->\r\n\t </script>\r\n \t</body>\n</html>";
}
}
开发者ID:Kavir91,项目名称:Convocatoria,代码行数:60,代码来源:index.php
示例11: print_table
function print_table($dir, $list, $allow)
{
// print table of files
global $dir_up;
if (!is_array($list)) {
return;
}
if ($dir != "" || strstr($dir, _EXT_PATH)) {
echo "<tr class=\"sectiontableentry1\"><td valign=\"baseline\"><a href=\"" . make_link("list", $dir_up, NULL) . "\">";
echo "<img border=\"0\" align=\"absmiddle\" src=\"" . _EXT_URL . "/images/up.png\" ";
echo "alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"/> ..</a></td>\n";
echo "<td> </td><td> </td><td> </td>";
echo "</tr>";
}
$i = 0;
while (list($item, ) = each($list)) {
if ($item == 'index.html') {
continue;
}
$abs_item = get_abs_item($dir, $item);
$is_writable = is_writable($abs_item);
$is_chmodable = $GLOBALS['ext_File']->is_chmodable($abs_item);
$is_readable = is_readable($abs_item);
$is_deletable = $GLOBALS['ext_File']->is_deletable($abs_item);
$file_info = @stat($abs_item);
$is_file = false;
//if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item);
if (@is_dir($abs_item)) {
$link = make_link("list", get_rel_item($dir, $item), NULL);
} else {
//if(get_is_editable($dir,$item) || get_is_image($dir,$item)) {
$link = make_link("download", $dir, $item);
$is_file = true;
}
//else $link = "";
$class = $i % 2 ? 'sectiontableentry1' : 'sectiontableentry2';
//echo "<tr class=\"rowdata\">"
echo '<tr class="' . $class . '">';
// Icon + Link
echo "<td nowrap=\"nowrap\">";
if ($is_readable) {
echo "<a href=\"" . $link . "\"";
if ($is_file) {
echo " title=\"" . $GLOBALS["messages"]["downlink"] . ": " . $item . "\"";
}
echo ">";
}
//else echo "<A>";
echo "<img border=\"0\" ";
echo "align=\"absmiddle\" vspace=\"5\" hspace=\"5\" src=\"" . _EXT_URL . "/images/" . get_mime_type($abs_item, "img") . "\" alt=\"\"> ";
$s_item = $item;
if (strlen($s_item) > 50) {
$s_item = substr($s_item, 0, 47) . "...";
}
$s_item = htmlspecialchars($s_item);
if (!$is_file) {
echo '<strong>' . $s_item . '</strong>';
} else {
echo $s_item;
}
if ($is_readable) {
echo "</a>";
// ...$extra...
}
echo "</td>\n";
// Size
echo "<td>" . parse_file_size(get_file_size($abs_item)) . "</td>\n";
// type
echo "<td>" . get_mime_type($abs_item, "type") . "</td>\n";
// modified
echo "<td>" . parse_file_date(get_file_date($abs_item)) . "</td>\n";
// actions
echo "</tr>\n";
$i++;
}
}
开发者ID:BACKUPLIB,项目名称:mwenhanced,代码行数:76,代码来源:extplorer.list.php
示例12: md5
if (Request::int('zip') && is_file($path_file)) {
$tmp_id = md5(uniqid("suppe"));
$zip_path_file = "{$TMP_PATH}/{$tmp_id}";
$tmp_file_name = escapeshellcmd("{$TMP_PATH}/{$file_name}");
@copy($path_file, $tmp_file_name);
if (create_zip_from_file($tmp_file_name, "{$zip_path_file}.zip") === false) {
@unlink($zip_path_file . '.zip');
@unlink($tmp_file_name);
throw new Exception(_("Fehler beim Erstellen des Zip-Archivs!"));
} else {
$file_name = $file_name . ".zip";
$path_file = $zip_path_file . ".zip";
@unlink($tmp_file_name);
}
}
$content_type = get_mime_type($file_name);
if (Request::int('force_download') || $content_type == "application/octet-stream") {
$content_disposition = "attachment";
} else {
$content_disposition = "inline";
}
// check if linked file is obtainable
if ($type == 6) {
$link_data = parse_link($path_file);
if ($link_data['response_code'] != 200) {
throw new Exception(_("Diese Datei wird von einem externen Server geladen und ist dort momentan nicht erreichbar!"));
}
$filesize = $link_data['Content-Length'];
if (!$filesize) {
$filesize = false;
}
开发者ID:ratbird,项目名称:hope,代码行数:31,代码来源:sendfile.php
示例13: print_table
function print_table($dir, $list, $allow)
{
// print table of files
global $dir_up;
if (!is_array($list)) {
return;
}
if ($dir != "" || strstr($dir, _QUIXPLORER_PATH)) {
echo "<tr class=\"row1\">\n\t \t\t\t<td> </td>\n\t \t\t\t<td valign=\"baseline\">\n\t \t\t\t\t<a href=\"" . make_link("list", $dir_up, NULL) . "\">\n\t \t\t\t\t<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_up.png\" alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"/> ..</a>\n\t \t\t\t</td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>";
if (extension_loaded("posix")) {
echo "<td> </td>";
}
echo "</tr>";
}
$i = 0;
$toggle = false;
while (list($item, $info) = each($list)) {
// link to dir / file
if (is_array($info)) {
$abs_item = $info;
if (extension_loaded('posix')) {
$user_info = posix_getpwnam($info['user']);
$file_info['uid'] = $user_info['uid'];
$file_info['gid'] = $user_info['gid'];
}
} else {
$abs_item = get_abs_item($dir, $item);
$file_info = @stat($abs_item);
}
$is_writable = @$GLOBALS['jx_File']->is_writable($abs_item);
$is_chmodable = @$GLOBALS['jx_File']->is_chmodable($abs_item);
$is_readable = @$GLOBALS['jx_File']->is_readable($abs_item);
$is_deletable = @$GLOBALS['jx_File']->is_deletable($abs_item);
$target = "";
$extra = "";
if (@$GLOBALS['jx_File']->is_link($abs_item)) {
$extra = " -> " . @readlink($abs_item);
}
if (@get_is_dir($abs_item, '')) {
$link = make_link("list", get_rel_item($dir, $item), NULL);
} else {
if (get_is_editable($abs_item) && $is_writable) {
$link = make_link('edit', $dir, $item);
} elseif ($is_readable) {
if (strstr(get_abs_dir($dir), $GLOBALS['mosConfig_absolute_path']) && !$GLOBALS['jx_File']->is_link($abs_item)) {
$link = $GLOBALS["home_url"] . "/" . get_rel_item($dir, $item);
$target = '_blank';
} else {
$link = make_link('download', $dir, $item);
}
}
}
if (jx_isIE()) {
echo '<tr onmouseover="style.backgroundColor=\'#D8ECFF\';" onmouseout="style.backgroundColor=\'#EAECEE\';" bgcolor=\'#EAECEE\'>';
} else {
$toggle = $toggle ? '1' : '0';
echo "<tr class=\"row{$toggle}\">";
$toggle = !$toggle;
}
echo "<td><input type=\"checkbox\" id=\"item_{$i}\" name=\"selitems[]\" value=\"";
echo urlencode($item) . "\" onclick=\"javascript:Toggle(this);\" /></td>\n";
// Icon + Link
echo "<td nowrap=\"nowrap\" align=\"left\">";
if ($is_readable) {
echo "<a href=\"" . $link . "\" target=\"" . $target . "\">";
}
//else echo "<<>";
echo "<img border=\"0\" width=\"22\" height=\"22\" ";
echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/" . get_mime_type($abs_item, "img") . "\" alt=\"\" /> ";
$s_item = $item;
if (strlen($s_item) > 50) {
$s_item = substr($s_item, 0, 47) . "...";
}
echo htmlspecialchars($s_item . $extra);
if ($is_readable) {
echo "</a>";
// ...$extra...
}
echo "</td>\n";
// Size
echo "<td>" . parse_file_size(get_file_size($abs_item)) . "</td>\n";
// type
echo "<td>" . get_mime_type($abs_item, "type") . "</td>\n";
// modified
echo "<td>" . parse_file_date(get_file_date($abs_item)) . "</td>\n";
// permissions
echo "<td>";
if ($allow && $is_chmodable) {
echo "<a href=\"" . make_link("chmod", $dir, $item) . "\" title=\"";
echo $GLOBALS["messages"]["permlink"] . "\">";
}
$perms = get_file_perms($abs_item);
if (strlen($perms) > 3) {
$perms = substr($perms, 2);
}
echo '<strong>' . $perms . '</strong><br />' . parse_file_type($dir, $item) . parse_file_perms($perms);
if ($allow && $is_chmodable) {
echo "</a>";
}
echo "</td>\n";
//.........这里部分代码省略.........
开发者ID:Caojunkai,项目名称:arcticfox,代码行数:101,代码来源:fun_list.php
示例14: ldRegisterFile
function ldRegisterFile($field = "file", &$error)
{
global $ARnls, $store, $arguments;
debug("ldRegisterFile([{$field}], [error])");
require_once $store->code . "modules/mod_mimemagic.php";
$result = array();
$file_data = $arguments[$field];
if ($file_data) {
$file_data = base64_decode($file_data);
if (!$file_data) {
$error = "could not base64_decode file '{$field}'";
} else {
$file_temp = tempnam($store->get_config("files") . "temp", "upload");
$fp = fopen($file_temp, "wb+");
if (!$fp) {
$error = "could not write file '{$field}'";
} else {
debug("\tfile_data (" . $file_data . ")");
fwrite($fp, $file_data, strlen($file_data));
fclose($fp);
$file_type = get_mime_type($file_temp);
$result[$field] = $field;
$result[$field . "_temp"] = substr($file_temp, strlen($store->get_config("files") . "temp/"));
$result[$field . "_size"] = filesize($file_temp);
$result[$field . "_type"] = $file_type;
debug(" http_post_vars (" . serialize($result) . ")");
}
}
}
debug("ldRegisterFile[end] ({$result})");
return $result;
}
开发者ID:poef,项目名称:ariadne,代码行数:32,代码来源:loader.soap.php
示例15: sendFile
function sendFile($filename)
{
$suffix = pathinfo($filename, PATHINFO_EXTENSION);
$size = filesize_unlimited($filename);
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . mb_basename($filename) . '"');
header('Content-Type: ' . get_mime_type($filename, $suffix));
header('Content-Length: ' . $size);
header("Content-Type: application/octet-stream");
ob_end_flush();
readfile($filename);
}
开发者ID:claytondaley,项目名称:resourcespace,代码行数:12,代码来源:utility.php
示例16: get_mime_type_from_filename
function get_mime_type_from_filename($filename)
{
$baseName = basename($filename);
$parts = explode('.', $baseName);
$ext = end($parts);
return get_mime_type($ext);
}
开发者ID:slab-php,项目名称:slab,代码行数:7,代码来源:global_functions.php
示例17: dealWithPublic
private function dealWithPublic($request, $response)
{
$uri = $request->server['request_uri'];
$file = realpath($this->public_path . $uri);
if (is_file($file)) {
if (!strncasecmp($file, $uri, strlen($this->public_path))) {
$response->status(403);
$response->end();
} else {
$response->header('Content-Type', get_mime_type($file));
$response->sendfile($file);
}
return true;
} else {
}
return false;
}
开发者ID:Remember2015,项目名称:lumoon,代码行数:17,代码来源:swoole.php
示例18: print_table
function print_table($list)
{
// print table of found items
if (!is_array($list)) {
return;
}
$cnt = count($list);
for ($i = 0; $i < $cnt; ++$i) {
$dir = $list[$i][0];
$item = $list[$i][1];
$s_dir = $dir;
if (strlen($s_dir) > 65) {
$s_dir = substr($s_dir, 0, 62) . "...";
}
$s_item = $item;
if (strlen($s_item) > 45) {
$s_item = substr($s_item, 0, 42) . "...";
}
$link = "";
$target = "";
if (get_is_dir($dir, $item)) {
$img = "dir.gif";
$link = make_link("list", get_rel_item($dir, $item), NULL);
} else {
$img = get_mime_type($dir, $item, "img");
$link = make_link("download", $dir, $item);
}
echo "<TR><TD>" . "<IMG border=\"0\" width=\"16\" height=\"16\" ";
echo "align=\"ABSMIDDLE\" src=\"_img/" . $img . "\" ALT=\"\"> ";
/*if($link!="")*/
echo "<A HREF=\"" . $link . "\" TARGET=\"" . $target . "\">";
//else echo "<A>";
echo $s_item . "</A></TD><TD><A HREF=\"" . make_link("list", $dir, NULL) . "\"> /";
echo $s_dir . "</A></TD></TR>\n";
}
}
开发者ID:morovan,项目名称:granitpiestany.sk,代码行数:36,代码来源:fun_search.php
示例19: edit_file
function edit_file($dir, $item)
{
if (!permissions_grant($dir, $item, "change")) {
show_error($GLOBALS["error_msg"]["accessfunc"]);
}
if (!get_is_file($dir, $item)) {
show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
}
if (!get_show_item($dir, $item)) {
show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
}
$fname = get_abs_item($dir, $item);
if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
// Save / Save As
$item = basename(stripslashes($GLOBALS['__POST']["fname"]));
$fname2 = get_abs_item($dir, $item);
if (!isset($item) || $item == "") {
show_error($GLOBALS["error_msg"]["miscnoname"]);
}
if ($fname != $fname2 && @file_exists($fname2)) {
show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
}
savefile($fname2);
$fname = $fname2;
}
// open file
$fp = @fopen($fname, "r");
if ($fp === false) {
show_error($item . ": " . $GLOBALS["error_msg"]["openfile"]);
}
// header
$s_item = get_rel_item($dir, $item);
if (strlen($s_item) > 50) {
$s_item = "..." . substr($s_item, -47);
}
show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item);
// Wordwrap (works only in IE)
?>
<script language="JavaScript1.2" type="text/javascript">
<!--
function chwrap()
|
请发表评论