Files
        @ afd821c14868
    
        
              Branch filter: 
        
    Location: SlatePermutate/admin.php - annotation
        
            
            afd821c14868
            4.6 KiB
            text/x-php
        
        
    
    Added tip bubbles to Class ID fields as a sample of functionality we should implement so users know what they need to do
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162  | 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 6c07ae1b7762 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 6c07ae1b7762 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 2105c4db86cf 0b3a61f80ac3 0b3a61f80ac3 afd821c14868 0b3a61f80ac3 0b3a61f80ac3 afd821c14868 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 afd821c14868 0b3a61f80ac3 0b3a61f80ac3 afd821c14868 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3 0b3a61f80ac3  | <?php
/*
 * Copyright 2010 Nathan Gelderloos, Ethan Zonca, Nathan Phillip Brink
 *
 * This file is part of SlatePermutate.
 *
 * SlatePermutate is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * SlatePermutate is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 */
  include_once 'inc/class.page.php';
  $scripts = array('jQuery','jQueryUI'); 
  $adminpage = new page('Administration',$scripts);
  if(!isset($admin_pass)) {
    echo "<p>Administration password not configured. See config.inc for more information.</p>";
    $adminpage->foot();
    exit;
  }
  // Force authentication
  else if (!isset($_SERVER['PHP_AUTH_USER']) || (!isset($_SERVER['PHP_AUTH_PW'])) || $_SERVER['PHP_AUTH_PW'] != $admin_pass) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo '<p>You must authenticate to view this page.</p>';
    $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 "<p><pre>{$dir}</pre> 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 "<p>Erased file: " . $dir . '/' . $file->getFilename() . "</p>";
        } 
      }
    }
  }
  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 '<select>';
    foreach($schools['list'] as $school){
      if(!$school['name'] != "Generic College") {
        echo '<option ';
        if(!$school['crawled']) {
          echo 'class="bold" ';
        }
        echo 'value="' . $school['name'] . '">';
        echo $school['name'];
        
        
        echo "</option>";
      }
    }
    echo "</select>";
  }
  function getNumSaved(){
    return file_get_contents("saved_schedules/lastid");
  }
?>
<?php /* Check if authorized */ 
  $res = checkAction();
  if($res != '') {
    echo '<p><em>' . $res . '</em> <a href="admin.php">(x)</a></p>';
  }
?>
<!-- Move to pagegen class instantiation -->
<script>
	$(function() {
		$( "#datepicker" ).datepicker();
                $( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
	});
</script>
<h3>Update</h3>
<p>You are currently running version <?php echo SP_PACKAGE_VERSION ?>. The latest available release is VERSION.</p>
<h3>Rehash</h3>
<p>Last rehash ocurred on  <?php echo getLastRehash() ?>.</p>
<ul>
  <li><a href="admin.php?rehash">Rehash All Institutions</a></li>
  <li><form action="admin.php">Rehash schedules for <?php schoolsDropList(); ?> <input type="submit" value="Go »" /> </form></li>
</ul>
<h3>Purge</h3>
<p>The cache currently contains <?php echo getNumSaved(); ?> schedules.</p>
<ul>
  <li><a href="admin.php?purge">Purge Entire Cache</a></li>
  <li><form action="admin.php">Purge cache up to <input type="text" name="purgetodate" size="8" id="datepicker"/> <input type="submit" value="Go »" /></form></li>
</ul>
<?php
$adminpage->foot();
 |