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


PHP CKFinder_Connector_Utils_Misc::returnBytes方法代码示例

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


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

示例1: CKFinder_Connector_Core_ResourceTypeConfig

 /**
  * Get ResourceType configuration
  *
  * @param string $resourceTypeNode
  * @return array
  * 
  */
 function CKFinder_Connector_Core_ResourceTypeConfig($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 $extension) {
                 $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));
                 }
             }
         }
     }
     $_view = "";
     if (isset($resourceTypeNode["defaultView"])) {
         $_view = $resourceTypeNode["defaultView"];
     }
     if (!strlen($_view) && isset($GLOBALS['config']['DefaultDisplaySettings']['view'])) {
         $_view = $GLOBALS['config']['DefaultDisplaySettings']['view'];
     }
     if ($_view == "List") {
         $this->_defaultView = "List";
     }
 }
开发者ID:ramavadakattu,项目名称:Groupalumini,代码行数:72,代码来源:ResourceTypeConfig.php

示例2: __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

示例3: setMemoryForImage

 /**
  * @link http://pl.php.net/manual/pl/function.imagecreatefromjpeg.php
  * function posted by e dot a dot schultz at gmail dot com
  *
  * @static
  * @access public
  * @param string $filename
  * @return boolean
  */
 public static function setMemoryForImage($imageWidth, $imageHeight, $imageBits, $imageChannels)
 {
     $MB = 1048576;
     // number of bytes in 1M
     $K64 = 65536;
     // number of bytes in 64K
     $TWEAKFACTOR = 2.4;
     // Or whatever works for you
     $memoryNeeded = round(($imageWidth * $imageHeight * $imageBits * $imageChannels / 8 + $K64) * $TWEAKFACTOR) + 3 * $MB;
     //ini_get('memory_limit') only works if compiled with "--enable-memory-limit" also
     //Default memory limit is 8MB so well stick with that.
     //To find out what yours is, view your php.ini file.
     $memoryLimit = CKFinder_Connector_Utils_Misc::returnBytes(@ini_get('memory_limit')) / $MB;
     // There are no memory limits, nothing to do
     if ($memoryLimit == -1) {
         return true;
     }
     if (!$memoryLimit) {
         $memoryLimit = 8;
     }
     $memoryLimitMB = $memoryLimit * $MB;
     if (function_exists('memory_get_usage')) {
         if (memory_get_usage() + $memoryNeeded > $memoryLimitMB) {
             $newLimit = $memoryLimit + ceil((memory_get_usage() + $memoryNeeded - $memoryLimitMB) / $MB);
             if (@ini_set('memory_limit', $newLimit . 'M') === false) {
                 return false;
             }
         }
     } else {
         if ($memoryNeeded + 3 * $MB > $memoryLimitMB) {
             $newLimit = $memoryLimit + ceil((3 * $MB + $memoryNeeded - $memoryLimitMB) / $MB);
             if (false === @ini_set('memory_limit', $newLimit . 'M')) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:phucanhhoang,项目名称:IT4895,代码行数:47,代码来源:Misc.php

示例4: 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

示例5: getConfig

 /**
  * Get private zip plugin config
  *
  * @access protected
  * @return array
  */
 protected function getConfig()
 {
     $config = array();
     $config['zipMaxSize'] = 'default';
     if (isset($GLOBALS['config']['ZipMaxSize']) && (string) $GLOBALS['config']['ZipMaxSize'] != 'default') {
         $config['zipMaxSize'] = CKFinder_Connector_Utils_Misc::returnBytes((string) $GLOBALS['config']['ZipMaxSize']);
     }
     return $config;
 }
开发者ID:jambik,项目名称:ikkf05,代码行数:15,代码来源:plugin.php


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