<?php require_once('Connections/connMontessori.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}
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_rsUserStarted = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_rsUserStarted = $_SESSION['MM_Username'];
}
mysql_select_db($database_connMontessori, $connMontessori);
$query_rsUserStarted = sprintf("SELECT * FROM usuarios WHERE username_usuario = %s", GetSQLValueString($colname_rsUserStarted, "text"));
$rsUserStarted = mysql_query($query_rsUserStarted, $connMontessori) or die(mysql_error());
$row_rsUserStarted = mysql_fetch_assoc($rsUserStarted);
$totalRows_rsUserStarted = mysql_num_rows($rsUserStarted);
?>
<?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['user'])) {
  $loginUsername=$_POST['user'];
  $password=$_POST['pass'];
  $MM_fldUserAuthorization = "nivel_usuario";
  $MM_redirectLoginSuccess = "acceso-ok.php";
  $MM_redirectLoginFailed = "padres-de-familia.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_connMontessori, $connMontessori);
  	
  $LoginRS__query=sprintf("SELECT username_usuario, passwd_usuario, nivel_usuario FROM usuarios WHERE username_usuario=%s AND passwd_usuario=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $connMontessori) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'nivel_usuario');
    
	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 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=utf-8" />
<title>Padres de Familia | Instituto Montessori Sabinas</title>
<link rel="stylesheet" type="text/css" href="files/Montessori_main.css" />
<!--[if IE ]><LINK rel="stylesheet" type="text/css" href="files/IE.css" media="screen"><![endif]--><!--[if lt IE 7]>
					<link rel="stylesheet" type="text/css" href="prebuilt/css/IE6.css" />
					<![endif]-->
<script type="text/javascript" src="files/prototype-1.6.0.2.js"></script>
<script type="text/javascript" src="files/site.js"></script>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<div id="wrapper">
  <div id="container">
    <? include('phps/header.php'); ?>
      <script type="text/javascript">
	function beforeSubmit(form){ 
		document.location.href = 'http://instituto-montessori.edu.mx/buscar.php?q=' + form.q.value; 
	}
	</script>
      <form style="z-index: 0;" id="seek" onsubmit="beforeSubmit(this);return false;" method="get" name="search" action="http://instituto-montessori.edu.mx/buscar.php">
        <p>
          <input id="searchfield" title="Buscar" onclick="if (this.value='Buscar') this.value='';" name="q" alt="search_for" maxlength="2047" value="Buscar" type="text" />
        </p>
        <div id="search-go">
          <input onsubmit="beforeSubmit(this);return false;" name="submit" alt="submit" value="Search Montessori" src="files/button_go.gif" type="image" />
        </div>
      </form>
      <dl id="quicklinks" class="off quicklinks">
        <? include('phps/quicks.php'); ?>
      </dl>
    </div>
    <ul id="breadcrumbs">
      <li><a href="">Inicio</a> »</li>
      <li><a href="#">Padres de Familia</a></li>
    </ul>
    <div id="content" class="inside">
      <div id="main_content" class="wide2">
        <h1>Acceso para Padres de Familia</h1>
        <table width="100%" border="0">
          <tr>
            <td width="54%" valign="top">
              <p><img src="files/userr.jpg" width="37" height="44" class="izquierda" /></p>
            <p>Por favor proporciona los datos de tu cuenta de padre de familia activo para tener acceso a las opciones avanzadas del sitio web.</p>
            <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>" style="padding:20px;">
              <p>
                <label for="user">Usuario: </label>
                <input style="padding:4px; width:200px; border:1px solid #ccc" type="text" name="user" id="user" />
                <img src="files/user.png" width="16" height="16" /></p>
              <p>
                <label for="pass">Contraseña:</label>
                <input style="padding:4px; width:200px; border:1px solid #ccc" type="password" name="pass" id="pass" />
                <img src="files/textfield_key.png" width="16" height="16" /></p>
              <p>
                <input type="submit" value="Iniciar sesión" style="background-color:#06C; color:#FFF; padding:3px; width:150px; border:0px;" />
            </p>
            </form>
            <p>Si no recuerdas los datos de tu cuenta, por favor envía un email a: <a href="mailto:montessori@instituto-montessori.edu.mx">montessori@instituto-montessori.edu.mx</a></p></td>
            <td width="46%" valign="top"><img src="files/padres.jpg" width="391" height="346" /></td>
          </tr>
        </table>
      </div>
    </div>
    <div id="crosslinks" style="margin-top:-50px; padding:0px;">
    <?php /*?>
      <div id="whatsnext">
        <h2><img alt="Quien eres?" src="files/crosslink_whatsnext.gif" /></h2>
        <ul>
          <li><a href="contacto.php">Cont&aacute;ctanos</a></li>
          <li><a href="#">Conoce Montessori</a></li>
          <li><a href="#">Información relevante</a></li>
          <li><a href="contents.php?type=redes-sociales">Redes Sociales</a></li>
        </ul>
      </div>
      <div id="anotherdimension">
        <h2><img alt="Another Dimension" src="files/crosslink_dimension.gif" /></h2>
        <h3>Conoce nuestro método</h3>
        <p>El <strong>método Montessori</strong> esta inspirado en el humanismo integral, que postula la formación de los seres humanos como personas únicas y plenamente capacitadas para actuar con libertad, inteligencia y dignidad.</p>
        <a href="#"> <img id="Image40" border="0" name="Image40" alt="Learn More" src="files/button_learnmore.gif" width="71" height="10" /></a> <a class="entirediv" href="#" target=""></a></div>
      <div id="profiles">
        <h2><img alt="Profiles" src="files/crosslink_profiles.gif" /></h2>
        <img title="imagen" alt="imagen" src="files/profile_thumb_jim_ellfson.jpg" />
        <blockquote>
          <p>La meta de la Educación Montessori debe ser cultivar el deseo natural de aprender.<br />
            <br />
          </p>
        </blockquote>
        <em>María Montessori</em></div>
      <div id="studentwork">
        <h2><img title="imagen" alt="imagen" src="files/crosslink_studentwork.gif" /></h2>
        <h3>DE CALIDAD</h3>
        <p><img title="imagen" alt="imagen" src="files/JosephDionisio_thumb.jpg" />Nuestros alumnos tienen la posibilidad de desarrollarse a nivel personal, a la sociedad y al medio ambiente.</p>
        <a href="#"><em>Conoce nuestras instalaciones</em></a> </div>
    <?php */?></div>
  </div>
</div>
<? include('phps/footer.php'); ?>
</body>
</html>
<?php
mysql_free_result($rsUserStarted);
?>
