public function backupAction() { //数据备份 $total = ceil(dircount() / $this->config->pageNum); // $GLOBALS['config']['pageNum']); $this->view->total = $total; if ($this->request->isPost()) { $this->view->disable(); $post = json_decode(file_get_contents("php://input"), true); if (isset($post['back'])) { databackup(); if (dircount() % $this->config->pageNum == 1) { $total++; } $p = $total; $this->common->syslog("手动备份数据库"); } else { $p = $post['p']; } $file = fileList($p); $i = 0; $filelist = array(); foreach ($file as $v) { if ($i++ < $this->config->pageNum) { $info['filename'] = $v; $info['path'] = $this->config->dataDir . $v; $info['mtime'] = date("Y-m-d H:i:s", filemtime(getcwd() . $info['path'])); array_push($filelist, $info); } } $info = array('total' => $total, 'info' => $filelist); echo json_encode($info); } }
$hiddencomtotal = $DB->result($DB->query("SELECT COUNT(commentid) FROM {$db_prefix}comments WHERE visible='0'"), 0); $tagtotal = $DB->result($DB->query("SELECT COUNT(mid) FROM {$db_prefix}metas WHERE type='tag'"), 0); $linktotal = $DB->result($DB->query("SELECT COUNT(linkid) FROM {$db_prefix}links"), 0); $server['datetime'] = sadate('Y-m-d H:i:s'); $server['software'] = $_SERVER['SERVER_SOFTWARE']; if (function_exists('memory_get_usage')) { $server['memory_info'] = get_real_size(memory_get_usage()); } $mysql_version = mysql_get_server_info(); $mysql_runtime = ''; $query = $DB->query("SHOW STATUS"); while ($r = $DB->fetch_array($query)) { if (eregi("^uptime", $r['Variable_name'])) { $mysql_runtime = $r['Value']; } } $mysql_runtime = format_timespan($mysql_runtime); require_once SABLOG_ROOT . 'include/func/attachment.func.php'; $attachdir = SABLOG_ROOT . $options['attachments_dir']; $attachsize = dirsize($attachdir); $dircount = dircount($attachdir); $realattachsize = is_numeric($attachsize) ? sizecount($attachsize) : '不详'; $stats = $DB->fetch_one_array("SELECT count(attachmentid) as count, sum(filesize) as sum FROM {$db_prefix}attachments"); $stats['count'] = $stats['count'] != 0 ? $stats['count'] : 0; $stats['sum'] = $stats['count'] == 0 ? '0 KB' : sizecount($stats['sum']); $now_version = rawurlencode($SABLOG_VERSION); $now_release = rawurlencode($SABLOG_RELEASE); $now_hostname = rawurlencode($_SERVER['HTTP_HOST']); $now_url = rawurlencode($options['url']); cpheader(); include template('main');