Ver Mensaje Individual
  #5 (permalink)  
Antiguo 02/12/2014, 17:12
Eyseman
 
Fecha de Ingreso: diciembre-2014
Mensajes: 3
Antigüedad: 9 años, 5 meses
Puntos: 0
Respuesta: Acceso multinivel

muchas gracias @huascar ya he ido progresando un poco aunque aun tengo ciertos dilemas, explico la opcion general la direccione a una pagina de login donde se autentica el usuario y lo redirige a general aqui el codigo del la validacion de usuario


php require_once('Connections/conexionbci.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;
}
}


// *** 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['Username'])) {
$loginUsername=$_POST['Username'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "general.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_conexionbci, $conexionbci);

$LoginRS__query=sprintf("SELECT strEmail, strPassword, intNivel FROM tblintegrantes WHERE strEmail=%s AND strPassword=%s AND intNivel=50",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $conexionbci) 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']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}

quite las etiquetas de php del codigo aqui publicado pero el codigo en uso si lo tiene

eso funciona bien si el usuario que se logea no tiene nivel 50 no lo lleva a general, el dilema que se me presenta ahora es que si tecleo lla ruta a general.php en la barra de direcciones del navegador me permiteel acceso; disculpen lo tedioso que soy pero como soluciono esto