예제 #1
0
/**
 * Authentifie le numéro de troll et un mot de pas hashé contre la base de donnée, et positionne les variables de
 * session en conséquence.
 * @return true si l'authentification a réussie
 * @return false si elle a échouée (mot de passe incorrecte ou troll inexistant)
 */
function userLogin($numTroll, $md5pass)
{
    global $db_vue_rm;
    // On regarde si le troll existe dans la base de données
    $sql = "SELECT pass_outils_troll, guilde_troll, nom_troll";
    $sql .= " FROM trolls WHERE id_troll={$numTroll}";
    $result = mysql_query($sql, $db_vue_rm);
    if ($result == false) {
        return false;
    }
    list($DBmd5pass, $DBAuthGuilde, $DBNomTroll) = mysql_fetch_array($result);
    if (mysql_affected_rows() > 0 && $DBmd5pass != "" && $DBmd5pass == $md5pass) {
        $_SESSION['AuthTroll'] = $numTroll;
        $_SESSION['Auth'] = $md5pass;
        $_SESSION['AuthGuilde'] = $DBAuthGuilde;
        $_SESSION['AuthNomTroll'] = $DBNomTroll;
        if (userIsGuilde() || userIsGroupSpec()) {
            // Controle de l'administrateur
            // Remplis la variable de session
            if (isDbAdministration()) {
                $_SESSION['admin'] = "authenticated";
            } else {
                $_SESSION['admin'] = "notauthorized";
            }
            $_SESSION['Status'] = "authentified";
            setcookie("cookie_id_troll", $_SESSION['AuthTroll'], time() + 31536000);
            // on garde le cookie 1 an
            enregistre_connection($_SESSION['AuthTroll']);
            return true;
        }
    }
    return false;
}
예제 #2
0
global $HTTP_GET_VARS;
if (isset($HTTP_GET_VARS['taniere']) && $HTTP_GET_VARS['taniere'] != '' && is_numeric($HTTP_GET_VARS['taniere'])) {
    $taniere = $HTTP_GET_VARS['taniere'];
} else {
    header("Location: ./index.php");
}
//taniere concernée
include_once '../functions_auth.php';
initAuth();
include_once '../secure.php';
include_once '../functions.php3';
include_once "./inc/tresor.inc.php";
include_once "./inc/fonctions.inc.php";
$no_troll = $_SESSION['AuthTroll'];
// Id du troll connecté
if (!isDbAdministration() && !isGGT()) {
    die("<h1><font color=black><b>Vous n'avez pas accès à cette page</b></font></h1");
}
global $HTTP_POST_VARS;
include_once '../inc_connect.php3';
foreach ($HTTP_POST_VARS as $champ => $value) {
    $tab = explode("_", $champ);
    if ($tab[0] == "res" && is_numeric($value)) {
        $result = reserverForce($tab[1], $value, $HTTP_POST_VARS['no_troll']);
    } else {
        if ($tab[0] == "deres") {
            $result = dereserver($tab[1], $HTTP_POST_VARS['no_troll']);
        } else {
            if ($tab[0] == "conf") {
                $result = confirmer($tab[1], $HTTP_POST_VARS['no_troll']);
            } else {
예제 #3
0
function initAuth()
{
    global $db_vue_rm;
    if (isset($_SERVER['REQUEST_URI'])) {
        $REQUEST_URI = $_SERVER['REQUEST_URI'];
    } else {
        $REQUEST_URI = "";
    }
    if (isset($_SERVER['HTTP_REFERER'])) {
        $HTTP_REFERER = $_SERVER['HTTP_REFERER'];
    } else {
        $HTTP_REFERER = "";
    }
    if (isset($_REQUEST['CHTROLL'])) {
        $CHTROLL = $_REQUEST['CHTROLL'];
    } else {
        $CHTROLL = "";
    }
    if (isset($_REQUEST['CHPASS'])) {
        $CHPASS = $_REQUEST['CHPASS'];
    } else {
        $CHPASS = "";
    }
    if (isset($_REQUEST['logout'])) {
        $logout = $_REQUEST['logout'];
    } else {
        $logout = "";
    }
    if (isset($_REQUEST['CHTROLL']) && isset($_REQUEST['CHPASS'])) {
        setcookie('autologin', $_REQUEST['autologin'], time() + 365 * 24 * 3600);
        if ($_REQUEST['autologin']) {
            setcookie('num_troll', $_REQUEST['CHTROLL'], time() + 365 * 24 * 3600);
            setcookie('hash_pass_troll', md5($_REQUEST['CHPASS']), time() + 365 * 24 * 3600);
        }
    }
    if (isset($_COOKIE['autologin'])) {
        $autologin = $_COOKIE['autologin'];
    } else {
        $autologin = false;
    }
    if ($autologin) {
        $CHTROLL = $_COOKIE['num_troll'];
        $CHPASS = $_COOKIE['hash_pass_troll'];
    }
    if ($HTTP_REFERER == "" || preg_match("/inc_authent/", $HTTP_REFERER)) {
        $GOTO = $REQUEST_URI;
    } else {
        $GOTO = $HTTP_REFERER;
    }
    if (!preg_match("/inc_authent/", $GOTO) && !preg_match("/index/", $GOTO)) {
        $_SESSION['uri'] = $GOTO;
    } else {
        $_SESSION['uri'] = "/cockpit.php";
    }
    # submit tout frais ?
    if ($CHTROLL > 0 || $CHPASS != "") {
        // Si le mot de passe n'est pas le mot de passe md5
        if (strlen($CHPASS) != 32) {
            // On se débarasse du pass en clair
            $CHPASS = md5($CHPASS);
        }
        $_SESSION['AuthTroll'] = $CHTROLL;
        $_SESSION['Auth'] = $CHPASS;
    }
    # demande de logout ?
    if ($logout) {
        $_SESSION['Status'] = "";
        $_SESSION['AuthTroll'] = "";
        $_SESSION['AuthNomTroll'] = "";
        $_SESSION['AuthGuilde'] = "";
        $_SESSION['Auth'] = "";
        $_SESSION['AuthGroupSpec'] = "";
        session_unset();
        session_destroy();
        setcookie('autologin', false);
        echo "<script language='JavaScript'>";
        echo "document.location.href='/index.php'";
        echo "</script>";
    }
    # Si la personne est déjà authentifiée
    if (isset($_SESSION['Status']) && $_SESSION['Status'] == "authentified") {
        return;
    }
    # Vérification normale
    if (is_numeric($CHTROLL) && $_SESSION['Status'] != "authentified") {
        $md5pass = "******";
        // Initialisation, mais çà sert pas à grand chose ici
        // On regarde si le troll existe dans la base de données
        $sql = "SELECT pass_outils_troll, guilde_troll, nom_troll, nom_rang_troll, groupe_spec_troll";
        $sql .= " FROM trolls WHERE id_troll={$CHTROLL}";
        $result = mysql_query($sql, $db_vue_rm);
        echo mysql_error();
        list($md5pass, $AuthGuilde, $AuthNomTroll, $nom_rang_troll, $groupe_spec_troll) = mysql_fetch_array($result);
        // S'il existe
        if (preg_match("/essai/", $nom_rang_troll)) {
            die("<h2>Vous êtes un troll à l'essai, vous n'avez pas accès aux outils pendant cette période<h2>");
        }
        if (mysql_affected_rows() > 0 && $md5pass != "") {
            // et que le mot de passe est correct
            if ($md5pass == $_SESSION['Auth']) {
                //$_SESSION[AuthTroll]=$_SESSION[AuthTroll]; // pour indiquer ici toutes les valeurs possibles de session
                $_SESSION['AuthGuilde'] = $AuthGuilde;
                $_SESSION['AuthNomTroll'] = $AuthNomTroll;
                $_SESSION['AuthGroupSpec'] = $groupe_spec_troll;
                //$_SESSION[Auth]=$_SESSION[Auth];
            } else {
                setcookie('autologin', false);
                die("<h2><font color='red'>Mot de passe incorrect</font></h2>");
            }
            // S'il n'existe pas dans la base de données
        } else {
            /* Premier connection du troll sur les outils */
            setcookie('autologin', false);
            echo "<script language='JavaScript'>";
            echo "document.location.href='/change_password.php'";
            echo "</script>";
            echo "2 - Si vous n'etes pas redirigé automatiquement, cliquez ici : ";
            echo "<a href='/change_password.php?act=premiere'> Là j'tai dis !! </a>";
        }
        if (userIsGuilde() || userIsGroupSpec()) {
            // Controle de l'administrateur
            // Remplis la variable de session
            if (isDbAdministration()) {
                $_SESSION['admin'] = "authenticated";
            } else {
                $_SESSION['admin'] = "notauthorized";
            }
            $_SESSION['Status'] = "authentified";
            setcookie("cookie_id_troll", $_SESSION['AuthTroll'], time() + 31536000);
            // on garde le cookie 1 an
            enregistre_connection($_SESSION['AuthTroll']);
            redirectAuth();
        } else {
            setcookie('autologin', false);
            session_unset();
            session_destroy();
            die("<h2>Soit vous n'êtes pas un Relais&Mago\n\t\t\t<br> soit le mot de passe est incorrect\n\t\t\t<br> soit c'est votre première connexion (réessayez)<br>\n\t\t\t<br><br>Conclusion : \n\t\t\t<br>Vous n'avez pas accès à ces pages<br>\n\t\t\tContactez glupglup (51166) pour résoudre le problème.<br><br>\n\t\t\t");
        }
    }
}
예제 #4
0
파일: index.php 프로젝트: relaismago/outils
$no_troll = $_SESSION['AuthTroll'];
// Id du troll connecté
?>
<br/>
<?php 
$maj = getDerniereMaj();
$c = ' Dernière mise à jour du contenu le ' . $maj['date'] . ' par ' . $maj['troll'];
afficher_contenu_tableau($c);
afficher_titre_tableau("Sélectionnez la tanière où passer votre commande");
$c = ' [ <a href="./affichage.php?taniere=33931">Le Mag\'Hasin de Kasseroll</a> ] <br>';
$c .= ' [ <a href="./affichage.php?taniere=34111">La Taverne d\'Heliacyn</a> ] <br>';
$c .= ' [ <a href="./affichage.php?taniere=38965">La Bïblyohtek de Grognon</a> ] <br>';
$c .= '<br>';
$c .= ' [ <a href="./recherche.php">Rechercher</a> ] <br>';
afficher_contenu_tableau($c);
if (isDbAdministration() || isGGT()) {
    if (!isGGT()) {
        $msg = "<b>Attention : vous êtes administrateur des outils et pas ";
        $msg .= "gestionnaire des grandes tanières, merci de ne pas trop jouer avec ça...</b>";
        afficher_titre_tableau("Gestion", $msg);
    } else {
        afficher_titre_tableau("Gestion");
    }
    $c = ' [ <a href="./affichageAdmin.php?taniere=33931">Derrière le comptoir du Mag\'Hasin</a> ] <br> ';
    $c .= ' [ <a href="./affichageAdmin.php?taniere=34111">Au bar de la Taverne</a> ] <br>';
    $c .= ' [ <a href="./affichageAdmin.php?taniere=38965">Au guichet de la Bïblyohtek</a> ] <br>';
    $c .= '<br>';
    $c .= ' [ <a href="./rechercheAdmin.php">Rechercher</a> ] <br>';
    $c .= '<br>';
    $c .= ' [ <a href="./affichageMaj.php">Mettre à jour</a> ] <br>';
    afficher_contenu_tableau($c);
예제 #5
0
파일: miss.php 프로젝트: relaismago/outils
    $text .= " <h5><font color='red'>Dépôt de candidature : <a href='/miss/miss.php?act_miss=enregistrement'>ICI</a></font>";
    $text .= " <font color='red'>Administration des Miss : <a href='/miss/miss.php?act_miss=admin'>ICI</a></font>";
    $text .= " <font color='red'>Résultats en cours : <a href='/miss/miss.php?act_miss=resultats'>ICI</a></font></h5>";
    afficher_titre_tableau("Administration", $text);
}
if ($_REQUEST[act_miss] == "enregistrement") {
    init_inscription_miss($ANNEE_MISS, $GENRE_MISS, $TYPE_MISS);
} elseif ($_REQUEST[act_miss] == "admin") {
    if (isDbAdministration()) {
        afficher_titre_tableau("Administration des Miss");
        init_admin_miss($ANNEE_MISS, $GENRE_MISS, $TYPE_MISS);
    } else {
        afficher_titre_tableau('Accès réservé aux administrateurs');
    }
} elseif ($_REQUEST[act_miss] == "resultats") {
    if (isDbAdministration()) {
        afficher_titre_tableau("Résultats");
        resultats_miss($ANNEE_MISS, $GENRE_MISS, $TYPE_MISS);
    } else {
        afficher_titre_tableau('Accès réservé aux administrateurs');
    }
} else {
    //init_inscription_miss( $ANNEE_MISS, $GENRE_MISS, $TYPE_MISS );
    init_miss($ANNEE_MISS, $GENRE_MISS, $TYPE_MISS, true);
}
require_once '../foot.php';
function init_miss($ANNEE_MISS, $GENRE_MISS, $TYPE_MISS, $is_vote = false)
{
    //	die('Votes non commencés');
    $display_proposition = false;
    //	$text .= " <h5><font color='red'>Déposition de candidature : <a href='/miss/miss.php?act_miss=enregistrement'>ICI</a></font><br>";