本文整理汇总了PHP中CUtils::return_bytes方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtils::return_bytes方法的具体用法?PHP CUtils::return_bytes怎么用?PHP CUtils::return_bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtils
的用法示例。
在下文中一共展示了CUtils::return_bytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSiteInfo
/**
* 获得站点信息
*/
public static function getSiteInfo()
{
$data = array();
$data['version'] = APP_VERSION;
$data['status'] = "done";
$data['app_name'] = 100;
$data['app_logo'] = MiniHttp::getSystemParam("absoluteUrl") . "/static/images/logo.png";
$data['default_size'] = 100;
$data['can_register'] = true;
$data['register_url'] = "";
//产品名称
$value = MiniOption::getInstance()->getOptionValue('site_name');
if (isset($value)) {
$data['app_name'] = $value;
}
//站点ID
$data['code'] = MiniSiteUtils::getSiteCode();
$data['site_id'] = MiniSiteUtils::getSiteID();
$data['wx_token'] = MiniSiteUtils::getWxToken();
//产品Logo
$value = MiniOption::getInstance()->getOptionValue('site_logo_url');
if (isset($value)) {
$data['app_logo'] = MiniHttp::getSystemParam("absoluteUrl") . $value;
}
//判断系统是否可以注册
$enableReg = MiniOption::getInstance()->getOptionValue("user_register_enabled");
if (isset($enableReg) && $enableReg == "0") {
$data['can_register'] = false;
}
//系统注册入口是否在第3方
$value = MiniOption::getInstance()->getOptionValue("user_create_url");
if (isset($value) && !empty($value)) {
$data['register_url'] = $value;
}
// 32M
$blockSize = 4 * 1024 * 1024;
// 内存配置需要
$memoryLimit = CUtils::return_bytes(ini_get('memory_limit'));
if ($memoryLimit < 4 * $blockSize) {
$blockSize = $memoryLimit / 4;
}
$postMaxSize = CUtils::return_bytes(ini_get('post_max_size'));
$uploadMaxFileSize = CUtils::return_bytes(ini_get('upload_max_filesize'));
$min = $postMaxSize > $uploadMaxFileSize ? $uploadMaxFileSize : $postMaxSize;
$data['block_size'] = $min > $blockSize ? $blockSize : $min;
if ($data['block_size'] == $postMaxSize && $data['block_size'] == $uploadMaxFileSize) {
$data['block_size'] = $data['block_size'] - 104858;
}
// 获取忘记密码使用短信口子地址
$forgetPasswordUrl = MiniHttp::getSystemParam("absoluteUrl");
$data['forget_password_url'] = $forgetPasswordUrl;
return $data;
}
示例2: invoke
/**
* 控制器执行主逻辑函数
* @param $uri 地址
* @return mixed $value 返回最终需要执行完的结果
*/
public function invoke($uri = null)
{
$user = MUserManager::getInstance()->getCurrentUser();
$device = MUserManager::getInstance()->getCurrentDevice();
$data = array();
$data['user_name'] = $user["user_name"];
$data['display_name'] = $user["nick"];
$data['id'] = $user["id"];
$data['uid'] = $user["user_uuid"];
$data['space'] = (double) $user["space"];
$data['used_space'] = (double) $user["usedSpace"];
$data['email'] = $user["email"];
$data['phone'] = $user["phone"];
$data['avatar'] = $user["avatar"];
$data['mult_user'] = false;
$data['site_id'] = MiniSiteUtils::getSiteID();
$data["device_id"] = $device["id"];
$value = MiniOption::getInstance()->getOptionValue('site_company');
if (isset($value)) {
$license['company'] = $value;
} else {
$license['company'] = "";
}
$license['licensestr'] = "";
//免费版本
$license['is_vip'] = false;
// 目前针对iis服务器,使客户端禁用put协议
if (isset($_SERVER['SERVER_SOFTWARE']) && strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'iis') !== false) {
$data['disable_put'] = true;
}
// 32M
$blockSize = 4 * 1024 * 1024;
// 内存配置需要
$mem_limit = CUtils::return_bytes(ini_get('memory_limit'));
if ($mem_limit < 4 * $blockSize) {
$blockSize = $mem_limit / 4;
}
$postMaxSize = CUtils::return_bytes(ini_get('post_max_size'));
$uploadMaxFileSize = CUtils::return_bytes(ini_get('upload_max_filesize'));
$min = $postMaxSize > $uploadMaxFileSize ? $uploadMaxFileSize : $postMaxSize;
$data['block_size'] = $min > $blockSize ? $blockSize : $min;
if ($data['block_size'] == $postMaxSize && $data['block_size'] == $uploadMaxFileSize) {
$data['block_size'] = $data['block_size'] - 104858;
}
echo json_encode($data);
}
示例3: apiInfo
/**
*
* 返回系统配置信息
* @since 1.1.0
* @return array
*/
public static function apiInfo()
{
$response = array();
$response['version'] = APP_VERSION;
$response['status'] = "done";
$response['appname'] = "迷你云";
$response['defaultsize'] = 100;
$response['enableReg'] = 0;
$response['mult_user'] = 0;
$value = MiniOption::getInstance()->getOptionValue('muti_clients');
if (isset($value)) {
$response['mult_user'] = intval($value) == 1 ? true : false;
}
//判断系统是否可以注册
$response['regurl'] = Yii::app()->params['app']['absoluteUrl'] . "/index.php/site/register";
$enableReg = MiniOption::getInstance()->getOptionValue("user_register_enabled");
if (isset($enableReg)) {
$response['enableReg'] = 1;
$retReg = MiniOption::getInstance()->getOptionValue("user_create_url");
if (isset($retReg) && !empty($retReg)) {
$response['regurl'] = $retReg;
}
}
// 32M
$blockSize = 4 * 1024 * 1024;
// 内存配置需要
$mem_limit = CUtils::return_bytes(ini_get('memory_limit'));
if ($mem_limit < 4 * $blockSize) {
$blockSize = $mem_limit / 4;
}
$postMaxSize = CUtils::return_bytes(ini_get('post_max_size'));
$uploadMaxFilesize = CUtils::return_bytes(ini_get('upload_max_filesize'));
$min = $postMaxSize > $uploadMaxFilesize ? $uploadMaxFilesize : $postMaxSize;
$response['block_size'] = $min > $blockSize ? $blockSize : $min;
if ($response['block_size'] == $postMaxSize && $response['block_size'] == $uploadMaxFilesize) {
$response['block_size'] = $response['block_size'] - 104858;
}
// 获取忘记密码使用短信口子地址
$response['forgetPwUrl'] = Yii::app()->params['app']['absoluteUrl'];
return $response;
}
示例4: envCheck
/**
* 检测系统环境
*/
private function envCheck()
{
$this->envItems = array('os' => array('c' => 'PHP_OS', 'r' => 'notset', 'b' => 'unix'), 'php' => array('c' => 'PHP_VERSION', 'r' => '5.3.0', 'b' => '5.3.0'), 'attachmentupload' => array('r' => 'notset', 'b' => '1024M'), 'gdversion' => array('r' => '1.0', 'b' => '2.0'), 'diskspace' => array('r' => 'notset', 'b' => 'notset'));
foreach ($this->envItems as $key => $item) {
// 检测php版本
if ($key == 'php') {
$this->envItems[$key]['current'] = PHP_VERSION;
} elseif ($key == 'attachmentupload') {
$this->envItems[$key]['current'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow';
// 8x1024x1024
if ($this->envItems[$key]['current'] == 'unknow' || CUtils::return_bytes($this->envItems[$key]['current']) < 8388608) {
$prompt = '<div style="color:orange;width:60px;float:left;text-align:right">' . $this->envItems[$key]['current'] . '</div><a target="_blank" href="' . $this->getUrl($key) . '">' . Yii::t("front_common", "install_setup1_get_help") . '</a>';
$this->envItems[$key]['current'] = $prompt;
$this->envItems[$key]['status'] = -1;
continue;
}
} elseif ($key == 'gdversion') {
if (function_exists('gd_info')) {
$this->envItems[$key]['status'] = 1;
} else {
$this->envItems[$key]['status'] = -1;
}
$tmp = function_exists('gd_info') ? gd_info() : array();
$prompt = '<font color="orange">' . Yii::t("front_common", "install_setup1_GD_library_notfound") . '</font> <a target="_blank" href="' . $this->getUrl($key) . '">' . Yii::t("front_common", "install_setup1_get_help") . '</a>';
$prompt2 = '<br><font color="orange">' . Yii::t("front_common", "install_setup1_not_found_freetype") . '</font> <a target="_blank" href="' . $this->getUrl($key) . '">' . Yii::t("front_common", "install_setup1_get_help") . '</a>';
if (!empty($tmp)) {
$free_type = $tmp['FreeType Support'] ? '' : $prompt2;
}
$this->envItems[$key]['current'] = empty($tmp['GD Version']) ? $prompt : $tmp['GD Version'] . $free_type;
unset($tmp);
continue;
} elseif ($key == 'diskspace') {
if (function_exists('disk_free_space')) {
$this->envItems[$key]['current'] = floor(disk_free_space(ROOT_PATH) / (1024 * 1024)) . 'M';
} else {
$this->envItems[$key]['current'] = 'unknow';
}
} elseif (isset($item['c'])) {
$this->envItems[$key]['current'] = constant($item['c']);
}
$this->envItems[$key]['status'] = 1;
if ($item['r'] != 'notset' && strcmp($this->envItems[$key]['current'], $item['r']) < 0) {
$this->envItems[$key]['status'] = 0;
if ($key == 'php') {
$this->addError('msg', Yii::t("front_common", "install_setup1_less_mini_config", array("{key}" => $this->toString($key))) . '<a target="_blank" href="' . $this->getUrl($key) . '">' . Yii::t("front_common", "install_setup1_get_help") . '</a>');
}
}
}
}