Changeset 109 for db/index.php
- Timestamp:
- Oct 14, 2007, 1:35:47 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
db/index.php
r102 r109 6 6 /* =========== Config aj. =========== */ 7 7 require_once "./config.php"; 8 require_once "./menu.php"; 9 10 require_once "./language/".$Config['DB_read']['language'].".php"; 8 require_once "./check_database.php"; 11 9 12 10 /* =========== Připojení k Databázi =========== */ 13 14 11 @mysql_connect( $Config['DB_read']['Database']['Host'], $Config['DB_read']['Database']['User'], $Config['DB_read']['Database']['Password'] ) 15 12 OR DIE("<p>Vyskytla se chyba a nelze se připojit k databázi.<br> Zkuste to později.</p>"); 16 @mysql_select_db($Config['DB_read']['DB_read']['Database_mangos']) 17 OR DIE("<p>Nepodařilo se nastavit pracovní databázi ".$Config['DB_read']['DB_read']['Database_mangos']."!</p>"); 18 /* $DB_realmd = mysql_select_db($Config['DB_read']['DB_read']['Database_realmd']); 19 if( !$DB_realmd ){ DIE("<p>Nepodařilo se nastavit pracovní databázi ".$Config['DB_read']['DB_read']['Database_realmd']."!</p>"); }; 20 $DB_web = mysql_select_db($Config['DB_read']['DB_read']['Database_web']); 21 if( !$DB_web ){ DIE("<p>Nepodařilo se nastavit pracovní databázi ".$Config['DB_read']['DB_read']['Database_web']."!</p>"); }; */ 22 @mysql_query("SET CHARACTER SET utf8"); 13 14 /* =========== Login / Logout =========== */ 15 @mysql_select_db($Config['DB_read']['DB_read']['Database_realmd']) 16 OR DIE("<p>Nepodařilo se nastavit pracovní databázi ".$Config['DB_read']['DB_read']['Database_realmd']."!</p>"); 17 @mysql_query("SET CHARACTER SET utf8"); 18 19 if( !empty($_POST['username']) AND !empty($_POST['pass']) ){ 20 $nick = $_POST['username']; 21 $heslo = $_POST['pass']; 22 $zakodovane_heslo = sha1(STRTOUPPER($nick).":".STRTOUPPER($heslo)); 23 24 /* přihlášení proběhne pouze pokud bylo odesláno heslo a jméno */ 25 $sql_user = @mysql_query("SELECT * FROM `account` WHERE (`username`='$nick' AND `I`='$zakodovane_heslo') LIMIT 1 "); 26 if( mysql_num_rows($sql_user) == 1 ) { 27 $login_info = @MySQL_Fetch_Array($sql_user); 28 29 @mysql_select_db($Config['DB_read']['DB_read']['Database_web']) 30 OR DIE("<p>Nepodařilo se nastavit pracovní databázi ".$Config['DB_read']['DB_read']['Database_web']."!</p>"); 31 @mysql_query("SET CHARACTER SET utf8"); 32 33 $sql_active_id_dotaz = @mysql_query("SELECT * FROM `acc_online` WHERE `nick`='".$login_info['username']."' LIMIT 1"); 34 if( @mysql_num_rows($sql_active_id_dotaz) == 1 ) { 35 $active = @MySQL_Fetch_Array($sql_active_id_dotaz); 36 } else{ unset($active); }; 37 38 if( empty($active['id']) ){ 39 @mysql_query("INSERT INTO `acc_online` ( `nick`, `phpsession`, `hodnost`, `dateoflogin` ) VALUES ( '".$login_info['username']."', '".$session."', '".$login_info['gmlevel']."', '".time()."' )"); 40 $login_err = "Přihlášení proběhlo úspěšně."; 41 } 42 elseif( !empty($active['id']) ){ 43 @mysql_query("DELETE FROM `acc_online` WHERE id='".$active['id']."' LIMIT 1 "); 44 @mysql_query("INSERT INTO `acc_online` ( `nick`, `phpsession`, `hodnost`, `dateoflogin` ) VALUES ( '".$login_info['username']."', '".$session."', '".$login_info['gmlevel']."', '".time()."' )"); 45 $login_err = "Přihlášení proběhlo úspěšně."; 46 } 47 else{ $login_err = "Chyba: Nelze se přihlásit! <br> Zkuste to znovu. "; }; 48 49 } 50 else{ $login_err = "Nejste registrovaný uživatel nebo byly špaťně zadány údaje,<br /> přihlásit se proto nemůžete! "; }; 51 } 52 elseif( isset($_POST['login']) AND ( empty($prijaty_nick) OR empty($prijate_heslo) ) ){ 53 $login_err = "Jeden z údajů chybí! Vyplňte Prosím jméno i heslo!"; 54 }; 55 56 @mysql_select_db($Config['DB_read']['DB_read']['Database_web']) 57 OR DIE("<p>Nepodařilo se nastavit pracovní databázi ".$Config['DB_read']['DB_read']['Database_web']."!</p>"); 58 @mysql_query("SET CHARACTER SET utf8"); 59 60 if( $_GET['id'] == "logout" ){ 61 session_destroy(); session_regenerate_id(); 62 @mysql_query("DELETE FROM `acc_online` WHERE `phpsession`='$session' LIMIT 1"); 63 unset($user); unset($SID); 64 }; 65 66 $user_sql = mysql_query("SELECT * FROM `acc_online` WHERE `phpsession`='".$session."' LIMIT 1 "); 67 if( @mysql_num_rows($user_sql) == 1 ) { 68 $user = @MySQL_Fetch_Array($user_sql); 69 $user['loged'] = 1; 70 $get = count($_GET); 71 if( $get < 1 ){ $SID = "?PHPSESSID=".$session; } 72 else{ $SID = "&PHPSESSID=".$session; }; 73 $time_login = $user['dateoflogin']+(60*20); $time_now = time(); 74 if( $time_login <= $time_now ){ 75 session_destroy(); session_regenerate_id(); 76 @mysql_query("DELETE FROM `acc_online` WHERE `phpsession`='$session' LIMIT 1"); unset($user); unset($SID); 77 } else{ mysql_query("UPDATE `acc_online` SET `dateoflogin` = '".$time_now."' WHERE `id`='".$user['id']."' LIMIT 1"); }; 78 79 } else{ unset($user); }; 80 81 /* =========== Definice Menu =========== */ 82 $Menu = array( 83 /* 0 => array("Typ - 1/2/3","Odkaz","Popisek"); 84 // typ: 1- kategorie 85 // 2- položka 86 // 3- jiné */ 87 88 1 => array(1,"index.php?id=uvod$SID","Hlavni"), 89 2 => array(2,"./../","Zpět na web"), 90 3 => array(2,"./../minimanager/","Minimanager"), 91 4 => array(2,"./../forum/","Forum"), 92 5 => array(2,"./../registrace/","Registrace"), 93 6 => array(2,"./index.php?id=bugreport$SID","Hlášení chyb"), 94 // 7 => array(2,"./index.php?id=stats$SID","Statistiky"), 95 // 8 => array(2,"./index.php?id=races$SID","Rasy"), 96 // 9 => array(2,"./index.php?id=classes$SID","Povolání"), 97 // 10 => array(1,"#","Obecné Hledání"), 98 // 11 => array(3,"<span style=\"padding-left: 5px;\">\n <input type=\"text\" name=\"search\" maxlength=\"255\" class=\"search\" title=\"Pro Odeslání stiskněte Enter\">\n </span>",""), 99 ); 100 if( $user['loged'] == 1 ){ 101 $Menu_add = array( 102 12 => array(1,"#",$user['nick']), 103 13 => array(2,"./index.php?id=myacc$SID","Muj účet"), 104 14 => array(2,"./../guildy.php","Guildy"), 105 15 => array(2,"./../honor.php","Honor"), 106 ); $Menu = array_merge($Menu, $Menu_add); 107 if( $user['hodnost'] == 3 ){ 108 $Menu_add = array( 109 16 => array(2,"./index.php?id=admin$SID","Administrace"), 110 ); $Menu = array_merge($Menu, $Menu_add); 111 }; 112 $Menu_add = array( 17 => array(2,"./index.php?id=logout$SID","Logout") ); $Menu = array_merge($Menu, $Menu_add); 113 } else { 114 $Menu_add = array( 115 12 => array(1,"#","Uživatelé"), 116 13 => array(2,"./index.php?id=login","Login"), 117 14 => array(2,"./../guildy.php","Guildy"), 118 15 => array(2,"./../honor.php","Honor"), 119 ); $Menu = array_merge($Menu, $Menu_add); 120 }; 121 $Menu_add = array( 122 // 18 => array(1,"./index.php?id=items$SID","Itemy"), 123 // 19 => array(2,"./index.php?id=items$SID","Hledání"), 124 // 20 => array(2,"./index.php?id=itemsets$SID","Sety"), 125 21 => array(1,"./index.php?id=questy$SID","Questy"), 126 22 => array(2,"./index.php?id=questy$SID","Hledání"), 127 // 23 => array(2,"./index.php?id=qzone$SID","Zóny"), 128 // 24 => array(2,"./index.php?id=qtrskill$SID","Profese"), 129 // 25 => array(2,"./index.php?id=qspecial$SID","Speciální"), 130 26 => array(1,"./index.php?id=creeps$SID","Bestiář"), 131 27 => array(2,"./index.php?id=creeps$SID","Hledání"), 132 // 28 => array(2,"./index.php?id=czone$SID","Zóny"), 133 // 29 => array(2,"./index.php?id=ctype$SID","Typy"), 134 // 30 => array(2,"./index.php?id=crare$SID","Unikátní"), 135 // 31 => array(1,"#","Geografie"), 136 // 32 => array(2,"./index.php?id=glevel$SID","Podle levelu"), 137 // 33 => array(2,"./index.php?id=gzone$SID","Zóny"), 138 // 34 => array(1,"./index.php?id=spells$SID","Spell"), 139 // 35 => array(2,"./index.php?id=spells$SID","Hledání"), 140 // 36 => array(2,"./index.php?id=sclass$SID","Podle tříd"), 141 // 37 => array(1,"./index.php?id=talents$SID","Talenty"), 142 // 38 => array(2,"./index.php?id=talents$SID","Prohlížet"), 143 // 39 => array(1,"./index.php?id=profes$SID","Profese"), 144 // 40 => array(2,"./index.php?id=profes$SID","Prohlížet"), 145 // 41 => array(2,"./index.php?id=pteach$SID","Učitelé"), 146 ); 147 $Menu = array_merge($Menu, $Menu_add); 23 148 24 149 /* =========== Speciální FCE =========== */ … … 118 243 }; 119 244 245 function GenerateMenu(){ 246 global $Menu; 247 248 $klice = array_keys($Menu); 249 $klice_count = count($klice); 250 251 for($i=0; $i <= $klice_count ;$i++){ 252 if($Menu[$klice[$i]][0] == 1){ 253 if( $inside_submenu == 1 ){ $Generated_Menu .= " </ul></li>\n"; } 254 elseif( !empty($Generated_Menu) ){ $Generated_Menu .= "</li>\n"; } unset($inside_submenu); 255 $Generated_Menu .= " <li><a href=\"".$Menu[$klice[$i]][1]."\">".$Menu[$klice[$i]][2]."</a>"; 256 $submenu = 1; 257 } 258 elseif($Menu[$klice[$i]][0] == 2){ 259 if( $submenu == 1 ){ $Generated_Menu .= "<ul>\n"; }; unset($submenu); 260 $Generated_Menu .= " <li><a href=\"".$Menu[$klice[$i]][1]."\">".$Menu[$klice[$i]][2]."</a></li>\n"; 261 $inside_submenu = 1; 262 } 263 elseif($Menu[$klice[$i]][0] == 3){ 264 if( $submenu == 1 ){ $Generated_Menu .= "<ul>"; }; unset($submenu); 265 $Generated_Menu .= " <li>".$Menu[$klice[$i]][1]."</li>\n"; 266 $inside_submenu = 1; 267 } 268 elseif( !empty($Menu[$klice[$i]][0]) AND !empty($Menu[$klice[$i]][1]) AND !empty($Menu[$klice[$i]][2]) ){ 269 $Generated_Menu .= " <li><a href=\"#\">Chyba !!</a>"; } 270 else{ $Generated_Menu .= " </ul></li>\n"; }; 271 }; 272 273 return $Generated_Menu; 274 }; 275 120 276 /* =========== END_TOP =========== */ 121 277 $vlozeni_souboru = "OK"; … … 124 280 /* =========== GET hodnoty =========== */ 125 281 $id = $_GET['id']; // tady získá id z adresy 282 $str = $_GET['str']; // tady získá str z adresy 283 $char = $_GET['char']; // tady získá str z adresy 126 284 $q = addslashes($_GET['q']); 127 285 $limit = $_GET['list']; // tady získá list z adresy … … 134 292 $creature = addslashes($_GET['creature']); 135 293 if( is_numeric($creature) == FALSE ){ unset($creature); }; 294 $item = addslashes($_GET['item']); 295 if( is_numeric($item) == FALSE ){ unset($item); }; 136 296 $lvl_d = addslashes($_GET['lvl_d']); 137 297 if( is_numeric($lvl_d) == FALSE ){ unset($lvl_d); }; … … 139 299 if( is_numeric($lvl_h) == FALSE ){ unset($lvl_h); }; 140 300 301 /* =========== Výchozí databáze =========== */ 302 @mysql_select_db($Config['DB_read']['DB_read']['Database_mangos']) 303 OR DIE("<p>Nepodařilo se nastavit pracovní databázi ".$Config['DB_read']['DB_read']['Database_mangos']."!</p>"); 304 @mysql_query("SET CHARACTER SET utf8"); 305 141 306 /* =========== Vložení základního souboru =========== */ 307 require_once "./language/".$Config['DB_read']['language'].".php"; 308 142 309 require_once "./post_read.php"; 143 310 require_once "./hlavni.php";
Note:
See TracChangeset
for help on using the changeset viewer.