Location: PHPKode > projects > Whiteboard > whiteboard1.0.3/program/restricted/clearsystem.php
<?php
/* Whiteboard Courseware System v1.0.3
   Copyright (C) 2002-2003 Todd Templeton

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 2 of the License, or (at your option)
   any later version.

   This program 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 General Public License for
   more details.

   You should have received a copy of the GNU General Public License along with
   this program; if not, write to the Free Software Foundation, Inc., 59 Temple
   Place, Suite 330, Boston, MA 02111-1307 USA

   Contact info: my paper address changes often, but you can contact me at
   hide@address.com
*/


define ("MODULE", "clearsystem");
define ("PATHTOHTTPROOT", "../");

require (PATHTOHTTPROOT . "include/include.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Clear System</title>
</head>
<body>
<?php
if (!$priv['isadmin']) {
  print ("permission denied<br>\n");
  exit ();
}
if (!defined ("ALLOWTOCLEARSYSTEM") || ($netid != ALLOWTOCLEARSYSTEM)) {
  print ("permission denied<br>\n");
  exit ();
}
if (isset ($action) && ($action == "clear")) {
  $tables = gettables (false, false);
  if (is_array ($tables)) {
    reset ($tables);
    while ($elementinfo = each ($tables)) {
      $key = $elementinfo['key'];
      if (!droptable ($key))
        print ("unable to drop '" . $key . "'<br>\n");
    }
  }
  if (is_bool ($dir = @opendir (COURSESDIR)))
    print ("unable to open courses directory '" . COURSESDIR . "'<br>\n");
  else {
    rewinddir ($dir);
    while ($file = readdir ($dir)) {
      if (($file != ".") && ($file != "..")) {
        $filepath = COURSESDIR . "/" . $file;
        @exec (RMCOMMAND . " -rf " . escapeshellarg ($filepath));
        if (file_exists ($filepath))
          print ("unable to delete '" . COURSESDIR . "/" . $file . "'<br>\n");
      }
    }
  }
  @unlink (ERRORLOG);
  if (file_exists (ERRORLOG))
    print ("unable to delete error log '" . ERRORLOG . "'<br>\n");
  print (linktags (PATHTOHTTPROOT . "restricted/administrators.php", "done", false));
  print ("\n");
}
else {
  print (linktags ("clearsystem.php?action=clear", "Clear System", false));
  print ("\n");
}
?>
</body>
</html>
Return current item: Whiteboard