Changeset 19 for minimanager/realm.php


Ignore:
Timestamp:
Aug 13, 2007, 9:05:34 PM (17 years ago)
Author:
george
Message:

Aktualizace MaNGOS Minimanageru na verzi 0.1.4a.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • minimanager/realm.php

    r5 r19  
    3434 global $lang_global, $lang_realm, $output, $realm_db, $user_name, $server, $realm_id, $icon_type, $timezone_type;
    3535
    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;
    4141 $order_dir = ($dir) ? "ASC" : "DESC";
    4242 $dir = ($dir) ? 0 : 1;
    4343 
    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);
    4648
    4749 $output .= "<center><table class=\"top_hidden\">
     
    5456   <table class=\"lined\">
    5557   <tr>
    56         <td width=\"5%\" class=\"head\">{$lang_global['delete']}</td>
    57         <td width=\"40%\" class=\"head\"><a href=\"realm.php?order_by=name&amp;dir=$dir\" class=\"head_link\">{$lang_realm['name']}</a></td>
    58         <td width=\"5%\" class=\"head\">{$lang_realm['online']}</td>
    59         <td width=\"10%\" class=\"head\">{$lang_realm['tot_char']}</td>
    60         <td width=\"10%\" class=\"head\"><a href=\"realm.php?order_by=address&amp;dir=$dir\" class=\"head_link\">{$lang_realm['address']}</a></td>
    61         <td width=\"5%\" class=\"head\"><a href=\"realm.php?order_by=port&amp;dir=$dir\" class=\"head_link\">{$lang_realm['port']}</a></td>
    62         <td width=\"8%\" class=\"head\"><a href=\"realm.php?order_by=icon&amp;dir=$dir\" class=\"head_link\">{$lang_realm['icon']}</a></td>
    63     <td width=\"5%\" class=\"head\"><a href=\"realm.php?order_by=color&amp;dir=$dir\" class=\"head_link\">{$lang_realm['color']}</a></td>
    64         <td width=\"7%\" class=\"head\"><a href=\"realm.php?order_by=timezone&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;dir=$dir\">".($order_by=='timezone' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_realm['timezone']}</a></th>
    6567   </tr>";
    6668
    67  while ($realm = $mysql->fetch_row($result)){
    68         $output .= "<tr><td><a href=\"realm.php?action=del_realm&amp;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&amp;id=$realm[0]\"><img src=\"img/aff_cross.png\" alt=\"\" /></a></td>";
    6971        if (isset($server[$realm[0]]['game_port'])) {
    7072                $output .= "<td><a href=\"realm.php?action=edit_realm&amp;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>";
    7375        } else $output .= "<td><a href=\"realm.php?action=edit_realm&amp;id=$realm[0]\">$realm[1] (Not Configured yet)</a></td>
    7476                                           <td>***</td>";
    7577
    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>
    7979                                <td>$realm[2]</td>
    8080                                <td>$realm[3]</td>
     
    8686 $output .= "</table><br /></center>";
    8787
    88  $mysql->close();
     88 $sql->close();
    8989}
    9090
     
    9999 if(!isset($_GET['id'])) redirect("realm.php?error=1");
    100100 
    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)) {
    109111        $output .= "<center>
    110112        <fieldset style=\"width: 550px;\">
     
    159161        $output .= "</tr></td>
    160162                                <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>";
    163164} else $output .= "<tr><td colspan=\"2\">{$lang_realm['conf_from_file']}</td><td>";
    164165
     
    177178  } else error($lang_global['err_no_result']);
    178179 
    179  $mysql->close();
     180 $sql->close();
    180181}
    181182
     
    192193 }
    193194 
    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();
    210210        redirect("realm.php?error=3");
    211211    } else {
    212                 $mysql->close();
     212                $sql->close();
    213213                redirect("realm.php?action=edit_realm&id=$id&error=4");
    214214        }
     
    226226
    227227 $output .= "<center><h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
    228  $output .= "<font class=\"bold\">{$lang_realm['realm_id']}: $id {$lang_global['will_be_erased']}</font><br /><br />";
     228 $output .= "<font class=\"bold\">{$lang_realm['realm_id']}: $id<br />{$lang_global['will_be_erased']}</font><br /><br />";
    229229 $output .= "<table class=\"hidden\">
    230230          <tr>
     
    245245 global $realm_db;
    246246
    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']);
    251251        else redirect("realm.php?error=1");
    252252
    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();
    257257        redirect("realm.php");
    258258    } else {
    259                 $mysql->close();
     259                $sql->close();
    260260                redirect("realm.php?error=2");
    261261        }
     
    270270 global $realm_db;
    271271
    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)
    276276  VALUES (NULL,'MANGOS','127.0.0.1', 8085 ,0 ,0 ,1)");
    277277
    278  $mysql->close();
     278 $sql->close();
    279279
    280280 if ($result) redirect("realm.php");
     
    290290 global $realm_db;
    291291
    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();
    300300
    301301 $url = (isset($_GET['url'])) ? $_GET['url'] : "index.php";
Note: See TracChangeset for help on using the changeset viewer.