本文整理汇总了PHP中eHelper::parseMemorySize方法的典型用法代码示例。如果您正苦于以下问题:PHP eHelper::parseMemorySize方法的具体用法?PHP eHelper::parseMemorySize怎么用?PHP eHelper::parseMemorySize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eHelper
的用法示例。
在下文中一共展示了eHelper::parseMemorySize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderForm
function renderForm()
{
/*
$template = "
<div class='form-group'>
<label for='firstname' class='col-sm-3 control-label'>First Name:**</label>
<div class='col-sm-9'>
<input id='firstname' class=\"form-control tbox\" type=\"text\" name=\"FIRSTNAME\" size=\"20\" maxlength=\"20\" value=\"". $_POST['FIRSTNAME']. "\" required />
</div>
</div> ";
*/
$ns = e107::getRender();
$tp = e107::getParser();
$text = "<div style='text-align:center'>\n\t\t\t<form enctype='multipart/form-data' method='post' onsubmit='return frmVerify()' action='" . e_SELF . "'>\n\t\t\t<table style='" . USER_WIDTH . "' class='table fborder'>\n\t\t\t<colgroup>\n\t\t\t<col style='width:30%' />\n\t\t\t<col style='width:70%' />\n\t\t\t</colgroup>\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . DOWLAN_11 . ":</td>\n\t\t\t<td class='forumheader3'>";
require_once e_CORE . "shortcodes/batch/download_shortcodes.php";
$dlparm = isset($download_category) ? $download_category : "";
$text .= $tp->parseTemplate("{DOWNLOAD_CATEGORY_SELECT={$dlparm}}", true, $download_shortcodes);
//FIXME - move to e_upload.php
$text .= "</td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td style='text-align:center' class='forumheader3'>" . LAN_419 . "</td>\n\t\t\t<td class='forumheader3'>";
// $text .= "<b>".LAN_406."</b><br />".LAN_419.":";
$a_filetypes = get_filetypes();
if (count($a_filetypes) == 0) {
$ns->tablerender(LAN_417, LAN_UL_025);
return;
}
$max_upload_size = calc_max_upload_size(-1);
// Find overriding maximum upload size
$max_upload_size = set_max_size($a_filetypes, $max_upload_size);
if (ADMIN) {
$upper_limit = calc_max_upload_size();
$allowed_filetypes = "<table class='table table-striped table-bordered'><tr><th class='text-center'>" . LAN_UL_023 . " </th><th style='text-align:right'>" . LAN_UL_024 . "</th></tr>";
foreach ($a_filetypes as $type => $size) {
$allowed_filetypes .= "<tr><td>{$type}</td><td style='text-align:right'>" . eHelper::parseMemorySize($size, 0) . "</td></tr>";
}
$allowed_filetypes .= "</table>";
} else {
$a_filetypes = array_keys($a_filetypes);
$allowed_filetypes = implode(' | ', $a_filetypes);
}
$text .= " " . $allowed_filetypes;
$text .= "<div class='alert alert-block alert-danger'>" . LAN_407 . "<br />" . LAN_418 . eHelper::parseMemorySize($max_upload_size, 0) . " (" . LAN_UL_022 . ")<br />";
$text .= "<span style='text-decoration:underline'>" . LAN_408 . "</span> " . LAN_420;
$text .= "</div>";
$text .= "</td></tr>";
//TODO Replcae all form inputs with $frm methods.
if (!USER) {
$text .= "<tr>\n\t\t\t<td class='forumheader3'>" . LAN_61 . "</td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_poster' type='text' size='50' maxlength='100' value='{$poster}' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'><span style='text-decoration:underline'>" . LAN_112 . "</span></td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_email' id='user_email' type='text' size='50' maxlength='100' value='" . $postemail . "' required /></td>\n\t\t\t</tr>";
}
$text .= "\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'><span style='text-decoration:underline'>" . LAN_409 . "</span></td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_name' id='file_name' type='text' size='50' maxlength='100' required /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . LAN_410 . "</td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_version' type='text' size='10' maxlength='10' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'><span style='text-decoration:underline'>" . LAN_411 . "</span></td>\n\t\t\t<td class='forumheader3'><input class='tbox' style='width:90%' id='file_realpath' name='file_userfile[]' type='file' size='47' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . LAN_412 . "</td>\n\t\t\t<td class='forumheader3'><input class='tbox' style='width:90%' name='file_userfile[]' type='file' size='47' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'><span style='text-decoration:underline'>" . LAN_413 . "</span></td>\n\t\t\t<td class='forumheader3'><textarea class='tbox form-control' style='width:90%' name='file_description' id='file_description' cols='59' rows='6' required></textarea></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . LAN_144 . "</td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_website' type='text' size='50' maxlength='100' value='" . (defined(USERURL) ? USERURL : "") . "' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . LAN_414 . "<br /><span class='smalltext'>" . LAN_415 . "</span></td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_demo' type='text' size='50' maxlength='100' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td style='text-align:center' colspan='2' class='forumheader'><input class='btn btn-primary button' type='submit' name='upload' value='" . LAN_416 . "' /></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</form>\n\t\t\t</div>";
$ns->tablerender(LAN_417, $text);
}
示例2: init
function init()
{
$sql = e107::getDb();
$tp = e107::getParser();
$ns = e107::getRender();
$frm = e107::getForm();
require_once e_PLUGIN . 'forum/forum_class.php';
$gen = e107::getDate();
$forum = new e107forum();
$total_posts = $sql->count('forum_post');
$total_topics = $sql->count('forum_thread');
$total_replies = $total_posts - $total_topics;
$total_views = 0;
$query = 'SELECT sum(thread_views) AS total FROM `#forum_thread` ';
if ($sql->gen($query)) {
$row = $sql->fetch();
$total_views = $row['total'];
}
$firstpost = $sql->select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default');
$fp = $sql->fetch();
$open_ds = $fp['post_datestamp'];
$open_date = $gen->convert_date($open_ds, 'long');
$open_since = $gen->computeLapse($open_ds);
$open_days = floor((time() - $open_ds) / 86400);
$postsperday = $open_days < 1 ? $total_posts : round($total_posts / $open_days);
global $mySQLdefaultdb;
$query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`";
$sql->gen($query);
$array = $sql->db_getList();
foreach ($array as $table) {
if ($table['Name'] == MPREFIX . 'forum_post') {
$db_size = eHelper::parseMemorySize($table['Data_length']);
$avg_row_len = eHelper::parseMemorySize($table['Avg_row_length']);
break;
}
}
$query = "\n\t\tSELECT ft.thread_id, ft.thread_user, ft.thread_name, ft.thread_total_replies, ft.thread_datestamp, f.forum_sef, f.forum_class, u.user_name, u.user_id FROM #forum_thread as ft\n\t\tLEFT JOIN #user AS u ON ft.thread_user = u.user_id\n\t\tLEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id\n\t\tWHERE ft.thread_active > 0\n\t\tAND f.forum_class IN (" . USERCLASS_LIST . ")\n\t\tORDER BY ft.thread_total_replies DESC LIMIT 0,10";
$sql->gen($query);
$most_activeArray = $sql->db_getList();
$query = "\n\t\tSELECT ft.*, f.forum_class, f.forum_sef, u.user_name, u.user_id FROM #forum_thread as ft\n\t\tLEFT JOIN #user AS u ON ft.thread_user = u.user_id\n\t\tLEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id\n\t\tWHERE f.forum_class IN (" . USERCLASS_LIST . ")\n\t\tORDER BY ft.thread_views DESC LIMIT 0,10";
$sql->gen($query);
$most_viewedArray = $sql->db_getList();
/*$sql->db_Select("user", "user_id, user_name, user_forums", "ORDER BY user_forums DESC LIMIT 0, 10", "no_where");
$posters = $sql -> db_getList();
$top_posters = array();
foreach($posters as $poster)
{
$percen = round(($poster['user_forums'] / $total_posts) * 100, 2);
$top_posters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['user_forums'], "percentage" => $percen);
}*/
// get all replies
$query = "\n\t\tSELECT COUNT(fp.post_id) AS post_count, u.user_name, u.user_id, fp.post_thread FROM #forum_post as fp\n\t\tLEFT JOIN #user AS u ON fp.post_user = u.user_id\n\t\tGROUP BY fp.post_user\n\t\tORDER BY post_count DESC LIMIT 0,10";
$sql->gen($query);
// $top_repliers_data = $sql->db_getList('ALL', false, false, 'user_id');
$top_repliers_data = $sql->retrieve($query, true);
// build top posters meanwhile
$top_posters = array();
$topReplier = array();
foreach ($top_repliers_data as $poster) {
$percent = round($poster['post_count'] / $total_posts * 100, 2);
$topReplier[] = intval($poster['user_id']);
$top_posters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'], LAN_ANONYMOUS), "user_forums" => $poster['post_count'], "percentage" => $percent);
}
// end build top posters
$ids = implode(',', $topReplier);
// find topics by top 10 users
$query = "\n\t\tSELECT COUNT(ft.thread_id) AS thread_count, u.user_id FROM #forum_thread as ft\n\t\tLEFT JOIN #user AS u ON ft.thread_user = u.user_id\n\t\tWHERE u.user_id IN ({$ids})\tGROUP BY ft.thread_user";
$sql->gen($query);
$top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id');
$top_repliers = array();
foreach ($top_repliers_data as $uid => $poster) {
$poster['post_count'] = $poster['post_count'] - $top_repliers_data_c[$uid]['thread_count'];
$percent = round($poster['post_count'] / $total_replies * 100, 2);
$top_repliers_sort[$uid] = $poster['post_count'];
//$top_repliers[$uid] = $poster;
$top_repliers_data[$uid]['user_forums'] = $poster['post_count'];
$top_repliers_data[$uid]['percentage'] = $percent;
//$top_repliers_data[$uid] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['post_count'], "percentage" => $percent);
}
// sort
arsort($top_repliers_sort, SORT_NUMERIC);
// build top repliers
foreach ($top_repliers_sort as $uid => $c) {
$top_repliers[] = $top_repliers_data[$uid];
}
// get all replies
$query = "\n\t\tSELECT COUNT(ft.thread_id) AS thread_count, u.user_name, u.user_id FROM #forum_thread as ft\n\t\tLEFT JOIN #user AS u ON ft.thread_user = u.user_id\n\t\tGROUP BY ft.thread_user\n\t\tORDER BY thread_count DESC LIMIT 0,10";
$sql->gen($query);
$top_topic_starters_data = $sql->db_getList();
$top_topic_starters = array();
foreach ($top_topic_starters_data as $poster) {
$percent = round($poster['thread_count'] / $total_topics * 100, 2);
$top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'], LAN_ANONYMOUS), "user_forums" => $poster['thread_count'], "percentage" => $percent);
}
/*
$query = "
SELECT SUBSTRING_INDEX(thread_user,'.',1) AS t_user, COUNT(SUBSTRING_INDEX(ft.thread_user,'.',1)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
LEFT JOIN #user AS u ON SUBSTRING_INDEX(ft.thread_user,'.',1) = u.user_id
WHERE ft.thread_parent=0
GROUP BY t_user
//.........这里部分代码省略.........
示例3: orphanFiles
function orphanFiles()
{
$files = e107::getFile()->get_files(e_DOWNLOAD);
$foundSome = false;
foreach ($files as $file) {
if (0 == $sql->db_Count('download', '(*)', " WHERE download_url='" . $file['fname'] . "'")) {
if (!$foundSome) {
// $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform");
$text .= '<form method="post" action="' . e_SELF . '?' . e_QUERY . '" id="myform">
<table class="adminlist">';
$text .= '<tr>';
$text .= '<th>' . DOWLAN_13 . '</th>';
$text .= '<th>' . DOWLAN_182 . '</th>';
$text .= '<th>' . DOWLAN_66 . '</th>';
$text .= '<th>' . LAN_OPTIONS . '</th>';
$text .= '</tr>';
$foundSome = true;
}
$filesize = is_readable(e_DOWNLOAD . $row['download_url']) ? eHelper::parseMemorySize(filesize(e_DOWNLOAD . $file['fname'])) : DOWLAN_181;
$filets = is_readable(e_DOWNLOAD . $row['download_url']) ? e107::getDate()->convert_date(filectime(e_DOWNLOAD . $file['fname']), "long") : DOWLAN_181;
$text .= '<tr>';
$text .= '<td>' . $tp->toHTML($file['fname']) . '</td>';
$text .= '<td>' . $filets . '</td>';
$text .= '<td>' . $filesize . '</td>';
}
}
}
示例4: array
if (FILE_UPLOADS && is_writable(e_BASE . $path . $dirs[$c])) {
$up_button = $frm->admin_button('erquest', FMLAN_21, 'action', '', array('id' => false, 'other' => "onclick='e107Helper.toggle(\"{$el_id}\")'"));
} else {
$up_button = " leave_32.png";
}
//FIXME - upload link not working, raplace with image
$text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='center middle'><a href='#{$el_id}' class='e-expandit'>upload</a></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<a class='action' href='" . e_SELF . "?" . $path . $dirs[$c] . "/'><img class='icon action S16' src='" . $imagedir . "folder.png' alt='" . $dirs[$c] . " " . FMLAN_31 . "' /></a>\n\t\t\t\t\t\t\t<a href='" . e_SELF . "?" . $path . $dirs[$c] . "/'>" . $dirs[$c] . "</a>\n\t\t\t\t\t\t\t<div class='e-hideme' id='{$el_id}'>\n\t\t\t\t\t\t\t\t<div class='field-spacer'>" . $frm->file('file_userfile[]', array('id' => false, 'size' => '20')) . $frm->admin_button('upload', FMLAN_22, '', '', array('id' => false)) . "</div>\n\t\t\t\t\t\t\t\t<input type='hidden' name='upload_dir[]' value='" . $path . $dirs[$c] . "' />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class='right'>" . $dirsize . "</td>\n\t\t\t\t\t\t<td class='right'> </td>\n\t\t\t\t\t</tr>\n\t";
$c++;
}
$c = 0;
while ($files[$c]) {
$img = strtolower(substr(strrchr($files[$c], "."), 1, 3));
if (!$img || !preg_match("/css|exe|gif|htm|jpg|js|php|png|txt|xml|zip/i", $img)) {
$img = "def";
}
$size = eHelper::parseMemorySize(filesize(e_BASE . $path . "/" . $files[$c]));
$gen = new convert();
$filedate = e107::getDate()->convert_date(filemtime(e_BASE . $path . "/" . $files[$c]), "forum");
$text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='center middle autocheck'>\n\t\t\t\t\t\t\t" . $frm->checkbox("selectedfile[{$c}]", 1, false, array('id' => false)) . "\n\t\t\t\t\t\t\t<input type='hidden' name='deleteconfirm[{$c}]' value='" . $path . $files[$c] . "' />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<img class='icon' src='" . $imagedir . $img . ".png' alt='" . $files[$c] . "' />\n\t\t\t\t\t\t\t<a href='" . e_SELF . "?" . $path . $files[$c] . "'>" . $files[$c] . "</a>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class='right'>" . $size . "</td>\n\t\t\t\t\t\t<td class='right'>" . $filedate . "</td>\n\t\t\t\t\t</tr>\n\t";
$c++;
}
$text .= "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<div class='buttons-bar left'>\n\t\t\t\t" . $frm->admin_button('check_all', 'jstarget:selectedfile', 'action', LAN_CHECKALL, array('id' => false)) . "\n\t\t\t\t" . $frm->admin_button('uncheck_all', 'jstarget:selectedfile', 'action', LAN_UNCHECKALL, array('id' => false)) . "\n\t";
if ($pubfolder || e_QUERY == "") {
require_once e_HANDLER . "file_class.php";
$fl = new e_file();
$dl_dirlist = $fl->get_dirs(e_DOWNLOAD);
$movechoice = array();
$movechoice[] = e_DOWNLOAD;
foreach ($dl_dirlist as $dirs) {
$movechoice[] = e_DOWNLOAD . $dirs . "/";
}
示例5: getMemoryUsage
/**
* Get the current memory usage of the code
* If $separator argument is null, raw data (array) will be returned
*
* @param null|string $separator
* @return string|array memory usage
*/
public static function getMemoryUsage($separator = '/')
{
$ret = array();
if (function_exists("memory_get_usage")) {
$ret[] = eHelper::parseMemorySize(memory_get_usage());
// With PHP>=5.2.0, can show peak usage as well
if (function_exists("memory_get_peak_usage")) {
$ret[] = eHelper::parseMemorySize(memory_get_peak_usage(TRUE));
}
} else {
$ret[] = 'Unknown';
}
return null !== $separator ? implode($separator, $ret) : $ret;
}
示例6: parseMemorySize
/**
* MOVED TO eHelper::parseMemorySize()
* FIXME - find all calls, replace with eHelper::parseMemorySize() (once eHelper lives in a separate file)
*
* @param integer $size
* @param integer $dp
* @return string formatted size
*/
public function parseMemorySize($size, $dp = 2)
{
return eHelper::parseMemorySize($size, $dp);
}
示例7: sc_download_mirror_filesize
function sc_download_mirror_filesize()
{
return eHelper::parseMemorySize($this->mirror['dlmirrorfile'][3]);
}