Changeset 609 for trunk/inc/player.php
- Timestamp:
- Aug 7, 2009, 10:03:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/player.php
r583 r609 7 7 private $db; 8 8 9 function __construct 9 function __construct($db) 10 10 { 11 11 $this->db = &$db; … … 15 15 { 16 16 if($err == 0) echo('<img src="imgs/inc/on.gif"> <font color="#234303" size="4">'.$text.'</font><br />'); 17 else echo('<img src="imgs/inc/off.gif"> <font color="#990000" size="4\">'.$text.'</font><br />');17 else echo('<img src="imgs/inc/off.gif"> <font color="#990000" size="4\">'.$text.'</font><br />'); 18 18 } 19 19 … … 49 49 if($sql->num_rows == 1) 50 50 { 51 $row = $sql->fetch_a rray();51 $row = $sql->fetch_assoc(); 52 52 $_SESSION['UserId'] = $row['id']; 53 53 $_SESSION['UserName'] = $username; … … 73 73 if(!array_key_exists('Time', $_SESSION)) $_SESSION['Time'] = time(); 74 74 if(!array_key_exists('UserId', $_SESSION)) $_SESSION['UserId'] = 0; 75 if($_SESSION['Time'] < (time() - 60 * $this->SessionTimeout)) 76 { 77 $this->Logout(); 78 } 75 if($_SESSION['Time'] < (time() - 60 * $this->SessionTimeout)) $this->Logout(); 79 76 $_SESSION['Time'] = time(); 80 77 return($_SESSION['UserId'] != 0); … … 83 80 public function LoginForm() 84 81 { 85 echo('<form method="post" action="?page=acc"> 86 <table>87 <tr>88 82 echo('<form method="post" action="?page=acc">'. 83 '<table>'. 84 '<tr>'. 85 '<td><b>Jméno : </b></td><td><input type="text" name="user" class="textinput"></td> 89 86 </tr> 90 87 <tr> … … 97 94 </form> 98 95 <div align="left"> 99 <a href="?page=register">Registrace</a><br /> <a href="?page=lostpass">Obnova hesla</a>100 </div>');96 <a href="?page=register">Registrace</a><br />'. //<a href="?page=lostpass">Obnova hesla</a> 97 '</div>'); 101 98 } 102 99 … … 105 102 global $Config; 106 103 107 $this->db->select_db($Config['Mangos']['DatabaseCharacters']); 108 $DbResult = $this->db->query( 109 'SELECT CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.($Config['Mangos']['CharacterDataOffset']['Level'] + 1).'), " ", -1)'. 110 ' AS UNSIGNED) AS `level` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;'); 104 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 105 $DbResult = $this->db->query('SELECT CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.($Config['Mangos']['CharacterDataOffset']['Level'] + 1).'), " ", -1) AS UNSIGNED) AS `level` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;'); 111 106 $row = $DbResult->fetch_assoc(); 112 107 return($row['level']); … … 146 141 if(!$this->IsOnline($guid)) 147 142 { 148 $this->db->select_db($Config['Mangos'][' DatabaseCharacters']);143 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 149 144 $row = $this->db->query('SELECT `data` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_assoc(); 150 145 $data = explode(' ', $row['data']); … … 161 156 global $Config; 162 157 163 $this->db->select_db($Config['Mangos'][' DatabaseCharacters']);158 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 164 159 if($this->CharInAcc($guid, 0)) 165 160 { … … 189 184 global $Config; 190 185 191 $this->db->select_db($Config['Mangos'][' DatabaseCharacters']);186 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 192 187 // .go xyz -90.54 41.35 -31.71 193 188 // .go xyz -91.01 100.46 -31.71 … … 230 225 global $Config; 231 226 232 $this->db->select_db($Config['Mangos'][' DatabaseCharacters']);227 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 233 228 $row = $this->db->query('SELECT `online` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;')->fetch_assoc(); 234 229 if($row['online'] == 1) return(true); 235 else return(false);230 else return(false); 236 231 } 237 232 … … 246 241 $acc = $_SESSION['UserId']; 247 242 } 248 $this->db->select_db($Config['Mangos'][' DatabaseCharacters']);243 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 249 244 if($this->db->query('SELECT `guid` FROM `characters` WHERE `characters`.`guid`="'.$char.'" AND `account`="'.$acc.'" LIMIT 1;')->num_rows == 1) 250 245 { … … 265 260 global $Config; 266 261 267 $this->db->select_db($Config['Mangos'][' DatabaseCharacters']);262 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 268 263 $row = $this->db->query('SELECT `guid` FROM `characters` WHERE `name` LIKE "'.$name.'" LIMIT 1;')->fetch_assoc(); 269 264 if($row['guid'] != '') … … 280 275 global $Config; 281 276 282 $this->db->select_db($Config['Mangos'][' DatabaseCharacters']);277 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 283 278 $row = $this->db->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;')->fetch_assoc(); 284 279 if($row['name'] != '') … … 359 354 <th>Nahráno</th> 360 355 </tr>'); 361 $this->db->select_db($Config['Mangos'][' DatabaseCharacters']);356 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']); 362 357 echo($this->db->error); 363 358 $sql = $this->db->query('SELECT `guid`,`name`,`race`,`totaltime`,`class`, mid(lpad( hex( CAST(substring_index(substring_index(data, " ", '.($Config['Mangos']['CharacterDataOffset']['Gender'] + 1).'), " ",-1) AS unsigned) ), 8, 0), 4, 1) AS gender FROM `characters` WHERE `account`='.$accid.' ORDER BY `totaltime` DESC LIMIT 0, 10');
Note:
See TracChangeset
for help on using the changeset viewer.