Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once('Connections/toast_sql.php'); ?>
- <?php
- //initialize the session
- if (!isset($_SESSION)) {
- session_start();
- }
- // ** Logout the current user. **
- $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
- if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
- $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
- }
- if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
- //to fully log out a visitor we need to clear the session varialbles
- $_SESSION['MM_Username'] = NULL;
- $_SESSION['MM_UserGroup'] = NULL;
- $_SESSION['PrevUrl'] = NULL;
- unset($_SESSION['MM_Username']);
- unset($_SESSION['MM_UserGroup']);
- unset($_SESSION['PrevUrl']);
- $logoutGoTo = "33.php";
- if ($logoutGoTo) {
- header("Location: $logoutGoTo");
- exit;
- }
- }
- ?>
- <?php
- if (!function_exists("GetSQLValueString")) {
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- if (PHP_VERSION < 6) {
- $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
- }
- $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
- switch ($theType) {
- case "text":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "long":
- case "int":
- $theValue = ($theValue != "") ? intval($theValue) : "NULL";
- break;
- case "double":
- $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
- break;
- case "date":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "defined":
- $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
- break;
- }
- return $theValue;
- }
- }
- $colname_test = "-1";
- if (isset($_SESSION['MM_username'])) {
- $colname_test = $_SESSION['MM_username'];
- }
- mysql_select_db($database_toast_sql, $toast_sql);
- $query_test = sprintf("SELECT * FROM users WHERE pseudo = %s", GetSQLValueString($colname_test, "text"));
- $test = mysql_query($query_test, $toast_sql) or die(mysql_error());
- $row_test = mysql_fetch_assoc($test);
- $totalRows_test = mysql_num_rows($test);
- ?>
- <?php
- // *** Validate request to login to this site.
- if (!isset($_SESSION)) {
- session_start();
- }
- $loginFormAction = $_SERVER['PHP_SELF'];
- if (isset($_GET['accesscheck'])) {
- $_SESSION['PrevUrl'] = $_GET['accesscheck'];
- }
- if (isset($_POST['pseudo'])) {
- $loginUsername=$_POST['pseudo'];
- $password=$_POST['pass'];
- $MM_fldUserAuthorization = "";
- $MM_redirectLoginSuccess = "33.php";
- $MM_redirectLoginFailed = "33.php";
- $MM_redirecttoReferrer = false;
- mysql_select_db($database_toast_sql, $toast_sql);
- $LoginRS__query=sprintf("SELECT pseudo, pass FROM users WHERE pseudo=%s AND pass=%s",
- GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
- $LoginRS = mysql_query($LoginRS__query, $toast_sql) or die(mysql_error());
- $loginFoundUser = mysql_num_rows($LoginRS);
- if ($loginFoundUser) {
- $loginStrGroup = "";
- if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
- //declare two session variables and assign them
- $_SESSION['MM_Username'] = $loginUsername;
- $_SESSION['MM_UserGroup'] = $loginStrGroup;
- if (isset($_SESSION['PrevUrl']) && false) {
- $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
- }
- header("Location: " . $MM_redirectLoginSuccess );
- }
- else {
- header("Location: ". $MM_redirectLoginFailed );
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Document sans titre</title>
- </head>
- <body>
- <?php
- if (empty($_SESSION['connected'])) {
- ?>
- <form id="form1" method="POST" action="<?php echo $loginFormAction; $_SESSION['connected'] = true;?>">
- <p>
- <label for="pse"></label>
- <input type="text" name="pseudo" id="pseudo" />
- </p>
- <p>
- <label for="pass"></label>
- <input type="text" name="pass" id="pass" />
- </p>
- <p>
- <input type="submit" name="ok" id="ok" value="Envoyer" />
- </p>
- </form>
- <p>
- <?php
- } else {
- ?>
- <a href="<?php echo $logoutAction ?>">Déconnecter</a>
- <p><?php echo $row_test['pseudo']; ?>
- <p><?php echo $row_test['pass']; ?>
- <p>
- <?php
- }
- ?>
- </body>
- </html>
- <?php
- mysql_free_result($test);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment