예제 #1
0
function Init()
{
    session_start();
    // chama config
    $configFile = $_SERVER['DOCUMENT_ROOT'] . '/painel/system/config.php';
    if (!file_exists($configFile)) {
        die('Erro arquivo config.php não existe!');
    } else {
        require_once $configFile;
    }
    //chama helpers
    if (!file_exists(FILE_HELP)) {
        die('Erro arquivo helpers.php não existe!');
    } else {
        require_once FILE_HELP;
    }
    //chama database
    if (!file_exists(FILE_DATABASE)) {
        die('Erro arquivo database.php não existe!');
    } else {
        require_once FILE_DATABASE;
    }
    DBConnect();
    DoLogout();
}
예제 #2
0
파일: login.php 프로젝트: pmolfese/nidb
/* database connection */
$link = mysql_connect($GLOBALS['cfg']['mysqlhost'], $GLOBALS['cfg']['mysqluser'], $GLOBALS['cfg']['mysqlpassword']) or die("Could not connect: " . mysql_error());
mysql_select_db($GLOBALS['cfg']['mysqldatabase']) or die("Could not select database<br>");
/* connect to CAS if enabled */
if ($GLOBALS['cfg']['enablecas']) {
    phpCAS::client(CAS_VERSION_2_0, $GLOBALS['cfg']['casserver'], intval($GLOBALS['cfg']['casport']), $GLOBALS['cfg']['cascontext']);
}
/* ----- determine which action to take ----- */
if ($action == "login") {
    if (!CheckLogin($username, $password)) {
        DisplayLogin("Incorrect login. Make sure Caps Lock is not on");
    } else {
        header("Location: index.php");
    }
} elseif ($action == "logout") {
    DoLogout();
} else {
    if ($GLOBALS['cfg']['enablecas']) {
        $username = AuthenticateCASUser();
        if ($username == "") {
            DisplayLogin("Invalid CAS login");
        } else {
            echo "Created the client (session already exists)...<br>";
            phpCAS::setNoCasServerValidation();
            if (phpCAS::checkAuthentication()) {
                $username = phpCAS::getUser();
                echo "Username [{$username}]";
            } else {
                phpCAS::forceAuthentication();
            }
            DoLogin($username);