本文整理汇总了PHP中setunits函数的典型用法代码示例。如果您正苦于以下问题:PHP setunits函数的具体用法?PHP setunits怎么用?PHP setunits使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setunits函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: NodeStats
function NodeStats($id, $dt) {
global $DB;
if ($stats = $DB->GetRow('SELECT SUM(download) AS download, SUM(upload) AS upload
FROM stats WHERE nodeid=? AND dt>?', array($id, time() - $dt))) {
list($result['download']['data'], $result['download']['units']) = setunits($stats['download']);
list($result['upload']['data'], $result['upload']['units']) = setunits($stats['upload']);
$result['downavg'] = $stats['download'] * 8 / 1000 / $dt;
$result['upavg'] = $stats['upload'] * 8 / 1000 / $dt;
}
return $result;
}
开发者ID:rzt,项目名称:lms,代码行数:11,代码来源:nodeinfo.php
示例2: ON
FROM stats
LEFT JOIN nodes ON (nodeid = nodes.id)
WHERE ownerid = ? AND dt >= ? AND dt < ?', array($customer, $from, $to))) {
for ($i = 1; $i <= date('t', $from); $i++) {
$stats[$i]['date'] = mktime(0, 0, 0, $month, $i, $year);
}
foreach ($list as $row) {
$day = date('j', $row['dt']);
$stats[$day]['download'] += $row['download'];
$stats[$day]['upload'] += $row['upload'];
}
for ($i = 1; $i <= date('t', $from); $i++) {
$stats[$i]['upavg'] = $stats[$i]['upload'] * 8 / 1000 / 86400;
//kbit/s
$stats[$i]['downavg'] = $stats[$i]['download'] * 8 / 1000 / 86400;
//kbit/s
$listdata['upload'] += $stats[$i]['upload'];
$listdata['download'] += $stats[$i]['download'];
$listdata['upavg'] += $stats[$i]['upavg'];
$listdata['downavg'] += $stats[$i]['downavg'];
list($stats[$i]['upload'], $stats[$i]['uploadunit']) = setunits($stats[$i]['upload']);
list($stats[$i]['download'], $stats[$i]['downloadunit']) = setunits($stats[$i]['download']);
}
$listdata['upavg'] = $listdata['upavg'] / date('t', $from);
$listdata['downavg'] = $listdata['downavg'] / date('t', $from);
list($listdata['upload'], $listdata['uploadunit']) = setunits($listdata['upload']);
list($listdata['download'], $listdata['downloadunit']) = setunits($listdata['download']);
}
$SMARTY->assign('stats', $stats);
$SMARTY->assign('listdata', $listdata);
clearheader();
开发者ID:repcio,项目名称:lms,代码行数:31,代码来源:printtraffic.php
示例3: foreach
die;
}
}
if (!isset($_GET['id'])) {
$SESSION->redirect('?' . $SESSION->get('backto'));
}
$message = $LMS->GetMessage($_GET['id']);
if ($message['userid']) {
$message['username'] = $LMS->GetUserName($message['userid']);
}
if ($message['customerid']) {
$message['customername'] = $LMS->GetCustomerName($message['customerid']);
}
if (sizeof($message['attachments'])) {
foreach ($message['attachments'] as $key => $val) {
list($size, $unit) = setunits(@filesize(ConfigHelper::getConfig('rt.mail_dir') . sprintf("/%06d/%06d/%s", $message['ticketid'], $message['id'], $val['filename'])));
$message['attachments'][$key]['size'] = $size;
$message['attachments'][$key]['unit'] = $unit;
}
}
if ($message['inreplyto']) {
$reply = $LMS->GetMessage($message['inreplyto']);
$message['inreplytoid'] = $reply['subject'];
}
if (!$message['customerid'] && !$message['userid'] && !$message['mailfrom']) {
$message['requestor'] = $DB->GetOne('SELECT requestor FROM rttickets WHERE id=?', array($message['ticketid']));
}
$layout['pagetitle'] = trans('Ticket Review');
$SESSION->save('backto', $_SERVER['QUERY_STRING']);
$SMARTY->assign('message', $message);
$SMARTY->display('rt/rtmessageview.html');
开发者ID:prezeskk,项目名称:lms,代码行数:31,代码来源:rtmessageview.php
示例4: GetNodeSessions
public function GetNodeSessions($nodeid)
{
$nodesessions = $this->DB->GetAll('SELECT INET_NTOA(ipaddr) AS ipaddr, mac, start, stop,
download, upload, terminatecause, type
FROM nodesessions WHERE nodeid = ? ORDER BY stop DESC LIMIT ' . intval(ConfigHelper::getConfig('phpui.nodesession_limit', 10)), array($nodeid));
if (!empty($nodesessions)) {
foreach ($nodesessions as $idx => $session) {
list($number, $unit) = setunits($session['download']);
$nodesessions[$idx]['download'] = round($number, 2) . ' ' . $unit;
list($number, $unit) = setunits($session['upload']);
$nodesessions[$idx]['upload'] = round($number, 2) . ' ' . $unit;
$nodesessions[$idx]['duration'] = uptimef($session['stop'] - $session['start']);
}
}
return $nodesessions;
}
开发者ID:jarecky,项目名称:lms,代码行数:16,代码来源:LMS.class.php
示例5: handle_file_uploads
function handle_file_uploads($elemid, &$error)
{
$tmpdir = $tmppath = '';
$fileupload = array();
if (isset($_POST['fileupload'])) {
$fileupload = $_POST['fileupload'];
$tmpdir = $fileupload[$elemid . '-tmpdir'];
if (empty($tmpdir)) {
$tmpdir = uniqid('lms-fileupload-');
$tmppath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tmpdir;
if (is_dir($tmppath) || !@mkdir($tmppath)) {
$tmpdir = '';
}
} elseif (preg_match('/^lms-fileupload-[0-9a-f]+$/', $tmpdir)) {
$tmppath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tmpdir;
if (!file_exists($tmppath)) {
@mkdir($tmppath);
}
} else {
$tmpdir = '';
}
if (isset($_GET['ajax'])) {
$files = array();
if (isset($_FILES[$elemid])) {
foreach ($_FILES[$elemid]['name'] as $fileidx => $filename) {
if (preg_match('/(\\.\\.|\\/)/', $filename)) {
continue;
}
if (!empty($filename)) {
if (is_uploaded_file($_FILES[$elemid]['tmp_name'][$fileidx]) && $_FILES[$elemid]['size'][$fileidx]) {
$files[] = array('name' => $filename, 'tmp_name' => $_FILES[$elemid]['tmp_name'][$fileidx], 'type' => $_FILES[$elemid]['type'][$fileidx], 'size' => $_FILES[$elemid]['size'][$fileidx]);
} else {
// upload errors
if (isset($error[$elemid])) {
$error[$elemid] .= "\n";
} else {
$error[$elemid] = '';
}
switch ($_FILES[$elemid]['error'][$fileidx]) {
case 1:
case 2:
$error[$elemid] .= trans('File is too large: $a', $filename);
break;
case 3:
$error[$elemid] .= trans('File upload has finished prematurely: $a', $filename);
break;
case 4:
$error[$elemid] .= trans('Path to file was not specified: $a', $filename);
break;
default:
$error[$elemid] .= trans('Problem during file upload: $a', $filename);
break;
}
}
}
}
}
if ($error && isset($error[$elemid])) {
$result = array('error' => $error[$elemid]);
} else {
if (isset($fileupload) && !empty($tmpdir)) {
$files2 = array();
foreach ($files as &$file) {
unset($file2);
if (isset($fileupload[$elemid])) {
foreach ($fileupload[$elemid] as &$file2) {
if ($file['name'] == $file2['name']) {
continue 2;
}
}
}
if (!file_exists($tmppath . DIRECTORY_SEPARATOR . $file['name'])) {
@move_uploaded_file($file['tmp_name'], $tmppath . DIRECTORY_SEPARATOR . $file['name']);
unset($file['tmp_name']);
}
$files2[] = $file;
}
unset($file);
$files = $files2;
unset($files2, $file2);
}
$result = array('error' => '', 'tmpdir' => $tmpdir, 'files' => $files);
}
header('Content-type: application/json');
print json_encode($result);
die;
} elseif (isset($fileupload[$elemid])) {
foreach ($fileupload[$elemid] as &$file) {
list($size, $unit) = setunits($file['size']);
$file['sizestr'] = sprintf("%.02f", $size) . ' ' . $unit;
}
unset($file);
${$elemid} = $fileupload[$elemid];
}
}
return compact('fileupload', 'tmppath', $elemid);
}
开发者ID:prezeskk,项目名称:lms,代码行数:97,代码来源:common.php
示例6: Traffic
function Traffic($from = 0, $to = 0, $owner = 0, $order = '')
{
global $LMS, $DB;
if ($owner) {
$owner = ' AND ownerid = ' . $owner;
}
// period
if (is_array($from)) {
$fromdate = mktime($from['Hour'], $from['Minute'], 0, $from['Month'], $from['Day'], $from['Year']);
} else {
$fromdate = $from;
}
if (is_array($to)) {
$todate = mktime($to['Hour'], $to['Minute'], 59, $to['Month'], $to['Day'], $to['Year']);
} else {
$todate = $to;
}
$delta = $todate - $fromdate ? $todate - $fromdate : 1;
if ($from || $to) {
$dt = " AND ( dt >= {$fromdate} AND dt <= {$todate} )";
}
// order
switch ($order) {
case 'nodeid':
$order = ' ORDER BY nodeid';
break;
case 'download':
$order = ' ORDER BY download DESC';
break;
case 'upload':
$order = ' ORDER BY upload DESC';
break;
case 'name':
$order = ' ORDER BY name';
break;
case 'ip':
$order = ' ORDER BY ipaddr';
break;
}
// join query from parts
$query = 'SELECT nodeid, name, inet_ntoa(ipaddr) AS ip, sum(upload) as upload, sum(download) as download
FROM stats
LEFT JOIN nodes ON stats.nodeid=nodes.id
WHERE 1=1 ' . ($dt ? $dt : '') . ($owner ? $owner : '') . ' GROUP BY nodeid, name, ipaddr ' . $order;
// get results
if ($traffic = $LMS->DB->GetAll($query)) {
$downloadsum = 0;
$uploadsum = 0;
foreach ($traffic as $idx => $row) {
$traffic['upload']['data'][] = $row['upload'];
$traffic['download']['data'][] = $row['download'];
$traffic['upload']['name'][] = $row['name'] ? $row['name'] : 'nieznany (ID: ' . $row['nodeid'] . ')';
$traffic['download']['name'][] = $row['name'] ? $row['name'] : 'nieznany (ID: ' . $row['nodeid'] . ')';
$traffic['upload']['ipaddr'][] = $row['ip'];
$traffic['download']['nodeid'][] = $row['nodeid'];
$traffic['upload']['nodeid'][] = $row['nodeid'];
$traffic['download']['ipaddr'][] = $row['ip'];
$downloadsum += $row['download'];
$uploadsum += $row['upload'];
$traffic['upload']['avg'][] = $row['upload'] * 8 / ($delta * 1000);
$traffic['download']['avg'][] = $row['download'] * 8 / ($delta * 1000);
}
$traffic['upload']['sum']['data'] = $uploadsum;
$traffic['download']['sum']['data'] = $downloadsum;
$traffic['upload']['avgsum'] = $uploadsum * 8 / ($delta * 1000);
$traffic['download']['avgsum'] = $downloadsum * 8 / ($delta * 1000);
// get maximum data from array
$maximum = max($traffic['download']['data']);
if ($maximum < max($traffic['upload']['data'])) {
$maximum = max($traffic['upload']['data']);
}
if ($maximum == 0) {
// do not need divide by zero
$maximum = 1;
}
// make data for bars drawing
$x = 0;
foreach ($traffic['download']['data'] as $data) {
$down = round($data * 150 / $maximum);
$traffic['download']['bar'][] = $down ? $down : 1;
list($traffic['download']['data'][$x], $traffic['download']['unit'][$x]) = setunits($data);
$x++;
}
$x = 0;
foreach ($traffic['upload']['data'] as $data) {
$up = round($data * 150 / $maximum);
$traffic['upload']['bar'][] = $up ? $up : 1;
list($traffic['upload']['data'][$x], $traffic['upload']['unit'][$x]) = setunits($data);
$x++;
}
//set units for data
list($traffic['download']['sum']['data'], $traffic['download']['sum']['unit']) = setunits($traffic['download']['sum']['data']);
list($traffic['upload']['sum']['data'], $traffic['upload']['sum']['unit']) = setunits($traffic['upload']['sum']['data']);
}
return $traffic;
}
开发者ID:kornelek,项目名称:lms,代码行数:96,代码来源:functions.php
示例7: GetNodeSessions
public function GetNodeSessions($nodeid)
{
$nodesessions = $this->DB->GetAll('SELECT INET_NTOA(ipaddr) AS ipaddr, mac, start, stop, download, upload
FROM nodesessions WHERE nodeid = ? ORDER BY stop DESC LIMIT 10', array($nodeid));
if (!empty($nodesessions)) {
foreach ($nodesessions as $idx => $session) {
list($number, $unit) = setunits($session['download']);
$nodesessions[$idx]['download'] = round($number, 2) . ' ' . $unit;
list($number, $unit) = setunits($session['upload']);
$nodesessions[$idx]['upload'] = round($number, 2) . ' ' . $unit;
$nodesessions[$idx]['duration'] = uptimef($session['stop'] - $session['start']);
}
}
return $nodesessions;
}
开发者ID:oswida,项目名称:lms,代码行数:15,代码来源:LMS.class.php
示例8: implode
} else {
$filtervalue = '';
}
break;
}
}
$nodesessions = $DB->GetAll('SELECT s.*, c.name, c.lastname FROM nodesessions s
LEFT JOIN nodes n ON n.id = s.nodeid
LEFT JOIN customers c ON c.id = s.customerid
WHERE ' . implode(' AND ', $where) . '
ORDER BY s.start DESC LIMIT 5000');
if (!empty($nodesessions)) {
foreach ($nodesessions as &$session) {
list($number, $unit) = setunits($session['download']);
$session['download'] = round($number, 2) . ' ' . $unit;
list($number, $unit) = setunits($session['upload']);
$session['upload'] = round($number, 2) . ' ' . $unit;
$session['duration'] = $session['stop'] ? uptimef($session['stop'] - $session['start']) : '-';
}
}
$pagelimit = ConfigHelper::getConfig('phpui.nodesession_pagelimit', 100);
$page = !isset($_GET['page']) ? 1 : intval($_GET['page']);
$listdata['total'] = count($nodesessions);
if (($page - 1) * $pagelimit > $listdata['total']) {
$page = 1;
}
$SMARTY->assign('listdata', $listdata);
$SMARTY->assign('pagelimit', $pagelimit);
$SMARTY->assign('start', ($page - 1) * $pagelimit);
$SMARTY->assign('page', $page);
$SMARTY->assign('filtertype', $filtertype);
开发者ID:itav,项目名称:lms,代码行数:31,代码来源:nodesessionlist.php
注:本文中的setunits函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论