File: /home/ednermusika/ednergranados.com/admin/admin.php
<?php require_once('../Connections/con_edner.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 = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "acceso_denegado.html";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
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_nombre_usuario = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_nombre_usuario = $_SESSION['MM_Username'];
}
mysql_select_db($database_con_edner, $con_edner);
$query_nombre_usuario = sprintf("SELECT usu_consecutivo, usu_correo, usu_nombre, usu_contrasena, usu_rol, usu_tipo, usu_activo FROM usuario WHERE usu_correo = %s", GetSQLValueString($colname_nombre_usuario, "text"));
$nombre_usuario = mysql_query($query_nombre_usuario, $con_edner) or die(mysql_error());
$row_nombre_usuario = mysql_fetch_assoc($nombre_usuario);
$totalRows_nombre_usuario = mysql_num_rows($nombre_usuario);
?>
<?php
$_SESSION['USUARIO'] = $row_nombre_usuario['usu_consecutivo'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edner Granados Impact Speaker</title>
<script src="js/iframes.js" type="text/javascript"></script>
<script type="text/javascript">
<?php
$rol = $row_nombre_usuario['usu_rol'];
switch($rol){
case 'SA': $_SESSION['ROL'] = "SA";
include_once('js/menu_superadmin.js');
break;
case 'ADMINISTRADOR': $_SESSION['ROL'] = "ADMINISTRADOR";
include_once('js/menu_admin.js');
break;
}
?>
</script>
<link href="css/admin.css" rel="stylesheet" type="text/css" />
</head>
<body onload="loadintoIframe('frame_contenido', 'inicio.php');">
<div id="contenedor">
<div id="encabezado">
<div id="encabezado_tabla">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="26%"><h2>Panel de Administración</h2>
<h5><?php echo $_SESSION['USUARIO'] ?>- <?php echo $row_nombre_usuario['usu_nombre']; ?></h5></td>
<td width="43%" align="center"><h2><a href="../index.php" target="_blank"><img src="img/logo-edner.png" width="445" height="93" border="0" /></a></h2></td>
<td width="31%" align="right"><a href="<?php echo $logoutAction ?>" class="ligas_cerrar">Cerrar sesión</a></td>
</tr>
</table>
</div>
</div>
<div id="menu">
<div id="menuh">
<script language="JavaScript">
f_mostrar_menu();
</script>
</div>
</div>
<div id="contenido">
<iframe id="frame_contenido" src="inicio.php" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:99%; display:none">
</iframe>
<h5> </h5>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($nombre_usuario);
?>