Código PHP:
<?php require_once('../Connections/tienda.php'); ?>
<?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;
}
}
mysql_select_db($database_tienda, $tienda);
$query_Recordset1 = "SELECT * FROM wp_groups_group";
$Recordset1 = mysql_query($query_Recordset1, $tienda) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?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'];
}
$password = $_POST['pass'];
$hash = $userinfo->pass;
require_once( './wp-includes/class-phpass.php');
$wp_hasher = new PasswordHash(8, TRUE);
if ($wp_hasher->CheckPassword($password, $hash)) {
$userinfo = get_userdatabylogin($user_name);
echo $userinfo->pass;
}
if (isset($_POST['usuario'])) {
$loginUsername=$_POST['usuario'];
$password=$_POST['pass'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "usuario.php?group_id=".$_POST['grupos'];
$MM_redirectLoginFailed = "error.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_tienda, $tienda);
$LoginRS__query=sprintf("SELECT user_login, user_pass FROM wp_users WHERE user_login=%s AND user_pass=%s ",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $tienda) 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 );
}
}
?>
<?php
include('header.php');
?>
<div id="contenido">
<div id="galerias1">
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<label for="usuario">Usuario:</label>
<input type="text" name="usuario" id="usuario" />
<label for="pass">Contraseña:</label>
<input type="password" name="pass" id="pass" />
<label for="grupos">Grupos:</label>
<select name="grupos" id="grupos">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['group_id']?>"><?php echo $row_Recordset1['name']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select>
<input type="submit" name="submit" id="submit" value="Enviar" />
</form>
</div>
</div>
<?php
include('footer.php');
?>
<?php
mysql_free_result($Recordset1);
?>