Example #1
0
<?php

# Include files required for the site to work properly.
require_once "includes/scripts/php/config.php";
require_once "includes/scripts/php/functions.php";
# Get some information that will be needed to render the page properly.
$validUser = userAuth($connection);
# If a page has been requested, get the information for it.
if (isset($_GET['p'])) {
    $page = getPage($_GET['p']);
    $pageTitle = getPageTitle($_GET['p']);
} else {
    $page = "home.php";
    $pageTitle = "- Home";
}
# If the user is logged into a valid account, get information needed to
# display the page.
if ($validUser) {
    # Get the account's username from the active session.
    session_start();
    $username = $_SESSION['user'][0];
    session_write_close();
    # Get the name associated with the user's account.
    $name = getName($username, $connection);
    # Determine if there are any active, unaccepted challenges for the
    # account.
    $hasChallenges = hasChallenges($username, $connection);
}
?>

<!DOCTYPE html>
Example #2
0
include_once "./php/functions.php";
//Starts the session
if (!isset($_SESSION)) {
    session_start();
}
//Default language load
if (!isset($_SESSION['LANG'])) {
    $_SESSION['LANG'] = 'french';
}
//Inits the authentification
if (!isset($_SESSION['AUTH'])) {
    $_SESSION['AUTH'] = 0;
}
//Verifies the user/pass combo of the user and grants the access (or not)
if (isset($_POST['inputUser']) && isset($_POST['inputPassword']) && ctype_alnum($_POST['inputUser']) && ctype_alnum($_POST['inputPassword'])) {
    userAuth($_POST['inputUser'], $_POST['inputPassword']);
}
//Adds or modifies the user
if (isset($_POST['modUser']) && ctype_alnum($_POST['modUser'])) {
    userAddRemove($_POST['modUser'], $_POST['modPassword'], isset($_POST['modAdmin']) ? true : false);
}
//Redirects to main page on first arrival
if (isset($_SESSION['AUTH']) && $_SESSION['AUTH'] == 1) {
    if ($_SESSION['PAGE'] == 'signin.php') {
        $_SESSION['PAGENAME'] = 'AM-VS TaskManager';
        $_SESSION['PAGE'] = 'main.php';
    } else {
        //Navigate to other pages
        if (isset($_POST['manage'])) {
            unset($_POST['manage']);
            $_SESSION['PAGENAME'] = 'AM-VS Manager';
Example #3
0
 public function testAuthorizedLogin()
 {
     userAuth("david", "david");
     $this->assertTrue($_SESSION['AUTH'] == 1);
 }