Пример #1
0
    if (!isset($_POST['body']) or $_POST['body'] == "") {
        cust_die("You must submit the body.");
    }
    // see if they can add news to the class (not needed if they're an admin)
    if (user_type() != "admin") {
        $user_id = $_SESSION['id'];
        connect_sql();
        $query = @query("SELECT 1 FROM `classes` WHERE `ID`='{$class_id}' AND `teacher`='{$user_id}' LIMIT 1") or die("Error checking the database.");
        if (num_rows($query) == 0) {
            cust_die("You may not add news to that class.");
        }
        disconnect_sql();
    }
    $subject = escape_string(htmlspecialchars($_POST['subject']));
    $body = escape_string(htmlspecialchars($_POST['body']));
    $timestamp = time();
    connect_sql();
    add_news_item($class_id, $subject, $body);
    disconnect_sql();
    print "The news item was added.  <a href=\"news.php?add\" title=\"add a news item\">Add another</a>?";
} else {
    any_errors();
    if (user_type() == "user") {
        display_latest_news($_SESSION['id'], 3);
    } else {
        print "You can add or edit news articles by following the respective links on your menu.";
    }
}
print "</div>";
display_copyright();
display_footer();
<section class="mt-md">
	<div class="container">
		<div class="row">
			<div class="col-md-7">
				<section class="noticias noticias-home">
					<?php 
$sticky_posts = display_sticky_news();
?>
					<?php 
display_latest_news($sticky_posts);
?>
					<a href="/noticias"><strong>Todas as Notícias</strong></a>
				</section>
			</div>
			<div class="col-md-5">
				<?php 
dynamic_sidebar('barra-lateral');
?>
			</div>
		</div>
	</div>
</section>
Пример #3
0
/**
 * displays the content for a user, depending upon what type of user he
 * or she is
 */
function display_content()
{
    if (user_type() == "user") {
        // print his or her latest grades, etc
        print "<div class=\"grades\"><p class=\"big\">Latest Grades&nbsp;<a href=\"classes.php?xml&amp;u={$_SESSION['id']}&p=" . gen_rss_pass($_SESSION['id']) . "\" title=\"latest grades feed\"><img src=\"images/xml.gif\" alt=\"latest grades via rss\" /></a></p>";
        // get their (5) latest grades
        display_latest_grades($_SESSION['id'], 5, "all");
        print "<p class=\"big\">Latest News&nbsp;<a href=\"news.php?xml&amp;u={$_SESSION['id']}&p=" . gen_rss_pass($_SESSION['id']) . "\" title=\"latest news feed\"><img src=\"images/xml.gif\" alt=\"latest news via rss\" /></a></p>";
        // get the user's class's latest news post
        display_latest_news($_SESSION['id'], 1);
        print "</div>";
        print "<p class=\"big\">Classes</p>";
        print_students_classes($_SESSION['id']);
    } elseif (user_type() == "teacher") {
        // eventually figure out what should go here.  suggestions?
        print "Use the menu above.";
    } elseif (user_type() == "admin") {
        // eventually figure out what should go here.  suggestions?
        print "Use the menu above to administer as you will.";
    } elseif (user_type() == "parent") {
        connect_sql();
        $parentID = $_SESSION['id'];
        // see which students the parent is a parent of, and print info about their grades.
        // the following will eventually be turned into a function
        $students = @query("SELECT `students` FROM `parents` WHERE `parent_ID`='{$parentID}'") or die("Error checking the database.");
        while ($row = result($students)) {
            $student = explode(",", $row->students);
            $i = 0;
            foreach ($student as $the_student) {
                // get his or her name
                $student_name = @query("SELECT `firstname`, `surname` FROM `users` WHERE `ID`='{$the_student}' LIMIT 1") or die("Error checking the database.");
                while ($row2 = result($student_name)) {
                    $students_name = stripslashes($row2->firstname) . " " . stripslashes($row2->surname);
                }
                print "<p class=\"title\">{$students_name}</p>";
                // print his or her latest grades, etc
                print "<div class=\"grades\"><p class=\"big\">Latest Grades&nbsp;<a href=\"classes.php?xml&amp;u={$the_student}&p=" . gen_rss_pass($the_student) . "\" title=\"latest grades feed\"><img src=\"images/xml.gif\" alt=\"latest grades via rss\" /></a></p>";
                // get their (5) latest grades
                display_latest_grades($the_student, 5, "all");
                print "<p class=\"big\">Latest News&nbsp;<a href=\"news.php?xml&amp;u={$the_student}&p=" . gen_rss_pass($the_student) . "\" title=\"latest news feed\"><img src=\"images/xml.gif\" alt=\"latest news via rss\" /></a></p>";
                // get the user's class's latest news post
                display_latest_news($the_student, 1);
                print "</div>";
                print "<p class=\"big\">Classes</p>";
                print_students_classes($the_student);
                $i++;
                // if we have more users to print, print a line
                if (isset($student[$i])) {
                    print "<hr />";
                }
            }
        }
        disconnect_sql();
    }
}