• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CKFinder_Connector_Utils_Misc类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: throwError

 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 function throwError($number, $uploaded = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $sFileName = $oRegistry->get("FileUpload_fileName");
     $sFileUrl = $oRegistry->get("FileUpload_url");
     header('Content-Type: text/html; charset=utf-8');
     $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName);
     if (!$uploaded) {
         $sFileName = "";
     }
     if (!empty($_GET['response_type']) && $_GET['response_type'] == 'txt') {
         echo $sFileName . "|" . $errorMessage;
         exit;
     }
     echo "<script type=\"text/javascript\">";
     if (!empty($_GET['CKFinderFuncNum'])) {
         $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName);
         if (!$uploaded) {
             $sFileUrl = "";
             $sFileName = "";
         }
         $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKFinderFuncNum']);
         echo "window.parent.CKFinder.tools.callFunction({$funcNum}, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "');";
     } else {
         echo "window.parent.OnUploadCompleted('" . str_replace("'", "\\'", $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "') ;";
     }
     echo "</script>";
     if ($exit) {
         exit;
     }
 }
开发者ID:mrschleig,项目名称:sensdata,代码行数:41,代码来源:FileUpload.php


示例2: throwError

 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 function throwError($number, $uploaded = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $sFileName = $oRegistry->get("FileUpload_fileName");
     $sFileUrl = $oRegistry->get("FileUpload_url");
     header('Content-Type: text/html; charset=utf-8');
     /**
      * echo <script> is not called before CKFinder_Connector_Utils_Misc::getErrorMessage
      * because PHP has problems with including files that contain BOM character.
      * Having BOM character after <script> tag causes a javascript error.
      */
     echo "<script type=\"text/javascript\">";
     if (!empty($_GET['CKEditor'])) {
         $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName);
         if (!$uploaded) {
             $sFileUrl = "";
             $sFileName = "";
         }
         $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']);
         echo "window.parent.CKEDITOR.tools.callFunction({$funcNum}, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "');";
     } else {
         if (!$uploaded) {
             echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
         } else {
             echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;";
         }
     }
     echo "</script>";
     if ($exit) {
         exit;
     }
 }
开发者ID:knieper,项目名称:crltmich,代码行数:42,代码来源:QuickUpload.php


示例3: __construct

 function __construct($thumbnailsNode)
 {
     if (extension_loaded('gd') && isset($thumbnailsNode['enabled'])) {
         $this->_isEnabled = CKFinder_Connector_Utils_Misc::booleanValue($thumbnailsNode['enabled']);
     }
     if (isset($thumbnailsNode['maxWidth'])) {
         $_maxWidth = intval($thumbnailsNode['maxWidth']);
         if ($_maxWidth >= 0) {
             $this->_maxWidth = $_maxWidth;
         }
     }
     if (isset($thumbnailsNode['maxHeight'])) {
         $_maxHeight = intval($thumbnailsNode['maxHeight']);
         if ($_maxHeight >= 0) {
             $this->_maxHeight = $_maxHeight;
         }
     }
     if (isset($thumbnailsNode['quality'])) {
         $_quality = intval($thumbnailsNode['quality']);
         if ($_quality > 0 && $_quality <= 100) {
             $this->_quality = $_quality;
         }
     }
     if (isset($thumbnailsNode['url'])) {
         $this->_url = $thumbnailsNode['url'];
     }
     if (isset($thumbnailsNode['directory'])) {
         $this->_directory = $thumbnailsNode['directory'];
     }
 }
开发者ID:kingwang317,项目名称:it4fun-guam,代码行数:30,代码来源:ThumbnailsConfig.php


