summaryrefslogtreecommitdiffstats
path: root/modules-available/dozmod/page.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/dozmod/page.inc.php')
-rw-r--r--modules-available/dozmod/page.inc.php67
1 files changed, 5 insertions, 62 deletions
diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php
index 67b791d1..4a43d881 100644
--- a/modules-available/dozmod/page.inc.php
+++ b/modules-available/dozmod/page.inc.php
@@ -5,7 +5,8 @@ class Page_DozMod extends Page
/** @var bool true if we have a proper subpage */
private $haveSubPage = false;
- private $validSections = ['expiredimages', 'mailconfig', 'templates', 'runtimeconfig', 'users', 'actionlog', 'networkshares', 'ldapfilters', 'runscripts', 'networkrules'];
+ private $validSections = ['expiredimages', 'mailconfig', 'templates', 'runtimeconfig', 'users', 'actionlog',
+ 'networkshares', 'ldapfilters', 'runscripts', 'networkrules', 'special'];
private $section;
@@ -15,15 +16,13 @@ class Page_DozMod extends Page
return;
/* different pages for different sections */
$this->section = Request::any('section', false, 'string');
- if ($this->section === 'blockstats') // HACK HACK
- return;
if ($this->section === false) {
foreach ($this->validSections as $this->section) {
if (User::hasPermission($this->section . '.*'))
break;
}
} elseif (!in_array($this->section, $this->validSections)) {
- Util::traceError('Invalid section: ' . $this->section);
+ ErrorHandler::traceError('Invalid section: ' . $this->section);
}
// Check permissions
User::assertPermission($this->section . '.*');
@@ -68,8 +67,8 @@ class Page_DozMod extends Page
/* add sub-menus */
foreach ($this->validSections as $section) {
- if (User::hasPermission($section . '.*')) {
- Dashboard::addSubmenu('?do=dozmod&section=' . $section, Dictionary::translate('submenu_' . $section, true));
+ if ($section !== 'special' && User::hasPermission($section . '.*')) {
+ Dashboard::addSubmenu('?do=dozmod&section=' . $section, Dictionary::translate('submenu_' . $section));
}
}
}
@@ -79,31 +78,10 @@ class Page_DozMod extends Page
/* different pages for different sections */
if ($this->haveSubPage !== false) {
SubPage::doRender();
- return;
- }
-
- if ($this->section === 'blockstats') {
- $this->showBlockStats();
}
}
- private function showBlockStats()
- {
- $res = Database::simpleQuery("SELECT blocksha1, blocksize, Count(*) AS blockcount FROM sat.imageblock"
- . " GROUP BY blocksha1, blocksize HAVING blockcount > 1 ORDER BY blockcount DESC, blocksha1 ASC");
- $data = array('hashes' => array());
- $spaceWasted = 0;
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $row['hash_hex'] = bin2hex($row['blocksha1']);
- $row['blocksize_s'] = Util::readableFileSize($row['blocksize']);
- $data['hashes'][] = $row;
- $spaceWasted += $row['blocksize'] * ($row['blockcount'] - 1);
- }
- $data['spacewasted'] = Util::readableFileSize($spaceWasted);
- Render::addTemplate('blockstats', $data);
- }
-
protected function doAjax()
{
User::load();
@@ -111,43 +89,8 @@ class Page_DozMod extends Page
if ($this->haveSubPage !== false) {
SubPage::doAjax();
- return;
}
- $action = Request::post('action');
-
- if ($action === 'getblockinfo') {
- $this->ajaxGetBlockInfo();
- }
- }
-
- private function ajaxGetBlockInfo()
- {
- $hash = Request::any('hash', false, 'string');
- $size = Request::any('size', false, 'string');
- if ($hash === false || $size === false) {
- die('Missing parameter');
- }
- if (!is_numeric($size) || strlen($hash) !== 40 || !preg_match('/^[a-f0-9]+$/i', $hash)) {
- die('Malformed parameter');
- }
- $res = Database::simpleQuery("SELECT i.displayname, v.createtime, v.filesize, Count(*) AS blockcount FROM sat.imageblock ib"
- . " INNER JOIN sat.imageversion v USING (imageversionid)"
- . " INNER JOIN sat.imagebase i USING (imagebaseid)"
- . " WHERE ib.blocksha1 = :hash AND ib.blocksize = :size"
- . " GROUP BY ib.imageversionid"
- . " ORDER BY i.displayname ASC, v.createtime ASC",
- array('hash' => hex2bin($hash), 'size' => $size), true);
- if ($res === false) {
- die('Database error: ' . Database::lastError());
- }
- $data = array('rows' => array());
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $row['createtime_s'] = date('d.m.Y H:i', $row['createtime']);
- $row['filesize_s'] = Util::readableFileSize($row['filesize']);
- $data['rows'][] = $row;
- }
- die(Render::parse('blockstats-details', $data));
}
}