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


PHP gpFiles::NoNull方法代码示例

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


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

示例1: CheckFile

 /**
  * Make sure the file is a css or js file and that it exists
  * @static
  */
 static function CheckFile(&$file)
 {
     global $dataDir;
     $comment_start = '<!--';
     $comment_end = '-->';
     $file = gp_combine::TrimQuery($file);
     if (empty($file)) {
         return false;
     }
     //translate addon paths
     $pos = strpos($file, '/data/_addoncode/');
     if ($pos !== false) {
         $file_parts = substr($file, $pos + 17);
         $file_parts = explode('/', $file_parts);
         $addon_key = array_shift($file_parts);
         $addon_config = gpPlugin::GetAddonConfig($addon_key);
         if ($addon_config) {
             $file = $addon_config['code_folder_rel'] . '/' . implode('/', $file_parts);
         }
     }
     //remove null charachters
     $file = gpFiles::NoNull($file);
     //require .js or .css
     $test = strtolower($file);
     if (substr($test, -3) != '.js' && substr($test, -4) != '.css' && substr($test, -5) != '.less') {
         echo "\n{$comment_start} File Not CSS, LESS or JS {$file} {$comment_end}\n";
         return false;
     }
     //paths that have been urlencoded
     if (strpos($file, '%') !== false) {
         $decoded_file = rawurldecode($file);
         if ($full_path = gp_combine::CheckFileSub($decoded_file)) {
             $file = $decoded_file;
             return $full_path;
         }
     }
     //paths that have not been encoded
     if ($full_path = gp_combine::CheckFileSub($file)) {
         return $full_path;
     }
     echo "\n{$comment_start} File Not Found {$dataDir}{$file} {$comment_end}\n";
     return false;
 }
开发者ID:AndFer22,项目名称:Typesetter,代码行数:47,代码来源:combine.php