示例4: throwError

 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 public function throwError($number, $uploaded = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $sFileName = $oRegistry->get("FileUpload_fileName");
     $sFileUrl = $oRegistry->get("FileUpload_url");
     $sEncodedFileName = CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($sFileName);
     $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sEncodedFileName);
     if (!empty($_GET['responseType']) && $_GET['responseType'] == 'json') {
         header('Content-Type: application/json; charset=utf-8');
         $data = array('fileName' => $sEncodedFileName, 'uploaded' => (int) $uploaded);
         if ($uploaded) {
             $data['url'] = $sFileUrl . CKFinder_Connector_Utils_Misc::encodeURIComponent($sEncodedFileName);
         }
         if ($number !== CKFINDER_CONNECTOR_ERROR_NONE) {
             $data['error'] = array('number' => $number, 'message' => $errorMessage);
         }
         echo json_encode($data);
     } else {
         header('Content-Type: text/html; charset=utf-8');
         /**
          * echo <script> is not called before CKFinder_Connector_Utils_Misc::getErrorMessage
          * because PHP has problems with including files that contain BOM character.
          * Having BOM character after <script> tag causes a javascript error.
          */
         echo "<script type=\"text/javascript\">";
         if (!empty($_GET['CKEditor'])) {
             if (!$uploaded) {
                 $sFileUrl = "";
                 $sFileName = "";
                 $sEncodedFileName = "";
             }
             $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']);
             echo "window.parent.CKEDITOR.tools.callFunction({$funcNum}, '" . str_replace("'", "\\'", $sFileUrl . CKFinder_Connector_Utils_Misc::encodeURIComponent($sEncodedFileName)) . "', '" . str_replace("'", "\\'", $errorMessage) . "');";
         } else {
             if (!$uploaded) {
                 echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
             } else {
                 echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . CKFinder_Connector_Utils_Misc::encodeURIComponent($sEncodedFileName)) . "', '" . str_replace("'", "\\'", $sEncodedFileName) . "', '') ;";
             }
         }
         echo "</script>";
     }
     if ($exit) {
         exit;
     }
 }
开发者ID:dinhtich1991,项目名称:staff,代码行数:56,代码来源:QuickUpload.php


示例5: __construct

 function __construct($accessControlNodes)
 {
     foreach ($accessControlNodes as $node) {
         $_folderView = isset($node['folderView']) ? CKFinder_Connector_Utils_Misc::booleanValue($node['folderView']) : false;
         $_folderCreate = isset($node['folderCreate']) ? CKFinder_Connector_Utils_Misc::booleanValue($node['folderCreate']) : false;
         $_folderRename = isset($node['folderRename']) ? CKFinder_Connector_Utils_Misc::booleanValue($node['folderRename']) : false;
         $_folderDelete = isset($node['folderDelete']) ? CKFinder_Connector_Utils_Misc::booleanValue($node['folderDelete']) : false;
         $_fileView = isset($node['fileView']) ? CKFinder_Connector_Utils_Misc::booleanValue($node['fileView']) : false;
         $_fileUpload = isset($node['fileUpload']) ? CKFinder_Connector_Utils_Misc::booleanValue($node['fileUpload']) : false;
         $_fileRename = isset($node['fileRename']) ? CKFinder_Connector_Utils_Misc::booleanValue($node['fileRename']) : false;
         $_fileDelete = isset($node['fileDelete']) ? CKFinder_Connector_Utils_Misc::booleanValue($node['fileDelete']) : false;
         $_role = isset($node['role']) ? $node['role'] : "*";
         $_resourceType = isset($node['resourceType']) ? $node['resourceType'] : "*";
         $_folder = isset($node['folder']) ? $node['folder'] : "/";
         $this->addACLEntry($_role, $_resourceType, $_folder, array($_folderView ? CKFINDER_CONNECTOR_ACL_FOLDER_VIEW : 0, $_folderCreate ? CKFINDER_CONNECTOR_ACL_FOLDER_CREATE : 0, $_folderRename ? CKFINDER_CONNECTOR_ACL_FOLDER_RENAME : 0, $_folderDelete ? CKFINDER_CONNECTOR_ACL_FOLDER_DELETE : 0, $_fileView ? CKFINDER_CONNECTOR_ACL_FILE_VIEW : 0, $_fileUpload ? CKFINDER_CONNECTOR_ACL_FILE_UPLOAD : 0, $_fileRename ? CKFINDER_CONNECTOR_ACL_FILE_RENAME : 0, $_fileDelete ? CKFINDER_CONNECTOR_ACL_FILE_DELETE : 0), array($_folderView ? 0 : CKFINDER_CONNECTOR_ACL_FOLDER_VIEW, $_folderCreate ? 0 : CKFINDER_CONNECTOR_ACL_FOLDER_CREATE, $_folderRename ? 0 : CKFINDER_CONNECTOR_ACL_FOLDER_RENAME, $_folderDelete ? 0 : CKFINDER_CONNECTOR_ACL_FOLDER_DELETE, $_fileView ? 0 : CKFINDER_CONNECTOR_ACL_FILE_VIEW, $_fileUpload ? 0 : CKFINDER_CONNECTOR_ACL_FILE_UPLOAD, $_fileRename ? 0 : CKFINDER_CONNECTOR_ACL_FILE_RENAME, $_fileDelete ? 0 : CKFINDER_CONNECTOR_ACL_FILE_DELETE));
     }
 }
开发者ID:abhaygmit,项目名称:testprj,代码行数:17,代码来源:AccessControlConfig.php


