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


PHP Misc::getFileExtension方法代码示例

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


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

示例1: printIphoneRemoteImageFilename

function printIphoneRemoteImageFilename($filename)
{
    $filename = md5($filename) . "." . Misc::getFileExtension($filename);
    return $filename;
}
开发者ID:hinablue,项目名称:TextCube,代码行数:5,代码来源:iphoneView.php

示例2: getMIMEType

 function getMIMEType($ext, $filename = null)
 {
     if ($filename) {
         return Misc::getMIMEType(Misc::getFileExtension($filename));
     } else {
         switch (strtolower($ext)) {
             // Image
             case 'gif':
                 return 'image/gif';
             case 'jpeg':
             case 'jpg':
             case 'jpe':
                 return 'image/jpeg';
             case 'png':
                 return 'image/png';
             case 'tiff':
             case 'tif':
                 return 'image/tiff';
             case 'bmp':
                 return 'image/bmp';
                 // Sound
             // Sound
             case 'wav':
                 return 'audio/x-wav';
             case 'mpga':
             case 'mp2':
             case 'mp3':
                 return 'audio/mpeg';
             case 'm3u':
                 return 'audio/x-mpegurl';
             case 'wma':
                 return 'audio/x-msaudio';
             case 'ra':
                 return 'audio/x-realaudio';
                 // Document
             // Document
             case 'css':
                 return 'text/css';
             case 'html':
             case 'htm':
             case 'xhtml':
                 return 'text/html';
             case 'rtf':
                 return 'text/rtf';
             case 'sgml':
             case 'sgm':
                 return 'text/sgml';
             case 'xml':
             case 'xsl':
                 return 'text/xml';
             case 'hwp':
             case 'hwpml':
                 return 'application/x-hwp';
             case 'pdf':
                 return 'application/pdf';
             case 'odt':
             case 'ott':
                 return 'application/vnd.oasis.opendocument.text';
             case 'ods':
             case 'ots':
                 return 'application/vnd.oasis.opendocument.spreadsheet';
             case 'odp':
             case 'otp':
                 return 'application/vnd.oasis.opendocument.presentation';
             case 'sxw':
             case 'stw':
                 return '	application/vnd.sun.xml.writer';
             case 'sxc':
             case 'stc':
                 return '	application/vnd.sun.xml.calc';
             case 'sxi':
             case 'sti':
                 return '	application/vnd.sun.xml.impress';
             case 'doc':
                 return 'application/vnd.ms-word';
             case 'xls':
             case 'xla':
             case 'xlt':
             case 'xlb':
                 return 'application/vnd.ms-excel';
             case 'ppt':
             case 'ppa':
             case 'pot':
             case 'pps':
                 return 'application/vnd.mspowerpoint';
             case 'vsd':
             case 'vss':
             case 'vsw':
                 return 'application/vnd.visio';
             case 'docx':
             case 'docm':
             case 'pptx':
             case 'pptm':
             case 'xlsx':
             case 'xlsm':
                 return 'application/vnd.openxmlformats';
             case 'csv':
                 return 'text/comma-separated-values';
                 // Multimedia
             // Multimedia
//.........这里部分代码省略.........
开发者ID:ragi79,项目名称:Textcube,代码行数:101,代码来源:Textcube.Function.Misc.php

示例3: getAddAttachment

function getAddAttachment($file)
{
    global $database, $serviceURL;
    requireComponent('Textcube.Function.misc');
    requireComponent('Textcube.Data.Attachment');
    Attachment::confirmFolder();
    if (empty($file['name']) || $file['error'] != 0) {
        return false;
    }
    $attachment = array();
    $attachment['ext'] = Misc::getFileExtension(Path::getBaseName($file['name']));
    $path = __TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/team";
    if (!is_dir($path)) {
        mkdir($path);
        if (!is_dir($path)) {
            return false;
        }
        @chmod($path, 0777);
    }
    do {
        $attachment['name'] = rand(1000000000, 9999999999.0) . "." . $attachment['ext'];
        $attachment['path'] = "{$path}/{$attachment['name']}";
    } while (file_exists($attachment['path']));
    if (!move_uploaded_file($file['tmp_name'], $attachment['path'])) {
        return false;
    }
    @chmod($attachment['path'], 0666);
    $tmpImage = POD::queryCell("SELECT image FROM {$database['prefix']}TeamUserSettings WHERE blogid=" . getBlogId() . " and userid=" . getUserId());
    if (!POD::execute("UPDATE {$database['prefix']}TeamUserSettings SET image='" . $attachment['name'] . "', updated=UNIX_TIMESTAMP() WHERE blogid=" . getBlogId() . " and userid=" . getUserId())) {
        @unlink($attachment['path']);
        $result = "{$serviceURL}/resources/image/spacer.gif";
    } else {
        $result = "{$serviceURL}/attach/" . getBlogId() . "/team/" . $attachment['name'];
    }
    if (!empty($tmpImage)) {
        @unlink($path . "/" . $tmpImage);
    }
    return $result;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:39,代码来源:index.php

示例4: FM_TTML_getAttachmentBinder

function FM_TTML_getAttachmentBinder($filename, $property, $folderPath, $folderURL, $imageBlocks = 1, $useAbsolutePath = true, $bRssMode = false, $onclickFlag = false)
{
    $context = Model_Context::getInstance();
    $blogid = getBlogId();
    $path = "{$folderPath}/{$filename}";
    if ($useAbsolutePath) {
        $url = $context->getProperty('uri.service') . "/attach/{$blogid}/{$filename}";
    } else {
        $url = "{$folderURL}/{$filename}";
    }
    $fileInfo = getAttachmentByOnlyName($blogid, $filename);
    switch (Misc::getFileExtension($filename)) {
        case 'jpg':
        case 'jpeg':
        case 'gif':
        case 'png':
        case 'bmp':
            $bPassing = false;
            if (defined('__TEXTCUBE_MOBILE__') || defined('__TEXTCUBE_IPHONE__')) {
                if (!is_null(Setting::getBlogSettingGlobal("resamplingDefault"))) {
                    $waterMarkOn = Setting::getBlogSettingGlobal("waterMarkDefault", "no");
                    $exist = preg_match('/class="tt-watermark"/i', $property);
                    if ($waterMarkOn == 'yes' && $exist == 1) {
                        $bPassing = true;
                    }
                }
                if ($bPassing == false) {
                    return fireEvent('ViewAttachedImageMobile', "<img src=\"" . $context->getProperty('uri.blog') . "/imageResizer/?f=" . urlencode($filename) . "\" alt=\"\" />", $path);
                }
            }
            if ($onclickFlag == true && $bRssMode == false && $bPassing == false) {
                $imageStr = '<img src="' . $url . '" ' . $property . ' style="cursor: pointer;" onclick="open_img(\'' . $url . '\'); return false;" />';
            } else {
                $imageStr = '<img src="' . $url . '" ' . $property . ' />';
            }
            return fireEvent('ViewAttachedImage', $imageStr, $path);
            break;
        case 'swf':
            $id = md5($url) . rand(1, 10000);
            if ($useAbsolutePath && strncasecmp($url, 'http://', 7) == 0) {
                $url = substr($url, 7);
            }
            return "<span id=\"{$id}\"><script type=\"text/javascript\">//<![CDATA[" . CRLF . "writeCode(getEmbedCode('{$url}','300','400','{$id}','#FFFFFF',''), \"{$id}\");//]]></script></span>";
            break;
        case 'wmv':
        case 'avi':
        case 'asf':
        case 'mpg':
        case 'mpeg':
            $id = md5($url) . rand(1, 10000);
            if ($useAbsolutePath && strncasecmp($url, 'http://', 7) == 0) {
                $url = substr($url, 7);
            }
            return "<span id=\"{$id}\"><script type=\"text/javascript\">//<![CDATA[" . CRLF . "writeCode('<embed {$property} autostart=\"0\" src=\"{$url}\"></embed>', \"{$id}\")//]]></script></span>";
            break;
        case 'mp3':
        case 'mp2':
        case 'wma':
        case 'wav':
        case 'mid':
        case 'midi':
            $id = md5($url) . rand(1, 10000);
            if ($useAbsolutePath && strncasecmp($url, 'http://', 7) == 0) {
                $url = substr($url, 7);
            }
            return "<span id=\"{$id}\"><script type=\"text/javascript\">//<![CDATA[" . CRLF . "writeCode('<embed {$property} autostart=\"0\" height=\"45\" src=\"{$url}\"></embed>', \"{$id}\")//]]></script></span>";
            break;
        case 'mov':
            $id = md5($url) . rand(1, 10000);
            return "<span id=\"{$id}\"><script type=\"text/javascript\">//<![CDATA[" . CRLF . "writeCode(" . '\'<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="400px" height="300px"><param name="src" value="' . $url . '" /><param name="controller" value="true" /><param name="pluginspage" value="http://www.apple.com/QuickTime/download/" /><!--[if !IE]> <--><object type="video/quicktime" data="' . $url . '" width="400px" height="300px" class="mov"><param name="controller" value="true" /><param name="pluginspage" value="http://www.apple.com/QuickTime/download/" /></object><!--> <![endif]--></object>\'' . ", \"{$id}\")//]]></script></span>";
            break;
        default:
            if (file_exists(ROOT . '/resources/image/extension/' . Misc::getFileExtension($fileInfo['label']) . '.gif')) {
                return '<a class="extensionIcon" href="' . ($useAbsolutePath ? $context->getProperty('uri.host') : '') . $context->getProperty('uri.blog') . '/attachment/' . $filename . '">' . fireEvent('ViewAttachedFileExtension', '<img src="' . ($useAbsolutePath ? $context->getProperty('uri.service') : $context->getProperty('service.path')) . '/resources/image/extension/' . Misc::getFileExtension($fileInfo['label']) . '.gif" alt="" />') . ' ' . htmlspecialchars($fileInfo['label']) . '</a>';
            } else {
                return '<a class="extensionIcon" href="' . ($useAbsolutePath ? $context->getProperty('uri.host') : '') . $context->getProperty('uri.blog') . '/attachment/' . $filename . '">' . fireEvent('ViewAttachedFileExtension', '<img src="' . ($useAbsolutePath ? $context->getProperty('uri.service') : $context->getProperty('service.path')) . '/resources/image/extension/unknown.gif" alt="" />') . ' ' . htmlspecialchars($fileInfo['label']) . '</a>';
            }
            break;
    }
}
开发者ID:ragi79,项目名称:Textcube,代码行数:80,代码来源:ttml.php

示例5: MT_Cover_getRemoteImageFilename

function MT_Cover_getRemoteImageFilename($filename)
{
    $filename = md5($filename) . "." . Misc::getFileExtension($filename);
    return $filename;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:5,代码来源:index.php

示例6: copyAttachments

function copyAttachments($blogid, $originalEntryId, $targetEntryId)
{
    global $database;
    $path = ROOT . "/attach/{$blogid}";
    $attachments = getAttachments($blogid, $originalEntryId);
    if (empty($attachments)) {
        return true;
    }
    $pool = DBModel::getInstance();
    $pool->reset('Entries');
    $pool->setQualifier('blogid', 'equals', $blogid);
    $pool->setQualifier('id', 'equals', $originalEntryId);
    if (!$pool->getCell('id')) {
        return 2;
    }
    // original entry does not exists;
    $pool->setQualifier('id', 'equals', $targetEntryId);
    if (!$pool->getCell('id')) {
        return 3;
    }
    // target entry does not exists;
    foreach ($attachments as $attachment) {
        $extension = Misc::getFileExtension($attachment['label']);
        $originalPath = "{$path}/{$attachment['name']}";
        do {
            $attachment['name'] = rand(1000000000, 9999999999) . ".{$extension}";
            $attachment['path'] = "{$path}/{$attachment['name']}";
        } while (file_exists($attachment['path']));
        if (!copy($originalPath, $attachment['path'])) {
            return 4;
        }
        // copy failed.
        $pool->reset('Attachments');
        $pool->setAttribute('blogid', $blogid);
        $pool->setAttribute('parent', $targetEntryId);
        $pool->setAttribute('name', $attachment['name'], true);
        $pool->setAttribute('label', $attachment['label'], true);
        $pool->setAttribute('mime', $attachment['mime'], true);
        $pool->setAttribute('size', $attachment['size'], true);
        $pool->setAttribute('width', $attachment['width']);
        $pool->setAttribute('height', $attachment['height']);
        $pool->setAttribute('attached', Timestamp::getUNIXtime());
        $pool->setAttribute('downloads', 0);
        $pool->setAttribute('enclosure', 0);
        if (!$pool->insert()) {
            return false;
        }
    }
    return true;
}
开发者ID:hinablue,项目名称:TextCube,代码行数:50,代码来源:blog.attachment.php

示例7: getEntryContentView

function getEntryContentView($blogid, $id, $content, $formatter, $keywords = array(), $type = 'Post', $useAbsolutePath = true, $bRssMode = false)
{
    $ctx = Model_Context::getInstance();
    requireModel('blog.attachment');
    requireModel('blog.keyword');
    requireLibrary('blog.skin');
    $cacheKey = 'entry-' . $id . '-' . $type . ($bRssMode ? 'format' : 'summarize') . ($useAbsolutePath ? 'absoultePath' : 'relativePath') . (defined('__TEXTCUBE_MOBILE__') ? 'mobile' : '');
    $cache = pageCache::getInstance();
    $cache->reset($cacheKey);
    if (!defined('__TEXTCUBE_NO_ENTRY_CACHE__') && $cache->load()) {
        // If cached content exists.
        $view = $cache->contents;
    } else {
        // No cache is found.
        $content = fireEvent('Format' . $type . 'Content', $content, $id);
        $func = $bRssMode ? 'summarizeContent' : 'formatContent';
        $view = $func($blogid, $id, $content, $formatter, $keywords, $useAbsolutePath);
        if (defined('__TEXTCUBE_MOBILE__')) {
            $view = stripHTML($view, array('a', 'abbr', 'acronym', 'address', 'b', 'blockquote', 'br', 'cite', 'code', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 's', 'samp', 'span', 'strike', 'strong', 'sub', 'sup', 'u', 'ul', 'var'));
        }
        if (!$useAbsolutePath) {
            $view = avoidFlashBorder($view);
        }
        if (!empty($keywords) && is_array($keywords)) {
            $view = bindKeywords($keywords, $view);
        }
        // image resampling
        if (Setting::getBlogSettingGlobal('resamplingDefault') == true) {
            preg_match_all("@<img.+src=['\"](.+)['\"](.*)/?>@Usi", $view, $images, PREG_SET_ORDER);
            $view = preg_replace("@<img.+src=['\"].+['\"].*/?>@Usi", '[#####_#####_#####_image_#####_#####_#####]', $view);
            $contentWidth = Misc::getContentWidth();
            if (count($images) > 0) {
                for ($i = 0; $i < count($images); $i++) {
                    if (strtolower(Misc::getFileExtension($images[$i][1])) == 'gif') {
                        $view = preg_replace('@\\[#####_#####_#####_image_#####_#####_#####\\]@', $images[$i][0], $view, 1);
                        continue;
                    }
                    $attributes = preg_match('/(style="cursor: pointer;" onclick="open_img\\((.[^"]+)\\); return false;")/si', $images[$i][2], $matches) ? ' ' . $matches[1] : '';
                    $attributes .= preg_match('/(alt="([^"]*)")/si', $images[$i][2], $matches) ? ' ' . $matches[1] : ' alt="resize"';
                    $attributes .= preg_match('/(title="([^"]*)")/si', $images[$i][2], $matches) ? $title = ' ' . $matches[1] : '';
                    $tempFileName = array_pop(explode('/', $images[$i][1]));
                    if (preg_match('/(.+)\\.w(\\d{1,})\\-h(\\d{1,})\\.(.+)/', $tempFileName, $matches)) {
                        $tempFileName = $matches[1] . '.' . $matches[4];
                    }
                    $newImage = $images[$i][0];
                    if (file_exists(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$tempFileName}")) {
                        $tempAttributes = Misc::getAttributesFromString($images[$i][2]);
                        $tempOriginInfo = getimagesize(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$tempFileName}");
                        if (isset($tempAttributes['width']) && $tempOriginInfo[0] > $tempAttributes['width']) {
                            $image = Utils_Image::getInstance();
                            list($tempImageURL, $tempImageWidth, $tempImageHeight, $tempImageSrc) = $image->getImageResizer($tempFileName, array('width' => $tempAttributes['width']));
                            $newImage = "<img src=\"{$tempImageURL}\" width=\"{$tempImageWidth}\" height=\"{$tempImageHeight}\"{$attributes}/>";
                        }
                    }
                    $view = preg_replace('@\\[#####_#####_#####_image_#####_#####_#####\\]@', $newImage, $view, 1);
                }
            }
        }
        $cache->contents = $view;
        $cache->update();
    }
    $cache->reset();
    $view = fireEvent('View' . $type . 'Content', $view, $id);
    return $view;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:65,代码来源:view.php


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