示例2: CheckFile

 /**
  * Make sure the fiel is a css or js file and that it exists
  * @static
  */
 function CheckFile(&$file, $css_comments = true)
 {
     global $dataDir, $dirPrefix, $dirPrefixEncoded;
     $file = gp_combine::TrimQuery($file);
     if ($css_comments) {
         $comment_start = '/*';
         $comment_end = '*/';
     } else {
         $comment_start = '<!--';
         $comment_end = '-->';
     }
     if (empty($file)) {
         return false;
     }
     //remove null charachters
     $file = gpFiles::NoNull($file);
     //require .js or .css
     $test = strtolower($file);
     if (substr($test, -3) != '.js' && substr($test, -4) != '.css') {
         echo "\n{$comment_start} File Not CSS or JS {$file} {$comment_end}\n";
         return false;
     }
     //paths that have been urlencoded
     if (strpos($file, '%') !== false) {
         $decoded_file = rawurldecode($file);
         if ($full_path = gp_combine::CheckFileSub($decoded_file)) {
             $file = $decoded_file;
             return $full_path;
         }
     }
     //paths that have not been encoded
     if ($full_path = gp_combine::CheckFileSub($file)) {
         return $full_path;
     }
     echo "\n{$comment_start} File Not Found {$dataDir}{$file} {$comment_end}\n";
     return false;
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:41,代码来源:combine.php

示例3: __construct

 /**
  * Check the path of the img, return full path of image if the requested image is found
  *
  */
 function __construct()
 {
     global $dataDir;
     if (!isset($_GET['w']) || !isset($_GET['h']) || !isset($_GET['img'])) {
         self::Send404();
         //dies
     }
     $img = $_GET['img'];
     $height = $_GET['h'];
     $width = $_GET['w'];
     $index = $_GET['i'];
     if (!is_numeric($height) || !is_numeric($width)) {
         self::Send404();
         //dies
     }
     $img = gpFiles::NoNull($img);
     //check file path
     if (strpos($img, './') !== false || strpos($img, '%2f') !== false || strpos($img, '%2F') !== false) {
         return false;
     }
     //make sure the index is set
     gp_resized::SetIndex();
     if (!isset(self::$index[$index])) {
         self::Send404();
         //dies
     }
     //if the image has been renamed, redirect to the new name
     $index_img = self::$index[$index];
     if ($index_img != $img) {
         $path = common::GetDir('/include/image.php', false) . '?i=' . $index . '&w=' . $width . '&h=' . $height . '&img=' . rawurlencode($index_img);
         common::Redirect($path);
     }
     $info = self::ImageInfo($img, $width, $height);
     $folder = $dataDir . '/data/_resized/' . $info['index'];
     $full_path = $folder . '/' . $info['name'];
     //if it exists return true
     if (file_exists($full_path)) {
         header('Cache-Control: public, max-age=5184000');
         //60 days
         //attempt to send 304
         $stats = lstat($full_path);
         if ($stats) {
             common::Send304(common::GenEtag($stats['mtime'], $stats['size']));
         }
         header('Content-Transfer-Encoding: binary');
         header('Content-Type: ' . $info['ctype']);
         readfile($full_path);
         die;
     }
     //redirect to next largest image if available
     $usage = self::GetUsage($info['index']);
     foreach ($usage as $size => $data) {
         if (!$data['uses']) {
             continue;
         }
         list($use_width, $use_height) = explode('x', $size);
         if ($use_width >= $width && $use_height > $height || $use_width > $width && $use_height >= $height) {
             $path = common::GetDir('/include/image.php', false) . '?i=' . $index . '&w=' . $use_width . '&h=' . $use_height . '&img=' . rawurlencode($img);
             common::Redirect($path);
             //dies
         }
     }
     //redirect to full size image
     $original = common::GetDir('/data/_uploaded' . $img, false);
     common::Redirect($original);
     //dies
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:71,代码来源:image.php

示例4: AllowedExtension

 /**
  * Check the file extension agains $allowed_types
  *
  */
 static function AllowedExtension(&$file, $fix = true)
 {
     global $upload_extensions_allow, $upload_extensions_deny;
     static $allowed_types = false;
     $file = gpFiles::NoNull($file);
     if (!gp_restrict_uploads) {
         return true;
     }
     $parts = explode('.', $file);
     if (count($parts) < 2) {
         return true;
     }
     //build list of allowed extensions once
     if (!$allowed_types) {
         if (is_string($upload_extensions_deny) && strtolower($upload_extensions_deny) === 'all') {
             $allowed_types = array();
         } else {
             $allowed_types = array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tif', 'tiff', 'wav', 'wma', 'svg', 'aiff', 'asf', 'avi', 'fla', 'flv', 'm4v', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ogg', 'oga', 'ogv', 'opus', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'swf', 'webm', 'wmv', '7z', 'bz', 'gz', 'gzip', 'rar', 'sdc', 'sitd', 'tar', 'tgz', 'zip', 'css', 'csv', 'doc', 'docx', 'htm', 'html', 'js', 'json', 'less', 'md', 'ods', 'odt', 'pdf', 'ppt', 'pptx', 'rtf', 'txt', 'sxc', 'sxw', 'vsd', 'xls', 'xlsx', 'xml');
         }
         if (is_array($upload_extensions_allow)) {
             $upload_extensions_allow = array_map('trim', $upload_extensions_allow);
             $upload_extensions_allow = array_map('strtolower', $upload_extensions_allow);
             $allowed_types = array_merge($allowed_types, $upload_extensions_allow);
         }
         if (is_array($upload_extensions_deny)) {
             $upload_extensions_allow = array_map('trim', $upload_extensions_allow);
             $upload_extensions_allow = array_map('strtolower', $upload_extensions_allow);
             $allowed_types = array_diff($allowed_types, $upload_extensions_deny);
         }
     }
     $allowed_types = gpPlugin::Filter('AllowedTypes', array($allowed_types));
     //make sure the extension is allowed
     $file_type = array_pop($parts);
     if (!in_array(strtolower($file_type), $allowed_types)) {
         return false;
     }
     if ($fix) {
         return implode('_', $parts) . '.' . $file_type;
     } else {
         return implode('.', $parts) . '.' . $file_type;
     }
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:46,代码来源:admin_uploaded.php


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