本文整理汇总了PHP中get_real_size函数的典型用法代码示例。如果您正苦于以下问题:PHP get_real_size函数的具体用法?PHP get_real_size怎么用?PHP get_real_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_real_size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: raise_memory_limit
/**
* Function to raise the memory limit to a new value.
* Will respect the memory limit if it is higher, thus allowing
* settings in php.ini, apache conf or command line switches
* to override it
*
* The memory limit should be expressed with a string (eg:'64M')
*
* @param string $newlimit the new memory limit
* @return bool
*/
function raise_memory_limit($newlimit)
{
if (empty($newlimit)) {
return false;
}
$cur = @ini_get('memory_limit');
if (empty($cur)) {
// if php is compiled without --enable-memory-limits
// apparently memory_limit is set to ''
$cur = 0;
} else {
if ($cur == -1) {
return true;
// unlimited mem!
}
$cur = get_real_size($cur);
}
$new = get_real_size($newlimit);
if ($new > $cur) {
ini_set('memory_limit', $newlimit);
return true;
}
return false;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:35,代码来源:setuplib.php
示例2: test_get_real_size
/**
* Test the get_real_size() function.
*
* @dataProvider data_for_test_get_real_size
*
* @param string $input the input for get_real_size()
* @param int $expectedbytes the expected bytes
*/
public function test_get_real_size($input, $expectedbytes)
{
$this->assertEquals($expectedbytes, get_real_size($input));
}
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:12,代码来源:setuplib_test.php
示例3: pieform_element_filebrowser
//.........这里部分代码省略.........
$smarty->assign('edit', !empty($element['edit']) ? $element['edit'] : -1);
if (isset($element['browse'])) {
$smarty->assign('browse', (int) $element['browse']);
}
$config = array_map('intval', $element['config']);
if ($group && $config['edit']) {
$smarty->assign('groupinfo', pieform_element_filebrowser_get_groupinfo($group));
}
if ($config['select']) {
if (function_exists($element['selectlistcallback'])) {
if ($form->is_submitted() && $form->has_errors() && isset($_POST[$prefix . '_selected']) && is_array($_POST[$prefix . '_selected'])) {
$value = array_keys($_POST[$prefix . '_selected']);
} else {
if (isset($element['defaultvalue'])) {
$value = $element['defaultvalue'];
} else {
$value = null;
}
}
// check to see if attached artefact items in $value array are actually allowed
// to be seen by this user
if (!empty($value)) {
foreach ($value as $k => $v) {
$file = artefact_instance_from_id($v);
if (!$file instanceof ArtefactTypeFile && !$file instanceof ArtefactTypeFolder || !$USER->can_view_artefact($file)) {
unset($value[$k]);
}
}
}
$selected = $element['selectlistcallback']($value);
}
$smarty->assign('selectedlist', $selected);
$selectedliststr = json_encode($selected);
}
if ($config['uploadagreement']) {
if (get_config_plugin('artefact', 'file', 'usecustomagreement')) {
$smarty->assign('agreementtext', get_field('site_content', 'content', 'name', 'uploadcopyright'));
} else {
$smarty->assign('agreementtext', get_string('uploadcopyrightdefaultcontent', 'install'));
}
} else {
if (!isset($config['simpleupload'])) {
$config['simpleupload'] = 1;
}
}
$licensing = '<div class="fileuploadlicense">' . license_form_files($prefix) . '</div>';
$smarty->assign('licenseform', $licensing);
if ($config['resizeonuploaduseroption'] == 1) {
$smarty->assign('resizeonuploadenable', get_config_plugin('artefact', 'file', 'resizeonuploadenable'));
$smarty->assign('resizeonuploadmaxwidth', get_config_plugin('artefact', 'file', 'resizeonuploadmaxwidth'));
$smarty->assign('resizeonuploadmaxheight', get_config_plugin('artefact', 'file', 'resizeonuploadmaxheight'));
}
if ($config['upload']) {
$maxuploadsize = display_size(get_max_upload_size(!$institution && !$group));
$smarty->assign('maxuploadsize', $maxuploadsize);
$smarty->assign('phpmaxfilesize', get_max_upload_size(false));
if ($group) {
$smarty->assign('uploaddisabled', !pieform_element_filebrowser_edit_group_folder($group, $folder));
}
}
if (!empty($element['browsehelp'])) {
$config['plugintype'] = $form->get_property('plugintype');
$config['pluginname'] = $form->get_property('pluginname');
$config['browsehelp'] = $element['browsehelp'];
}
$config['showtags'] = !empty($config['tag']) ? (int) $userid : 0;
$config['editmeta'] = (int) ($userid && !$config['edit'] && !empty($config['tag']));
$smarty->assign('config', $config);
$filters = isset($element['filters']) ? $element['filters'] : null;
$filedata = ArtefactTypeFileBase::get_my_files_data($folder, $userid, $group, $institution, $filters);
$smarty->assign('filelist', $filedata);
$configstr = json_encode($config);
$fileliststr = json_encode($filedata);
$smarty->assign('prefix', $prefix);
$accepts = isset($element['accept']) ? 'accept="' . Pieform::hsc($element['accept']) . '"' : '';
$smarty->assign('accepts', $accepts);
$initjs = "{$prefix} = new FileBrowser('{$prefix}', {$folder}, {$configstr}, config);\n{$prefix}.filedata = {$fileliststr};";
if ($config['select']) {
$initjs .= "{$prefix}.selecteddata = {$selectedliststr};";
}
if (isset($tabdata)) {
$initjs .= "{$prefix}.tabdata = " . json_encode($tabdata) . ';';
}
$_PIEFORM_FILEBROWSERS[$prefix]['views_js'] = $initjs;
$initjs .= "addLoadEvent({$prefix}.init);";
$initjs .= "upload_max_filesize = '" . get_real_size(ini_get('upload_max_filesize')) . "';";
$smarty->assign('initjs', $initjs);
$smarty->assign('querybase', $element['page'] . (strpos($element['page'], '?') === false ? '?' : '&'));
$params = 'folder=' . $folder;
if ($group) {
$params .= '&group=' . $group;
}
if ($institution) {
$params .= '&institution=' . $institution;
}
$switchwidth = ArtefactTypeFileBase::get_switch_width();
$smarty->assign('switchwidth', $switchwidth);
$smarty->assign('folderparams', $params);
return $smarty->fetch('artefact:file:form/filebrowser.tpl');
}
开发者ID:rboyatt,项目名称:mahara,代码行数:101,代码来源:filebrowser.php
示例4: require_once
$CFG->filepermissions = ($CFG->directorypermissions & 0666);
$CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
$CFG->running_installer = true;
$CFG->early_install_lang = true;
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = true;
$CFG->debugdeveloper = true;
// Require all needed libs
require_once($CFG->libdir.'/setuplib.php');
// we need to make sure we have enough memory to load all libraries
$memlimit = @ini_get('memory_limit');
if (!empty($memlimit) and $memlimit != -1) {
if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
// do NOT localise - lang strings would not work here and we CAN not move it to later place
echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
echo "Please contact server administrator to fix PHP.ini memory settings.";
die;
}
}
// Continue with lib loading
require_once($CFG->libdir.'/classes/text.php');
require_once($CFG->libdir.'/classes/string_manager.php');
require_once($CFG->libdir.'/classes/string_manager_install.php');
require_once($CFG->libdir.'/classes/string_manager_standard.php');
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->libdir.'/outputlib.php');
require_once($CFG->libdir.'/dmllib.php');
开发者ID:rwijaya,项目名称:moodle,代码行数:31,代码来源:install.php
示例5: get_directory_size
/**
* Adds up all the files in a directory and works out the size.
*
* @param string $rootdir The directory to start from
* @param string $excludefile A file to exclude when summing directory size
* @return int The summed size of all files and subfiles within the root directory
*/
function get_directory_size($rootdir, $excludefile = '')
{
global $CFG;
// Do it this way if we can, it's much faster.
if (!empty($CFG->pathtodu) && is_executable(trim($CFG->pathtodu))) {
$command = trim($CFG->pathtodu) . ' -sk ' . escapeshellarg($rootdir);
$output = null;
$return = null;
exec($command, $output, $return);
if (is_array($output)) {
// We told it to return k.
return get_real_size(intval($output[0]) . 'k');
}
}
if (!is_dir($rootdir)) {
// Must be a directory.
return 0;
}
if (!($dir = @opendir($rootdir))) {
// Can't open it for some reason.
return 0;
}
$size = 0;
while (false !== ($file = readdir($dir))) {
$firstchar = substr($file, 0, 1);
if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
continue;
}
$fullfile = $rootdir . '/' . $file;
if (filetype($fullfile) == 'dir') {
$size += get_directory_size($fullfile, $excludefile);
} else {
$size += filesize($fullfile);
}
}
closedir($dir);
return $size;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:45,代码来源:moodlelib.php
示例6: exists
function exists()
{
$oldmemlimit = @ini_get('memory_limit');
if (empty($oldmemlimit)) {
// PHP not compiled with memory limits, this means that it's
// probably limited to 8M or in case of Windows not at all.
// We can ignore it for now - there is not much to test anyway
// TODO: add manual test that fills memory??
return false;
}
$oldmemlimit = get_real_size($oldmemlimit);
//now lets change the memory limit to something unique below 128M==134217728
if (empty($CFG->extramemorylimit)) {
raise_memory_limit('128M');
} else {
raise_memory_limit($CFG->extramemorylimit);
}
$testmemlimit = get_real_size(@ini_get('memory_limit'));
//verify the change had any effect at all
if ($oldmemlimit == $testmemlimit) {
//memory limit can not be changed - is it big enough then?
if ($oldmemlimit < get_real_size('128M')) {
return true;
} else {
return false;
}
}
reduce_memory_limit($oldmemlimit);
return false;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:30,代码来源:health.php
示例7: pathinfo
</td>
<td class="extra">
<span class="label label-important">
<?php
$pathinfo = pathinfo($file['url']);
$extension = strtolower($pathinfo['extension']);
echo $extension;
?>
</span>
</td>
<td class="description"><?php
echo htmlentities($file['description']);
?>
</td>
<td><?php
$this_file_size = get_real_size(UPLOADED_FILES_FOLDER . $file['url']);
echo format_file_size($this_file_size);
?>
</td>
<td data-value="<?php
echo strtotime($file['timestamp']);
?>
">
<?php
echo $date;
?>
</td>
<?php
if ($file['expired'] == true) {
?>
<td class="extra"></td>
开发者ID:BastienDurel,项目名称:ProjectSend,代码行数:31,代码来源:template.php
示例8: get_max_upload_size
/**
* Determines maximum upload size based on quota and PHP settings.
*
* @param bool $is_user whether upload size should be evaluated for user (quota is considered)
* @return integer
*/
function get_max_upload_size($is_user)
{
global $USER;
if (!($postmaxsize = get_real_size(ini_get('post_max_size')))) {
$maxuploadsize = get_real_size(ini_get('upload_max_filesize'));
} else {
$maxuploadsize = max(1024, min($postmaxsize - 4096, get_real_size(ini_get('upload_max_filesize'))));
}
if ($is_user) {
$userquotaremaining = $USER->get('quota') - $USER->get('quotaused');
$maxuploadsize = min($maxuploadsize, $userquotaremaining);
}
return $maxuploadsize;
}
开发者ID:kienv,项目名称:mahara,代码行数:20,代码来源:mahara.php
示例9: raise_memory_limit
/**
* Function to raise the memory limit to a new value.
* Will respect the memory limit if it is higher, thus allowing
* settings in php.ini, apache conf or command line switches
* to override it.
*
* The memory limit should be expressed with a constant
* MEMORY_STANDARD, MEMORY_EXTRA or MEMORY_HUGE.
* It is possible to use strings or integers too (eg:'128M').
*
* @param mixed $newlimit the new memory limit
* @return bool success
*/
function raise_memory_limit($newlimit)
{
global $CFG;
if ($newlimit == MEMORY_UNLIMITED) {
ini_set('memory_limit', -1);
return true;
} else {
if ($newlimit == MEMORY_STANDARD) {
if (PHP_INT_SIZE > 4) {
$newlimit = get_real_size('128M');
// 64bit needs more memory
} else {
$newlimit = get_real_size('96M');
}
} else {
if ($newlimit == MEMORY_EXTRA) {
if (PHP_INT_SIZE > 4) {
$newlimit = get_real_size('384M');
// 64bit needs more memory
} else {
$newlimit = get_real_size('256M');
}
if (!empty($CFG->extramemorylimit)) {
$extra = get_real_size($CFG->extramemorylimit);
if ($extra > $newlimit) {
$newlimit = $extra;
}
}
} else {
if ($newlimit == MEMORY_HUGE) {
$newlimit = get_real_size('2G');
} else {
$newlimit = get_real_size($newlimit);
}
}
}
}
if ($newlimit <= 0) {
debugging('Invalid memory limit specified.');
return false;
}
$cur = ini_get('memory_limit');
if (empty($cur)) {
// if php is compiled without --enable-memory-limits
// apparently memory_limit is set to ''
$cur = 0;
} else {
if ($cur == -1) {
return true;
// unlimited mem!
}
$cur = get_real_size($cur);
}
if ($newlimit > $cur) {
ini_set('memory_limit', $newlimit);
return true;
}
return false;
}
开发者ID:ftecpos,项目名称:ia2,代码行数:72,代码来源:lib.php
示例10: download_file
function download_file()
{
$this->check_level = array(9, 8, 7, 0);
if (isset($_GET['id']) && isset($_GET['client'])) {
/** Do a permissions check for logged in user */
if (isset($this->check_level) && in_session_or_cookies($this->check_level)) {
/**
* Get the file name
*/
$this->statement = $this->dbh->prepare("SELECT url, expires, expiry_date FROM " . TABLE_FILES . " WHERE id=:id");
$this->statement->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
$this->statement->execute();
$this->statement->setFetchMode(PDO::FETCH_ASSOC);
$this->row = $this->statement->fetch();
$this->real_file_url = $this->row['url'];
$this->expires = $this->row['expires'];
$this->expiry_date = $this->row['expiry_date'];
$this->expired = false;
if ($this->expires == '1' && time() > strtotime($this->expiry_date)) {
$this->expired = true;
}
$this->can_download = false;
if (CURRENT_USER_LEVEL == 0) {
if ($this->expires == '0' || $this->expired == false) {
/**
* Does the client have permission to download the file?
* First, get the list of different groups the client belongs to.
*/
$this->groups = $this->dbh->prepare("SELECT DISTINCT group_id FROM " . TABLE_MEMBERS . " WHERE client_id=:id");
$this->groups->bindValue(':id', CURRENT_USER_ID, PDO::PARAM_INT);
$this->groups->execute();
if ($this->groups->rowCount() > 0) {
$this->groups->setFetchMode(PDO::FETCH_ASSOC);
while ($this->row_groups = $this->groups->fetch()) {
$this->groups_ids[] = $this->row_groups["group_id"];
}
if (!empty($this->groups_ids)) {
$this->found_groups = implode(',', $this->groups_ids);
}
}
$this->params = array(':client_id' => CURRENT_USER_ID);
$this->fq = "SELECT * FROM " . TABLE_FILES_RELATIONS . " WHERE (client_id=:client_id";
// Add found groups, if any
if (!empty($this->found_groups)) {
$this->fq .= ' OR FIND_IN_SET(group_id, :groups)';
$this->params[':groups'] = $this->found_groups;
}
// Continue assembling the query
$this->fq .= ') AND file_id=:file_id AND hidden = "0"';
$this->params[':file_id'] = (int) $_GET['id'];
$this->files = $this->dbh->prepare($this->fq);
$this->files->execute($this->params);
if ($this->files->rowCount() > 0) {
$this->can_download = true;
}
/** Continue */
if ($this->can_download == true) {
/**
* If the file is being downloaded by a client, add +1 to
* the download count
*/
$this->statement = $this->dbh->prepare("INSERT INTO " . TABLE_DOWNLOADS . " (user_id , file_id) VALUES (:user_id, :file_id)");
$this->statement->bindValue(':user_id', CURRENT_USER_ID, PDO::PARAM_INT);
$this->statement->bindParam(':file_id', $_GET['id'], PDO::PARAM_INT);
$this->statement->execute();
/**
* The owner ID is generated here to prevent false results
* from a modified GET url.
*/
$log_action = 8;
$log_action_owner_id = CURRENT_USER_ID;
}
}
} else {
$this->can_download = true;
$log_action = 7;
$global_user = get_current_user_username();
$global_id = get_logged_account_id($global_user);
$log_action_owner_id = $global_id;
}
if ($this->can_download == true) {
/** Record the action log */
$new_log_action = new LogActions();
$log_action_args = array('action' => $log_action, 'owner_id' => $log_action_owner_id, 'affected_file' => (int) $_GET['id'], 'affected_file_name' => $this->real_file_url, 'affected_account' => (int) $_GET['client_id'], 'affected_account_name' => $_GET['client'], 'get_user_real_name' => true, 'get_file_real_name' => true);
$new_record_action = $new_log_action->log_action_save($log_action_args);
$this->real_file = UPLOADED_FILES_FOLDER . $this->real_file_url;
if (file_exists($this->real_file)) {
while (ob_get_level()) {
ob_end_clean();
}
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($this->real_file));
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Cache-Control: private', false);
header('Content-Length: ' . get_real_size($this->real_file));
header('Connection: close');
readfile($this->real_file);
exit;
//.........这里部分代码省略.........
开发者ID:baldzern4,项目名称:ProjectSend,代码行数:101,代码来源:process.php
示例11: get_real_size
$other_free_size = $other_free_size + $table['Data_free'];
$table['Create_time'] = $table['Create_time'] ? $table['Create_time'] : 'Unknow';
$table['Update_time'] = $table['Update_time'] ? $table['Update_time'] : 'Unknow';
$table['Data_length'] = get_real_size($table['Data_length']);
$table['Index_length'] = get_real_size($table['Index_length']);
$table['Data_free'] = get_real_size($table['Data_free']);
$other_table_num++;
$other_table[] = $table;
}
}
$sablog_data_size = get_real_size($sablog_data_size);
$sablog_index_size = get_real_size($sablog_index_size);
$sablog_free_size = get_real_size($sablog_free_size);
$other_data_size = get_real_size($other_data_size);
$other_index_size = get_real_size($other_index_size);
$other_free_size = get_real_size($other_free_size);
unset($table);
$subnav = '数据库信息';
}
if ($action == 'checkresume' && $dbimport) {
$subnav = '恢复数据';
$sqlfile = htmlspecialchars($sqlfile);
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\\s*(\\w+).*/s", "\\1", loadfile($backupdir . '/' . $sqlfile, 200))));
if (count($identify) != 3) {
$location = getlink('tools', 'filelist', array('message' => 23));
} elseif ($identify[2] != 1) {
$location = getlink('tools', 'filelist', array('message' => 24));
} elseif ($identify[1] != $SABLOG_VERSION) {
$location = getlink('tools', 'filelist', array('message' => 25));
}
if ($location) {
开发者ID:BGCX261,项目名称:zjnewcitycode-svn-to-git,代码行数:31,代码来源:tools.php
示例12: format_size
/**
* change target int to specified unit
* @param string $_size : eg) 1GB, 2G, 1024KB ....
* @param string $_unit : eg) gb, g, mb, m, kb, k, b
* @param boolean $_num : true = value + *iB / false = only value
* @param boolean $_int : true = round / false = not round
* @param boolean $_comma : true = comma separated value / false = only value
* @return int|float|string
*/
function format_size($_size, $_unit = "", $_num = false, $_int = false, $_comma = false)
{
if (!$_size) {
return 0;
}
$str = array();
$str['gb'] = 'GiB';
$str['g'] = 'GiB';
$str['mb'] = 'MiB';
$str['m'] = 'MiB';
$str['kb'] = 'KiB';
$str['k'] = 'KiB';
$str['b'] = 'Byte';
$scan = array();
$scan['gb'] = 1073741824;
// 1024 * 1024 * 1024
$scan['g'] = 1073741824;
// 1024 * 1024 * 1024
$scan['mb'] = 1048576;
// 1024 * 1024
$scan['m'] = 1048576;
// 1024 * 1024
$scan['kb'] = 1024;
$scan['k'] = 1024;
$scan['b'] = 1;
// if conversion not supported, return original
$unit = strtolower($_unit);
if (!gv($unit, $scan)) {
return $_size;
}
$b_size = get_real_size($_size);
// change to byte unit
$size = $b_size / gv($unit, $scan);
// calculate unit
// round
if ($_int) {
$size = round($size);
}
// separate by comma
if ($_comma) {
$size = number_format($size);
}
return $size . ($_num ? ' ' . gv($unit, $str) : '');
}
开发者ID:jonathan1212,项目名称:zf2,代码行数:53,代码来源:function.php
示例13: get_max_upload_file_size
/**
* Returns the maximum size for uploading files.
*
* There are five possible upload limits:
* 1. in Apache using LimitRequestBody (no way of checking or changing this)
* 2. in php.ini for 'upload_max_filesize' (can not be changed inside PHP)
* 3. in .htaccess for 'upload_max_filesize' (can not be changed inside PHP)
* 4. in php.ini for 'post_max_size' (can not be changed inside PHP)
* 5. by the limitations on the current situation (eg file quota)
*
* The last one is passed to this function as an argument (in bytes).
* Anything defined as 0 is ignored.
* The smallest of all the non-zero numbers is returned.
*
* @param int $maxbytes Current maxbytes (in bytes)
* @return int The maximum size for uploading files.
* @todo Finish documenting this function
*/
function get_max_upload_file_size($maxbytes = 0)
{
if (!($filesize = ini_get('upload_max_filesize'))) {
$filesize = '5M';
}
$minimumsize = get_real_size($filesize);
if ($postsize = ini_get('post_max_size')) {
$postsize = get_real_size($postsize);
if ($postsize < $minimumsize) {
$minimumsize = $postsize;
}
}
if ($maxbytes and $maxbytes < $minimumsize) {
$minimumsize = $maxbytes;
}
return $minimumsize;
}
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:35,代码来源:elgglib.php
示例14: getphpcfg
} else {
$fileupload = '<font color="red">禁止</font>';
}
$globals = getphpcfg('register_globals');
$safemode = getphpcfg('safe_mode');
$gd_version = gd_version();
$gd_version = $gd_version ? '版本:' . $gd_version : '不支持';
//查询数据信息
$hiddenarttotal = $DB->result($DB->query("SELECT COUNT(articleid) FROM {$db_prefix}articles WHERE visible='0'"), 0);
$hiddencomtotal = $DB->result($DB->query("SELECT COUNT(commentid) FROM {$db_prefix}comments WHERE visible='0'"), 0);
$tagtotal = $DB->result($DB->query("SELECT COUNT(mid) FROM {$db_prefix}metas WHERE type='tag'"), 0);
$linktotal = $DB->result($DB->query("SELECT COUNT(linkid) FROM {$db_prefix}links"), 0);
$server['datetime'] = sadate('Y-m-d H:i:s');
$server['software'] = $_SERVER['SERVER_SOFTWARE'];
if (function_exists('memory_get_usage')) {
$server['memory_info'] = get_real_size(memory_get_usage());
}
$mysql_version = mysql_get_server_info();
$mysql_runtime = '';
$query = $DB->query("SHOW STATUS");
while ($r = $DB->fetch_array($query)) {
if (eregi("^uptime", $r['Variable_name'])) {
$mysql_runtime = $r['Value'];
}
}
$mysql_runtime = format_timespan($mysql_runtime);
require_once SABLOG_ROOT . 'include/func/attachment.func.php';
$attachdir = SABLOG_ROOT . $options['attachments_dir'];
$attachsize = dirsize($attachdir);
$dircount = dircount($attachdir);
$realattachsize = is_numeric($attachsize) ? sizecount($attachsize) : '不详';
开发者ID:BGCX261,项目名称:zjnewcitycode-svn-to-git,代码行数:31,代码来源:main.php
示例15: definition
function definition()
{
global $CFG, $COURSE, $EXERCISE_TYPE, $EXERCISE_ASSESSMENT_COMPS;
$mform =& $this->_form;
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('title', 'exercise'), array('size' => '64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEAN);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('static', 'description', get_string('description', 'exercise'), get_string('descriptionofexercise', 'exercise', $COURSE->students));
$filesize = array();
$sizelist = array('10Kb', '50Kb', '100Kb', '500Kb', '1Mb', '2Mb', '5Mb', '10Mb', '20Mb', '50Mb');
$maxsize = get_max_upload_file_size();
foreach ($sizelist as $size) {
$sizebytes = get_real_size($size);
if ($sizebytes < $maxsize) {
$filesize[$sizebytes] = $size;
}
}
$filesize[$maxsize] = display_size($maxsize);
ksort($filesize, SORT_NUMERIC);
$mform->addElement('select', 'maxbytes', get_string('maximumsize', 'exercise'), $filesize);
$mform->setHelpButton('maxbytes', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
$mform->setDefault('maxbytes', get_real_size('500K'));
$mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'exercise'));
$numbers = array();
$numbers[22] = 'All';
$numbers[21] = 50;
for ($i = 20; $i >= 0; $i--) {
$numbers[$i] = $i;
}
//-------------------------------------------------------------------------------
$mform->addElement('header', 'leaguetablehdr', get_string('leaguetable', 'exercise'));
$mform->addElement('select', 'showleaguetable', get_string('numberofentriesinleaguetable', 'exercise'), $numbers);
$mform->setHelpButton('showleaguetable', array('leaguetable', get_string('numberofentriesinleaguetable', 'exercise'), 'exercise'));
$mform->addElement('selectyesno', 'anonymous', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), $numbers);
$mform->setHelpButton('anonymous', array('leaguetablenames', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), 'exercise'));
//-------------------------------------------------------------------------------
$mform->addElement('header', 'gradeshdr', get_string('grades'));
$grades = array();
for ($i = 100; $i >= 0; $i--) {
$grades[$i] = $i;
}
$mform->addElement('select', 'gradinggrade', get_string('gradeforstudentsassessment', 'exercise', $COURSE->student), $grades);
$mform->setHelpButton('gradinggrade', array('gradinggrade', get_string('gradinggrade', 'exercise'), 'exercise'));
$mform->setDefault('gradinggrade', 100);
$mform->addElement('select', 'grade', get_string('gradeforsubmission', 'exercise'), $grades);
$mform->setHelpButton('grade', array('grade', get_string('gradeforsubmission', 'exercise'), 'exercise'));
$mform->setDefault('grade', 100);
$mform->addElement('select', 'gradingstrategy', get_string('gradingstrategy', 'exercise'), $EXERCISE_TYPE);
$mform->setHelpButton('gradingstrategy', array('gradingstrategy', get_string('gradingstrategy', 'exercise'), 'exercise'));
$mform->setDefault('gradingstrategy', 1);
$options = array(get_string('usemean', 'exercise'), get_string('usemaximum', 'exercise'));
$mform->addElement('select', 'usemaximum', get_string('handlingofmultiplesubmissions', 'exercise'), $options);
$mform->setHelpButton('usemaximum', array('usemax', get_string('handlingofmultiplesubmissions', 'exercise'), 'exercise'));
$mform->setDefault('usemaximum', 0);
$options = array();
for ($i = 20; $i >= 0; $i--) {
$options[$i] = $i;
}
$mform->addElement('select', 'nelements', get_string('numberofassessmentelements', 'exercise'), $options);
$mform->setHelpButton('nelements', array('nelements', get_string('numberofassessmentelements', 'exercise'), 'exercise'));
$mform->setDefault('nelements', 1);
$COMPARISONS = array();
foreach ($EXERCISE_ASSESSMENT_COMPS as $KEY => $COMPARISON) {
$COMPARISONS[] = $COMPARISON['name'];
}
$mform->addElement('select', 'assessmentcomps', get_string('comparisonofassessments', 'exercise'), $options);
$mform->setHelpButton('assessmentcomps', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
$mform->setDefault('assessmentcomps', 2);
//-------------------------------------------------------------------------------
$mform->addElement('header', 'passwordhdr', get_string('password'));
$mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'exercise'));
$mform->setHelpButton('usepassword', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
$mform->setDefault('usepassword', 0);
$mform->addElement('text', 'password', get_string('password'));
$mform->setHelpButton('password', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
$mform->setType('password', PARAM_RAW);
//-------------------------------------------------------------------------------
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:88,代码来源:mod_form.php
示例16: html_output
" target="_blank">
<?php
echo html_output($row['filename']);
?>
</a>
<?php
} else {
echo html_output($row['filename']);
}
?>
</td>
<td data-value="<?php
echo get_real_size($this_file_absolute);
?>
"><?php
$this_file_size = get_real_size($this_file_absolute);
echo html_output(format_file_size($this_file_size));
?>
</td>
<?php
if ($current_level != '0') {
?>
<td><?php
echo html_output($row['uploader']);
?>
</td>
<td>
<?php
if ($row['public_allow'] == '1') {
?>
<a href="javascript:void(0);" class="btn-primary btn btn-small public_link" data-id="<?php
开发者ID:baldzern4,项目名称:ProjectSend,代码行数:31,代码来源:manage-files.php
示例17: pieform_element_filebrowser
/**
* Browser for files area.
*
* @param Pieform $form The form to render the element for
* @param array $element The element to render
* @return string The HTML for the element
*/
function pieform_element_filebrowser(Pieform $form, $element)
{
global $USER, $_PIEFORM_FILEBROWSERS;
$smarty = smarty_core();
$group = $form->get_property('group');
$institution = $form->get_property('institution');
if (!empty($element['tabs'])) {
$tabdata = pieform_element_filebrowser_configure_tabs($element['tabs']);
$smarty->assign('tabs', $tabdata);
if (!$group && $tabdata['owner'] == 'group') {
$group = $tabdata['ownerid'];
} else {
if (!$institution) {
if ($tabdata['owner'] == 'institution') {
$institution = $tabdata['ownerid'];
} else {
if ($tabdata['owner'] == 'site') {
$institution = 'mahara';
}
}
}
}
}
$userid = $group || $institution ? null : $USER->get('id');
// refresh quotas
if ($userid) {
$USER->quota_refresh();
}
$folder = $element['folder'];
$path = pieform_element_filebrowser_get_path($folder);
$smarty->assign('folder', $folder);
$smarty->assign('foldername', $path[0]->title);
$smarty->assign('path', array_reverse($path));
$smarty->assign('highlight', $element['highlight'][0]);
$smarty->assign('edit', !empty($element['edit']) ? $element['edit'] : -1);
if (isset($element['browse'])) {
$smarty->assign('browse', (int) $element['browse']);
}
$config = array_map('intval', $element['config']);
if ($group && $config['edit']) {
$smarty->assign('groupinfo', pieform_element_filebrowser_get_groupinfo($group));
}
$formid = $form->get_name();
$prefix = $formid . '_' . $element['name'];
if ($config['select']) {
if (function_exists($element['selectlistcallback'])) {
if ($form->is_submitted() && $form->has_errors() && isset($_POST[$prefix . '_selected']) && is_array($_POST[$prefix . '_selected'])) {
$value = array_keys($_POST[$prefix . '_selected']);
} else {
if (isset($element['defaultvalue'])) {
$value = $element['defaultvalue'];
} else {
$value = null;
}
}
$selected = $element['selectlistcallback']($value);
}
$smarty->assign('selectedlist', $selected);
$selectedliststr = json_encode($selected);
}
if ($config['uploadagreement']) {
if (get_config_plugin('artefact', 'file', 'usecustomagreement')) {
$smarty->assign('agreementtext', get_field('site_content', 'content', 'name', 'uploadcopyright'));
} else {
$smarty->assign('agreementtext', get_string('uploadcopyrightdefaultcontent', 'install'));
}
}
if ($config['upload']) {
$maxuploadsize = min(get_real_size(ini_get('post_max_size')), get_real_size(ini_get('upload_max_filesize')));
if (!$institution && !$group) {
$userquotaremaining = $USER->get('quota') - $USER->get('quotaused');
$maxuploadsize = min($maxuploadsize, $userquotaremaining);
}
$maxuploadsize = display_size($maxuploadsize);
$smarty->assign('maxuploadsize', $maxuploadsize);
}
if (!empty($element['browsehelp'])) {
$config['plugintype'] = $form->get_property('plugintype');
$config['pluginname'] = $form->get_property('pluginname');
$config['browsehelp'] = $element['browsehelp'];
}
$config['showtags'] = !empty($config['tag']) ? (int) $userid : 0;
$config['editmeta'] = (int) ($userid && !$config['edit'] && !empty($config['tag']));
$smarty->assign('config', $config);
$filters = isset($element['filters']) ? $element['filters'] : null;
$filedata = ArtefactTypeFileBase::get_my_files_data($folder, $userid, $group, $institution, $filters);
$smarty->assign('filelist', $filedata);
$configstr = json_encode($config);
$fileliststr = json_encode($filedata);
$smarty->assign('prefix', $prefix);
$initjs = "{$prefix} = new FileBrowser('{$prefix}', {$folder}, {$configstr}, config);\n{$prefix}.filedata = {$fileliststr};";
if ($config['select']) {
$initjs .= "{$prefix}.selecteddata = {$selectedliststr};";
//.........这里部分代码省略.........
开发者ID:gbleydon,项目名称:mahara-survey,代码行数:101,代码来源:surveybrowser.php
示例18: moodle_request_shutdown
/**
* This function expects to called during shutdown
* should be set via register_shutdown_function()
* in lib/setup.php .
*
* @return void
*/
function moodle_request_shutdown()
{
global $CFG;
// help apache server if possible
$apachereleasemem = false;
if (function_exists('apache_child_terminate') && function_exists('memory_get_usage') && ini_get_bool('child_terminate')) {
$limit = empty($CFG->apachemaxmem) ? 64 * 1024 * 1024 : $CFG->apachemaxmem;
//64MB default
if (memory_get_usage() > get_real_size($limit)) {
$apachereleasemem = $limit;
@apache_child_terminate();
}
}
// deal with perf logging
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if ($apachereleasemem) {
error_log('Mem usage over ' . $apachereleasemem . ': marking Apache child for reaping.');
}
if (defined('MDL_
|
请发表评论