Example #1
0
function print_states($tracker)
{
    global $rulescnt;
    $rulesid = "";
    $bytes = 0;
    $states = 0;
    $packets = 0;
    $evaluations = 0;
    $stcreations = 0;
    $rules = get_pf_rules($rulescnt, $tracker);
    if (is_array($rules)) {
        foreach ($rules as $rule) {
            $bytes += $rule['bytes'];
            $states += $rule['states'];
            $packets += $rule['packets'];
            $evaluations += $rule['evaluations'];
            $stcreations += $rule['state creations'];
            if (strlen($rulesid) > 0) {
                $rulesid .= ",";
            }
            $rulesid .= "{$rule['id']}";
        }
    }
    printf("<a href=\"diag_dump_states.php?ruleid=%s\" data-toggle=\"popover\" data-trigger=\"hover focus\" title=\"%s\" ", $rulesid, gettext("States details"));
    printf("data-content=\"evaluations: %s<br>packets: %s<br>bytes: %s<br>states: %s<br>state creations: %s\" data-html=\"true\">", format_number($evaluations), format_number($packets), format_bytes($bytes), format_number($states), format_number($stcreations));
    printf("%d/%s</a><br>", format_number($states), format_bytes($bytes));
}
Example #2
0
 public function artc()
 {
     $id = I('id');
     $info = D('Article')->get_info($id);
     if (!$info) {
         $this->error('非法ID!', U('Index/index'), false, true);
     }
     $info['description'] = stripcslashes($info['description']);
     preg_match_all("/(?<=\\[attach\\])([\\d]*)(?=\\[\\/attach\\])/", $info['description'], $arr);
     preg_match_all("/(?<=\\[qnattach\\])([\\d]*)(?=\\[\\/qnattach\\])/", $info['description'], $qnarr);
     foreach ($arr[0] as $key => $vo) {
         $replace = '<a href="' . U('File/download', array('id' => think_encrypt($vo))) . '" target="_blank" >' . getattachname($vo) . '</a><span class="attachspan">(下载次数:' . getattachdnum($vo) . '次;大小:' . format_bytes(getattachsize($vo)) . ')</span>';
         $info['description'] = str_replace('[attach]' . $vo . '[/attach]', $replace, $info['description']);
     }
     foreach ($qnarr[0] as $key1 => $vo1) {
         $replace1 = '<a href="' . U('File/download', array('qn' => 1, 'id' => think_encrypt($vo1))) . '" target="_blank" >' . getqnattachname($vo1) . '</a><span class="attachspan">(下载次数:' . getqnattachdnum($vo1) . '次;大小:' . format_bytes(getqnattachsize($vo1)) . ')</span>';
         $info['description'] = str_replace('[qnattach]' . $vo1 . '[/qnattach]', $replace1, $info['description']);
     }
     if ($info['status'] != 1 && $info['uid'] != $_SESSION['cs_home']['user_auth']['uid']) {
         $this->error('你无权查看该内容!', '', false, true);
     }
     $focus['rowid'] = $info['id'];
     $focus['type'] = 1;
     if ($sccount = M('focus')->where($focus)->count() != $info['sccount']) {
         D('Article')->where(array('id' => $id))->setField('sccount', $sccount);
     }
     D('Article')->where(array('id' => $id))->setInc('view', 1);
     if (!empty($info['tag'])) {
         $tags = explode(',', $info['tag']);
         $info['linktag'] = '';
         foreach ($tags as $key1 => $vo1) {
             $maptag['title'] = $vo1;
             $maptag['type'] = 1;
             $tagid = M('tags')->where($maptag)->getField('id');
             $url = CSU('/tagart/' . $tagid, 'Index/tagart', array('id' => $tagid));
             $info['linktag'] .= '<a style="margin-left:5px;" href="' . $url . '">[' . $vo1 . ']</a>';
             $info['tagarr'][$key1] = '<a class="tag" href="' . $url . '">' . $vo1 . '</a>';
         }
     }
     $shareurl = 'http://' . $_SERVER['HTTP_HOST'] . CSU('/artc/' . $info['id'], 'Index/artc', array('id' => $info['id']));
     $sharedes = '原文链接:' . $shareurl;
     $sharetitle = $info['title'] . '-' . C('WEB_SITE_TITLE');
     $authorinfo = query_user(array('space_url', 'signature', 'avatar64', 'nickname'), $info['uid']);
     $map['id'] = is_login();
     $map['rowid'] = $info['id'];
     $map['type'] = 1;
     if (M('Focus')->where($map)->count() > 0) {
         $hassc = true;
     }
     $this->assign('shareurl', $shareurl);
     $this->assign('hassc', $hassc);
     $this->assign('sharedes', $sharedes);
     $this->assign('sharetitle', $sharetitle);
     $this->assign('authorinfo', $authorinfo);
     $this->assign('info', $info);
     $this->assign('webdescription', $info['title']);
     $this->assign('webkeyword', $info['title']);
     $this->assign('webtitle', $info['title']);
     $this->display();
 }
Example #3
0
function Movie_thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir)
{
    $filename = $filelist[$filekey];
    $file = "{$basedir}/{$filename}";
    $mimetype = mime_content_type($file);
    $filesize = filesize($file);
    $nicefilesize = format_bytes($filesize);
    $caption = get_caption($file);
    if (!isset($caption) || $caption == "") {
        $caption = $filename;
    }
    $imagetag = " MOVIE:  {$filename} <br/>";
    $filesize_display = " File Size: {$nicefilesize} <br/>";
    #<a href='?action=send_file&gallery=$gallery&dirkey=$dirkey&filekey=$filekey'>
    print <<<HTMLEND

    <div class=thumbnail >
\t\t<div class=movie >
\t\t{$imagetag}
\t\t{$filesize_display}
\t\t<a href='send_file.php?mode=attach&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}'>
\t\tDownload
\t\t</a>
\t\t|
\t\t<a href='gallery.php?action=display_image&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}' type='{$mimetype}' >
\t\tView in browser
\t\t</a>

    
    \t</div>
    </div>
   
HTMLEND;
}
Example #4
0
/**
 * 扫描目录所有文件,并生成treegrid数据
 * @param string $path     目录
 * @param string $filter   过滤文件名
 * @param number $i        辅助用,这个不用传参
 * @return array
 */
