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


PHP XenForo_Helper_File::getFileExtension方法代码示例

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


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

示例1: renderRaw

 public function renderRaw()
 {
     $attachment = $this->_params['attachment'];
     if (!headers_sent() && function_exists('header_remove')) {
         header_remove('Expires');
         header('Cache-control: private');
     }
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
     $imageTypes = array('svg' => 'image/svg+xml', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (isset($imageTypes[$extension]) && ($attachment['width'] && $attachment['height'])) {
         $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
         $this->setDownloadFileName($attachment['filename'], true);
     } else {
         $this->_response->setHeader('Content-type', 'application/octet-stream', true);
         $this->setDownloadFileName($attachment['filename']);
     }
     $this->_response->setHeader('ETag', '"' . $attachment['attach_date'] . '"', true);
     $this->_response->setHeader('Content-Length', $attachment['file_size'], true);
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     $attachmentFile = $this->_params['attachmentFile'];
     $options = XenForo_Application::getOptions();
     if ($options->SV_AttachImpro_XAR) {
         if (SV_AttachmentImprovements_AttachmentHelper::ConvertFilename($attachmentFile)) {
             if (XenForo_Application::debugMode() && $options->SV_AttachImpro_log) {
                 XenForo_Error::debug('X-Accel-Redirect:' . $attachmentFile);
             }
             $this->_response->setHeader('X-Accel-Redirect', $attachmentFile);
             return '';
         }
         if (XenForo_Application::debugMode() && $options->SV_AttachImpro_log) {
             XenForo_Error::debug('X-Accel-Redirect skipped');
         }
     }
     return new XenForo_FileOutput($attachmentFile);
 }
开发者ID:Xon,项目名称:XenForo-AttachmentImprovements,代码行数:35,代码来源:View.php

示例2: renderRaw

 public function renderRaw()
 {
     $url = $this->_params['url'];
     $width = $this->_params['width'];
     $height = $this->_params['height'];
     $crop = $this->_params['crop'];
     $extension = XenForo_Helper_File::getFileExtension($url);
     $imageInfo = @getimagesize($url);
     if (!$imageInfo || !in_array($imageInfo[2], array_values(sonnb_XenGallery_Model_PhotoData::$typeMap)) || !in_array(strtolower($extension), array_keys(sonnb_XenGallery_Model_PhotoData::$imageMimes))) {
         $url = XenForo_Template_Helper_Core::getAvatarUrl(array(), 'l');
         $extension = XenForo_Helper_File::getFileExtension($url);
         $imageInfo = @getimagesize($url);
     }
     $this->_response->setHeader('Content-type', sonnb_XenGallery_Model_PhotoData::$imageMimes[$extension], true);
     $this->_response->setHeader('ETag', XenForo_Application::$time, true);
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     $this->setDownloadFileName($url, true);
     $image = XenForo_Image_Abstract::createFromFile($url, sonnb_XenGallery_Model_PhotoData::$typeMap[$extension]);
     if ($image) {
         if (XenForo_Image_Abstract::canResize($width, $height)) {
             if ($crop) {
                 $image->thumbnail($width * 2, $height * 2);
                 $image->crop(0, 0, $width, $height);
             } else {
                 $image->thumbnail($width, $height);
             }
         } else {
             $image->output(sonnb_XenGallery_Model_PhotoData::$typeMap[$extension]);
         }
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:31,代码来源:Thumbnail.php

示例3: actionIndex

 public function actionIndex()
 {
     $attachmentId = $this->_input->filterSingle('attachment_id', XenForo_Input::UINT);
     $cache = XenForo_Application::getCache();
     $imageTypes = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if ($cache) {
         $attachment = unserialize($cache->load('attachment_cache_' . md5($attachmentId)));
         if (!$attachment) {
             $attachment = $this->_getAttachmentOrError($attachmentId);
             $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
             if (isset($imageTypes[$extension])) {
                 $cache->save(serialize($attachment), 'attachment_cache_' . md5($attachmentId), array(), 3600);
             }
         }
     } else {
         $attachment = $this->_getAttachmentOrError($attachmentId);
     }
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
     if (!in_array($extension, array_keys($imageTypes))) {
         return parent::actionIndex();
     }
     $attachmentModel = $this->_getAttachmentModel();
     $filePath = $attachmentModel->getAttachmentDataFilePath($attachment);
     if (!file_exists($filePath) || !is_readable($filePath)) {
         return $this->responseError(new XenForo_Phrase('attachment_cannot_be_shown_at_this_time'));
     }
     $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('attachments', $attachment));
     $eTag = $this->_request->getServer('HTTP_IF_NONE_MATCH');
     $this->_routeMatch->setResponseType('raw');
     if ($eTag && $eTag == $attachment['attach_date']) {
         return $this->responseView('XenForo_ViewPublic_Attachment_View304');
     }
     $viewParams = array('attachment' => $attachment, 'attachmentFile' => $filePath);
     return $this->responseView('XenForo_ViewPublic_Attachment_View', '', $viewParams);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:35,代码来源:Attachment.php

示例4: get_attach_file_name

 public static function get_attach_file_name($attachmentFilename)
 {
     if ($attachmentFilename) {
         $extension = XenForo_Helper_File::getFileExtension($attachmentFilename);
         return str_replace($extension, '', $attachmentFilename);
     }
     return '';
 }
开发者ID:Sywooch,项目名称:forums,代码行数:8,代码来源:Listener.php

示例5: _createAddonFile

 protected function _createAddonFile()
 {
     $contents = str_replace('/>', '>', file_get_contents($this->_path . '/build-files/addon.xml'));
     $dir = new DirectoryIterator($this->_path . '/build-files');
     foreach ($dir as $file) {
         if ($file->isDot() or $file->isDir() or XenForo_Helper_File::getFileExtension($file->getFilename()) != 'xml' or $file->getFilename() == 'addon.xml') {
             continue;
         }
         $contents .= str_replace('<?xml version="1.0" encoding="utf-8"?>' . "\n", '', file_get_contents($file->getPathname()));
     }
     return $contents . '</addon>';
 }
开发者ID:robclancy,项目名称:XenForo-Build-Tools,代码行数:12,代码来源:Buildpackage.php

示例6: renderRaw

 public function renderRaw()
 {
     $extension = XenForo_Helper_File::getFileExtension($this->_params['thumbnailPath']);
     $imageTypes = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
     $this->setDownloadFileName($this->_params['thumbnailPath'], true);
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     if (!is_readable($this->_params['thumbnailPath']) || !file_exists($this->_params['thumbnailPath'])) {
         $this->_params['thumbnailPath'] = XenGallery_Template_Helper_Core::helperDummyImage('visible', '', '', true);
     }
     return new XenForo_FileOutput($this->_params['thumbnailPath']);
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:12,代码来源:Thumbnail.php

示例7: renderRaw

 public function renderRaw()
 {
     $parent = parent::renderRaw();
     $attachment = $this->_params['attachment'];
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
     $imageTypes = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (in_array($extension, array_keys($imageTypes))) {
         $this->_response->setHeader('Expires', gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime('+30 days')), true);
         $this->_response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s \\G\\M\\T', $attachment['attach_date']), true);
         $this->_response->setHeader('Cache-Control', 'public, max-age=2592000', true);
     }
     return $parent;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:13,代码来源:View.php

示例8: actionAddOnsServerFile

 public function actionAddOnsServerFile()
 {
     $q = $this->_input->filterSingle('q', XenForo_Input::STRING);
     $paths = array();
     /** @var XenForo_Application $app */
     $app = XenForo_Application::getInstance();
     $libraryPath = sprintf('%s/library', $app->getRootDir());
     $library = 'library';
     $libraryLength = min(strlen($library), strlen($q));
     if (strlen($q) > 0 && strpos($q, '.') === false && substr($q, 0, $libraryLength) === substr($library, 0, $libraryLength)) {
         if (strlen($q) < 7) {
             $q = 'library/';
             $paths[] = 'library';
         }
         $parts = explode('/', $q);
         array_shift($parts);
         $prefix = '';
         if (count($parts) > 0) {
             $prefix = array_pop($parts);
         }
         $path = rtrim(sprintf('%s/%s', $libraryPath, implode('/', $parts)), '/');
         if (is_dir($path)) {
             $contents = scandir($path);
             foreach ($contents as $content) {
                 if (substr($content, 0, 1) === '.') {
                     continue;
                 }
                 if ($prefix !== '' && substr($content, 0, strlen($prefix)) !== $prefix) {
                     continue;
                 }
                 $contentPath = sprintf('%s/%s', $path, $content);
                 if (is_dir($contentPath)) {
                     $paths[] = $contentPath;
                 } else {
                     $ext = XenForo_Helper_File::getFileExtension($contentPath);
                     if ($ext === 'xml') {
                         array_unshift($paths, $contentPath);
                     }
                 }
             }
         }
     }
     $results = array();
     foreach ($paths as $path) {
         $relativePath = preg_replace('#^' . preg_quote($app->getRootDir()) . '/#', '', $path);
         $results[$relativePath] = basename($path);
     }
     $view = $this->responseView();
     $view->jsonParams = array('results' => $results);
     return $view;
 }
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:51,代码来源:Tools.php

示例9: getAttachmentsForXenGalleryByAttachmentIds

 public function getAttachmentsForXenGalleryByAttachmentIds($attachmentIds)
 {
     $db = $this->_getDb();
     $attachments = $this->fetchAllKeyed("\n\t\t\t\tSELECT attachment.*, attachment_data.*, post.username, post.user_id\n\t\t\t\tFROM xf_attachment AS attachment\n\t\t\t\t\tLEFT JOIN xf_attachment_data AS attachment_data\n\t\t\t\t\t\tON (attachment.data_id = attachment_data.data_id)\n\t\t\t\t\tLEFT JOIN xf_post AS post\n\t\t\t\t\t\tON (attachment.content_id = post.post_id)\n\t\t\t\tWHERE attachment.attachment_id IN (" . $db->quote($attachmentIds) . ")\n\t\t\t\t\tAND attachment.content_type = 'post'\n\t\t\t\t\tAND post.message_state = 'visible'\n\t\t\t\tORDER BY attachment.attachment_id ASC", 'attachment_id');
     if ($attachments) {
         foreach ($attachments as $attachId => $attachment) {
             $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
             if (!in_array($extension, array('gif', 'png', 'jpg', 'jpeg', 'jpe'))) {
                 unset($attachments[$attachId]);
             }
         }
     }
     return $attachments;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:14,代码来源:Attachment.php

示例10: getTemplateIdFromFilePath

 public static function getTemplateIdFromFilePath($filePath)
 {
     $basename = basename($filePath);
     $extension = XenForo_Helper_File::getFileExtension($basename);
     if (!in_array($extension, array('html', 'css'))) {
         return 0;
     }
     $sanExtension = substr($basename, 0, -1 * (strlen($extension) + 1));
     $parts = explode('_', $sanExtension);
     $lastPart = array_pop($parts);
     if (!is_numeric($lastPart)) {
         return 0;
     }
     return intval($lastPart);
 }
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:15,代码来源:Template.php

示例11: renderRaw

 public function renderRaw()
 {
     $attachment = $this->_params['attachment'];
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
     $imageTypes = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (in_array($extension, array_keys($imageTypes))) {
         $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
         $this->setDownloadFileName($attachment['filename'], true);
     } else {
         $this->_response->setHeader('Content-type', 'unknown/unknown', true);
         $this->setDownloadFileName($attachment['filename']);
     }
     $this->_response->setHeader('ETag', $attachment['attach_date'], true);
     $this->_response->setHeader('Content-Length', $attachment['file_size'], true);
     return new XenForo_FileOutput($this->_params['attachmentFile']);
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:16,代码来源:View.php

示例12: renderRaw

 public function renderRaw()
 {
     $image = $this->_params['image'];
     $filename = basename($image['url']);
     $extension = XenForo_Helper_File::getFileExtension($filename);
     $imageTypes = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (in_array($extension, array_keys($imageTypes))) {
         $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
         $this->setDownloadFileName($filename, true);
     } else {
         $this->_response->setHeader('Content-type', 'application/octet-stream', true);
         $this->setDownloadFileName($filename);
     }
     $this->_response->setHeader('ETag', '"' . $image['fetch_date'] . '"', true);
     $this->_response->setHeader('Content-Length', $image['file_size'], true);
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     return new XenForo_FileOutput($image['file_path']);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:18,代码来源:View.php

示例13: renderHtml

 public function renderHtml()
 {
     parent::renderHtml();
     if (isset($this->_params['editorTemplate']) && $this->_params['editorTemplate']->getParam('showWysiwyg')) {
         $attachPattern = '/\\[ATTACH(.*?)\\](.*?)\\[\\/ATTACH\\]/si';
         $count = @preg_match_all($attachPattern, $this->_params['post']['message'], $matches);
         if ($count) {
             $cache = XenForo_Application::getCache();
             $imageTypes = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
             foreach ($matches[0] as $position => $match) {
                 if ($match && intval($matches[2][$position]) > 0) {
                     $attachmentId = intval($matches[2][$position]);
                     if ($cache) {
                         $attachment = unserialize($cache->load('attachment_cache_' . md5($attachmentId)));
                         if (!$attachment) {
                             $attachment = $this->_getAttachment($attachmentId);
                             $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
                             if (isset($imageTypes[$extension])) {
                                 $cache->save(serialize($attachment), 'attachment_cache_' . md5($attachmentId), array(), 3600);
                             }
                         }
                     } else {
                         $attachment = $this->_getAttachment($attachmentId);
                     }
                     if ($attachment && $attachment['thumbnail_width']) {
                         $attachment = $this->_getAttachmentModel()->prepareAttachment($attachment);
                         if ($matches[1][$position]) {
                             $replace = '<img class="attachFull bbCodeImage" src="' . XenForo_Link::buildPublicLink('attachments', array('attachment_id' => $attachment['attachment_id'])) . '" alt="attachFull' . $attachment['attachment_id'] . '" data-mce-src="' . XenForo_Link::buildPublicLink('attachments', array('attachment_id' => $attachment['attachment_id'])) . '" />';
                         } else {
                             $replace = '<img class="attachThumb bbCodeImage" src="' . $attachment['thumbnailUrl'] . '" alt="attachThumb' . $attachment['attachment_id'] . '" data-mce-src="' . $attachment['thumbnailUrl'] . '" />';
                         }
                     }
                     if (!empty($replace)) {
                         $htmlMessage = str_replace($match, $replace, $this->_params['editorTemplate']->getParam('messageHtml'));
                         $this->_params['editorTemplate']->setParam('messageHtml', $htmlMessage);
                     }
                 }
             }
         }
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:41,代码来源:Edit.php

示例14: renderTagAttach

 public function renderTagAttach(array $tag, array $rendererStates)
 {
     $imageTypes = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (empty($rendererStates['viewAttachments'])) {
         $rendererStates['viewAttachments'] = true;
     }
     $attachmentId = intval($this->stringifyTree($tag['children']));
     if (!empty($rendererStates['attachments'][$attachmentId])) {
         $extension = XenForo_Helper_File::getFileExtension($rendererStates['attachments'][$attachmentId]['filename']);
         if (!empty($rendererStates['attachments'][$attachmentId]['temp_hash'])) {
             $rendererStates['attachments'][$attachmentId]['temp_hash'] = '';
         }
         if (in_array($extension, array_keys($imageTypes))) {
             $rendererStates['viewAttachments'] = true;
         }
     } else {
         if ($tag['option'] == 'full' && $tag['children'] && $rendererStates['viewAttachments'] && $rendererStates['lightBox'] && $attachmentId) {
             $cache = XenForo_Application::getCache();
             if ($cache) {
                 $attachment_check = unserialize($cache->load('attachment_cache_' . md5($attachmentId)));
                 if (!$attachment_check) {
                     $attachment_check = $this->_getAttachmentModel()->getAttachmentById($attachmentId);
                     $cache->save(serialize($attachment_check), 'attachment_cache_' . md5($attachmentId), array(), 3600);
                 }
             } else {
                 $attachment_check = $this->_getAttachmentModel()->getAttachmentById($attachmentId);
             }
             if ($attachment_check && in_array(XenForo_Helper_File::getFileExtension($attachment_check['filename']), array_keys($imageTypes))) {
                 $attachment = $this->_getAttachmentModel()->prepareAttachment($attachment_check);
                 if (!empty($attachment['temp_hash'])) {
                     $attachment['temp_hash'] = '';
                 }
                 $rendererStates['canView'] = true;
                 $rendererStates['validAttachment'] = true;
                 $rendererStates['viewAttachments'] = true;
                 $rendererStates['attachments'][$attachment['attachment_id']] = $attachment;
             }
         }
     }
     return parent::renderTagAttach($tag, $rendererStates);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:41,代码来源:Base.php

示例15: renderRaw

 public function renderRaw()
 {
     $attachment = $this->_params['attachment'];
     if (!headers_sent() && function_exists('header_remove')) {
         header_remove('Expires');
         header('Cache-control: private');
     }
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
     $imageTypes = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (in_array($extension, array_keys($imageTypes))) {
         $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
         $this->setDownloadFileName($attachment['filename'], true);
     } else {
         $this->_response->setHeader('Content-type', 'application/octet-stream', true);
         $this->setDownloadFileName($attachment['filename']);
     }
     $this->_response->setHeader('ETag', '"' . $attachment['attach_date'] . '"', true);
     $this->_response->setHeader('Content-Length', $attachment['file_size'], true);
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     return new XenForo_FileOutput($this->_params['attachmentFile']);
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:21,代码来源:View.php


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