$leftPercentage = round($capacity / $total * 100); $lastRun = isset($settings['last_run']) ? $settings['last_run'] : 'Not available'; /** * Send warning if the storage left is <= NOTIFY_MIN_SPACE_PERCENTAGE * OTHERWISE * send notification if change is > NOTIFY_PERCENTAGE_CHANGE */ $cdn->active = true; if ($leftPercentage <= NOTIFY_MIN_SPACE_PERCENTAGE) { echo ' - [WARNING] Storage critical: ' . $cdn->capacity_free_gb . '/' . $total . 'GB left' . chr(10); mailAdmins('WARNING: STORAGE ALMOST EMPTY ' . $cdn->name, "Yo, bitches!\n\nWARNING: content-provider \"{$cdn->name}\" has almost exceeded it's disk space and has disabled automatically.\n\nLast recorded date: {$lastRun}\nLast recorded diskspace: " . round($cdn->capacity_free_gb) . "GB\nDiskspace available: " . round($capacity) . "GB\nDiskspace limit: " . round($total) . "GB\n\n- The Ninja Robot"); $cdn->active = false; } else { if ($cdn->capacity_free_gb > 0) { $beforePercentage = round($cdn->capacity_free_gb / $total * 100); $change = $leftPercentage - $beforePercentage; echo ' - [INFO] Storage changed by ' . $change . '%' . chr(10); if ($change >= NOTIFY_PERCENTAGE_CHANGE) { mailAdmins('Storage notification for ' . $cdn->name, "Yo, bitches!\n\nPlease be aware that content-provider \"{$cdn->name}\" has expanded it's storage by {$change}%.\n\nLast recorded date: {$lastRun}\nLast recorded diskspace: " . round($cdn->capacity_free_gb) . "GB\nDiskspace available: " . round($capacity) . "GB\nDiskspace limit: " . round($total) . "GB\nIncrease percentage: {$change}%\n\nA warning will be sent when the storage-provider has " . NOTIFY_MIN_SPACE_PERCENTAGE . "% storage left.\n\n- The Ninja Robot"); } } } echo chr(10); $cdn->capacity_free_gb = $capacity; $cdn->capacity_max_gb = $total; $cdn->update(); } // Update settings $settings['last_run'] = \Pecee\Date::toDateTime(); writeSettings();
# # # # # # # # require "../settings.php"; if ($_POST) { switch ($_POST["key"]) { case "confirm": $OUTPUT = confirmSettings($_POST); break; case "write": $OUTPUT = writeSettings($_POST); break; default: $OUTPUT = editSettings(); } } else { # print form for data entry $OUTPUT = editSettings(); } require "../template.php"; ## # Functions ## # form to enter new data function editSettings() {
function settingsPage() { if (!isLogged()) { header('Location: ' . Path::signin() . '&target=settings'); exit; } global $tpl; global $_CONFIG; if (!empty($_POST)) { if (!empty($_POST['token']) && acceptToken($_POST['token'])) { if (!empty($_POST['title'])) { $_CONFIG['title'] = htmlspecialchars($_POST['title']); } if (!empty($_POST['password'])) { $_CONFIG['hash'] = sha1($_CONFIG['login'] . $_POST['password'] . $_CONFIG['salt']); } if (!empty($_POST['locale'])) { $_CONFIG['locale'] = array_key_exists($_POST['locale'], $_CONFIG['locales']) ? $_POST['locale'] : 'en'; } if (!empty($_POST['pagination'])) { $_CONFIG['pagination'] = max(2, $_POST['pagination'] + 0); } if (!empty($_POST['robots'])) { $_CONFIG['robots'] = parseRobots(in_array('index', $_POST['robots']), in_array('follow', $_POST['robots']), in_array('archive', $_POST['robots'])); } else { $_CONFIG['robots'] = parseRobots(false, false, false); } $_CONFIG['author'] = empty($_POST['author']) ? $_CONFIG['login'] : htmlspecialchars(trim($_POST['author'])); writeSettings(); header('Location: ' . Path::settings() . '&update'); exit; } errorPage('The received token was empty or invalid.', 'Invalid security token'); } $tpl->assign('page_title', 'Settings'); $tpl->assign('menu_links', Path::menu('settings')); $tpl->assign('menu_links_admin', Path::menuAdmin('admin')); $tpl->assign('username', $_CONFIG['login']); $tpl->assign('locales', displayLocales($_CONFIG['locale'])); $tpl->assign('robots', getRobots(ROBOTS)); $tpl->assign('token', getToken()); $tpl->draw('admin.settings'); exit; }
$writeSettings = false; this_session_start(); if (login_setup() == true) { header('Location index.php'); } if (login_setup() == false) { if (isset($_POST['username'], $_POST['password'], $_POST['password2'])) { if ($_POST['password'] == $_POST['password2']) { $settings['loginUsername'] = $_POST['username']; $salt = md5(uniqid(mt_rand(1, mt_getrandmax()))); $settings['loginSalt'] = $salt; $password = md5($_POST['password'] . $salt); $settings['loginPassword'] = $password; $settings['loginTry'] = 0; ksort($settings); writeSettings($settings); header('Location: login.php?newuser'); } else { header('Location: setup.php?error=1'); } } include 'head.php'; include 'menu-nologin.php'; ?> <div class="container"> <style> .form-signin {