function scandir_tree($path, $filter = SITE_DIR, &$i = 1)
{
    $result = array();
    $path = realpath($path);
    $path = str_replace(array('/', '\\'), DS, $path);
    $filter = str_replace(array('/', '\\'), DS, $filter);
    $list = glob($path . DS . '*');
    foreach ($list as $key => $filename) {
        $result[$key]['id'] = $i;
        $result[$key]['name'] = str_replace($filter, '', $filename);
        $i++;
        if (is_dir($filename)) {
            $result[$key]['type'] = 'dir';
            $result[$key]['size'] = '-';
            $result[$key]['mtime'] = '-';
            $result[$key]['state'] = 'closed';
            $result[$key]['children'] = scandir_tree($filename, $filter, $i);
            //easyui当children为空时会出现问题,因此在这里过滤
            if (empty($result[$key]['children'])) {
                $result[$key]['iconCls'] = 'tree-folder';
                unset($result[$key]['state']);
                unset($result[$key]['children']);
            }
        } else {
            $result[$key]['type'] = 'file';
            $result[$key]['size'] = format_bytes(filesize($filename), ' ');
            $result[$key]['mtime'] = date('Y-m-d H:i:s', filemtime($filename));
        }
    }
    return $result;
}
 protected function _after_find(&$result, $options)
 {
     $result['update_time_text'] = date('Y-m-d H:i:s', $result['update_time']);
     $result['document_title'] = M('Doc0s1')->getFieldById($result['record_id'], 'title');
     //$result['document_title'] = M('Document')->getFieldById($result['record_id'], 'title');
     $result['size'] = format_bytes($result['size']);
 }
 public function lists()
 {
     $type = I('get.type', 'Picture');
     $type = ucfirst($type);
     $title = I('get.title');
     if (empty($this->_path[$type])) {
         $this->error($type . '请选择正确的资源类型');
     }
     $files_list = array();
     //获取该目录下所有文件
     $fileslist = Amango_Scanfiles('./Uploads/' . $type . '/');
     $files_list = explode(',', $fileslist);
     $current_path = $this->_path[$type][1];
     //获取路径
     if (in_array($title, $files_list)) {
         $current_path = $current_path . $title . '/';
         $parent_ext = './' . $title . '/';
     } else {
         $parent_ext = './';
     }
     $file_list = array();
     //遍历目录下文件 取得文件信息
     $totalkbs = 0;
     if ($handle = opendir($current_path)) {
         $i = 0;
         while (false !== ($filename = readdir($handle))) {
             if ($filename[0] == '.') {
                 continue;
             }
             $file = $current_path . $filename;
             if (!is_dir($file)) {
                 $file_ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
                 if (!in_array($file_ext, $this->deny_ext_arr)) {
                     $nowsize = filesize($file);
                     $filesize = $filesize + $nowsize;
                     $file_list[$parent_ext][$i]['is_dir'] = false;
                     $file_list[$parent_ext][$i]['has_file'] = false;
                     $file_list[$parent_ext][$i]['filesize'] = format_bytes($nowsize);
                     $file_list[$parent_ext][$i]['dir_path'] = '';
                     $file_list[$parent_ext][$i]['filetype'] = $file_ext;
                     $file_list[$parent_ext][$i]['filename'] = $filename;
                     //文件名,包含扩展名
                     $file_list[$parent_ext][$i]['datetime'] = date('Y-m-d H:i:s', filectime($file));
                     //文件最后修改时间
                 }
             }
             $i++;
         }
         closedir($handle);
     }
     $this->assign('filesize', format_bytes($filesize));
     $this->assign('filenums', count($file_list[$parent_ext]));
     $this->assign('type', $type);
     $this->assign('nowdir', $title);
     $this->assign('sub_dirs', $files_list);
     $this->assign('subfileslist', $file_list[$parent_ext]);
     $this->assign('catename', $this->_path[$type][0]);
     $this->display();
 }
Example #7
0
    /**
     * 数据库备份/还原列表
     */
    public function import_list($type = null)
    {
        if (IS_POST) {
            $path = C('DATA_BACKUP_PATH');
            if (!is_dir($path)) {
                mkdir($path, 0755, true);
            }
            $path = realpath($path);
            $flag = \FilesystemIterator::KEY_AS_FILENAME;
            $glob = new \FilesystemIterator($path, $flag);
            $list = array();
            foreach ($glob as $name => $file) {
                if (preg_match('/^\\d{8,8}-\\d{6,6}-\\d+\\.sql(?:\\.gz)?$/', $name)) {
                    $name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
                    $date = "{$name[0]}-{$name[1]}-{$name[2]}";
                    $time = "{$name[3]}:{$name[4]}:{$name[5]}";
                    $part = $name[6];
                    if (isset($list["{$date} {$time}"])) {
                        $info = $list["{$date} {$time}"];
                        $info['part'] = max($info['part'], $part);
                        $info['size'] = $info['size'] + $file->getSize();
                    } else {
                        $info['part'] = $part;
                        $info['size'] = $file->getSize();
                    }
                    $extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
                    $info['compress'] = $extension === 'SQL' ? '-' : $extension;
                    $info['time'] = strtotime("{$date} {$time}");
                    $list["{$date} {$time}"] = $info;
                }
            }
            foreach ($list as $list_key => $list_one) {
                $_list_one['id'] = date('Ymd-His', $list_one['time']);
                $_list_one['part'] = $list_one['part'];
                $_list_one['size'] = format_bytes($list_one['size']);
                $_list_one['compress'] = $list_one['compress'];
                $_list_one['time'] = $list_key;
                $_list_one['operate'] = '
					<a href="#" onclick="Ajax_DatabaseImport(\'' . U('import', array('time' => $list_one['time'])) . '\',\'DatabaseImport_Data_List\');">还原</a>
					<a href="#" onclick="Datagrid_Ajax(\'' . U('del', array('time' => $list_one['time'])) . '\',\'DatabaseImport_Data_List\');">删除</a>
				';
                $_list[] = $_list_one;
            }
            $total = count($_list);
            if ($total == 0) {
                $_list = '';
            }
            $data = array('total' => $total, 'rows' => $_list);
            $this->ajaxReturn($data);
        } else {
            $operate = '
			<a class="easyui-linkbutton" href="JavaScript:void(0);" data-options="iconCls:\'iconfont icon-refresh\',plain:true" onclick="Data_Reload(\'DatabaseImport_Data_List\');">刷新还原列表</a>
			';
            $this->assign('operate', $operate);
            $this->display();
        }
    }
Example #8
0
	/**
	 * Returns disk space data
	 *
	 * @return	array
	 */
    public function getUsedDiskSpace()
    {
        $disk_space['b_free'] = disk_free_space('/');
        $disk_space['b_total'] = disk_total_space('/');
        $disk_space['free'] = format_bytes($disk_space['b_free']);
        $disk_space['total'] = format_bytes($disk_space['b_total']);
        $disk_space['used'] = format_bytes($disk_space['b_total'] - $disk_space['b_free']);
        $disk_space['per_used'] =   100 - (int) ($disk_space['b_free'] / $disk_space['b_total'] * 100);

        return $disk_space;
    }
