Advertisement
Guest User

Strange security

a guest
Apr 21st, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. <?php
  2.  
  3. function check_login_cp($admin,$url)
  4.  
  5. {
  6.  
  7.         global $db;
  8.     global $db_admin;
  9.  
  10.  if (!$_SERVER['HTTP_REFERER']) { header('Location: index.php'); die( "Hacking attempt!" ); exit; }
  11.  
  12.  if (!isset($_SESSION["adm_ident"])) { header('Location: index.php'); die( "Hacking attempt!" ); exit; }
  13.  
  14.  if (!isset($_SESSION['admin_login'])) { header('Location: index.php'); die( "Hacking attempt!" ); exit; }
  15.  
  16. $sql    = 'SELECT * FROM ' . $db_admin . ' '
  17.         . 'WHERE login="' . $_SESSION['admin_login'] . '"';
  18. $r_auth = $db->query($sql);
  19. $f_auth = $db->fetcharray($r_auth);
  20.  
  21. if ($f_auth['login'] == $_SESSION['admin_login']
  22.     and $f_auth['password'] == $_SESSION['admin_pass']
  23.     and mysql_numrows($r_auth) == '1')
  24. {
  25.     mysql_free_result($r_auth);
  26.     $_SESSION['name_admin'] = $f_auth['name'];
  27.     $_SESSION['admin_login'] = $f_auth['login'];
  28.     $_SESSION['icq_admin'] = $f_auth['icq'];
  29.     $_SESSION['phone_admin'] = $f_auth['phone'];
  30.     $_SESSION['adress_admin'] = $f_auth['adress'];
  31.     $menu_start=explode("#", $f_auth['menu']);
  32.     $_SESSION['menu'] = $menu_start[1];
  33.     $_SESSION['menu_punkt'] = $menu_start[0];
  34.     $_SESSION['num_admin'] = $f_auth['num'];
  35. }
  36.  else
  37.  
  38. {
  39.     $_SESSION = array();
  40.         $_SESSION ['url'] = $url;
  41.     header('Location: index.php');
  42.     die();
  43.     exit;
  44.     return;
  45. }
  46.  
  47. }
  48.  
  49.  
  50. if ($_GET["REQ"] == "auth")
  51.  
  52. {
  53.     if (!isset($_SESSION["adm_ident"]))
  54.  
  55.     {
  56.         session_start();
  57.  
  58.         $vid_login = trim(htmlspecialchars(strip_tags($_POST["login"])));
  59.         $vid_password = trim(htmlspecialchars(strip_tags($_POST["pass"])));
  60.  
  61.         if ($vid_login!='' and $vid_password!='') {
  62.  
  63.             $_SESSION["admin_login"] = $vid_login;
  64.             $_SESSION["admin_pass"] = md5($vid_password);
  65.             $_SESSION["adm_ident"] = time();
  66.         }
  67.     }
  68.      
  69. check_login_cp('0_1','main.php');
  70. header('Location: /');
  71.  
  72. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement