本文整理汇总了PHP中FormatBytes函数的典型用法代码示例。如果您正苦于以下问题:PHP FormatBytes函数的具体用法?PHP FormatBytes怎么用?PHP FormatBytes使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FormatBytes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: today
function today()
{
if (isset($_GET["today"])) {
$user = $_GET["today"];
$t = "today";
$Q1 = " AND DATE_FORMAT( zdate, '%Y-%m-%d' )=DATE_FORMAT( NOW(), '%Y-%m-%d' )";
}
if (isset($_GET["week"])) {
$t = "week";
$user = $_GET["week"];
$Q1 = " AND WEEK( zdate)=WEEK( NOW()) AND YEAR(zdate)=YEAR(NOW())";
}
if (isset($_GET["month"])) {
$t = "month";
$user = $_GET["month"];
$Q1 = " AND MONTH( zdate)=MONTH( NOW()) AND YEAR(zdate)=YEAR(NOW())";
}
$dansguardian_events = "dansguardian_events_" . date('Ym');
$sql = "SELECT SUM(QuerySize) as tsize, sitename FROM {$dansguardian_events} WHERE CLIENT='{$user}'{$Q1} GROUP BY sitename ORDER BY SUM(QuerySize) DESC";
$html = "\n\t<br>\n\t<center>\n\t<table style='width:500px;border:1px solid #CCCCCC'>\n\t<tr>\n\t\t<th colspan=2>{website}</th>\n\t\t<th>size</th>\n\t</tr>\n\t";
$q = new mysql();
$results = $q->QUERY_SQL($sql, "artica_events");
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$js = "Loadjs('squid.uris.stats.php?domain={$ligne["sitename"]}&user={$user}&t={$t}')";
$html = $html . "\n\t<tr" . CellRollOver() . ">\n\t\t<td width=1%><img src='img/web-22.png'></td>\n\t\t<td style='font-size:13px' " . CellRollOver($js, "{display_queries_list}") . ">{$ligne["sitename"]}</td>\n\t\t<td style='font-size:13px'>" . FormatBytes($ligne["tsize"] / 1024) . "</td>\n\t</tr>\n\t";
}
$html = $html . "</table></center>";
echo $html;
}
示例2: search
function search()
{
$tpl = new templates();
$MyPage = CurrentPageName();
$sock = new sockets();
$q = new mysql();
$database = "artica_events";
$t = $_GET["t"];
$search = '%';
$page = 1;
$FORCE_FILTER = null;
$total = 0;
$table = "last_boot";
$data = array();
$data['page'] = $page;
$data['total'] = 0;
$data['rows'] = array();
$fontsize = 20;
$style = "style='font-size:18px'";
$dataX = unserialize($sock->GET_INFO("InfluxDBRestoreArray"));
$c = 0;
$tpl = new templates();
while (list($path, $size) = each($dataX)) {
$c++;
$ms5 = md5($path);
$color = "black";
$size = FormatBytes(intval($size) / 1024);
$data['rows'][] = array('id' => $ms5, 'cell' => array("<span {$style}>{$path}</a></span>", "<span {$style}>{$size}</a></span>"));
}
if ($c == 0) {
json_error_show("no data");
}
$data['total'] = $c;
echo json_encode($data);
}
示例3: page
function page()
{
$sock = new sockets();
$ArticaTechNetSquidRepo = unserialize(base64_decode($sock->GET_INFO("ArticaTechNetSquidRepo")));
$tpl = new templates();
$realsquidversion = $sock->getFrameWork("squid.php?full-version=yes");
$many = texttooltip("{manual_update}", "position:left:{manual_update_proxy_explain}", "Loadjs('squid.compilation.status.php')", null, 0, "font-size:30px;");
$html = "\n\t\t\t\n\t<div style='font-size:30px;margin-bottom:30px'>{available_versions} | {current}: {$realsquidversion} | {$many}</div>\n\t<table style='width:100%'>\n\t<tr>\n\t<th style='font-size:22px'>{version}</th>\t\t\n\t<th style='font-size:22px'>{filename}</th>\n\t<th style='font-size:22px'>{filesize}</th>\n\t<th style='font-size:22px'> </tf>\n\t</tr>\t\t\t\t\n\t";
while (list($key, $array) = each($ArticaTechNetSquidRepo)) {
$URL = $array["URL"];
$VERSION = $array["VERSION"];
$FILESIZE = $array["FILESIZE"];
$FILENAME = $array["FILENAME"];
$FILESIZE = FormatBytes($FILESIZE / 1024);
$button = button("{update2}", "Loadjs('squid.update.progress.php?key={$key}&filename={$FILENAME}');", 22);
if ($realsquidversion == $VERSION) {
$button = "{current}";
}
if ($color == null) {
$color = "#F2F0F1";
} else {
$color = null;
}
$html = $html . "\n\t\t<tr style='background-color:{$color};height:80px'>\n\t\t\t<td style='font-size:22px;padding-left:10px'>{$VERSION}</td>\n\t\t\t<td style='font-size:22px;padding-left:10px'><a href=\"{$URL}\" target=_new style='text-decoration:underline'>{$FILENAME}</a></td>\t\n\t\t\t<td style='font-size:22px;padding-left:10px'>{$FILESIZE}</td>\t\n\t\t\t<td style='font-size:22px;padding-left:10px'><center>{$button}</center></td>\t\n\t\t</tr>\n\t\t";
}
$html = $html . "</table>";
echo $tpl->_ENGINE_parse_body($html);
}
示例4: section_websites_search
function section_websites_search()
{
$boot = new boostrap_form();
$tpl = new templates();
$q = new mysql_squid_builder();
$page = CurrentPageName();
$table = "visited_sites_tot";
$searchstring = string_to_flexquery("sites-search");
$ORDER = $boot->TableOrder(array("size" => "ASC"));
if ($q->COUNT_ROWS($table) == 0) {
senderrors("no data");
}
$sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250";
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
senderrors($q->mysql_error . "<br>{$sql}");
}
while ($ligne = mysql_fetch_assoc($results)) {
$md = md5(serialize($ligne));
$ligne["size"] = FormatBytes($ligne["size"] / 1024);
$sitenameenc = urlencode($ligne["familysite"]);
$js = "Loadjs('miniadm.webstats.familysite.all.php?familysite={$sitenameenc}')";
$link = $boot->trswitch($js);
$tr[] = "\n\t\t<tr id='{$md}'>\n\t\t\t<td style='font-size:16px' width=10% nowrap {$link}>{$ligne["familysite"]}</td>\n\t\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["hits"]}</td>\n\t\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["size"]}</td>\n\t\t</tr>\n\t\t";
}
echo $boot->TableCompile(array("familysite" => "{familysite}", "hits" => "{hits}", "size" => "{size}"), $tr);
}
示例5: popup
function popup()
{
$page = CurrentPageName();
$sock = new sockets();
$datas = unserialize(base64_decode($sock->getFrameWork("squid.php?squidclient-infos=yes")));
while (list($index, $line) = each($datas)) {
if (preg_match("#^.+?:\$#", $line)) {
$html[] = "\n\t\t\t</div><div style='width:95%;margin-top:15px;' class=form>\n\t\t\t<div style='font-size:16px;font-weight:bold;width:100%;padding-right:20px;text-align:right'>{$line}<hr></div>";
continue;
}
if (preg_match("#\\s+(.+?):(.+?)\$#", $line, $re)) {
$re[2] = trim($re[2]);
if (preg_match("#([0-9]+).*?KB#i", $re[2], $ri)) {
$re[2] = FormatBytes($ri[1]);
}
$html[] = "<div style='font-size:14px;'>{$re[1]}: <strong>{$re[2]}</strong></div>";
continue;
}
if (preg_match("#\\s+([0-9]+)\\s+(.+?)\$#", $line, $re)) {
$html[] = "<div style='font-size:14px;'>{$re[2]}: <strong>{$re[1]}</strong></div>";
continue;
}
}
$html[] = "</div>";
echo @implode("", $html);
}
示例6: FileInfo
function FileInfo($original_path)
{
$path = $original_path;
$sock = new sockets();
$array = unserialize(base64_decode($sock->getFrameWork("cmd.php?filestat=" . base64_encode($path))));
$type = base64_decode($sock->getFrameWork("cmd.php?filetype=" . base64_encode($path)));
$permissions = $array["perms"]["human"];
$permissions_dec = $array["perms"]["octal1"];
$accessed = $array["time"]["accessed"];
$modified = $array["time"]["modified"];
$created = $array["time"]["created"];
$file = $array["file"]["basename"];
$permissions_g = $array["owner"]["group"]["name"] . ":" . $array["owner"]["owner"]["name"];
$ext = Get_extension($file);
$page = CurrentPageName();
$cr = new SimpleCrypt($ldap->ldap_password);
$path_encrypted = base64_encode($original_path);
if ($array["size"]["blocks"] != null) {
$download = Paragraphe("download-64.png", "{download}", "{download} {$file}<br>" . FormatBytes($array["size"]["size"] / 1024), "{$page}?download-file={$path_encrypted}");
}
$img = "img/ext/def.jpg";
if (is_file("img/ext/{$ext}.jpg")) {
$img = "img/ext/{$ext}.jpg";
}
$table = "\n\t<table>\n\t<tr>\n\t\t<td class=legend>{permission}:</td>\n\t\t<td><strong>{$permissions} {$permissions_g} ({$permissions_dec})</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend>{accessed}:</td>\n\t\t<td><strong>{$accessed}</td>\n\t</tr>\n<tr><td class=legend>{modified}:</td><td><strong>{$modified}</td></tr>\n<tr><td class=legend>{created}:</td><td><strong>{$created}</td></tr>\n<tr>\n\t<td class=legend>{size}:</td>\n\t<td><strong>{$array["size"]["size"]} bytes (" . FormatBytes($array["size"]["size"] / 1024) . ")</td>\n</tr>\n<tr>\n\t<td class=legend>blocks:</td>\n\t<td><strong>{$array["size"]["blocks"]}</td>\n</tr>\t\n<tr>\n\t<td class=legend>block size:</td>\n\t<td><strong>{$array["size"]["block_size"]}</td>\n</tr>\n</table>";
if ($array["size"]["blocks"] == null) {
$table = null;
}
$html = "\n<div style='font-size:11px;margin-top:3px;padding-top:5px;border-top:1px solid #CCCCCC;text-align:right;'><i>{$type}</i></div>\n<table style='width:100%'>\n<tr>\n<td width=1% valign='top'><img src='{$img}' style='margin:15px'></td>\n<td valign='top'>\n<hr>\n{$table}\n</td>\n<td valign='top'>\n{$download}\n</td>\n</tr>\n</table>";
$tpl = new templates();
return $tpl->_ENGINE_parse_body($html);
}
示例7: table
function table()
{
$tpl = new templates();
$page = CurrentPageName();
$cachefile = "/usr/share/artica-postfix/ressources/logs/web/MYSQLDB_STATUS";
$tbl = unserialize(base64_decode(@file_get_contents($cachefile)));
while (list($dbname, $array) = each($tbl)) {
$t = $_GET["table"];
$size = FormatBytes($array["size"] / 1024);
$DEV = $array["INFO"]["DEV"];
$TOTAL = FormatBytes($array["INFO"]["TOT"] / 1024);
$USED = FormatBytes($array["INFO"]["USED"] / 1024);
$AIV = FormatBytes($array["INFO"]["AIV"] / 1024);
$POURC = $array["INFO"]["POURC"];
$MOUNTED = $array["INFO"]["MOUNT"];
$CleanMySQLLogs = $tpl->javascript_parse_text("{CleanMySQLLogs}");
$dbnameTXT = $tpl->_ENGINE_parse_body("{{$dbname}}");
$action = null;
if ($dbname == "APP_MYSQL_ARTICA") {
$action = imgtootltip("database-disconnect-64.png", null, "CleanMySQLLogs()");
}
$tr[] = "\n\t<tr>\n\t\t<td width=1% nowrap><img src='img/database-connect-settings-64.png'></td>\n\t\t<td style='font-size:18px'>{$dbnameTXT}</td>\n\t\t<td style='font-size:18px'>{$size}</td>\n\t\t<td style='font-size:18px'>{$MOUNTED}</td>\t\n\t\t<td style='font-size:18px'>{$USED}/{$TOTAL} ({$POURC}%)</td>\n\t\t<td style='font-size:18px' width=1% nowrap>{$action}</td>\n\t</tr>\n\t";
}
echo $tpl->_ENGINE_parse_body("\n\t\n\t\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan=2>{service}</th>\n\t\t\t\t\t<th >{size}</th>\n\t\t\t\t\t<th >{disk}</th>\n\t\t\t\t\t<th >{use}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("", $tr) . "</tbody></table>\n\t\t\t\t\t\n<script>\n\nvar xCleanMySQLLogs=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>10){alert(results);}\n\tLoadAjax('{$t}','{$page}?table={$t}');\n\t}\n\n\tfunction CleanMySQLLogs(){\n\t\tif(!confirm('{$CleanMySQLLogs}')){return;}\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('CleanMySQLLogs','yes');\n\t\tXHR.sendAndLoad('{$page}', 'POST',xCleanMySQLLogs);\t\t\n\t\t\n\t\t\n\t\t\t\t\t\n\t}\n</script>\n";
}
示例8: lighttpd_status
function lighttpd_status()
{
$ini = new Bs_IniHandler();
$sock = new sockets();
$tpl = new templates();
$page = CurrentPageName();
$ini->loadString(base64_decode($sock->getFrameWork('services.php?lighttpd-status=yes')));
$LIGHTTPD = DAEMON_STATUS_ROUND("LIGHTTPD", $ini, null, 1);
$LIGHTTPD_PID = $ini->_params["LIGHTTPD"]["master_pid"];
$FRAMEWORK = DAEMON_STATUS_ROUND("FRAMEWORK", $ini, null, 1);
$FRAMEWORK_PID = $ini->_params["FRAMEWORK"]["master_pid"];
$php_cgi_array = unserialize(base64_decode($sock->getFrameWork('services.php?php-cgi-array=yes')));
$LIGHTTPD_AR[] = "<table style='width:99%' class=form>";
while (list($pid, $array) = each($php_cgi_array[$LIGHTTPD_PID])) {
$RSS = FormatBytes($array["RSS"]);
$VM = FormatBytes($array["VM"]);
$TTL = $array["TTL"];
$LIGHTTPD_AR[] = "<tr>\n\t\t<td><strong style='font-size:12px'>PID:{$pid}</strong></td>\n\t\t<td><strong style='font-size:12px'>RSS:{$RSS}</strong></td>\n\t\t<td><strong style='font-size:12px'>VM:{$VM}</strong></td>\n\t\t<td><strong style='font-size:12px'>TTL:{$TTL}</strong></td>\n\t\t</tr>\n\t\t";
}
$LIGHTTPD_AR[] = "</table>";
$LIGHTTPDF_AR[] = "<table style='width:99%' class=form>";
while (list($pid, $array) = each($php_cgi_array[$FRAMEWORK_PID])) {
$RSS = FormatBytes($array["RSS"]);
$VM = FormatBytes($array["VM"]);
$TTL = $array["TTL"];
$LIGHTTPDF_AR[] = "<tr>\n\t\t<td><strong style='font-size:12px'>PID:{$pid}</strong></td>\n\t\t<td><strong style='font-size:12px'>RSS:{$RSS}</strong></td>\n\t\t<td><strong style='font-size:12px'>VM:{$VM}</strong></td>\n\t\t<td><strong style='font-size:12px'>TTL:{$TTL}</strong></td>\n\t\t</tr>\n\t\t";
}
$LIGHTTPDF_AR[] = "</table>";
$html = "<table style='width:99%' class=form>\n\t<tr>\n\t\t<td>{$LIGHTTPD} " . @implode("\n", $LIGHTTPD_AR) . "</td>\n\t</tr>\n\t<tr>\n\t\t<td><hr></td>\n\t</tr>\n\t<tr>\n\t\t<td>{$FRAMEWORK}" . @implode("\n", $LIGHTTPDF_AR) . "</td>\n\t</tr>\n\t</table>\t\n\t";
echo $tpl->_ENGINE_parse_body($html);
}
示例9: page
function page()
{
$sock = new sockets();
$ArticaTechNetInfluxRepo = unserialize(base64_decode($sock->GET_INFO("ArticaTechNetProFTPDRepo")));
$tpl = new templates();
$version = $sock->GET_INFO("ProFTPDVersion");
$manual_update = $tpl->javascript_parse_text("{manual_update}");
$html = "\n\t\t\t\n\t<div style='font-size:30px;margin-bottom:30px'>{available_versions} | {current}: {$version}\n\t | <a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('update.upload.php')\"\n\tstyle='text-decoration:underline'>{$manual_update}</a>\n\t | <a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('influx.refresh.update.php')\"\n\tstyle='text-decoration:underline'>{refresh}</a>\n\t\n\t\n\t</div>\n\t<table style='width:100%'>\n\t<tr>\n\t<th style='font-size:22px'>{version}</th>\n\t<th style='font-size:22px'>{OS}</th>\n\t<th style='font-size:22px'>{filename}</th>\n\t<th style='font-size:22px'>{filesize}</th>\n\t<th style='font-size:22px'> </tf>\n\t</tr>\t\t\t\t\n\t";
$color = null;
while (list($key, $array) = each($ArticaTechNetInfluxRepo)) {
while (list($OS, $MAIN) = each($array)) {
$URL = $MAIN["URL"];
$VERSION = $MAIN["VERSION"];
$FILESIZE = $MAIN["FILESIZE"];
$FILENAME = $MAIN["FILENAME"];
$FILESIZE = FormatBytes($FILESIZE / 1024);
$button = button("{update2}", "Loadjs('proftpd.update.progress.php?key={$key}&OS={$OS}&filename={$FILENAME}');", 32);
if ($color == null) {
$color = "#F2F0F1";
} else {
$color = null;
}
$html = $html . "\n\t\t<tr style='background-color:{$color};height:80px'>\n\t\t\t<td style='font-size:28px;padding-left:10px'><center>{$VERSION}</center></td>\n\t\t\t<td style='font-size:28px;padding-left:10px'><center>{$OS}</center></td>\n\t\t\t<td style='font-size:28px;padding-left:10px;text-align:right'><a href=\"{$URL}\" target=_new style='text-decoration:underline'>{$FILENAME}</a></td>\t\n\t\t\t<td style='font-size:28px;padding-left:10px;text-align:right'>{$FILESIZE}</td>\t\n\t\t\t<td style='font-size:28px;padding-left:10px'><center>{$button}</center></td>\t\n\t\t</tr>\n\t\t";
}
}
$html = $html . "</table>";
echo $tpl->_ENGINE_parse_body($html);
}
示例10: build
function build()
{
$sock = new sockets();
$unix = new unix();
$sysctl = $unix->find_program("sysctl");
$echo = $unix->find_program("echo");
$HugePages = $sock->GET_INFO("HugePages");
$KernelShmmax = $sock->GET_INFO("KernelShmmax");
$meminfo = MemInfo();
$HUGEPAGESIZE = intval($meminfo["HUGEPAGESIZE"]);
$HUGEPAGESIZEBytes = $HUGEPAGESIZE;
if (!is_numeric($HugePages)) {
$HugePages = 0;
}
if (!is_numeric($KernelShmmax)) {
$KernelShmmax = 0;
}
if ($HugePages > 0) {
$HugePagesB = $HugePages * 1024;
$HugePagesB = $HugePagesB * 1024;
$HugePagesF = $HugePagesB / $HUGEPAGESIZEBytes;
echo "HUGEPAGESIZE = {$HUGEPAGESIZE} ({$HUGEPAGESIZEBytes} bytes) " . FormatBytes($HUGEPAGESIZEBytes / 1024) . "\n";
echo "HugePages = {$HugePages} Mb ({$HugePagesB} bytes)\n";
echo "HugePages Final = {$HugePagesF} " . FormatBytes($HugePagesF / 1024) . " \n";
$unix->sysctl("vm.nr_hugepages", $HugePagesF);
shell_exec("{$sysctl} -w vm.nr_hugepages={$HugePagesF}");
for ($i = 0; $i < 10; $i++) {
shell_exec("{$echo} {$HugePagesF} > /proc/sys/vm/nr_hugepages");
sleep(1);
}
}
// sysctl
}
示例11: page
function page()
{
$page = CurrentPageName();
$tpl = new templates();
$q = new mysql();
$databases = $q->DATABASE_LIST();
while (list($database, $line) = each($databases)) {
$tbs = $tbs + $line[0];
$tx = trim($line[1]);
$re = explode(" ", $tx);
$tsize = $re[0];
$unit = $re[1];
if ($unit == "KB") {
$size = $size + $tsize;
}
if ($unit == "MB") {
$tsize = intval($tsize) * 1024;
$size = $size + $tsize;
}
if ($unit == "GB") {
$tsize = intval($tsize) * 1024;
$tsize = $tsize * 1024;
$size = $size + $tsize;
}
}
$text = $tpl->_ENGINE_parse_body("{INNODB_FILE_PER_TABLE_ASK}");
$size = FormatBytes($size);
$text = str_replace("%free", "<strong>{$size}</strong>", $text);
$text = str_replace("%tablesnum", "<strong>{$tbs}</strong>", $text);
$t = time();
$html = "\n\t\n\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td valign='top' width=1%><img src='img/database-connect-128.png'></td>\n\t\t<td valign='top' width=99% style='padding-left:20px'>\n\t\t<div style='font-size:18px;font-weight:bold'>InnoDB File per Table</div>\n\t\t<div id='{$t}-div'></div>\n\t\t<div style='font-size:14px'>{$text}</div>\n\t\t<div style='margin:10px;text-align:center'>" . button("{i_understand_continue}", "SaveContinue{$t}()", "18px") . "</div>\n\t\t<div style='margin:10px;text-align:center'>" . button("{convertto_innodb_file_per_table}", "ConvertInnodb{$t}()", "18px") . "</div>\n\t\t<div style='margin:10px;text-align:center'>\n\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:s_PopUpFull('http://www.mail-appliance.org/index.php?cID=278','1024','900');\"\n\t\tstyle='font-size:18px;'>{online_help}</a>\n\t\t\n\t\t\n\t\t</td>\n\t</tr>\n\t</table>\n\t\n\t<script>\n\t\tvar x_SaveContinue{$t}= function (obj) {\n\t\t\tvar tempvalue=obj.responseText;\n\t\t\tif(tempvalue.length>3){alert(tempvalue)};\n\t\t\tdocument.location.href='admin.index.php';\n\t\t\t\n\t\t}\n\t\n\t\n\t\tfunction SaveContinue{$t}(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('InnoDBFilePerTableAsk','yes');\n\t\t\tAnimateDiv('{$t}-div');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveContinue{$t});\t\n\t\t}\n\t\t\n\t\tfunction ConvertInnodb{$t}(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('ConvertInnoDB','yes');\n\t\t\tAnimateDiv('{$t}-div');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveContinue{$t});\t\t\t\n\t\t\n\t\t}\n\t\n\t</script>\n\t\n\t\n\t";
echo $tpl->_ENGINE_parse_body($html);
}
示例12: ShowProgress_js
function ShowProgress_js()
{
$t = $_GET["t"];
$tt = time();
$page = CurrentPageName();
$tpl = new templates();
$titleAdd = null;
$please_wait = $tpl->javascript_parse_text("{please_wait}");
$sock = new sockets();
$ISRunAR = unserialize(base64_decode($sock->getFrameWork("zarafa.php?restore-process-array=yes")));
if (is_array($ISRunAR)) {
$PID = intval($ISRunAR["PID"]);
$TIME = $ISRunAR["TIME"];
if ($ISRunAR["SIZE"] > 0) {
$ISRunARS = FormatBytes($ISRunAR["SIZE"]);
}
}
if ($PID > 0) {
$titleAdd = $tpl->javascript_parse_text("{running} {since} {$TIME}Mn PID {$PID}");
}
header("content-type: application/x-javascript");
$file = "/usr/share/artica-postfix/ressources/RestoreFromBackup_progress.progress";
$ARRAY = unserialize(@file_get_contents($file));
if (!is_array($ARRAY)) {
echo "\n\t\tfunction Start{$tt}(){\n\t\t\tLoadjs('{$page}?ShowProgress-js=yes&t={$t}');\n\t\t}\n\t\tdocument.getElementById('title{$t}').innerHTML='{$please_wait}';\n\t\tsetTimeout('Start{$tt}()',3000);\n\t\t";
return;
}
$text = $tpl->javascript_parse_text($ARRAY["TEXT"]);
$prc = $ARRAY["POURC"];
if ($prc > 99) {
echo "\n\t\t\tdocument.getElementById('title{$t}').innerHTML='{$text} {$ISRunARS}';\n\t\t\t\$('#Status{$t}').progressbar({ value: {$prc} });\n\t\t\t";
return;
}
echo "\n\tfunction Start{$tt}(){\n\t\t\n\t\tGetLogs{$t}();\n\t\tLoadjs('{$page}?ShowProgress-js=yes&t={$t}');\n\t}\n\t\n\tif(document.getElementById('title{$t}')){\n\t\tdocument.getElementById('title{$t}').innerHTML='{$text} {$ISRunARS} {$titleAdd}';\n\t\t\$('#Status{$t}').progressbar({ value: {$prc} });\n\t\tsetTimeout('Start{$tt}()',2000);\n\t}\n\t";
}
示例13: start
function start()
{
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$unix = new unix();
$pid = $unix->get_pid_from_file($pidFile);
if ($unix->process_exists($pid)) {
return;
}
@file_put_contents($pidFile, getmypid());
$time = $unix->file_time_min($pidtime);
if ($time < 5) {
return;
}
@file_put_contents($pidtime, time());
$free = $unix->find_program("free");
$echo = $unix->find_program("echo");
$sync = $unix->find_program("sync");
$swapoff = $unix->find_program("swapoff");
$swapon = $unix->find_program("swapon");
exec("{$free} 2>&1", $results);
$used = 0;
$total = 0;
while (list($num, $ligne) = each($results)) {
if (preg_match("#Swap:\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)#", $ligne, $re)) {
$total = $re[1];
$used = $re[2];
}
}
if (!is_numeric($total)) {
return;
}
if ($total == 0) {
return;
}
if ($used == 0) {
return;
}
if ($total == $used) {
return;
}
$tot1 = $used / $total;
$tot1 = $tot1 * 100;
if ($GLOBALS["VERBOSE"]) {
echo "Swap:{$used}/{$total} - {$tot1}\n";
}
$perc = round($tot1);
if ($GLOBALS["VERBOSE"]) {
echo "Swap:{$used}/{$total} {$perc}%\n";
}
$t = time();
$GLOBALS["ALL_SCORES"]++;
shell_exec("{$swapoff} -a && {$swapon} -a");
$usedTXT = FormatBytes($used);
$report = $unix->ps_mem_report();
$distance = $unix->distanceOfTimeInWords($t, time(), true);
squid_admin_mysql(0, "System swap exceed rule: {$perc}%", "Used {$usedTXT}\nSystem cache was flushed took {$distance}\nThis means you did have enough memory for this computer.\n{$report}", __FILE__, __LINE__);
}
示例14: tables_title
function tables_title(){
$q=new mysql_squid_builder();
$tpl=new templates();
$array=$q->COUNT_ALL_TABLES();
echo $tpl->_ENGINE_parse_body("
<div style='float:right'>". imgtootltip("refresh-24.png","{refresh}","RefreshTableTitle{$_GET["t"]}()")."</div>
<div style='font-size:18px'>{current}: {$array[0]} Tables (".FormatBytes($array[1]/1024).")</div>");
}
示例15: install
function install($filename)
{
$GLOBALS["PROGRESS_FILE"] = "/usr/share/artica-postfix/ressources/logs/squid.install.progress";
$GLOBALS["LOG_FILE"] = "/usr/share/artica-postfix/ressources/logs/web/squid.install.progress.txt";
$unix = new unix();
$LINUX_CODE_NAME = $unix->LINUX_CODE_NAME();
$LINUX_DISTRIBUTION = $unix->LINUX_DISTRIBUTION();
$LINUX_VERS = $unix->LINUX_VERS();
$LINUX_ARCHITECTURE = $unix->LINUX_ARCHITECTURE();
$APACHEUSER = $unix->APACHE_SRC_ACCOUNT();
$DebianVer = "debian{$LINUX_VERS[0]}";
$TMP_DIR = $unix->TEMP_DIR();
$ORGV = @file_get_contents("/usr/share/artica-postfix/VERSION");
$PATCH_VER = null;
$tarballs_file = "/usr/share/artica-postfix/ressources/conf/upload/{$filename}";
echo "Package {$tarballs_file}\n";
$size = filesize($tarballs_file);
echo "Size....................: " . FormatBytes($size / 1024) . "\n";
build_progress("Analyze...", 10);
echo "Current system..........: {$LINUX_CODE_NAME} {$LINUX_DISTRIBUTION} {$LINUX_VERS[0]}/{$LINUX_VERS[1]} {$LINUX_ARCHITECTURE}\n";
echo "Package.................: {$filename}\n";
echo "Temp dir................: {$TMP_DIR}\n";
if (!is_file($tarballs_file)) {
echo "{$tarballs_file} no such file...\n";
build_progress("No such file...", 110);
return;
}
echo "Uncompressing {$tarballs_file}...\n";
build_progress("{extracting} {$filename}...", 20);
$chown = $unix->find_program("chown");
$chmod = $unix->find_program("chmod");
$tar = $unix->find_program("tar");
$rm = $unix->find_program("rm");
$nohup = $unix->find_program("nohup");
$php = $unix->LOCATE_PHP5_BIN();
$squid = $unix->LOCATE_SQUID_BIN();
build_progress("{extracting} {$filename}...", 50);
system("{$tar} xf {$tarballs_file} -C /");
echo "Removing {$tarballs_file}...\n";
@unlink($tarballs_file);
shell_exec("{$rm} -rf /usr/share/artica-postfix/ressources/conf/upload/*");
@unlink(dirname(__FILE__) . "/ressources/logs/squid.compilation.params");
build_progress("{restarting} Squid-cache...", 60);
system("/etc/init.d/squid restart --force");
build_progress("{reconfiguring} Squid-cache...", 65);
system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
build_progress("{reconfiguring} {APP_UFDBGUARD}...", 70);
system("{$php} /usr/share/artica-postfix/exec.squidguard.php --build --force");
build_progress("{restarting} {APP_C_ICAP}...", 80);
system("/etc/init.d/c-icap restart");
build_progress("Refresh local versions...", 90);
system('/usr/share/artica-postfix/bin/process1 --force --verbose --' . time());
$squid_version = x_squid_version();
build_progress("{success} v.{$squid_version}...", 100);
echo "Starting......: " . date("H:i:s") . " Done you can close the screen....\n";
}