示例6: throwError

 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 public function throwError($number, $uploaded = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $sFileName = $oRegistry->get("FileUpload_fileName");
     header('Content-Type: text/html; charset=utf-8');
     $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName);
     if (!$uploaded) {
         $sFileName = "";
     }
     echo "<script type=\"text/javascript\">";
     echo "window.parent.OnUploadCompleted('" . str_replace("'", "\\'", $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "') ;";
     echo "</script>";
     if ($exit) {
         exit;
     }
 }
开发者ID:redeyes1024,项目名称:medlii_mlm_backend,代码行数:26,代码来源:FileUpload.php


示例7: loadValues

 /**
  * Load values from config
  *
  * @access private
  */
 private function loadValues()
 {
     if (function_exists('CheckAuthentication')) {
         $this->_isEnabled = CheckAuthentication();
     }
     if (isset($GLOBALS['config']['LicenseName'])) {
         $this->_licenseName = (string) $GLOBALS['config']['LicenseName'];
     }
     if (isset($GLOBALS['config']['LicenseKey'])) {
         $this->_licenseKey = (string) $GLOBALS['config']['LicenseKey'];
     }
     if (isset($GLOBALS['config']['FilesystemEncoding'])) {
         $this->_filesystemEncoding = (string) $GLOBALS['config']['FilesystemEncoding'];
     }
     if (isset($GLOBALS['config']['RoleSessionVar'])) {
         $this->_roleSessionVar = (string) $GLOBALS['config']['RoleSessionVar'];
     }
     if (isset($GLOBALS['config']['CheckDoubleExtension'])) {
         $this->_checkDoubleExtension = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['CheckDoubleExtension']);
     }
     if (isset($GLOBALS['config']['DisallowUnsafeCharacters'])) {
         $this->_disallowUnsafeCharacters = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['DisallowUnsafeCharacters']);
     }
     if (isset($GLOBALS['config']['SecureImageUploads'])) {
         $this->_secureImageUploads = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['SecureImageUploads']);
     }
     if (isset($GLOBALS['config']['CheckSizeAfterScaling'])) {
         $this->_checkSizeAfterScaling = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['CheckSizeAfterScaling']);
     }
     if (isset($GLOBALS['config']['ForceAscii'])) {
         $this->_forceAscii = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['ForceAscii']);
     }
     if (isset($GLOBALS['config']['HtmlExtensions'])) {
         $this->_htmlExtensions = (array) $GLOBALS['config']['HtmlExtensions'];
     }
     if (isset($GLOBALS['config']['HideFolders'])) {
         $this->_hideFolders = (array) $GLOBALS['config']['HideFolders'];
     }
     if (isset($GLOBALS['config']['HideFiles'])) {
         $this->_hideFiles = (array) $GLOBALS['config']['HideFiles'];
     }
     if (isset($GLOBALS['config']['ChmodFiles'])) {
         $this->_chmodFiles = $GLOBALS['config']['ChmodFiles'];
     }
     if (isset($GLOBALS['config']['ChmodFolders'])) {
         $this->_chmodFolders = $GLOBALS['config']['ChmodFolders'];
     }
     if (isset($GLOBALS['config']['DefaultResourceTypes'])) {
         $_defaultResourceTypes = (string) $GLOBALS['config']['DefaultResourceTypes'];
         if (strlen($_defaultResourceTypes)) {
             $this->_defaultResourceTypes = explode(",", $_defaultResourceTypes);
         }
     }
     if (isset($GLOBALS['config']['TempDirectory'])) {
         $this->_tempDirectory = $GLOBALS['config']['TempDirectory'];
     }
     if (isset($GLOBALS['config']['XSendfile'])) {
         $this->_xsendfile = CKFinder_Connector_Utils_Misc::booleanValue($GLOBALS['config']['XSendfile']);
     }
     if (isset($GLOBALS['config']['XSendfileNginx'])) {
         $this->_xsendfileNginx = (array) $GLOBALS['config']['XSendfileNginx'];
     }
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:68,代码来源:Config.php


示例8: sendResponse

 * Handle FileUpload command

 *

 * @package CKFinder

 * @subpackage CommandHandlers

 * @copyright CKSource - Frederico Knabben

 */
