Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. <?php require_once('Connections/conex_fastpetcare.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6. if (PHP_VERSION < 6) {
  7. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8. }
  9.  
  10. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12. switch ($theType) {
  13. case "text":
  14. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15. break;
  16. case "long":
  17. case "int":
  18. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19. break;
  20. case "double":
  21. $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22. break;
  23. case "date":
  24. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25. break;
  26. case "defined":
  27. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28. break;
  29. }
  30. return $theValue;
  31. }
  32. }
  33. ?>
  34. <?php
  35. // *** Validate request to login to this site.
  36. if (!isset($_SESSION)) {
  37. session_start();
  38. }
  39.  
  40. $loginFormAction = $_SERVER['PHP_SELF'];
  41. if (isset($_GET['accesscheck'])) {
  42. $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  43. }
  44.  
  45. if (isset($_POST['usuario'])) {
  46. $loginUsername=$_POST['usuario'];
  47. $password=$_POST['password'];
  48. $MM_fldUserAuthorization = "";
  49. $MM_redirectLoginSuccess = "administrador/marcos_administrador/completo_adm.html";
  50. $MM_redirectLoginFailed = "error_inicio_sesion.php";
  51. $MM_redirecttoReferrer = false;
  52. mysql_select_db($database_conex_fastpetcare, $conex_fastpetcare);
  53.  
  54. $LoginRS__query=sprintf("SELECT rut, password FROM usuarios WHERE rut=%s AND password=%s",
  55. GetSQLValueString($loginUsername, "int"), GetSQLValueString($password, "text"));
  56.  
  57. $LoginRS = mysql_query($LoginRS__query, $conex_fastpetcare) or die(mysql_error());
  58. $loginFoundUser = mysql_num_rows($LoginRS);
  59. if ($loginFoundUser) {
  60. $loginStrGroup = "";
  61.  
  62. if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  63. //declare two session variables and assign them
  64. $_SESSION['MM_Username'] = $loginUsername;
  65. $_SESSION['MM_UserGroup'] = $loginStrGroup;
  66.  
  67. if (isset($_SESSION['PrevUrl']) && false) {
  68. $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
  69. }
  70. header("Location: " . $MM_redirectLoginSuccess );
  71. }
  72. else {
  73. header("Location: ". $MM_redirectLoginFailed );
  74. }
  75. }
  76. ?>
  77. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  78. <html xmlns="http://www.w3.org/1999/xhtml">
  79. <head>
  80. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  81. <title>Documento sin título</title>
  82. </head>
  83.  
  84. <body>
  85. <form id="form_inicio_sesion" name="form_inicio_sesion" method="POST" action="<?php echo $loginFormAction; ?>">
  86. <table width="200" border="1">
  87. <tr>
  88. <td colspan="2"><div align="center">Iniciar sesión</div></td>
  89. </tr>
  90. <tr>
  91. <td>Usuario</td>
  92. <td><label for="usuario"></label>
  93. <input name="usuario" type="text" id="usuario" maxlength="9" /></td>
  94. </tr>
  95. <tr>
  96. <td>Contraseña</td>
  97. <td><label for="password"></label>
  98. <input name="password" type="password" id="password" maxlength="20" /></td>
  99. </tr>
  100. <tr>
  101. <td colspan="2"><div align="center"><input type="submit" name="btn_iniciar_sesion" id="btn_iniciar_sesion" value="Iniciar sesión" /></div></td>
  102. </tr>
  103. </table>
  104. </form>
  105. </body>
  106. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement