Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1. /* Website Administrator for this domain - dependent on staff_id that is admin */
  2.     $link=mysql_connect ('localhost', 'cm_esites','$password');
  3.     if (!$link) {
  4.         die('Could not connect: ' . mysql_error());
  5.     }
  6.     if (!mysql_select_db('cm_esites')) {
  7.         die('Could not select database: ' . mysql_error());
  8.     }
  9.     // this requires that a matching username and password is found -- AND -- that user is
  10.     // indicated as the staff_id_admin in e_sites_control as this is the only person (staff) working
  11.     // for that that subscriber that can alter the website. However, a company may have many staff members
  12.     // only one can administrate the website.
  13.     $sql="select e_manresu.*, e_sites_control.site_id,e_staff.security_level
  14.                 from e_manresu,e_sites_control,e_staff
  15.                 where e_manresu.u_username='".$postget["uname"]."' AND e_manresu.u_password='".$postget["passwd"]."'
  16.                 AND e_sites_control.staff_id_admin = e_manresu.staff_id and e_staff.staff_id = e_manresu.staff_id";
  17.     $result = mysql_query($sql);
  18.     if (!$result) {
  19.     die('Could not query:' . mysql_error());
  20.     }
  21.  
  22.     while ($rows=mysql_fetch_assoc($result)){
  23.         $config["admin_uname"]=$rows['u_username'];
  24.         $config["admin_passwd"]=$rows['u_password'];
  25.         $_SESSION['site_id']=$site_id=$rows['site_id'];
  26.         if($rows['security_level']=='99'){
  27.            $_SESSION['super_admin']='true';
  28.         }
  29.     }      
  30.     mysql_close($link);
  31.     if( ($postget["uname"]==$config["admin_uname"]) && ($postget["passwd"]==$config["admin_passwd"]))
  32.     {
  33.         $_SESSION['encaps']['admin_uname'] = $config['admin_uname'];
  34.         $_SESSION['encaps']['admin_passwd'] = $config['admin_passwd'];
  35.     }  
  36.     else
  37.     {
  38.         // sleep(3);
  39.         echo $_SESSION['encaps']['admin_passwd'];
  40.         echo "Login failed";
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement