Changeset 19 for minimanager/realm.php
- Timestamp:
- Aug 13, 2007, 9:05:34 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/realm.php
r5 r19 34 34 global $lang_global, $lang_realm, $output, $realm_db, $user_name, $server, $realm_id, $icon_type, $timezone_type; 35 35 36 $ mysql = new MySQL;37 $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);38 39 $order_by = (isset($_GET['order_by'])) ? $ mysql->quote_smart($_GET['order_by']) : "name";40 $dir = (isset($_GET['dir'])) ? $ mysql->quote_smart($_GET['dir']) : 1;36 $sql = new SQL; 37 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 38 39 $order_by = (isset($_GET['order_by'])) ? $sql->quote_smart($_GET['order_by']) : "name"; 40 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1; 41 41 $order_dir = ($dir) ? "ASC" : "DESC"; 42 42 $dir = ($dir) ? 0 : 1; 43 43 44 $result = $mysql->query("SELECT id,name,address,port,icon,color,timezone FROM `realmlist` ORDER BY $order_by $order_dir"); 45 $total_realms = $mysql->num_rows($result); 44 $result = $sql->query("SELECT `realmlist`.id AS rid,name,address,port,icon,color,timezone, 45 (SELECT SUM(numchars) FROM realmcharacters WHERE realmid = rid) 46 FROM `realmlist` ORDER BY $order_by $order_dir"); 47 $total_realms = $sql->num_rows($result); 46 48 47 49 $output .= "<center><table class=\"top_hidden\"> … … 54 56 <table class=\"lined\"> 55 57 <tr> 56 <t d width=\"5%\" class=\"head\">{$lang_global['delete']}</td>57 <t d width=\"40%\" class=\"head\"><a href=\"realm.php?order_by=name&dir=$dir\" class=\"head_link\">{$lang_realm['name']}</a></td>58 <t d width=\"5%\" class=\"head\">{$lang_realm['online']}</td>59 <t d width=\"10%\" class=\"head\">{$lang_realm['tot_char']}</td>60 <t d width=\"10%\" class=\"head\"><a href=\"realm.php?order_by=address&dir=$dir\" class=\"head_link\">{$lang_realm['address']}</a></td>61 <t d width=\"5%\" class=\"head\"><a href=\"realm.php?order_by=port&dir=$dir\" class=\"head_link\">{$lang_realm['port']}</a></td>62 <t d width=\"8%\" class=\"head\"><a href=\"realm.php?order_by=icon&dir=$dir\" class=\"head_link\">{$lang_realm['icon']}</a></td>63 <t d width=\"5%\" class=\"head\"><a href=\"realm.php?order_by=color&dir=$dir\" class=\"head_link\">{$lang_realm['color']}</a></td>64 <t d width=\"7%\" class=\"head\"><a href=\"realm.php?order_by=timezone&dir=$dir\" class=\"head_link\">{$lang_realm['timezone']}</a></td>58 <th width=\"5%\">{$lang_global['delete_short']}</th> 59 <th width=\"40%\"><a href=\"realm.php?order_by=name&dir=$dir\">".($order_by=='name' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_realm['name']}</a></th> 60 <th width=\"5%\">{$lang_realm['online']}</th> 61 <th width=\"10%\">{$lang_realm['tot_char']}</th> 62 <th width=\"10%\"><a href=\"realm.php?order_by=address&dir=$dir\">".($order_by=='address' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_realm['address']}</a></th> 63 <th width=\"5%\"><a href=\"realm.php?order_by=port&dir=$dir\">".($order_by=='port' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_realm['port']}</a></th> 64 <th width=\"8%\"><a href=\"realm.php?order_by=icon&dir=$dir\">".($order_by=='icon' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_realm['icon']}</a></th> 65 <th width=\"5%\"><a href=\"realm.php?order_by=color&dir=$dir\">".($order_by=='color' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_realm['color']}</a></th> 66 <th width=\"7%\"><a href=\"realm.php?order_by=timezone&dir=$dir\">".($order_by=='timezone' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_realm['timezone']}</a></th> 65 67 </tr>"; 66 68 67 while ($realm = $ mysql->fetch_row($result)){68 $output .= "<tr><td><a href=\"realm.php?action=del_realm&id=$realm[0]\"><img src=\"img/ x.ico\" class=\"no_border\" alt=\"\" /></a></td>";69 while ($realm = $sql->fetch_row($result)){ 70 $output .= "<tr><td><a href=\"realm.php?action=del_realm&id=$realm[0]\"><img src=\"img/aff_cross.png\" alt=\"\" /></a></td>"; 69 71 if (isset($server[$realm[0]]['game_port'])) { 70 72 $output .= "<td><a href=\"realm.php?action=edit_realm&id=$realm[0]\">$realm[1]</a></td>"; 71 if (test_port($server[$realm[0]]['addr'],$server[$realm[0]]['game_port'])) $output .= "<td><img src=\"img/up.gif\" class=\"no_border\"alt=\"\" /></td>";72 else $output .= "<td><img src=\"img/down.gif\" class=\"no_border\"alt=\"\" /></td>";73 if (test_port($server[$realm[0]]['addr'],$server[$realm[0]]['game_port'])) $output .= "<td><img src=\"img/up.gif\" alt=\"\" /></td>"; 74 else $output .= "<td><img src=\"img/down.gif\" alt=\"\" /></td>"; 73 75 } else $output .= "<td><a href=\"realm.php?action=edit_realm&id=$realm[0]\">$realm[1] (Not Configured yet)</a></td> 74 76 <td>***</td>"; 75 77 76 $query_1 = $mysql->query("SELECT SUM(numchars) FROM realmcharacters WHERE realmid = '$realm[0]'"); 77 78 $output .= "<td>".$mysql->result($query_1, 0)."</td> 78 $output .= "<td>$realm[7]</td> 79 79 <td>$realm[2]</td> 80 80 <td>$realm[3]</td> … … 86 86 $output .= "</table><br /></center>"; 87 87 88 $ mysql->close();88 $sql->close(); 89 89 } 90 90 … … 99 99 if(!isset($_GET['id'])) redirect("realm.php?error=1"); 100 100 101 $mysql = new MySQL; 102 $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 103 104 $id = $mysql->quote_smart($_GET['id']); 105 106 $result = $mysql->query("SELECT id,name,address,port,icon,color,timezone FROM realmlist WHERE id ='$id'"); 107 108 if ($realm = $mysql->fetch_row($result)) { 101 $sql = new SQL; 102 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 103 104 $id = $sql->quote_smart($_GET['id']); 105 106 $result = $sql->query("SELECT realmlist.id AS rid,name,address,port,icon,color,timezone, 107 (SELECT SUM(numchars) FROM realmcharacters WHERE realmid = rid) 108 FROM realmlist WHERE id ='$id'"); 109 110 if ($realm = $sql->fetch_row($result)) { 109 111 $output .= "<center> 110 112 <fieldset style=\"width: 550px;\"> … … 159 161 $output .= "</tr></td> 160 162 <tr><td>"; 161 $result = $mysql->query("SELECT SUM(numchars) FROM realmcharacters WHERE realmid = '$realm[0]'"); 162 $output .= "<tr><td>{$lang_realm['tot_char']}</td><td>".$mysql->result($result, 0)."</td></tr>"; 163 $output .= "<tr><td>{$lang_realm['tot_char']}</td><td>$realm[7]</td></tr>"; 163 164 } else $output .= "<tr><td colspan=\"2\">{$lang_realm['conf_from_file']}</td><td>"; 164 165 … … 177 178 } else error($lang_global['err_no_result']); 178 179 179 $ mysql->close();180 $sql->close(); 180 181 } 181 182 … … 192 193 } 193 194 194 $mysql = new MySQL; 195 $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 196 197 $id = $mysql->quote_smart($_GET['id']); 198 $new_name = $mysql->quote_smart($_GET['new_name']); 199 $new_address = $mysql->quote_smart($_GET['new_address']); 200 $new_port = $mysql->quote_smart($_GET['new_port']); 201 $new_icon = $mysql->quote_smart($_GET['new_icon']); 202 $new_color = $mysql->quote_smart($_GET['new_color']); 203 $new_timezone = $mysql->quote_smart($_GET['new_timezone']); 204 205 $sql = "UPDATE realmlist SET name='$new_name', address ='$new_address' , port ='$new_port', icon ='$new_icon', color ='$new_color', timezone ='$new_timezone' WHERE id = '$id'"; 206 $query = $mysql->query($sql); 207 208 if ($mysql->affected_rows()) { 209 $mysql->close(); 195 $sql = new SQL; 196 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 197 198 $id = $sql->quote_smart($_GET['id']); 199 $new_name = $sql->quote_smart($_GET['new_name']); 200 $new_address = $sql->quote_smart($_GET['new_address']); 201 $new_port = $sql->quote_smart($_GET['new_port']); 202 $new_icon = $sql->quote_smart($_GET['new_icon']); 203 $new_color = $sql->quote_smart($_GET['new_color']); 204 $new_timezone = $sql->quote_smart($_GET['new_timezone']); 205 206 $query = $sql->query("UPDATE realmlist SET name='$new_name', address ='$new_address' , port ='$new_port', icon ='$new_icon', color ='$new_color', timezone ='$new_timezone' WHERE id = '$id'"); 207 208 if ($sql->affected_rows()) { 209 $sql->close(); 210 210 redirect("realm.php?error=3"); 211 211 } else { 212 $ mysql->close();212 $sql->close(); 213 213 redirect("realm.php?action=edit_realm&id=$id&error=4"); 214 214 } … … 226 226 227 227 $output .= "<center><h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />"; 228 $output .= "<font class=\"bold\">{$lang_realm['realm_id']}: $id 228 $output .= "<font class=\"bold\">{$lang_realm['realm_id']}: $id<br />{$lang_global['will_be_erased']}</font><br /><br />"; 229 229 $output .= "<table class=\"hidden\"> 230 230 <tr> … … 245 245 global $realm_db; 246 246 247 $ mysql = new MySQL;248 $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);249 250 if(isset($_GET['id'])) $id = $ mysql->quote_smart($_GET['id']);247 $sql = new SQL; 248 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 249 250 if(isset($_GET['id'])) $id = $sql->quote_smart($_GET['id']); 251 251 else redirect("realm.php?error=1"); 252 252 253 $ mysql->query("DELETE FROM realmlist WHERE id = '$id'");254 255 if ($ mysql->affected_rows()) {256 $ mysql->close();253 $sql->query("DELETE FROM realmlist WHERE id = '$id'"); 254 255 if ($sql->affected_rows()) { 256 $sql->close(); 257 257 redirect("realm.php"); 258 258 } else { 259 $ mysql->close();259 $sql->close(); 260 260 redirect("realm.php?error=2"); 261 261 } … … 270 270 global $realm_db; 271 271 272 $ mysql = new MySQL;273 $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);274 275 $result = $ mysql->query("INSERT INTO realmlist (id, name, address, port, icon, color, timezone)272 $sql = new SQL; 273 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 274 275 $result = $sql->query("INSERT INTO realmlist (id, name, address, port, icon, color, timezone) 276 276 VALUES (NULL,'MANGOS','127.0.0.1', 8085 ,0 ,0 ,1)"); 277 277 278 $ mysql->close();278 $sql->close(); 279 279 280 280 if ($result) redirect("realm.php"); … … 290 290 global $realm_db; 291 291 292 $ mysql = new MySQL;293 $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);294 295 $id = (isset($_GET['id'])) ? $ mysql->quote_smart($_GET['id']) : 1;296 297 $result = $ mysql->query("SELECT id FROM realmlist WHERE id ='$id'");298 if ($ mysql->num_rows($result)) $_SESSION['realm_id'] = $id;299 $ mysql->close();292 $sql = new SQL; 293 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 294 295 $id = (isset($_GET['id'])) ? $sql->quote_smart($_GET['id']) : 1; 296 297 $result = $sql->query("SELECT id FROM realmlist WHERE id ='$id'"); 298 if ($sql->num_rows($result)) $_SESSION['realm_id'] = $id; 299 $sql->close(); 300 300 301 301 $url = (isset($_GET['url'])) ? $_GET['url'] : "index.php";
Note:
See TracChangeset
for help on using the changeset viewer.