Example #9
0
 public function step1()
 {
     $items = array(array('os' => array('操作系统', 1, null, PHP_OS), 'php' => array('PHP版本', 0, '5.3', PHP_VERSION), 'upload' => array('附件上传', 1, null, function_exists('ini_get') ? ini_get('upload_max_filesize') : '未知'), 'disk' => array('磁盘空间', 1, null, function_exists('disk_free_space') ? format_bytes(disk_free_space(realpath(SITE_DIR))) : '未知')), array('pdo' => array('pdo', 0, null, '不支持', 'class_exists'), 'pdo_mysql' => array('pdo_mysql', 0, null, '不支持', 'extension_loaded'), 'json' => array('json', 0, null, '不支持', 'extension_loaded'), 'curl_init' => array('curl', 0, null, '不支持', 'function_exists'), 'gd' => array('gd', 0, null, '不支持', 'extension_loaded'), 'Imagick' => array('imagick', 0, null, '建议开启(可选)', 'class_exists'), 'Gmagick' => array('gmagick', 0, null, '建议开启(可选)', 'class_exists')), array(array(str_replace(SITE_DIR, '.', CONF_PATH . 'config.php'), 0, null, '不可写', CONF_PATH . 'config.php'), array(str_replace(SITE_DIR, '.', RUNTIME_PATH), 0, null, '不可写', RUNTIME_PATH), array(UPLOAD_PATH, 0, null, '不可写', UPLOAD_PATH)));
     if (APP_MODE == 'sae') {
         unset($items[2]);
     }
     $status = true;
     foreach ($items as $k => &$item) {
         foreach ($item as $k2 => &$info) {
             if ($info[1]) {
                 continue;
             }
             switch ($k) {
                 case 0:
                     //运行环境
                     if ($k2 == 'php') {
                         if ($info[3] >= $info[2]) {
                             $info[1] = 1;
                         } else {
                             $status = false;
                         }
                     }
                     break;
                 case 1:
                     //扩展支持
                     if ($info[4]($k2)) {
                         $info[1] = 1;
                         $info[3] = '支持';
                     } else {
                         if (in_array($k2, array('Imagick', 'Gmagick'))) {
                             break;
                         }
                         $status = false;
                     }
                     break;
                 case 2:
                     //权限检测
                     if (is_writable($info[4])) {
                         $info[1] = 1;
                         $info[3] = '可写';
                     } else {
                         $status = false;
                     }
                     break;
             }
         }
     }
     if ($status) {
         session('install_step', 2);
     }
     $this->assign('item', array($status, $items));
     $this->display();
 }