class CKFinder_Connector_CommandHandler_FileUpload extends CKFinder_Connector_CommandHandler_CommandHandlerBase
{
    /**

     * Command name

     *

     * @access protected

     * @var string

     */
    protected $command = "FileUpload";
    /**

     * send response (save uploaded file, resize if required)

     * @access public

     *

     */
    public function sendResponse()
    {
        $iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
        $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
        $oRegistry->set("FileUpload_fileName", "unknown file");
        $uploadedFile = array_shift($_FILES);
        if (!isset($uploadedFile['name'])) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID);
        }
        $sUnsafeFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile['name']));
        $sFileName = CKFinder_Connector_Utils_FileSystem::secureFileName($sUnsafeFileName);
        if ($sFileName != $sUnsafeFileName) {
            $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
        }
        $oRegistry->set("FileUpload_fileName", $sFileName);
        $this->checkConnector();
        $this->checkRequest();
        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
        }
        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $_resourceTypeConfig->checkIsHiddenFile($sFileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
        }
        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
        if (!$resourceTypeInfo->checkExtension($sFileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
        }
        $oRegistry->set("FileUpload_fileName", $sFileName);
        $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
        $maxSize = $resourceTypeInfo->getMaxSize();
        if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size'] > $maxSize) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
        }
        $htmlExtensions = $_config->getHtmlExtensions();
        $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
        if ($htmlExtensions && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions) && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
        }
        $secureImageUploads = $_config->getSecureImageUploads();
        if ($secureImageUploads && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
        }
        switch ($uploadedFile['error']) {
            case UPLOAD_ERR_OK:
                break;
            case UPLOAD_ERR_INI_SIZE:
            case UPLOAD_ERR_FORM_SIZE:
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
                break;
            case UPLOAD_ERR_PARTIAL:
            case UPLOAD_ERR_NO_FILE:
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
                break;
            case UPLOAD_ERR_NO_TMP_DIR:
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
                break;
            case UPLOAD_ERR_CANT_WRITE:
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
                break;
            case UPLOAD_ERR_EXTENSION:
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
                break;
        }
        $sServerDir = $this->_currentFolder->getServerPath();
//.........这里部分代码省略.........
开发者ID:neelmanis,项目名称:Jobready_New,代码行数:101,代码来源:FileUpload.php


示例9: __construct

 /**
  * Get ResourceType configuration
  *
  * @param string $resourceTypeNode
  * @return array
  *
  */
 function __construct($resourceTypeNode)
 {
     if (isset($resourceTypeNode["name"])) {
         $this->_name = $resourceTypeNode["name"];
     }
     if (isset($resourceTypeNode["url"])) {
         $this->_url = $resourceTypeNode["url"];
     }
     if (!strlen($this->_url)) {
         $this->_url = "/";
     } else {
         if (substr($this->_url, -1, 1) != "/") {
             $this->_url .= "/";
         }
     }
     if (isset($resourceTypeNode["maxSize"])) {
         $this->_maxSize = CKFinder_Connector_Utils_Misc::returnBytes((string) $resourceTypeNode["maxSize"]);
     }
     if (isset($resourceTypeNode["directory"])) {
         $this->_directory = $resourceTypeNode["directory"];
     }
     if (!strlen($this->_directory)) {
         $this->_directory = resolveUrl($this->_url);
     }
     if (isset($resourceTypeNode["allowedExtensions"])) {
         if (is_array($resourceTypeNode["allowedExtensions"])) {
             foreach ($resourceTypeNode["allowedExtensions"] as $e) {
                 $this->_allowedExtensions[] = strtolower(trim((string) $e));
             }
         } else {
             $resourceTypeNode["allowedExtensions"] = trim((string) $resourceTypeNode["allowedExtensions"]);
             if (strlen($resourceTypeNode["allowedExtensions"])) {
                 $extensions = explode(",", $resourceTypeNode["allowedExtensions"]);
                 foreach ($extensions as $e) {
                     $this->_allowedExtensions[] = strtolower(trim($e));
                 }
             }
         }
     }
     if (isset($resourceTypeNode["deniedExtensions"])) {
         if (is_array($resourceTypeNode["deniedExtensions"])) {
             foreach ($resourceTypeNode["deniedExtensions"] as $extension) {
                 $this->_deniedExtensions[] = strtolower(trim((string) $e));
             }
         } else {
             $resourceTypeNode["deniedExtensions"] = trim((string) $resourceTypeNode["deniedExtensions"]);
             if (strlen($resourceTypeNode["deniedExtensions"])) {
                 $extensions = explode(",", $resourceTypeNode["deniedExtensions"]);
                 foreach ($extensions as $e) {
                     $this->_deniedExtensions[] = strtolower(trim($e));
                 }
             }
         }
     }
 }
开发者ID:itmyprofession,项目名称:admin,代码行数:62,代码来源:ResourceTypeConfig.php


