Ejemplo n.º 1
0
<?php

require_once 'config.inc.php';
$tpl_main = new TemplatePower('template/master.html');
$tpl_main->prepare();
// see if the login form was submitted
if (isset($_POST['login'])) {
    $user = stripslashes($_POST['username']);
    $pass = stripslashes($_POST['password']);
    $goto = $_POST['redirect'];
    if ($_AUTH->login($user, $pass)) {
        include_once $goto;
        die;
    } else {
        $tpl = new TemplatePower('template/error.html');
        $tpl->assignGlobal('error_message', 'Invalid username / password.' . $user);
    }
    // display the default login form
} else {
    $tpl = new TemplatePower('template/login.html');
    $tpl->assignGlobal('redirect', $_GET['redirect']);
}
$tpl->prepare();
$tpl->showUnAssigned(false);
$tpl_main->assign('content', $tpl->getOutputContent());
$tpl_main->showUnAssigned(false);
$tpl_main->printToScreen();
Ejemplo n.º 2
0
    // pull the template together
    $tpl->prepare();
    // display the selected course
    if (isset($course)) {
        $c = get_user_courses($_DB);
        $course = $c[0]['courseID'];
        set_course_template($_DB, $tpl, $course);
    }
    // add the remaining components to the template
    $tpl->assignGlobal('course_select_box', gen_course_select_box($_DB));
    $tpl->assignGlobal('username', $_SESSION['userName']);
}
// for all of the pages, put the content into the main template
$tpl->showUnAssigned(false);
$tpl_main->assignGlobal("content", $tpl->getOutputContent());
$tpl_main->showUnAssigned(false);
$tpl_main->printToScreen();
/**
 * Return a list of courses that the user is enrolled in
 *
 * @db the MySQL database connection
 *
 **/
function get_user_courses($db)
{
    $user = $_SESSION['userID'];
    $db->sql_query("SELECT * FROM courses WHERE courseID = ( SELECT course FROM studentstocourses WHERE student =  '{$user}' ) ");
    return $db->sql_fetchrowset();
}
/**
 * Return a HTML combo box populated with the courses that the user is in