Example #10
0
 public function filelist_rubbish()
 {
     $File = M('File');
     $where['status'] = 0;
     $count = $File->where($where)->count();
     $Page = new \Think\Page($count, 24);
     $show = $Page->show();
     $filelist = $File->where($where)->field(true)->order('addtime desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
     foreach ($filelist as $key => &$val) {
         $val['size'] = format_bytes($val['size']);
     }
     $this->assign('filelist', $filelist);
     $this->assign('pages', $show);
     $this->display();
 }
Example #11
0
 public function hasErrors()
 {
     // check file size
     if ($this->maxFileSize && $_FILES[$this->altName()]['size'] > $this->maxFileSize) {
         $this->errors[] = t('The file size exceeds max of ' . format_bytes($this->maxFileSize));
     }
     // file extensions allowed validator
     if ($this->allowedExtensions) {
         $extValidator = new \Meta\Validation\FileExtension(array('allowedExtensions' => $this->allowedExtensions, 'value' => $this->getValue()));
         if (!$extValidator->execute()) {
             $this->errors[] = $extValidator->error();
         }
     }
     return count($this->errors) > 0;
 }
 /**
  * 数据库还原列表
  */
 public function importlist()
 {
     if (IS_POST) {
         $path = C('DATA_BACKUP_PATH');
         if (!is_dir($path)) {
             mkdir($path, 0755, true);
         }
         $path = realpath($path);
         $flag = \FilesystemIterator::KEY_AS_FILENAME;
         $glob = new \FilesystemIterator($path, $flag);
         $list = array();
         foreach ($glob as $name => $file) {
             if (preg_match('/^\\d{8,8}-\\d{6,6}-\\d+\\.sql(?:\\.gz)?$/', $name)) {
                 $name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
                 $date = "{$name[0]}-{$name[1]}-{$name[2]}";
                 $time = "{$name[3]}:{$name[4]}:{$name[5]}";
                 $part = $name[6];
                 if (isset($list["{$date} {$time}"])) {
                     $info = $list["{$date} {$time}"];
                     $info['part'] = max($info['part'], $part);
                     $info['size'] = $info['size'] + $file->getSize();
                 } else {
                     $info['part'] = $part;
                     $info['size'] = $file->getSize();
                 }
                 $extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
                 $info['compress'] = $extension === 'SQL' ? '-' : $extension;
                 $info['time'] = strtotime("{$date} {$time}");
                 $list["{$date} {$time}"] = $info;
             }
         }
         $temp = array();
         foreach ($list as $key => $value) {
             $list[$key]['name'] = date('Ymd-His', strtotime($key));
             $list[$key]['datetime'] = date('Y-m-d H:i:s', strtotime($key));
             $list[$key]['size'] = format_bytes($list[$key]['size']);
             $temp[] = $list[$key];
         }
         $list = $temp;
         $this->ajaxReturn($list);
     } else {
         $currentpos = D('Menu')->currentPos(I('get.menuid'));
         //栏目位置
         $treegrid = array('options' => array('title' => $currentpos, 'url' => U('Database/importlist', array('grid' => 'treegrid')), 'idField' => 'time', 'treefield' => 'time'), 'fields' => array('备份名称' => array('field' => 'name', 'width' => 80), '卷数' => array('field' => 'part', 'width' => 50), '压缩' => array('field' => 'compress', 'width' => 50), '数据大小' => array('field' => 'size', 'width' => 50, 'formatter' => 'function(size){return "<font color=green>"+size+"</font>";}'), '备份时间' => array('field' => 'datetime', 'width' => 80, 'formatter' => 'function(datetime){return "<font color=red>"+datetime+"</font>";}'), '管理操作' => array('field' => 'time', 'width' => 80, 'formatter' => 'databaseImportModule.operate')));
         $this->assign('treegrid', $treegrid);
         $this->display("import");
     }
 }
/**
 *  Recursively construct the proper HTML
 *  for representing a folder full of items
 *
 *  @param array $dirs       array of directory objects to process
 *  @param array $path_array path components in array form
 *  @param array $item_info  metadata about each item
 *
 *  @return void
 *
 *  @author Ken Auberry <*****@*****.**>
 */
function build_folder_structure(&$dirs, $path_array, $item_info)
{
    if (count($path_array) > 1) {
        if (!isset($dirs['folders'][$path_array[0]])) {
            $dirs['folders'][$path_array[0]] = array();
        }
        build_folder_structure($dirs['folders'][$path_array[0]], array_splice($path_array, 1), $item_info);
    } else {
        $size_string = format_bytes($item_info['size']);
        $item_id = $item_info['item_id'];
        $url = base_url() . "myemsl/itemauth/{$item_id}";
        $item_info['url'] = $url;
        $item_info_json = json_encode($item_info);
        $dirs['files'][$item_id] = "<a class='item_link' id='item_{$item_id}' href='#'>{$path_array[0]}</a> <span class='fineprint'>[size: {$size_string}]</span><span class='item_data_json' id='item_id_{$item_id}' style='display:none;'>{$item_info_json}</span>";
    }
}
Example #14
0
function drive_details($drive)
{
    if (isset($drive["fsSize"])) {
        $pdsize = $drive["fsSize"] * 1024;
        $pfree = $drive["fsFree"] * 1024;
        $pused = $pdsize - $pfree;
        $pused_size = $pused / $pdsize * 100;
        $output['used'] = format_bytes($pused, true, '', '');
        $output['free'] = format_bytes($pfree, true, '', '');
        $output['percent'] = $pused_size;
    }
    $output['id'] = $drive["id"] . " (" . $drive["device"] . ")";
    $output['temp'] = $drive['temp'];
    $output['size'] = format_bytes($drive["size"] * 1024);
    $output['errors'] = $drive['numErrors'];
    return $output;
}
Example #15
0
/**
 * 上传目录列表
 * @param string $path 目录名
 * @return array
 */
function file_list_upload($path)
{
    $config = C('TMPL_PARSE_STRING');
    switch (strtoupper(C('FILE_UPLOAD_TYPE'))) {
        case 'SAE':
            $path = str_replace(DS, '/', rtrim($path, DS));
            $arr = explode('/', ltrim($path, './'));
            $domain = array_shift($arr);
            $filePath = implode('/', $arr);
            $s = new SaeStorage();
            $list = $s->getListByPath($domain, $filePath);
            $res = array();
            while (isset($list['dirNum']) && $list['dirNum']) {
                $list['dirNum']--;
                array_push($res, array('type' => 'dir', 'name' => $list['dirs'][$list['dirNum']]['name'], 'path' => ltrim($list['dirs'][$list['dirNum']]['fullName'], 'upload/'), 'size' => '-', 'mtime' => '-', 'url' => '#'));
            }
            while (isset($list['fileNum']) && $list['fileNum']) {
                $list['fileNum']--;
                array_push($res, array('type' => 'file', 'name' => $list['files'][$list['fileNum']]['Name'], 'path' => ltrim($list['files'][$list['fileNum']]['fullName'], 'upload/'), 'size' => format_bytes($list['files'][$list['fileNum']]['length'], ' '), 'mtime' => date('Y-m-d H:i:s', $list['files'][$list['fileNum']]['uploadTime']), 'url' => ltrim($list['files'][$list['fileNum']]['fullName'], 'upload/')));
            }
            return $res;
            break;
        case 'FTP':
            $storage = new \Common\Plugin\Ftp();
            $list = $storage->ls($path);
            foreach ($list as &$item) {
                $item['path'] = ltrim($item['path'], UPLOAD_PATH);
                $item['url'] = str_replace('\\', '/', $item['path']);
            }
            return $list;
            break;
        default:
            $path = realpath($path);
            $path = str_replace(array('/', '\\'), DS, $path);
            $list = glob($path . DS . '*');
            $res = array();
            foreach ($list as $key => $filename) {
                array_push($res, array('type' => is_dir($filename) ? 'dir' : 'file', 'name' => basename($filename), 'path' => ltrim(str_replace(realpath(UPLOAD_PATH), '', $filename), DS), 'size' => format_bytes(filesize($filename), ' '), 'mtime' => date('Y-m-d H:i:s', filemtime($filename)), 'url' => ltrim(str_replace(array(realpath(UPLOAD_PATH), '\\'), array('', '/'), $filename), '/')));
            }
            return $res;
    }
}
Example #16
0
 public function testFormatBytes()
 {
     $this->assertSame('10 B', format_bytes(10));
     $this->assertSame('100 B', format_bytes(100));
     $this->assertSame('1,0 kB', format_bytes(1000));
     $this->assertSame('1,0 kB', format_bytes(1024));
     $this->assertSame('1,0 kB', format_bytes(1025));
     $this->assertSame('1 kB', format_bytes(1025, 0));
     $this->assertSame('15 kB', format_bytes(15245, 0));
     $this->assertSame('15 kB', format_bytes(15645, 0));
     $this->assertSame('15,3 kB', format_bytes(15645));
     $this->assertSame('15,6 kB', format_bytes(15945));
     $this->assertSame('16 kB', format_bytes(15945, 0));
     $this->assertSame('15 MB', format_bytes(15945987, 0));
     $this->assertSame('15,2 MB', format_bytes(15945987));
     $this->assertSame('2 GB', format_bytes(2000000000, 0));
     $this->assertSame('3 TB', format_bytes(3000000000000, 0));
     $this->assertSame('1 TB', format_bytes(1000000000000, 0));
     $this->assertSame('1 PB', format_bytes(1000000000000000, 0));
     $this->assertSame('8 PB', format_bytes(9000000000000000, 0));
 }
Example #17
0
 public function get_backups()
 {
     $bdir = $this->_get_backup_dir();
     if (!file_exists($bdir)) {
         $this->_backup_summary['info'] = "No backups";
         return $this->_backup_summary;
     }
     $files = scandir($bdir);
     if (count($files) < 1) {
         $this->_backup_summary['info'] = "No backups";
         return null;
     }
     $bupfiles = preg_grep("/^backup\\-*/", $files);
     if (count($bupfiles) < 1) {
         $this->_backup_summary['info'] = "No backups";
         return null;
     }
     $total_size = 0;
     $bburl = $this->site->siteurl . $this->_get_backup_dir();
     foreach ($bupfiles as $b) {
         $this->_backup_summary['count']++;
         $size = filesize($bdir . $b);
         $total_size += $size;
         $m = $this->_bb_regex($b);
         $d = $m['date'];
         $t = $m['type'];
         if ($t == 'full' && $d > $this->_backup_summary['lastfull']) {
             $this->_backup_summary['lastfull'] = $d;
             $this->_backup_summary['fullurl'] = $bburl . $b;
         } else {
             if ($t == 'db' && $d > $this->_backup_summary['lastdb']) {
                 $this->_backup_summary['lastdb'] = $d;
                 $this->_backup_summary['dburl'] = $bburl . $b;
             }
         }
         $this->_backups[$b] = array('size' => $size, 'date' => $d, 'type' => $t, 'url' => $bburl . $b, 'dir' => $bdir . $b);
     }
     $this->_backup_summary['totalsize'] = format_bytes($total_size);
     return $this->_backups;
 }
Example #18
0
/**
 * check_config
 * This checks the script configuration... Like upload limit, thumbs, etc. 
 */
function check_config()
{
    global $config, $install_errors;
    if (!defined('HTTP_HOST')) {
        $install_errors[] = 'Can\'t resolve <code>HTTP_HOST</code>. Please check at the bottom of <code>config.php</code>';
    }
    // Upload limit vs php.ini value -> http://php.net/manual/ini.php
    $ini_upload_bytes = return_bytes(trim(ini_get('upload_max_filesize')) . 'B');
    $max_size_bytes = return_bytes($config['max_filesize']);
    if (!is_numeric($max_size_bytes)) {
        $install_errors[] = 'Invalid numeric value in <code>$config[\'max_filesize\']</code>';
    } else {
        if ($ini_upload_bytes < $max_size_bytes) {
            $install_errors[] = 'Max. image size (' . $config['max_filesize'] . ') is greater than the value in <code>php.ini</code> (' . format_bytes($ini_upload_bytes) . ')';
        }
    }
    if (!is_int($config['thumb_width'])) {
        $install_errors[] = 'Invalid thumb size width in <code>$config[\'thumb_width\']</code>';
    }
    if (!is_int($config['thumb_height'])) {
        $install_errors[] = 'Invalid thumb size height in <code>$config[\'thumb_height\']</code>';
    }
    if (!is_int($config['min_resize_size']) || $config['min_resize_size'] < 0) {
        $install_errors[] = 'Invalid minimum resize size in <code>$config[\'min_resize_size\']</code>';
    }
    if (!is_int($config['max_resize_size']) || $config['max_resize_size'] < 0) {
        $install_errors[] = 'Invalid maximum resize size in <code>$config[\'max_resize_size\']</code>';
    }
    if (is_int($config['min_resize_size']) && is_int($config['max_resize_size']) && $config['min_resize_size'] > $config['max_resize_size']) {
        $install_errors[] = 'Minimum resize size can\'t be larger than maximum resize size. Please check <code>$config[\'min_resize_size\']</code> and <code>$config[\'max_resize_size\']</code>';
    }
    if (!conditional_config('multiupload')) {
        $config['multiupload_limit'] = 1;
    } else {
        if ($config['multiupload_limit'] <= 0 || $config['multiupload_limit'] == '') {
            $config['multiupload_limit'] = 0;
        }
    }
    if (!check_value(chevereto_config('file_naming')) || !in_array(chevereto_config('file_naming'), array('original', 'random', 'mixed'))) {
        $config['file_naming'] = 'original';
    }
    if (!is_numeric($config['multiupload_limit']) && !is_bool($config['multiupload_limit'])) {
        $install_errors[] = 'Invalid multiupload limit value in <code>$config[\'multiupload_limit\']</code>';
    }
    if ($config['multiupload_limit'] > 100) {
        $install_errors[] = 'Multiupload limit value can\'t be higher than 100 in <code>$config[\'multiupload_limit\']</code>';
    }
    if ($config['short_url_service'] == 'bitly') {
        $bitly_status = fetch_url('http://api.bit.ly/v3/validate?x_login='******'short_url_user'] . '&x_apiKey=' . $config['short_url_keypass'] . '&apiKey=' . $config['short_url_keypass'] . '&login='******'short_url_user'] . '&format=json');
        $bitly_json = json_decode($bitly_status);
        if ($bitly_json->data->valid !== 1) {
            $install_errors[] = 'The <a href="http://bit.ly/" target="_blank">bit.ly</a> user/api is invalid. bitly server says <code>' . $bitly_json->status_txt . '</code>. Please double check your data.';
        }
    }
    // Facebook comments
    if (use_facebook_comments() && !check_value($config['facebook_app_id'])) {
        $install_errors[] = 'You are are trying to use Facebook comments but <code>$config[\'facebook_app_id\']</code> is not setted.';
    }
    // Virtual folders
    foreach (array('virtual_folder_image', 'virtual_folder_uploaded') as $value) {
        if (!check_value($config[$value])) {
            $install_errors[] = '<code>$config[\'' . $value . '\']</code> is not setted.';
        }
    }
    // Passwords
    if ($config['user_password'] == $config['admin_password']) {
        $install_errors[] = 'Admin and user passwords must be different. Please check <code>$config[\'admin_password\']</code> and <code>$config[\'user_password\']</code>';
    }
    // Flood report email?
    if (check_value($config['flood_report_email']) && !check_email_address($config['flood_report_email'])) {
        $install_errors[] = 'It appears that <code>$config[\'flood_report_email\']</code> has a invalid email address';
    }
    // Watermark
    if (conditional_config('watermark_enable')) {
        define('__CHV_WATERMARK_FILE__', __CHV_ROOT_DIR__ . ltrim($config['watermark_image'], '/'));
        if (!is_int($config['watermark_margin'])) {
            $install_errors[] = 'Watermark margin must be integer in <code>$config[\'watermark_margin\']</code>';
        }
        if (!is_int($config['watermark_opacity'])) {
            $install_errors[] = 'Watermark opacity must be integer in <code>$config[\'watermark_opacity\']</code>';
        }
        if ($config['watermark_opacity'] > 100 or $config['watermark_opacity'] < 0) {
            $install_errors[] = 'Watermark opacity value out of limis (' . $config['watermark_opacity'] . '). <code>$config[\'watermark_opacity\']</code> must be in the range 0 to 100';
        }
        // Watermark position
        if (!check_value($config['watermark_position'])) {
            $config['watermark_position'] = 'center center';
        }
        $watermark_position = explode(' ', strtolower($config['watermark_position']));
        if (!isset($watermark_position[1])) {
            $watermark_position[1] = 'center';
        }
        if (preg_match('/^left|center|right$/', $watermark_position[0])) {
            $config['watermark_x_position'] = $watermark_position[0];
        } else {
            $install_errors[] = 'Invalid watermark horizontal position in <code>$config[\'watermark_position\']</code>';
        }
        if (preg_match('/^top|center|bottom$/', $watermark_position[1])) {
            $config['watermark_y_position'] = $watermark_position[1];
        } else {
            $install_errors[] = 'Invalid watermark vertical position in <code>$config[\'watermark_position\']</code>';
        }
        if (!file_exists(__CHV_WATERMARK_FILE__)) {
            $install_errors[] = 'Watermark image file doesn\'t exists. Please check the path in <code>$config[\'watermark_image\']</code>';
        } else {
            $watermark_image_info = get_info(__CHV_WATERMARK_FILE__);
            if ($watermark_image_info['mime'] !== 'image/png') {
                $install_errors[] = 'Watermark image file must be a PNG image in <code>$config[\'watermark_image\']</code>';
            }
        }
    }
    // Flood limits
    $flood_limits = array('minute', 'hour', 'day', 'week', 'month');
    $flood_value_error = false;
    foreach ($flood_limits as $value) {
        if (!check_value($config['max_uploads_per_' . $value]) || !is_numeric($config['max_uploads_per_' . $value])) {
            $install_errors[] = 'Invalid config value in <code>$config[\'' . $value . '\']</code>';
            $flood_value_error = true;
        }
    }
    if ($flood_value_error == false) {
        $flood_lower_than = array('minute' => array('hour', 'day', 'week', 'month'), 'hour' => array('day', 'week', 'month'), 'day' => array('week', 'month'), 'week' => array('month'));
        foreach ($flood_lower_than as $period => $lower_than) {
            foreach ($lower_than as $value) {
                if ($config['max_uploads_per_' . $period] >= $config['max_uploads_per_' . $value]) {
                    $install_errors[] = '<code>max_uploads_per_' . $period . '</code> must be lower than <code>max_uploads_per_' . $value . '</code>';
                }
            }
        }
    }
    // dB settings
    foreach (array('db_host', 'db_name', 'db_user') as $value) {
        if (!check_value($config[$value])) {
            $install_errors[] = '<code>$config[\'' . $value . '\']</code>';
        }
    }
    if (count($install_errors) == 0) {
        require_once __CHV_PATH_CLASSES__ . 'class.db.php';
        $dB = new dB();
        if ($dB->dead) {
            chevereto_die('<code>' . $dB->error . '</code>', 'Database error', array('The system has encountered a error when it try to connect to the database server.', 'Please note this error and if you need help go to <a href="http://chevereto.com/support/">Chevereto support</a>.'));
        } else {
            // Check maintenance mode
            if ($dB->get_option('maintenance') && !defined('SKIP_MAINTENANCE')) {
                $config['maintenance'] = true;
            }
        }
    }
    return count($install_errors) == 0 ? true : false;
}
Example #19
0
								<td width="78%" class="listr">
									<?php 
        echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
        echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
        ?>
								</td>
							</tr>
							<tr>
								<td width="22%" class="vncellt"><?php 
        echo gettext("In/out packets (block)");
        ?>
