Пример #1
0
/* print "</pre>"; */
// include all necessary files
include "includes.inc.php";
if ($_SESSION['ltype'] != 'admin') {
    // take them right to the user lookup page
    header("Location: username_lookup.php");
    exit;
}
db_connect($dbhost, $dbuser, $dbpass, $dbdb);
// what's the action?
$curraction = $_REQUEST['action'];
$id = $_REQUEST['id'];
if ($curraction == 'del') {
    $id = $_REQUEST['id'];
    if ($id > 0) {
        course::delCourse($id);
        $message = "Class ID {$id} deleted successfully.";
    }
}
// if they want to add a class...
if ($curraction == 'add') {
    // check for errors first
    if (course::courseExists(generateCodeFromData($_REQUEST['department'], $_REQUEST['number'], $_REQUEST['section'], $_REQUEST['semester'], $_REQUEST['year']))) {
        error("A class with that code already exists.");
    }
    if (!ereg("^[a-zA-Z0-9\\._\\-]{1,}\$", $_REQUEST['external_id'])) {
        error("You must enter an external ID. Only combination of charactors \"a-z\" and \"A-Z\", numbers, and the charactors '-_.' are allowed.");
    }
    if (!ereg("^[a-zA-Z]{1,}\$", $_REQUEST['department'])) {
        error("You must enter a department. Only charactors \"a-z\" and \"A-Z\" are allowed.");
    }