Changeset 19 for minimanager/login.php
- Timestamp:
- Aug 13, 2007, 9:05:34 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/login.php
r5 r19 19 19 if ( empty($_POST['user']) || empty($_POST['pass']) ) redirect("login.php?error=2"); 20 20 21 $ mysql = new MySQL;22 $link = $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);23 24 $user_name = $ mysql->quote_smart($_POST['user']);25 $user_pass = $ mysql->quote_smart($_POST['pass']);26 27 $result = $ mysql->query("SELECT id,gmlevel,username FROM account WHERE username='$user_name' AND I='$user_pass' ");28 29 if ($ mysql->num_rows($result) == 1) {30 $id = $ mysql->result($result, 0, 'id');31 $result1 = $ mysql->query("SELECT count(*) FROM account_banned WHERE id ='$id'");32 if ($ mysql->result($result1, 0)) {33 $ mysql->close();21 $sql = new SQL; 22 $link = $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 23 24 $user_name = $sql->quote_smart($_POST['user']); 25 $user_pass = $sql->quote_smart($_POST['pass']); 26 27 $result = $sql->query("SELECT id,gmlevel,username FROM account WHERE username='$user_name' AND I='$user_pass' "); 28 29 if ($sql->num_rows($result) == 1) { 30 $id = $sql->result($result, 0, 'id'); 31 $result1 = $sql->query("SELECT count(*) FROM account_banned WHERE id ='$id'"); 32 if ($sql->result($result1, 0)) { 33 $sql->close(); 34 34 redirect("login.php?error=3"); 35 35 } else { 36 36 $_SESSION['user_id'] = $id; 37 $_SESSION['uname'] = $ mysql->result($result, 0, 'username');38 $_SESSION['user_lvl'] = $ mysql->result($result, 0, 'gmlevel');39 $_SESSION['realm_id'] = $ mysql->quote_smart($_POST['realm']);37 $_SESSION['uname'] = $sql->result($result, 0, 'username'); 38 $_SESSION['user_lvl'] = $sql->result($result, 0, 'gmlevel'); 39 $_SESSION['realm_id'] = $sql->quote_smart($_POST['realm']); 40 40 $_SESSION['client_ip'] = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : getenv('REMOTE_ADDR'); 41 41 … … 45 45 setcookie("p_hash", $user_pass, time()+60*60*24*7); 46 46 } 47 $ mysql->close();47 $sql->close(); 48 48 redirect("index.php"); 49 49 } 50 50 } else { 51 $ mysql->close();51 $sql->close(); 52 52 redirect("login.php?error=1"); 53 53 } … … 90 90 </tr>"; 91 91 92 $ mysql = new MySQL;93 $link = $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);94 $result = $ mysql->query("SELECT id,name FROM `realmlist` LIMIT 10");95 96 if ($ mysql->num_rows($result)>1){92 $sql = new SQL; 93 $link = $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 94 $result = $sql->query("SELECT id,name FROM `realmlist` LIMIT 10"); 95 96 if ($sql->num_rows($result)>1){ 97 97 $output .= "<tr align=\"left\"> 98 98 <td colspan=\"2\">{$lang_login['select_realm']} : 99 99 <select name=\"realm\">"; 100 100 101 while ($realm = $ mysql->fetch_row($result)){101 while ($realm = $sql->fetch_row($result)) 102 102 $output .= "<option value=\"$realm[0]\">$realm[1]</option>"; 103 } 103 104 104 $output .= "</select></td></tr>"; 105 105 } else { 106 $output .= "<input type=\"hidden\" name=\"realm\" value=\"".$ mysql->result($result, 0, 'id')."\" />";106 $output .= "<input type=\"hidden\" name=\"realm\" value=\"".$sql->result($result, 0, 'id')."\" />"; 107 107 } 108 $ mysql->close();108 $sql->close(); 109 109 110 110 $output .= "<tr align=\"left\"> … … 131 131 //################################################################################################# 132 132 function do_cookie_login(){ 133 global $lang_global, $realm_db;133 global $lang_global, $realm_db; 134 134 135 135 if ( empty($_COOKIE['uname']) || empty($_COOKIE['p_hash']) || empty($_COOKIE['realm_id'])) redirect("login.php?error=2"); 136 136 137 $ mysql = new MySQL;138 $link = $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);139 $user_name = $ mysql->quote_smart($_COOKIE['uname']);140 $user_pass = $ mysql->quote_smart($_COOKIE['p_hash']);141 142 $result = $ mysql->query("SELECT username,gmlevel,id FROM account WHERE username='$user_name' AND I='$user_pass'");143 144 if ($ mysql->num_rows($result) == 1) {145 $id = $ mysql->result($result, 0, 'id');146 $result1 = $ mysql->query("SELECT count(*) FROM account_banned WHERE id ='$id'");147 if ($ mysql->result($result1, 0)) {148 $ mysql->close();137 $sql = new SQL; 138 $link = $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 139 $user_name = $sql->quote_smart($_COOKIE['uname']); 140 $user_pass = $sql->quote_smart($_COOKIE['p_hash']); 141 142 $result = $sql->query("SELECT username,gmlevel,id FROM account WHERE username='$user_name' AND I='$user_pass'"); 143 144 if ($sql->num_rows($result)) { 145 $id = $sql->result($result, 0, 'id'); 146 $result1 = $sql->query("SELECT count(*) FROM account_banned WHERE id ='$id'"); 147 if ($sql->result($result1, 0)) { 148 $sql->close(); 149 149 redirect("login.php?error=3"); 150 150 } else { 151 151 $_SESSION['user_id'] = $id; 152 $_SESSION['uname'] = $ mysql->result($result, 0, 'username');153 $_SESSION['user_lvl'] = $ mysql->result($result, 0, 'gmlevel');154 $_SESSION['realm_id'] = $ mysql->quote_smart($_COOKIE['realm_id']);152 $_SESSION['uname'] = $sql->result($result, 0, 'username'); 153 $_SESSION['user_lvl'] = $sql->result($result, 0, 'gmlevel'); 154 $_SESSION['realm_id'] = $sql->quote_smart($_COOKIE['realm_id']); 155 155 $_SESSION['client_ip'] = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : getenv('REMOTE_ADDR'); 156 156 157 $ mysql->close();157 $sql->close(); 158 158 redirect("index.php"); 159 159 } 160 160 } else { 161 $ mysql->close();161 $sql->close(); 162 162 setcookie ("uname", "", time() - 3600); 163 163 setcookie ("realm_id", "", time() - 3600); … … 173 173 if (isset($_COOKIE["uname"]) && isset($_COOKIE["p_hash"]) && isset($_COOKIE["realm_id"]) && !isset($_GET['error'])) { 174 174 do_cookie_login(); 175 exit();176 175 } 177 176
Note:
See TracChangeset
for help on using the changeset viewer.