예제 #1
0
/**
 * Checks a login request for invalid inputs and performs all
 * SQL actions if no error occurs
 * also fills the $_SESSION-Array with account related information
 *
 * @access public
 * @return true
 */
function complete_login()
{
    if (valid_request(array(isset($_POST['login']), isset($_POST['password'])))) {
        global $db;
        global $smarty;
        //session_start();      session.auto_start = 1
        //see if we hit the right email/nick -password pair
        $sql = "get_user_id_login('" . $_POST['login'] . "', '" . md5($_POST['password']) . "')";
        $db->run($sql);
        if (!$db->empty_result) {
            $_SESSION['accepted'] = true;
            //store the user informations for further actions
            $row = $db->get_result_row();
            $_SESSION['user_id'] = $row['user_id'];
            //is the user admin
            $sql = "get_admin_id(" . $_SESSION['user_id'] . ")";
            $db->run($sql);
            if (!$db->empty_result) {
                $_SESSION['admin'] = true;
            } else {
                $_SESSION['admin'] = false;
            }
            //is the user head admin
            $sql = "get_head_admin_id(" . $_SESSION['user_id'] . ")";
            $db->run($sql);
            if (!$db->empty_result) {
                $_SESSION['head_admin'] = true;
            } else {
                $_SESSION['head_admin'] = false;
            }
            //will be filled when trying to access the areas
            $_SESSION['team_admin'] = array();
            $_SESSION['team_writer'] = array();
            if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1') {
                if (php_sapi_name() == 'cgi') {
                    header('Status: 303 See Other');
                } else {
                    header('HTTP/1.1 303 See Other');
                }
            }
            display_success("login");
            display_visitor_data();
            //show user related stuff
            $smarty->assign('content', $smarty->fetch("succes.tpl"));
        } else {
            // invalid login
            display_errors(100);
        }
    }
    return true;
}
예제 #2
0
파일: index.php 프로젝트: soi/paul
   ******************/
// @todo delete when release
error_reporting(E_ALL);
ini_set('display_errorss', 1);
require 'constants.php';
require CLASS_PATH . SMARTY_CON_PATH;
require 'display_functions.php';
require 'complete_functions.php';
require CLASS_PATH . 'class.mysql.connection.php';
//main db connection
$db = new mysql_connection('ripersoi.dyndns.org', 'paul_usr', 'YsvQz8SfV9', 'paul');
//$db = new mysql_connection('localhost', 'paul_usr', 'YsvQz8SfV9', 'paul');
//main smarty instance
$smarty = new smarty_connect();
$smarty->debugging_ctrl = $_SERVER['SERVER_NAME'] == 'localhost' ? 'URL' : 'NONE';
$registered = display_visitor_data();
//display the news by default
if (!isset($_GET['site'])) {
    assign_news($smarty);
    $smarty->assign('content', $smarty->fetch("news.tpl"));
} else {
    //has the user permission to visit the site?
    $perm_sites = get_permitted_sites();
    if (in_array($_GET['site'], $perm_sites)) {
        switch ($_GET['site']) {
            case 'add_admin':
                $smarty->assign('content', $smarty->fetch("add_admin.tpl"));
                break;
            case 'add_game':
                display_add_game();
                break;