Example #1
0
     }
     // print a reply form
     print "<form action=\"forum.php\" method=\"post\" name=\"replyform\"><tr><td><hr class=\"mainpagehr\" /></td></tr><tr><td>Reply:</td></tr><tr><td><textarea name=\"body\" rows=\"10\" cols=\"28\"></textarea></td></tr><tr><td><input type=\"hidden\" name=\"classid\" value=\"{$class_id}\" /><input type=\"hidden\" name=\"topicid\" value=\"{$topic_ID}\" /><input type=\"submit\" name=\"addpost\" value=\"add post\" /></td></tr><tr><td>Back to the <a href=\"forum.php?id={$class_id}\" title=\"forum\">forum</a>?</td></tr></form>";
 } else {
     $tdcolour = 0;
     $topics = @query("SELECT * FROM `topics` WHERE `class_ID`='{$class_id}' ORDER BY `ID`") or die("Error getting topics from the database.");
     while ($row = result($topics)) {
         $id = $row->ID;
         $name = stripslashes($row->name);
         print "<tr class=\"tdcolour{$tdcolour}\"><td><a href=\"forum.php?id={$class_id}&topic={$id}\" title=\"{$name}\">{$name}</a></td>";
         // if the user is an administrator or the class's teacher, allow him or her to delete the topic (and all associated posts)
         if (user_type() == "admin" or user_type() == "teacher") {
             $good = 1;
             if (user_type() == "teacher") {
                 // see if they teach the class
                 $class_data = get_class_data($class_id);
                 $class_data = explode("::", $class_data);
                 $teacher_id = $class_data[1];
                 if ($teacher_id != $_SESSION['id']) {
                     $good = 0;
                 }
             }
             if ($good == 1) {
                 print "<td><a href=\"forum.php?id={$class_id}&delete&t={$id}\" title=\"delete this topic\">delete</a></td>";
             }
         }
         print "</tr>\n";
         if ($tdcolour == 0) {
             $tdcolour++;
         } else {
             $tdcolour = 0;
Example #2
0
/**
 * gets a user's latest news posts
 *
 * prints $user's $number latest news posts from his or her classes
 */
function display_latest_news($user, $number)
{
    // get the classes the user is currently in
    $users_classes = classes_by_semester($user, current_semester);
    // get rid of the extra comma
    $users_classes = substr($users_classes, 0, strlen($users_classes) - 1);
    $classes = explode(",", $users_classes);
    foreach ($classes as $class) {
        // get the class's name
        $class_data = get_class_data($class);
        $class_data = explode("::", $class_data);
        $class_name = $class_data[0];
        if (get_news($class, $number) != "No news.") {
            print "<p class=\"class_name\">{$class_name}</p>";
            print "<ul>";
            $news = get_news($class, $number);
            $news_post = explode("_____", $news);
            foreach ($news_post as $the_news) {
                if ($the_news != "") {
                    $the_news = explode("::::", $the_news);
                    print "<li>" . $the_news[2] . " - " . $the_news[3] . "</li>";
                }
            }
        }
        print "</ul>";
    }
}
Example #3
0
 }
 $actual_password = gen_rss_pass($user);
 if ($actual_password != escape_string($_GET['p'])) {
     die("Incorrect password.");
 }
 $number = 3;
 $lastbuild = time();
 rss_header("latest class news", "latest news for various classes", server_root . "news.php", $lastbuild);
 // get the classes the user is currently in
 $users_classes = classes_by_semester($user, current_semester);
 // get rid of the extra comma
 $users_classes = substr($users_classes, 0, strlen($users_classes) - 1);
 $classes = explode(",", $users_classes);
 foreach ($classes as $class) {
     // get the class's name
     $class_data = get_class_data($class);
     $class_data = explode("::", $class_data);
     $class_name = $class_data[0];
     $news = get_news($class, $number);
     if ($news != "No news.") {
         $news_post = explode("_____", $news);
         foreach ($news_post as $the_news) {
             if ($the_news != "") {
                 $the_news = explode("::::", $the_news);
                 $timestamp = $the_news[1];
                 $subject = $the_news[2];
                 $body = $the_news[3];
                 rss_item($class_name . ":  " . $subject, $body, server_root . "news.php", $timestamp);
             }
         }
     }
Example #4
0
 $teacher_name = @query("SELECT `firstname`,`surname` FROM `users` WHERE `ID`='{$teacher}' LIMIT 1") or die("Error getting the teacher's name.");
 $result = result($teacher_name);
 $teacher_name = stripslashes($result->firstname) . " " . stripslashes($result->surname);
 $room = stripslashes($row->room);
 $period = $row->period;
 $semester = $row->semester;
 print "<div class=\"class_info\"><p>{$class_name}, taught by <a href=\"messages.php?compose&amp;id={$teacher}\" title=\"Send {$teacher_name} a message.\">{$teacher_name}</a>";
 print "</p>";
 // check if the requested grading period is actually when the class takes places
 if (isset($_GET['gp']) && is_numeric($_GET['gp'])) {
     $grading_period = escape_string($_GET['gp']);
 } else {
     $grading_period = current_semester;
 }
 // get the grading periods the class takes place in
 $classdata = get_class_data($requested_class);
 $classdata = explode(",", $classdata);
 if ($grading_period == current_semester) {
     $this_semester = $classdata[4];
     $n = 5;
     $other_semesters = "";
     while (isset($classdata[$n])) {
         $other_semesters .= "<a href=\"classes.php?class={$requested_class}&amp;gp={$classdata[$n]}\" title=\"assignments for grading period {$classdata[$n]}\">{$classdata[$n]}</a> ";
         $n++;
     }
 } else {
     $this_semester = $grading_period;
     $n = 4;
     $other_semesters = "";
     while (isset($classdata[$n])) {
         if ($classdata[$n] != $this_semester) {