示例10: createThumb

 /**
  * Create thumbnail
  *
  * @param string $sourceFile
  * @param string $targetFile
  * @param int $maxWidth
  * @param int $maxHeight
  * @param boolean $preserverAspectRatio
  * @param boolean $bmpSupported
  * @return boolean
  * @static
  * @access public
  */
 public static function createThumb($sourceFile, $targetFile, $maxWidth, $maxHeight, $quality, $preserverAspectRatio, $bmpSupported = false)
 {
     $sourceImageAttr = @getimagesize($sourceFile);
     if ($sourceImageAttr === false) {
         return false;
     }
     $sourceImageWidth = isset($sourceImageAttr[0]) ? $sourceImageAttr[0] : 0;
     $sourceImageHeight = isset($sourceImageAttr[1]) ? $sourceImageAttr[1] : 0;
     $sourceImageMime = isset($sourceImageAttr["mime"]) ? $sourceImageAttr["mime"] : "";
     $sourceImageBits = isset($sourceImageAttr["bits"]) ? $sourceImageAttr["bits"] : 8;
     $sourceImageChannels = isset($sourceImageAttr["channels"]) ? $sourceImageAttr["channels"] : 3;
     if (!$sourceImageWidth || !$sourceImageHeight || !$sourceImageMime) {
         return false;
     }
     $iFinalWidth = $maxWidth == 0 ? $sourceImageWidth : $maxWidth;
     $iFinalHeight = $maxHeight == 0 ? $sourceImageHeight : $maxHeight;
     if ($sourceImageWidth <= $iFinalWidth && $sourceImageHeight <= $iFinalHeight) {
         if ($sourceFile != $targetFile) {
             copy($sourceFile, $targetFile);
         }
         return true;
     }
     if ($preserverAspectRatio) {
         // Gets the best size for aspect ratio resampling
         $oSize = CKFinder_Connector_CommandHandler_Thumbnail::GetAspectRatioSize($iFinalWidth, $iFinalHeight, $sourceImageWidth, $sourceImageHeight);
     } else {
         $oSize = array('Width' => $iFinalWidth, 'Height' => $iFinalHeight);
     }
     CKFinder_Connector_Utils_Misc::setMemoryForImage($sourceImageWidth, $sourceImageHeight, $sourceImageBits, $sourceImageChannels);
     switch ($sourceImageAttr['mime']) {
         case 'image/gif':
             if (@imagetypes() & IMG_GIF) {
                 $oImage = @imagecreatefromgif($sourceFile);
             } else {
                 $ermsg = 'GIF images are not supported';
             }
             break;
         case 'image/jpeg':
             if (@imagetypes() & IMG_JPG) {
                 $oImage = @imagecreatefromjpeg($sourceFile);
             } else {
                 $ermsg = 'JPEG images are not supported';
             }
             break;
         case 'image/png':
             if (@imagetypes() & IMG_PNG) {
                 $oImage = @imagecreatefrompng($sourceFile);
             } else {
                 $ermsg = 'PNG images are not supported';
             }
             break;
         case 'image/wbmp':
             if (@imagetypes() & IMG_WBMP) {
                 $oImage = @imagecreatefromwbmp($sourceFile);
             } else {
                 $ermsg = 'WBMP images are not supported';
             }
             break;
         case 'image/bmp':
             /*
              * This is sad that PHP doesn't support bitmaps.
              * Anyway, we will use our custom function at least to display thumbnails.
              * We'll not resize images this way (if $sourceFile === $targetFile),
              * because user defined imagecreatefrombmp and imagecreatebmp are horribly slow
              */
             if ($bmpSupported && @imagetypes() & IMG_JPG && $sourceFile != $targetFile) {
                 $oImage = CKFinder_Connector_Utils_Misc::imageCreateFromBmp($sourceFile);
             } else {
                 $ermsg = 'BMP/JPG images are not supported';
             }
             break;
         default:
             $ermsg = $sourceImageAttr['mime'] . ' images are not supported';
             break;
     }
     if (isset($ermsg) || false === $oImage) {
         return false;
     }
     $oThumbImage = imagecreatetruecolor($oSize["Width"], $oSize["Height"]);
     if ($sourceImageAttr['mime'] == 'image/png') {
         $bg = imagecolorallocatealpha($oThumbImage, 255, 255, 255, 127);
         // (PHP 4 >= 4.3.2, PHP 5)
         imagefill($oThumbImage, 0, 0, $bg);
         imagealphablending($oThumbImage, false);
         imagesavealpha($oThumbImage, true);
     }
     //imagecopyresampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight);
//.........这里部分代码省略.........
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:Thumbnail.php


示例11: buildXml

 /**
  * handle request and build XML
  * @access protected
  *
  */
 protected function buildXml()
 {
     $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
     if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
     }
     // Map the virtual path to the local server path.
     $_sServerDir = $this->_currentFolder->getServerPath();
     // Create the "Files" node.
     $oFilesNode = new Ckfinder_Connector_Utils_XmlNode("Files");
     $this->_connectorNode->addChild($oFilesNode);
     if (!is_dir($_sServerDir)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
     }
     $files = array();
     $thumbFiles = array();
     if ($dh = @opendir($_sServerDir)) {
         while (($file = readdir($dh)) !== false) {
             if ($file != "." && $file != ".." && !is_dir($_sServerDir . $file)) {
                 $files[] = $file;
             }
         }
         closedir($dh);
     } else {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
     }
     $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
     if (sizeof($files) > 0) {
         $_thumbnailsConfig = $_config->getThumbnailsConfig();
         $_thumbServerPath = '';
         $_showThumbs = !empty($_GET['showThumbs']) && $_GET['showThumbs'] == 1;
         if ($_thumbnailsConfig->getIsEnabled() && ($_thumbnailsConfig->getDirectAccess() || $_showThumbs)) {
             $_thumbServerPath = $this->_currentFolder->getThumbsServerPath();
         }
         natcasesort($files);
         $i = 0;
         foreach ($files as $file) {
             $filemtime = @filemtime($_sServerDir . $file);
             //otherwise file doesn't exist or we can't get it's filename properly
             if ($filemtime !== false) {
                 $filename = CKFinder_Connector_Utils_Misc::mbBasename($file);
                 if (!$resourceTypeInfo->checkExtension($filename, false)) {
                     continue;
                 }
                 if ($resourceTypeInfo->checkIsHiddenFile($filename)) {
                     continue;
                 }
                 $oFileNode[$i] = new Ckfinder_Connector_Utils_XmlNode("File");
                 $oFilesNode->addChild($oFileNode[$i]);
                 $oFileNode[$i]->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding(CKFinder_Connector_Utils_Misc::mbBasename($file)));
                 $oFileNode[$i]->addAttribute("date", @date("YmdHi", $filemtime));
                 if (!empty($_thumbServerPath) && preg_match(CKFINDER_REGEX_IMAGES_EXT, $filename)) {
                     if (file_exists($_thumbServerPath . $filename)) {
                         $oFileNode[$i]->addAttribute("thumb", $filename);
                     } elseif ($_showThumbs) {
                         $oFileNode[$i]->addAttribute("thumb", "?" . $filename);
                     }
                 }
                 $size = filesize($_sServerDir . $file);
                 if ($size && $size < 1024) {
                     $size = 1;
                 } else {
                     $size = (int) round($size / 1024);
                 }
                 $oFileNode[$i]->addAttribute("size", $size);
                 $i++;
             }
         }
     }
 }
