Changeset 2910
- Timestamp:
- 03/27/11 20:57:09 (2 years ago)
- File:
-
- 1 edited
-
alternc/trunk/bureau/admin/adm_login.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
alternc/trunk/bureau/admin/adm_login.php
r2900 r2910 30 30 require_once("../class/config.php"); 31 31 32 // If we just want to return to our previous session 33 $oldid=intval($_COOKIE['oldid']); 34 if ($oldid) { 32 /* 33 We come into this page in two situations : 34 * with a user id to go to (we check the current account is admin and is allowed to connect to this account) 35 * with no parameter when the admin want to go back to his admin account. 36 */ 37 38 39 // * with no parameter when the admin want to go back to his admin account. 40 if (!$_REQUEST["id"] && $_COOKIE["oldid"]) { 41 // We check the cookie's value : 42 list($newuid,$passcheck)=explode("/",$_COOKIE["oldid"]); 43 $newuid=intval($newuid); 44 if (!$newuid) { 45 $error=_("Your authentication information are incorrect"); 46 include("index.php"); 47 exit(); 48 } 49 $admin->enabled=true; 50 $r=$admin->get($newuid); 51 if ($passcheck!=md5($r["pass"])) { 52 $error=_("Your authentication information are incorrect"); 53 include("index.php"); 54 exit(); 55 } 56 57 // Ok, so we remove the cookie : 35 58 setcookie('oldid','',0,'/'); 36 59 unset($_COOKIE['oldid']); 37 60 38 $db->query("select lastip from membres where uid='$oldid';"); 39 $db->next_record(); 40 if ($db->f("lastip") != getenv("REMOTE_ADDR") ) { 41 die('Error : bad IP address'); 42 } 43 44 if (!$mem->setid($oldid)) { 45 $oldid=null; 61 // And we go back to the former administrator account : 62 if (!$mem->setid($newuid)) { 46 63 $error=$err->errstr(); 47 64 include("index.php"); 48 65 exit(); 49 66 } 50 $oldid=null;51 67 include_once("adm_list.php"); 52 68 exit(); 53 69 } 54 70 71 72 // * with a user id to go to (we check the current account is admin and is allowed to connect to this account) 55 73 if (!$admin->enabled) { 56 74 __("This page is restricted to authorized staff"); … … 63 81 getFields($fields); 64 82 83 // Depending on subadmin_restriction, a subadmin can (or cannot) connect to account he didn't create 65 84 $subadmin=variable_get("subadmin_restriction"); 66 67 85 if ($subadmin==0 && !$admin->checkcreator($id)) { 68 86 __("This page is restricted to authorized staff"); … … 73 91 $error=$err->errstr(); 74 92 } else { 75 setcookie('oldid',$cuid,0,'/'); 76 $_COOKIE['oldid']=$cuid; 93 $oldid=$cuid."/".md5($mem->user["pass"]); 94 setcookie('oldid',$oldid,0,'/'); 95 $_COOKIE['oldid']=$oldid; 77 96 78 97 if (!$mem->setid($id)) { … … 81 100 exit(); 82 101 } 83 102 // Now we are the other user :) 84 103 include_once("main.php"); 85 104 exit(); 86 105 } 87 106 107 // If there were an error, let's show it : 88 108 include_once("head.php"); 89 109 … … 97 117 exit(); 98 118 } 119 120 include_once("foot.php"); 121 99 122 ?> 100 <?php include_once("foot.php"); ?>
Note: See TracChangeset
for help on using the changeset viewer.