</td>
								<td width="78%" class="listr">
									<?php 
        echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
        echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
        ?>
								</td>
							</tr>
                                <?php 
        if (isset($ifinfo['inerrs'])) {
            ?>
							<tr>
								<td width="22%" class="vncellt"><?php 
            echo gettext("In/out errors");
            ?>
</td>
								<td width="78%" class="listr">
									<?php 
            echo htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);
            ?>
Example #20
0
/"><?php 
    echo $item["id"];
    ?>
</a></td>
					<td class="wrap"><?php 
    echo htmlspecialchars($item["filename"]);
    ?>
</td>
					<td><?php 
    echo $item["mimetype"];
    ?>
</td>
					<td class="nowrap" data-sort-value="<?php 
    echo $item["date"];
    ?>
"><?php 
    echo date("r", $item["date"]);
    ?>
</td>
					<td><?php 
    echo format_bytes($item["filesize"]);
    ?>
</td>
				</tr>
			<?php 
}
?>
		</tbody>
	</table>
</div>
Example #21
0
function return_rowhelper_row($rownum, $mountpoint, $fstype, $disk, $size, $encpass)
{
    global $g, $select_txt, $custom_disks, $savemsg;
    $release = php_uname("r");
    $release = trim($release[0]);
    // Mount point
    $disks = installer_find_all_disks();
    $custom_txt .= "<tr>";
    $custom_txt .= "<td><input size='8' id='mountpoint{$rownum}' name='mountpoint{$rownum}' value='{$mountpoint}'></td>";
    // Filesystem type array
    $types = array('UFS' => 'UFS', 'UFS+S' => 'UFS + Softupdates', 'UFS.eli' => 'Encrypted UFS', 'UFS+S.eli' => 'Encrypted UFS + Softupdates', 'SWAP' => 'SWAP');
    // UFS + Journaling was introduced in 9.0
    if ($release == "9") {
        $types['UFS+J'] = "UFS + Journaling";
        $types['UFS+J.eli'] = "Encrypted UFS + Journaling";
    }
    // Add ZFS Boot loader if it exists
    if (file_exists("/boot/gptzfsboot")) {
        $types['ZFS'] = "Zetabyte Filesystem";
        $types['ZFS.eli'] = "Encrypted Zetabyte Filesystem";
    }
    // fstype form field
    $custom_txt .= "<td><select onChange='javascript:row_helper_dynamic_custom()' id='fstype{$rownum}' name='fstype{$rownum}'>";
    $select_txt = "";
    foreach ($types as $type => $desc) {
        if ($type == $fstype) {
            $SELECTED = "SELECTED";
        } else {
            $SELECTED = "";
        }
        $select_txt .= "<option value='{$type}' {$SELECTED}>{$desc}</option>";
    }
    $custom_txt .= "{$select_txt}</select>\n";
    $custom_txt .= "</td>";
    // Disk selection form field
    $custom_txt .= "<td><select id='disk{$rownum}' name='disk{$rownum}'>\n";
    $custom_disks = "";
    foreach ($disks as $dsk) {
        $disksize_bytes = format_bytes($dsk['size'] * 1048576);
        $disksize = $dsk['size'];
        if ($disk == $dsk['disk']) {
            $SELECTED = "SELECTED";
        } else {
            $SELECTED = "";
        }
        $custom_disks .= "<option value='{$dsk['disk']}' {$SELECTED}>{$dsk['disk']} - {$dsk['desc']} - {$disksize}MB ({$disksize_bytes})</option>";
    }
    $custom_txt .= "{$custom_disks}</select></td>\n";
    // Slice size
    $custom_txt .= "<td><input onChange='javascript:row_helper_dynamic_custom();' name='size{$rownum}' id='size{$rownum}' size='8' type='text' value='{$size}'></td>";
    // Encryption password
    $custom_txt .= "<td>";
    $custom_txt .= "<input id='encpass{$rownum}' name='encpass{$rownum}' size='8' value='{$encpass}'>";
    $custom_txt .= "</td>";
    // Add Rowhelper + button
    if ($rownum > 0) {
        $custom_txt .= "<td><a onclick=\"removeRow(this); return false;\" href=\"#\"><img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_x.gif\" alt=\"\" title=\"remove this entry\"/></a></td>";
    }
    $custom_txt .= "</tr>";
    return $custom_txt;
}
Example #22
0
        echo $item['host'];
        ?>
:<?php 
        echo $item['port'];
        ?>
</td>
        <td><?php 
        echo $item['tags'];
        ?>
</td>
        <td><?php 
        echo $item['innodb_buffer_pool_instances'];
        ?>
</td>
        <td><?php 
        echo format_bytes($item['innodb_buffer_pool_size']);
        ?>
</td>
        <td><?php 
        echo $item['innodb_buffer_pool_pages_total'];
        ?>
</td>
        <td><?php 
        echo $item['innodb_buffer_pool_pages_data'];
        ?>
</td>
        <td><?php 
        echo $item['innodb_buffer_pool_pages_dirty'];
        ?>
</td>
        <td><?php 
Example #23
0
function direktorija($dir, $i, $dziljums)
{
    global $pats;
    global $lasitdir;
    global $lasitfailus;
    global $shimg;
    $i++;
    if ($parbaudadir = opendir($dir)) {
        $irdir = 0;
        $irfails = 0;
        while ($file = readdir($parbaudadir)) {
            if ($file != '.' && $file != '..') {
                if (is_dir($dir . '/' . $file)) {
                    $lasitdir[$irdir] = $file;
                    $irdir++;
                } else {
                    $lasitfailus[$irfails] = $file;
                    $irfails++;
                }
            }
        }
        if (count($lasitdir) > 0) {
            sort($lasitdir);
            for ($j = 0; $j < count($lasitdir); $j++) {
                $saite = '<a href="' . $pats . '?' . en_crypt('dir=' . $dir . '/' . $lasitdir[$j] . '') . '">' . $lasitdir[$j] . '</a>';
                $saitedzd = '<a href="' . $pats . '?' . en_crypt('c=' . $dir . '/' . $lasitdir[$j] . '&dzeest=yes&dir=' . $dir . '') . '" onclick="javascript:return confirm(\'Dzēst?\');">X</a>';
                $urlis = mapURL($dir . '/' . $lasitdir[$j]);
                $urlis = str_replace("\\", '/', $urlis);
                $imgdir = $shimg == 1 ? '<img src="' . $pats . '?' . en_crypt('icon=view') . '" alt="" />' : '[go]';
                $skat = '<a href="' . $urlis . '/">' . $imgdir . '</a> ';
                $dir_css = $j % 2 ? 'a' : 'b';
                $imgdir1 = $shimg == 1 ? '<img src="' . $pats . '?' . en_crypt('icon=folder') . '" alt="" />' : '[dir]';
                $druka = '<div class="' . $dir_css . '" onmouseover="fa(this);" onmouseout="fb(this);">' . $skat . ' ' . $imgdir1 . '<em class="dir">' . $saite . '</em><em class="chmod">' . substr(base_convert(fileperms($dir . '/' . $lasitdir[$j]), 10, 8), 2) . '</em><em class="kb"></em><em class="data">' . gmdate('[ Y-m-d, H:i:s ]', 2 * 3600 + filemtime($dir . '/' . $lasitdir[$j])) . '</em>  <del title="dzēst!">' . $saitedzd . '</del></div>
';
                echo $druka;
                if ($i < $dziljums) {
                    direktorija($dir . '/' . $lasitdir[$j], $i, $dziljums);
                }
            }
        }
        echo '<div class="nav"> </div>
';
        if (count($lasitfailus) > 0) {
            sort($lasitfailus);
            for ($k = 0; $k < count($lasitfailus); $k++) {
                $saite = '<a href="' . $pats . '?' . en_crypt('c=' . $dir . '/' . $lasitfailus[$k] . '&faili=yes&dir=' . $dir . '') . '#f">' . $lasitfailus[$k] . '</a>';
                $saitedz = '<a href="' . $pats . '?' . en_crypt('c=' . $dir . '/' . $lasitfailus[$k] . '&dzeest=yes&dir=' . $dir . '') . '" onclick="javascript:return confirm(\'Dzēst?\');">X</a>';
                ### lejupielaade
                $imgdir = $shimg == 1 ? '<img src="' . $pats . '?' . en_crypt('icon=view') . '" alt="" />' : '[go]';
                $lej_img = $shimg == 1 ? '<img src="' . $pats . '?' . en_crypt('icon=save') . '" alt="" />' : '[save]';
                $sleja = '<a href="' . $pats . '?' . en_crypt('c=' . $dir . '/' . $lasitfailus[$k] . '&leja=' . $lasitfailus[$k] . '&dir=' . $dir . '') . '">' . $lej_img . '</a>';
                ###
                $urlis = mapURL($dir);
                $urlis = str_replace("\\", '/', $urlis);
                #AAAA
                $filu_css = $k % 2 ? 'c' : 'd';
                $ext = substr(strrchr($dir . '/' . $lasitfailus[$k], '.'), 1);
                $skat_img = $shimg == 1 ? '<img src="' . $pats . '?' . en_crypt('icon=view') . '" alt="" />' : '[view]';
                $moz_icon = $shimg == 1 ? '<img src="moz-icon://.' . $ext . '?size=16" alt="' . $ext . '" />' : '[' . $ext . ']';
                $skat = '<a href="' . $urlis . '/' . $lasitfailus[$k] . '">' . $skat_img . '</a> ';
                $druka = '<div class="' . $filu_css . '" onmouseover="fa(this);" onmouseout="fb(this);"> ' . $skat . $sleja . ' ' . $moz_icon . '<em class="dir">' . $saite . '</em><em class="chmod">' . substr(base_convert(fileperms($dir . '/' . $lasitfailus[$k]), 10, 8), 3) . '</em><em class="kb">' . format_bytes(filesize($dir . '/' . $lasitfailus[$k])) . '</em><em class="data">' . gmdate('[ Y-m-d, H:i:s ]', 2 * 3600 + filemtime($dir . '/' . $lasitfailus[$k])) . '</em>  <del title="dzēst!">' . $saitedz . '</del></div>
';
                echo $druka;
            }
        }
        closedir($parbaudadir);
    }
}
Example #24
0
<div>
<a id="linkaccount" href = "linkaccount.php">Link Account</a>
<a id="logout" href = "logout.php">Log Out</a>
</div>
<div id="accountInfo">
<?php 
#grabs quota from each account and shows you how much space you have used so far
$accounts = query("SELECT * FROM dropbox_accounts WHERE id = ?", $_SESSION["id"]);
foreach ($accounts as $account) {
    $client = new dbx\Client($account["dropbox_accessToken"], "PHP");
    $userData = $client->getAccountInfo();
    $email = $account["dropbox_email"];
    $normalbytes = $userData['quota_info']['normal'];
    $quotabytes = $userData['quota_info']['quota'];
    #format_bytes is in config.php converts bytes to more readable format.
    print "<br><a class=\"emaillink\" href=\"index.php?{$email}&/\">" . $email . '</a>:' . '</br>' . format_bytes($normalbytes) . ' out of ' . format_bytes($quotabytes) . '</br>';
}
?>
</div>
<!--example from plupload, filelist will show if you dont have flash, or HTML5-->
<div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
<br />
<!--clicking on of these will trigger actions in the script below-->
<div id="container">
    <a id="pickfiles" href="javascript:;">[Select files]</a> 
    <a id="uploadfiles" href="javascript:;">[Upload files]</a>
</div>

<br />
<!--where the files you have uploaded will show up-->
<pre id="console"></pre>
Example #25
0
" />
<?php 
        }
        $c++;
        ?>
					</td>
					<td><?php 
        echo $date;
        ?>
</td>
					<td><?php 
        echo $version['version'];
        ?>
</td>
					<td><?php 
        echo format_bytes($version['filesize']);
        ?>
</td>
					<td><?php 
        echo htmlspecialchars($version['description']);
        ?>
</td>
					<td>
						<a href="diag_confbak.php?newver=<?php 
        echo $version['time'];
        ?>
" class="btn btn-xs btn-success" 
							onclick="return confirm('<?php 
        echo gettext("Are you sure you want to replace the current configuration with this backup?");
        ?>
')">
Example #26
0
function get_interfacestats()
{
    global $config;
    //build interface list for widget use
    $ifdescrs = get_configured_interface_list();
    $array_in_packets = array();
    $array_out_packets = array();
    $array_in_bytes = array();
    $array_out_bytes = array();
    $array_in_errors = array();
    $array_out_errors = array();
    $array_collisions = array();
    $array_interrupt = array();
    $new_data = "";
    //build data arrays
    foreach ($ifdescrs as $ifdescr => $ifname) {
        $ifinfo = get_interface_info($ifdescr);
        $new_data .= "{$ifinfo['inpkts']},";
        $new_data .= "{$ifinfo['outpkts']},";
        $new_data .= format_bytes($ifinfo['inbytes']) . ",";
        $new_data .= format_bytes($ifinfo['outbytes']) . ",";
        if (isset($ifinfo['inerrs'])) {
            $new_data .= "{$ifinfo['inerrs']},";
            $new_data .= "{$ifinfo['outerrs']},";
        } else {
            $new_data .= "0,";
            $new_data .= "0,";
        }
        if (isset($ifinfo['collisions'])) {
            $new_data .= htmlspecialchars($ifinfo['collisions']) . ",";
        } else {
            $new_data .= "0,";
        }
    }
    //end for
    return $new_data;
}
    foreach ($ifdescrs as $ifname) {
        print "<th>" . $ifname . "</th>";
    }
    print "</tr>";
    print "</thead>";
    print "<tbody>";
    foreach ($rows as $key => $name) {
        print "<tr>";
        print "<td><b>" . $name . "</b></td>";
        foreach ($ifdescrs as $ifdescr => $ifname) {
            $ifinfo = get_interface_info($ifdescr);
            if ($ifinfo['status'] == "down") {
                continue;
            }
            $ifinfo['inbytes'] = format_bytes($ifinfo['inbytes']);
            $ifinfo['outbytes'] = format_bytes($ifinfo['outbytes']);
            print "<td>" . (isset($ifinfo[$key]) ? htmlspecialchars($ifinfo[$key]) : 'n/a') . "</td>";
        }
        print "</td>";
        print "</tr>";
    }
    print "</tbody>";
    exit;
}
?>
<table id="iftbl" class="table table-striped table-hover">
	<tr><td><?php 