开发者ID:laiello,项目名称:tix-consultorios,代码行数:75,代码来源:GetFiles.php


示例12: sendResponse

 /**
  * send response (save uploaded file, resize if required)
  * @access public
  *
  */
 public function sendResponse()
 {
     $iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
     $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $oRegistry->set("FileUpload_fileName", "unknown file");
     $uploadedFile = array_shift($_FILES);
     if (!isset($uploadedFile['name'])) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID);
     }
     $sUnsafeFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile['name']));
     $sFileName = str_replace(array(":", "*", "?", "|", "/"), "_", $sUnsafeFileName);
     if ($_config->forceAscii()) {
         $sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
     }
     if ($sFileName != $sUnsafeFileName) {
         $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
     }
     //file named with chinese charactor
     $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
     $sFileName = date("Ymd") . "_" . date("His") . "." . $sExtension;
     //end
     $oRegistry->set("FileUpload_fileName", $sFileName);
     $this->checkConnector();
     $this->checkRequest();
     if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
     }
     $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
     if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $_resourceTypeConfig->checkIsHiddenFile($sFileName)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
     }
     $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
     if (!$resourceTypeInfo->checkExtension($sFileName)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
     }
     $sFileNameOrginal = $sFileName;
     $oRegistry->set("FileUpload_fileName", $sFileName);
     $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
     $maxSize = $resourceTypeInfo->getMaxSize();
     if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size'] > $maxSize) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
     }
     $htmlExtensions = $_config->getHtmlExtensions();
     $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
     if ($htmlExtensions && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions) && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
     }
     $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
     $secureImageUploads = $_config->getSecureImageUploads();
     if ($secureImageUploads && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
     }
     switch ($uploadedFile['error']) {
         case UPLOAD_ERR_OK:
             break;
         case UPLOAD_ERR_INI_SIZE:
         case UPLOAD_ERR_FORM_SIZE:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
             break;
         case UPLOAD_ERR_PARTIAL:
         case UPLOAD_ERR_NO_FILE:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
             break;
         case UPLOAD_ERR_CANT_WRITE:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
             break;
         case UPLOAD_ERR_EXTENSION:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
             break;
     }
     $sServerDir = $this->_currentFolder->getServerPath();
     $iCounter = 0;
     //personnal
     $now = time();
     $yearDir = $sServerDir . '/' . date('Y', $now) . '/';
     if (!file_exists($yearDir) && !is_dir($yearDir)) {
         mkdir($yearDir, 0777);
     }
     $monthDir = $yearDir . date('m', $now) . '/';
     if (!file_exists($monthDir) && !is_dir($monthDir)) {
         mkdir($monthDir, 0777);
     }
     $dayDir = $monthDir . date('d', $now);
     if (!file_exists($dayDir) && !is_dir($dayDir)) {
         mkdir($dayDir, 0777);
     }
     $sServerDir = $dayDir;
     $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl() . date('Y', $now) . '/' . date('m', $now) . '/' . date('d', $now) . '/');
     //personnal end
     //file_put_contents($_SERVER['DOCUMENT_ROOT'].'/s.txt',$this->_currentFolder->getUrl());
     //
