diff --git a/admin.php b/admin.php new file mode 100755 --- /dev/null +++ b/admin.php @@ -0,0 +1,161 @@ +. + */ + + include_once 'inc/class.page.php'; + $scripts = array('jQuery','jQueryUI'); + $adminpage = new page('Administration',$scripts); + + if(!isset($admin_pass)) { + echo "

Administration password not configured. See config.inc for more information.

"; + $adminpage->foot(); + } + + // Force authentication + if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_PW'] != $admin_pass) { + header('WWW-Authenticate: Basic realm="My Realm"'); + header('HTTP/1.0 401 Unauthorized'); + echo '

You must authenticate to view this page.

'; + $adminpage->foot(); + exit; + } + + function isBeforeDate($first, $reference) { + return true; + } + + function emptySavedDir($todate = null) { + // Empty the saved_schedules directory + $dir = "saved_schedules"; + if(!is_dir($dir)) { + echo "

{$dir}
is not a valid directory!"; + return; + } + + // Do this the new fun php5 OO-way + foreach(new DirectoryIterator($dir) as $file) { + $isBeforeDate = isBeforeDate($file->getCTime, $todate); + if(!$todate || $isBeforeDate) { + if(is_numeric($file->getFilename())){ + // unlink($dir . '/' . $file->getFilename()); + echo "

Erased file: " . $dir . '/' . $file->getFilename() . "

"; + } + } + } + } + + function checkAction() { + $result = ''; + if(isset($_GET['rehash'])) { + // Run the rehash + $result = 'Rehash Complete'; + } + else if(isset($_GET['purgetodate'])) { + // Purge saved schedule cache up to date + emptySavedDir($_GET['purgetodate']); + $result = 'Purged all saved schedules up to ' . $_GET['purgetodate']; + } + else if(isset($_GET['purge'])) { + // Purge the saved schedule cache + emptySavedDir(); + $result = 'Purge Complete'; + } + return $result; + } + + function getLastRehash(){ + $stats = stat("cache/schools"); + if(!$stats){ + return "never"; + } + return date("F j, Y, g:i a", $stats[9]); + } + + function getSchools() { + if(!stat("cache/schools")){ + return false; + } + + $schoolsArr = unserialize(file_get_contents("cache/schools")); + return $schoolsArr; + } + + function schoolsDropList(){ + $schools = getSchools(); + echo '"; + } + + function getNumSaved(){ + return file_get_contents("saved_schedules/lastid"); + } + +?> + + +' . $res . ' (x)

'; + } +?> + + + + + +

Update

+

You are currently running version VERSION. The latest available release is VERSION.

+ +

Rehash

+

Last full rehash ocurred on .

+ + +

Purge

+

The cache currently holds schedules.

+ + +foot();