echo gettext("Retrieving interface data");
?>
</td></tr>
</table>
Example #28
0
function track_data()
{
    $tracks = CMP3File::get_tracks(TRACKS_LOCATION);
    $data = ["total_tracks" => count($tracks), "tracks_location" => TRACKS_LOCATION, "tracks_size" => format_bytes(folder_size(TRACKS_LOCATION))];
    return $data;
}
                            <td class="num">
                                <input class="ids" checked="chedked" type="checkbox" name="tables[]" value="<?php 
            echo $table["name"];
            ?>
">
                            </td>
                            <td><?php 
            echo $table["name"];
            ?>
</td>
                            <td><?php 
            echo $table["rows"];
            ?>
</td>
                            <td><?php 
            echo format_bytes($table["data_length"]);
            ?>
</td>
                            <td><?php 
            echo $table["create_time"];
            ?>
</td>
                            <td class="info">未备份</td>
                            <td class="action">
                                <a class="ajax-get no-refresh" href="<?php 
            echo U('optimize?tables=' . $table['name']);
            ?>
">优化表</a>&nbsp;
                                <a class="ajax-get no-refresh" href="<?php 
            echo U('repair?tables=' . $table['name']);
            ?>
<?php 
}
?>
	   </nav>
<?php 
// The notes displayed on the page are large, the page content comparitively small. A "Note" button
// is provided so that you only see the notes if you ask for them
?>
<div id="infoblock" class="panel panel-default">
	<div class="panel-heading"><h2 class="panel-title">Notes</h2></div>
	<div class="panel-body">
	<?php 
echo gettext("Any files that you upload here with the filename prefix of captiveportal- will " . "be made available in the root directory of the captive portal HTTP(S) server. " . "You may reference them directly from your portal page HTML code using relative paths. " . "Example: you've uploaded an image with the name 'captiveportal-test.jpg' using the " . "file manager. Then you can include it in your portal page like this:");
?>
<br /><br />
	<pre>&lt;img src=&quot;captiveportal-test.jpg&quot; width=... height=...&gt;</pre><br />
	<?php 
echo gettext("In addition, you can also upload .php files for execution.\tYou can pass the filename " . "to your custom page from the initial page by using text similar to:");
?>
<br /><br />
	<pre>&lt;a href="/captiveportal-aup.php?zone=$PORTAL_ZONE$&amp;redirurl=$PORTAL_REDIRURL$"&gt;<?php 
echo gettext("Acceptable usage policy");
?>
&lt;/a&gt;</pre><br />
	<?php 
echo sprintf(gettext("The total size limit for all files is %s."), format_bytes($g['captiveportal_element_sizelimit']));
?>
	</div>
</div>
<?php 
include "foot.inc";