//.........这里部分代码省略.........
开发者ID:ailingsen,项目名称:pigcms,代码行数:101,代码来源:FileUpload.php


示例13: CKFinder_Connector_Core_ThumbnailsConfig

 function CKFinder_Connector_Core_ThumbnailsConfig($thumbnailsNode)
 {
     if (extension_loaded('gd') && isset($thumbnailsNode['enabled'])) {
         $this->_isEnabled = CKFinder_Connector_Utils_Misc::booleanValue($thumbnailsNode['enabled']);
     }
     if (isset($thumbnailsNode['directAccess'])) {
         $this->_directAccess = CKFinder_Connector_Utils_Misc::booleanValue($thumbnailsNode['directAccess']);
     }
     if (isset($thumbnailsNode['bmpSupported'])) {
         $this->_bmpSupported = CKFinder_Connector_Utils_Misc::booleanValue($thumbnailsNode['bmpSupported']);
     }
     if (isset($thumbnailsNode['maxWidth'])) {
         $_maxWidth = intval($thumbnailsNode['maxWidth']);
         if ($_maxWidth >= 0) {
             $this->_maxWidth = $_maxWidth;
         }
     }
     if (isset($thumbnailsNode['maxHeight'])) {
         $_maxHeight = intval($thumbnailsNode['maxHeight']);
         if ($_maxHeight >= 0) {
             $this->_maxHeight = $_maxHeight;
         }
     }
     if (isset($thumbnailsNode['quality'])) {
         $_quality = intval($thumbnailsNode['quality']);
         if ($_quality > 0 && $_quality <= 100) {
             $this->_quality = $_quality;
         }
     }
     if (isset($thumbnailsNode['url'])) {
         $this->_url = $thumbnailsNode['url'];
     }
     if (!strlen($this->_url)) {
         $this->_url = "/";
     } else {
         if (substr($this->_url, -1, 1) != "/") {
             $this->_url .= "/";
         }
     }
     if (isset($thumbnailsNode['directory'])) {
         $this->_directory = $thumbnailsNode['directory'];
     }
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:43,代码来源:ThumbnailsConfig.php


示例14: buildXml

 /**
  * handle request and build XML
  * @access protected
  *
  */
 function buildXml()
 {
     $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
     // Create the "ConnectorInfo" node.
     $_oConnInfo = new Ckfinder_Connector_Utils_XmlNode("ConnectorInfo");
     $this->_connectorNode->addChild($_oConnInfo);
     $_oConnInfo->addAttribute("enabled", $_config->getIsEnabled() ? "true" : "false");
     if (!$_config->getIsEnabled()) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED);
     }
     $_ln = '';
     $_lc = $_config->getLicenseKey() . '                                  ';
     $pos = strpos(CKFINDER_CHARS, $_lc[0]) % 5;
     if ($pos == 1 || $pos == 4) {
         $_ln = $_config->getLicenseName();
     }
     $_oConnInfo->addAttribute("s", $_ln);
     $_oConnInfo->addAttribute("c", trim($_lc[11] . $_lc[0] . $_lc[8] . $_lc[12] . $_lc[26] . $_lc[2] . $_lc[3] . $_lc[25] . $_lc[1]));
     $_thumbnailsConfig = $_config->getThumbnailsConfig();
     $_thumbnailsEnabled = $_thumbnailsConfig->getIsEnabled();
     $_oConnInfo->addAttribute("thumbsEnabled", $_thumbnailsEnabled ? "true" : "false");
     if ($_thumbnailsEnabled) {
         $_oConnInfo->addAttribute("thumbsUrl", $_thumbnailsConfig->getUrl());
         $_oConnInfo->addAttribute("thumbsDirectAccess", $_thumbnailsConfig->getDirectAccess() ? "true" : "false");
     }
     $_imagesConfig = $_config->getImagesConfig();
     $_oConnInfo->addAttribute("imgWidth", $_imagesConfig->getMaxWidth());
     $_oConnInfo->addAttribute("imgHeight", $_imagesConfig->getMaxHeight());
     // Create the "ResourceTypes" node.
     $_oResourceTypes = new Ckfinder_Connector_Utils_XmlNode("ResourceTypes");
     $this->_connectorNode->addChild($_oResourceTypes);
     // Create the "PluginsInfo" node.
     $_oPluginsInfo = new Ckfinder_Connector_Utils_XmlNode("PluginsInfo");
     $this->_connectorNode->addChild($_oPluginsInfo);
     // Load the resource types in an array.
     $_aTypes = $_config->getDefaultResourceTypes();
     if (!sizeof($_aTypes)) {
         $_aTypes = $_config->getResourceTypeNames();
     }
     $_aTypesSize = sizeof($_aTypes);
     if ($_aTypesSize) {
         $phpMaxSize = 0;
         $max_upload = CKFinder_Connector_Utils_Misc::returnBytes(ini_get('upload_max_filesize'));
         if ($max_upload) {
             $phpMaxSize = $max_upload;
         }
         $max_post = CKFinder_Connector_Utils_Misc::returnBytes(ini_get('post_max_size'));
         if ($max_post) {
             $phpMaxSize = $phpMaxSize ? min($phpMaxSize, $max_post) : $max_post;
         }
         //ini_get('memory_limit') only works if compiled with "--enable-memory-limit"
         $memory_limit = CKFinder_Connector_Utils_Misc::returnBytes(@ini_get('memory_limit'));
         if ($memory_limit && $memory_limit != -1) {
             $phpMaxSize = $phpMaxSize ? min($phpMaxSize, $memory_limit) : $memory_limit;
         }
         $_oConnInfo->addAttribute("uploadMaxSize", $phpMaxSize);
         $_oConnInfo->addAttribute("uploadCheckImages", $_config->checkSizeAfterScaling() ? "false" : "true");
         for ($i = 0; $i < $_aTypesSize; $i++) {
             $_resourceTypeName = $_aTypes[$i];
             $_acl = $_config->getAccessControlConfig();
             $_aclMask = $_acl->getComputedMask($_resourceTypeName, "/");
             if (($_aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) {
                 continue;
             }
             if (!isset($_GET['type']) || $_GET['type'] === $_resourceTypeName) {
                 //print $_resourceTypeName;
                 $_oTypeInfo = $_config->getResourceTypeConfig($_resourceTypeName);
                 //print_r($_oTypeInfo);
                 $_oResourceType[$i] = new Ckfinder_Connector_Utils_XmlNode("ResourceType");
                 $_oResourceTypes->addChild($_oResourceType[$i]);
                 $_oResourceType[$i]->addAttribute("name", $_resourceTypeName);
                 $_oResourceType[$i]->addAttribute("url", $_oTypeInfo->getUrl());
                 $_oResourceType[$i]->addAttribute("allowedExtensions", implode(",", $_oTypeInfo->getAllowedExtensions()));
                 $_oResourceType[$i]->addAttribute("deniedExtensions", implode(",", $_oTypeInfo->getDeniedExtensions()));
                 $_oResourceType[$i]->addAttribute("hash", substr(md5($_oTypeInfo->getDirectory()), 0, 16));
                 $_oResourceType[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_oTypeInfo->getDirectory()) ? "true" : "false");
                 $_oResourceType[$i]->addAttribute("acl", $_aclMask);
                 $maxSize = $_oTypeInfo->getMaxSize();
                 if ($phpMaxSize) {
                     $maxSize = $maxSize ? min($maxSize, $phpMaxSize) : $phpMaxSize;
                 }
                 $_oResourceType[$i]->addAttribute("maxSize", $maxSize);
             }
         }
     }
     $config = $GLOBALS['config'];
     if (!empty($config['Plugins']) && is_array($config['Plugins'])) {
         $_oConnInfo->addAttribute("plugins", implode(",", $config['Plugins']));
     }
     CKFinder_Connector_Core_Hooks::run('InitCommand', array(&$this->_connectorNode));
 }
开发者ID:kartikads,项目名称:ch,代码行数:96,代码来源:Init.php


示例15: setMemoryForImage

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CKunenaConfig类代码示例发布时间:2022-05-23
下一篇:
PHP CKFinder_Connector_Utils_FileSystem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap