Example #1
0
function search()
{
    global $lang_global, $output, $itemperpage, $item_datasite, $mangos_db, $characters_db, $realm_id, $sql_search_limit;
    wowhead_tt();
    if (!isset($_GET['search_value']) || !isset($_GET['search_by'])) {
        redirect("mail_on.php?error=2");
    }
    $sql = new SQL();
    $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
    $search_value = $sql->quote_smart($_GET['search_value']);
    $search_by = $sql->quote_smart($_GET['search_by']);
    $search_menu = array('sender', 'receiver');
    // if (!array_key_exists($search_by, $search_menu)) $search_by = 'sender';
    $start = isset($_GET['start']) ? $sql->quote_smart($_GET['start']) : 0;
    $order_by = isset($_GET['order_by']) ? $sql->quote_smart($_GET['order_by']) : "id";
    $dir = isset($_GET['dir']) ? $sql->quote_smart($_GET['dir']) : 1;
    $order_dir = $dir ? "ASC" : "DESC";
    $dir = $dir ? 0 : 1;
    $temp = $sql->query("SELECT guid FROM `characters` WHERE name like '%{$search_value}%'");
    $search_value = $sql->result($temp, 0, 'guid');
    $query_1 = $sql->query("SELECT count(*) FROM `mail`");
    $query = $sql->query("SELECT a.id, a.messageType, a.sender, a.receiver, a.subject, a.itemTextId, a.has_items, a.money, a.cod, a.checked, b.item_template\r\n            FROM mail a\r\n            INNER JOIN mail_items b ON a.id = b.mail_id\r\n            WHERE {$search_by} = {$search_value}\r\n            ORDER BY {$order_by} {$order_dir} LIMIT {$start}, {$itemperpage}");
    $this_page = $sql->num_rows($query);
    $all_record = $sql->result($query_1, 0);
    $total_found = $sql->num_rows($query);
    //==========================top page navigation starts here========================
    $output .= "<center><table class=\"top_hidden\">\r\n    <tr><td>\r\n            <table class=\"hidden\">\r\n                <tr><td>\r\n            <form action=\"mail_on.php\" method=\"get\" name=\"form\">\r\n            <input type=\"hidden\" name=\"action\" value=\"search\" />\r\n            <input type=\"hidden\" name=\"error\" value=\"4\" />\r\n            <input type=\"text\" size=\"45\" name=\"search_value\" />\r\n            <select name=\"search_by\">\r\n                <option value=\"sender\">Sender</option>\r\n                <option value=\"receiver\">Receiver</option>\r\n            </select></form></td><td>";
    makebutton($lang_global['search'], "javascript:do_submit()", 80);
    $output .= "</td></tr></table>\r\n            <td align=\"right\">";
    $output .= generate_pagination("mail_on.php?action=search&amp;order_by={$order_by}&amp;dir=" . !$dir, $all_record, $itemperpage, $start);
    $output .= "</td></tr></table>";
    //==========================top page navigation ENDS here ========================
    $output .= "<table class=\"lined\">\r\n  <tr>\r\n    <th width=\"5%\">ID</th>\r\n    <th width=\"5%\">Source</th>\r\n    <th width=\"10%\">Sender</th>\r\n    <th width=\"10%\">Receiver</th>\r\n    <th width=\"15%\">Subject</th>\r\n    <th width=\"5%\">Has Items</th>\r\n    <th width=\"25%\">Text</th>\r\n    <th width=\"15%\">Money</th>\r\n    <th width=\"5%\">Checked</th>\r\n  </tr>";
    while ($mail = $sql->fetch_array($query)) {
        $g = floor($mail[7] / 10000);
        $mail[7] -= $g * 10000;
        $s = floor($mail[7] / 100);
        $mail[7] -= $s * 100;
        $c = $mail[7];
        $money = "";
        if ($mail[7] > 0) {
            $money = $g . "<img src=\"./img/gold.gif\" /> " . $s . "<img src=\"./img/silver.gif\" /> " . $c . "<img src=\"./img/copper.gif\" /> ";
        }
        $output .= "<tr valign=top>\r\n                    <td>{$mail['0']}</td>\r\n                    <td>" . get_mail_source($mail[1]) . "</td>\r\n                    <td><a href=\"char.php?id={$mail['2']}\">" . get_char_name($mail[2]) . "</a></td>\r\n                    <td><a href=\"char.php?id={$mail['3']}\">" . get_char_name($mail[3]) . "</a></td>\r\n                    <td>{$mail['4']}</td>\r\n            ";
        $output .= "<td>";
        $output .= "\r\n                    <a style=\"padding:2px;\" href=\"{$item_datasite}{$mail[10]}\" target=\"_blank\">\r\n                      <img class=\"bag_icon\" src=\"" . get_item_icon($mail[10]) . "\" alt=\"\" />\r\n                  </a>";
        //maketooltip("<img src=\"./img/up.gif\" alt=\"\">", $item_datasite{$mail[10]}, $mail[10], "item_tooltip", "target=\"_blank\"");
        $output .= "</td>";
        $output .= "<td>" . get_mail_text($mail[5]) . "</td>\r\n                        <td>{$money}</td>\r\n        <td>" . get_check_state($mail[9]) . "</td>\r\n                   </tr>";
    }
    /*--------------------------------------------------*/
    $output .= "<tr><td colspan=\"6\" class=\"hidden\" align=\"right\">All Mails: {$all_record}</td></tr>\r\n </table></center>";
    $sql->close();
}
/**
 * calculate creature health, mana and armor
 * 
 * kinda crappy way, but works
 * 
 * if $type is used:
 * 1 -> returns health
 * 2 -> returns mana
 * 3 -> returns armor
 * 0 -> returns array(health,mana,armor)      
 */
function get_additional_data($entryid, $type = 0)
{
    global $world_db, $realm_id;
    if (!is_numeric($entryid)) {
        return array(0, 0, 0);
    }
    $sqlw = new SQL();
    $sqlw->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
    $q = $sqlw->query("\n\t\tSELECT \n\t\t\t(SELECT unit_class \n\t\t\tFROM creature_template \n\t\t\tWHERE entry = " . $entryid . ") AS class, \n\t\t\t\t(SELECT FLOOR(minlevel + (RAND() * (maxlevel - minlevel + 1))) \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ") AS level, \n\t\t\t\t(SELECT exp \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ") AS exp;");
    $data = $sqlw->fetch_assoc($q);
    if ($sqlw->num_rows($q) == 0) {
        return array(0, 0, 0);
    }
    $q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Health_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basehp" . $data['exp'] . " \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5), \n\t\t\t\t((SELECT Mana_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basemana \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5),\n\t\t\t\t((SELECT Armor_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t*(SELECT basearmor \n\t\t\t\tFROM creature_classlevelstats \n\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
    if ($type == 1) {
        $q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Health_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basehp" . $data['exp'] . " \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
    }
    if ($type == 2) {
        $q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Mana_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basemana \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
    }
    if ($type == 3) {
        $q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Armor_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basearmor \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
    }
    $query = $sqlw->query($q);
    $result = $sqlw->fetch_row($query);
    $sqlw->close();
    unset($sql);
    if ($type == 2 && $result[0] == 0.5) {
        return 0;
    }
    if ($type == 0 && $result[1] == 0.5) {
        return array($result[0], 0, $result[2]);
    }
    return $type > 0 ? $result[0] : $result;
}
Example #3
0
function dologin(&$sqlr)
{
    global $mmfpm_db, $require_account_verify;
    if (empty($_POST['user']) || empty($_POST['pass'])) {
        redirect('login.php?error=2');
    }
    $user_name = $sqlr->quote_smart($_POST['user']);
    $user_pass = $sqlr->quote_smart($_POST['pass']);
    if (255 < strlen($user_name) || 255 < strlen($user_pass)) {
        redirect('login.php?error=1');
    }
    $result = $sqlr->query('SELECT id, username 
						FROM account 
						WHERE username = \'' . $user_name . '\' AND sha_pass_hash = \'' . $user_pass . '\'');
    $result2 = $sqlr->query('SELECT id, gmlevel FROM account_access');
    if ($require_account_verify) {
        $sqlm = new SQL();
        $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
        $result2 = $sqlm->query("SELECT * \n\t\t\t\t\t\t\t\t\tFROM mm_account_verification \n\t\t\t\t\t\t\t\t\tWHERE username = '******'");
        if ($sqlm->num_rows($result2) >= 1) {
            $sqlm->close;
            redirect('login.php?error=7');
        }
    }
    unset($user_name);
    if (1 == $sqlr->num_rows($result)) {
        $id = $sqlr->result($result, 0, 'id');
        if ($sqlr->result($sqlr->query('SELECT count(*) FROM account_banned WHERE id = ' . $id . ' AND active = \'1\''), 0)) {
            redirect('login.php?error=3');
        } else {
            $_SESSION['user_id'] = $id;
            $_SESSION['uname'] = $sqlr->result($result, 0, 'username');
            if ($sqlr->result($result2, 0, 'gmlevel') == null) {
                $_SESSION['user_lvl'] = 0;
            } else {
                $_SESSION['user_lvl'] = $sqlr->result($result2, 0, 'gmlevel');
            }
            $_SESSION['realm_id'] = $sqlr->quote_smart($_POST['realm']);
            $_SESSION['client_ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : getenv('REMOTE_ADDR');
            $_SESSION['logged_in'] = true;
            if (isset($_POST['remember']) && $_POST['remember'] != '') {
                setcookie('uname', $_SESSION['uname'], time() + 60 * 60 * 24 * 7);
                setcookie('realm_id', $_SESSION['realm_id'], time() + 60 * 60 * 24 * 7);
                setcookie('p_hash', $user_pass, time() + 60 * 60 * 24 * 7);
            }
            redirect('index.php');
        }
    } else {
        redirect('login.php?error=1');
    }
}
Example #4
0
function get_item_name($item_id, &$sqlw = 0)
{
    global $world_db, $realm_id;
    if ($item_id) {
        if (empty($sqlw)) {
            $sqlw = new SQL();
            $sqlw->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
        }
        $deplang = get_lang_id();
        $result = $sqlw->query('SELECT IFNULL(' . ($deplang != 0 ? 'name_loc' . $deplang . '' : 'NULL') . ', name) as name FROM item_template LEFT JOIN locales_item ON item_template.entry = locales_item.entry WHERE item_template.entry = ' . $item_id . '');
        $item_name = 1 == $sqlw->num_rows($result) ? $sqlw->result($result, 0, 'name') : 'ItemID: ' . $item_id . ' Not Found';
        return $item_name;
    } else {
        return NULL;
    }
}
Example #5
0
<?php

require_once "header.php";
//##############################################################################################
// MAIN
//##############################################################################################
$username = isset($_GET['username']) ? $_GET['username'] : NULL;
$authkey = isset($_GET['authkey']) ? $_GET['authkey'] : NULL;
$output .= "<div class=\"top\">";
$sql = new SQL();
$sql->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
$query = $sql->query("SELECT * FROM mm_account WHERE username = '******' AND authkey = '{$authkey}'");
$lang_verify = lang_verify();
if ($sql->num_rows($query) < 1) {
    $output .= "<h1><font class=\"error\">{$lang_verify['verify_failed']}</font></h1>";
} else {
    $output .= "<h1><font class=\"error\">{$lang_verify['verify_success']}</font></h1>";
    $sql2 = new SQL();
    $sql2->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    $data = mysql_fetch_array($query);
    list($id, $username, $pass, $mail, $joindate, $last_ip, $failed_logins, $locked, $last_login, $expansion) = $data;
    $sql2->query("INSERT INTO account (id,username,sha_pass_hash,email, joindate,last_ip,failed_logins,locked,last_login,expansion) VALUES ('',UPPER('{$username}'),'{$pass}','{$mail}',now(),'{$last_ip}','0','{$locked}',NULL,'{$expansion}')");
    $result = $sql2->query("SELECT * FROM account WHERE username='******'");
    $data = mysql_fetch_assoc($result);
    $sql2->query("INSERT INTO account_access (`id`,`gmlevel`) VALUES ('{$data['id']}','0')");
}
$sql->query("DELETE FROM mm_account WHERE username='******'");
$output .= "</div>";
$output .= "<center><br /><table class=\"hidden\"><tr><td>" . makebutton($lang_global['home'], 'index.php', 130) . "</td></tr></table></center>";
require_once "footer.php";
Example #6
0
function run_cleanup()
{
    global $lang_cleanup, $lang_global, $output, $realm_db, $characters_db, $realm_id, $user_lvl;
    if (empty($_GET['cleanup_by']) || empty($_GET['cleanup_sign'])) {
        redirect("cleanup.php?error=1");
    }
    $sql = new SQL();
    $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    $cleanup_by = $sql->quote_smart($_GET['cleanup_by']);
    $cleanup_sign = $sql->quote_smart($_GET['cleanup_sign']);
    $cleanup_value = $sql->quote_smart($_GET['cleanup_value']);
    switch ($cleanup_by) {
        // clean by lvl
        case "char_lvl":
            $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
            $result = $sql->query("SELECT guid FROM `characters` WHERE level {$cleanup_sign} {$cleanup_value}");
            $total_chars = $sql->num_rows($result);
            $output .= "<center>";
            if ($total_chars) {
                $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
                $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n        <input type=\"hidden\" name=\"type\" value=\"char\" />\r\n        <font class=\"bold\">{$lang_cleanup['chars_id']}: ";
                $pass_array = "";
                while ($char = $sql->fetch_row($result)) {
                    $output .= "<a href=\"char.php?id={$char['0']}\" target=\"_blank\">{$char['0']}, </a>";
                    $pass_array .= "-{$char['0']}";
                }
                $output .= "<input type=\"hidden\" name=\"check\" value=\"{$pass_array}\" />";
                $output .= "<br />{$lang_cleanup['tot_of']} {$total_chars} {$lang_global['will_be_erased']}</font><br /><br />";
                $output .= "<table class=\"hidden\">\r\n           <tr><td>";
                makebutton($lang_global['yes'], "javascript:do_submit()", 120);
                makebutton($lang_global['no'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n         </table>\r\n    </form>";
            } else {
                $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
                $output .= "<table class=\"hidden\">\r\n          <tr><td>";
                makebutton($lang_global['go_back'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n        </table>";
            }
            $output .= "</center><br />";
            break;
            //last loggin
        //last loggin
        case "last_login":
            $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
            $result = $sql->query("SELECT id FROM account WHERE last_login {$cleanup_sign} '{$cleanup_value}' AND gmlevel < {$user_lvl}");
            $total_accounts = $sql->num_rows($result);
            $output .= "<center>";
            if ($total_accounts) {
                $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
                $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n        <input type=\"hidden\" name=\"type\" value=\"acc\" />\r\n        <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
                $pass_array = "";
                while ($acc = $sql->fetch_row($result)) {
                    $output .= "<a href=\"user.php?action=edit_user&amp;id={$acc['0']}\" target=\"_blank\">{$acc['0']}, </a>";
                    $pass_array .= "-{$acc['0']}";
                }
                $output .= "<input type=\"hidden\" name=\"check\" value=\"{$pass_array}\" />";
                $output .= "<br />{$lang_cleanup['tot_of']} {$total_accounts} {$lang_global['will_be_erased']}</font><br /><br />";
                $output .= "<table class=\"hidden\">\r\n           <tr><td>";
                makebutton($lang_global['yes'], "javascript:do_submit()", 120);
                makebutton($lang_global['no'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n          </table>\r\n    </form>";
            } else {
                $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
                $output .= "<table class=\"hidden\">\r\n          <tr><td>";
                makebutton($lang_global['go_back'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n        </table>";
            }
            $output .= "</center><br />";
            break;
            //failed loggin attempts
        //failed loggin attempts
        case "failed_login":
            $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
            $result = $sql->query("SELECT id FROM account WHERE failed_logins {$cleanup_sign} {$cleanup_value} AND gmlevel < {$user_lvl}");
            $total_accounts = $sql->num_rows($result);
            $output .= "<center>";
            if ($total_accounts) {
                $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
                $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n        <input type=\"hidden\" name=\"type\" value=\"acc\" />\r\n        <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
                $pass_array = "";
                while ($acc = $sql->fetch_row($result)) {
                    $output .= "<a href=\"user.php?action=edit_user&amp;id={$acc['0']}\" target=\"_blank\">{$acc['0']}, </a>";
                    $pass_array .= "-{$acc['0']}";
                }
                $output .= "<input type=\"hidden\" name=\"check\" value=\"{$pass_array}\" />";
                $output .= "<br />{$lang_cleanup['tot_of']} {$total_accounts} {$lang_global['will_be_erased']}</font><br /><br />";
                $output .= "<table class=\"hidden\">\r\n           <tr><td>";
                makebutton($lang_global['yes'], "javascript:do_submit()", 120);
                makebutton($lang_global['no'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n          </table>\r\n      </form>";
            } else {
                $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
                $output .= "<table class=\"hidden\">\r\n          <tr><td>";
                makebutton($lang_global['go_back'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n        </table>";
            }
            $output .= "</center><br />";
            break;
            //clean banned accounts
        //clean banned accounts
        case "banned":
            $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
            $result = $sql->query("SELECT id FROM account_banned");
            $total_accounts = $sql->num_rows($result);
            $output .= "<center>";
            if ($total_accounts) {
                $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
                $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n        <input type=\"hidden\" name=\"type\" value=\"acc\" />\r\n        <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
                $pass_array = "";
                while ($acc = $sql->fetch_row($result)) {
                    $output .= "<a href=\"user.php?action=edit_user&amp;id={$acc['0']}\" target=\"_blank\">{$acc['0']}, </a>";
                    $pass_array .= "-{$acc['0']}";
                }
                $output .= "<input type=\"hidden\" name=\"check\" value=\"{$pass_array}\" />";
                $output .= "<br />{$lang_cleanup['tot_of']} {$total_accounts} {$lang_global['will_be_erased']}</font><br /><br />";
                $output .= " <table class=\"hidden\">\r\n           <tr><td>";
                makebutton($lang_global['yes'], "javascript:do_submit()", 120);
                makebutton($lang_global['no'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n          </table>\r\n      </form>";
            } else {
                $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
                $output .= "<table class=\"hidden\">\r\n          <tr><td>";
                makebutton($lang_global['go_back'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n        </table>";
            }
            $output .= "</center><br />";
            break;
            //clean chars with given total time played
        //clean chars with given total time played
        case "totaltime":
            $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
            $result = $sql->query("SELECT guid FROM `characters` WHERE totaltime {$cleanup_sign} {$cleanup_value}");
            $total_chars = $sql->num_rows($result);
            $output .= "<center>";
            if ($total_chars) {
                $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
                $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n        <input type=\"hidden\" name=\"type\" value=\"char\" />\r\n        <font class=\"bold\">{$lang_cleanup['chars_id']}: ";
                $pass_array = "";
                while ($char = $sql->fetch_row($result)) {
                    $output .= "<a href=\"char.php?id={$char['0']}\" target=\"_blank\">{$char['0']}, </a>";
                    $pass_array .= "-{$char['0']}";
                }
                $output .= "<input type=\"hidden\" name=\"check\" value=\"{$pass_array}\" />";
                $output .= "<br />{$lang_cleanup['tot_of']} {$total_chars} {$lang_global['will_be_erased']}</font><br /><br />";
                $output .= " <table class=\"hidden\">\r\n           <tr><td>";
                makebutton($lang_global['yes'], "javascript:do_submit()", 120);
                makebutton($lang_global['no'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n          </table>\r\n      </form>";
            } else {
                $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
                $output .= "<table class=\"hidden\">\r\n          <tr><td>";
                makebutton($lang_global['go_back'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n        </table>";
            }
            $output .= "</center><br />";
            break;
            //clean locked acc
        //clean locked acc
        case "locked":
            $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
            $result = $sql->query("SELECT id FROM account WHERE locked {$cleanup_sign} {$cleanup_value} AND gmlevel < {$user_lvl}");
            $total_accounts = $sql->num_rows($result);
            $output .= "<center>";
            if ($total_accounts) {
                $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
                $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n        <input type=\"hidden\" name=\"type\" value=\"acc\" />\r\n        <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
                $pass_array = "";
                while ($acc = $sql->fetch_row($result)) {
                    $output .= "<a href=\"user.php?action=edit_user&amp;id={$acc['0']}\" target=\"_blank\">{$acc['0']}, </a>";
                    $pass_array .= "-{$acc['0']}";
                }
                $output .= "<input type=\"hidden\" name=\"check\" value=\"{$pass_array}\" />";
                $output .= "<br />{$lang_cleanup['tot_of']} {$total_accounts} {$lang_global['will_be_erased']}</font><br /><br />";
                $output .= "<table class=\"hidden\">\r\n           <tr><td>";
                makebutton($lang_global['yes'], "javascript:do_submit()", 120);
                makebutton($lang_global['no'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n          </table>\r\n      </form>";
            } else {
                $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
                $output .= "<table class=\"hidden\">\r\n          <tr><td>";
                makebutton($lang_global['go_back'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n        </table>";
            }
            $output .= "</center><br />";
            break;
            //accounts without chars or specified number of chars
        //accounts without chars or specified number of chars
        case "num_of_char_in_acc":
            $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
            $result = $sql->query("SELECT id FROM account WHERE gmlevel < {$user_lvl}");
            $acc_output_array = array();
            while ($acc = $sql->fetch_row($result)) {
                $total_chars_in_acc = 0;
                foreach ($characters_db as $db) {
                    $sql->connect($db['addr'], $db['user'], $db['pass'], $db['name']);
                    $query = $sql->query("SELECT count(*) FROM `characters` WHERE account = '{$acc['0']}'");
                    $total_chars_in_acc = $total_chars_in_acc + $sql->result($query, 0);
                }
                switch ($cleanup_sign) {
                    case "=":
                        if ($total_chars_in_acc == $cleanup_value) {
                            array_push($acc_output_array, $acc[0]);
                        }
                        break;
                    case "<":
                        if ($total_chars_in_acc < $cleanup_value) {
                            array_push($acc_output_array, $acc[0]);
                        }
                        break;
                    case "<=":
                        if ($total_chars_in_acc <= $cleanup_value) {
                            array_push($acc_output_array, $acc[0]);
                        }
                        break;
                    case ">":
                        if ($total_chars_in_acc > $cleanup_value) {
                            array_push($acc_output_array, $acc[0]);
                        }
                        break;
                    case ">=":
                        if ($total_chars_in_acc >= $cleanup_value) {
                            array_push($acc_output_array, $acc[0]);
                        }
                        break;
                    case "!=":
                        if ($total_chars_in_acc != $cleanup_value) {
                            array_push($acc_output_array, $acc[0]);
                        }
                        break;
                    default:
                        redirect("cleanup.php?error=1");
                }
            }
            $output .= "<center>";
            if ($acc_output_array) {
                $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
                $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n        <input type=\"hidden\" name=\"type\" value=\"acc\" />\r\n        <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
                $pass_array = "";
                for ($i = 0; $i < count($acc_output_array); $i++) {
                    $output .= "<a href=\"user.php?action=edit_user&amp;id={$acc_output_array[$i]}\" target=\"_blank\">{$acc_output_array[$i]}, </a>";
                    $pass_array .= "-{$acc_output_array[$i]}";
                }
                $output .= "<input type=\"hidden\" name=\"check\" value=\"{$pass_array}\" />";
                $output .= "<br />{$lang_cleanup['tot_of']} " . count($acc_output_array) . " {$lang_global['will_be_erased']}</font><br /><br />";
                $output .= " <table class=\"hidden\">\r\n           <tr><td>";
                makebutton($lang_global['yes'], "javascript:do_submit()", 120);
                makebutton($lang_global['no'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n          </table>\r\n      </form>";
            } else {
                $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
                $output .= "<table class=\"hidden\">\r\n          <tr><td>";
                makebutton($lang_global['go_back'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n        </table>";
            }
            $output .= "</center><br />";
            break;
            //guild  without chars or specified number of chars
        //guild  without chars or specified number of chars
        case "num_of_char_in_guild":
            $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
            $result = $sql->query("SELECT guildid FROM guild");
            $guild_output_array = array();
            while ($guild = $sql->fetch_row($result)) {
                $query = $sql->query("SELECT count(*) FROM guild_member WHERE guildid = '{$guild['0']}'");
                $total_chars_in_guild = $sql->result($query, 0);
                switch ($cleanup_sign) {
                    case "=":
                        if ($total_chars_in_guild == $cleanup_value) {
                            array_push($guild_output_array, $guild[0]);
                        }
                        break;
                    case "<":
                        if ($total_chars_in_guild < $cleanup_value) {
                            array_push($guild_output_array, $guild[0]);
                        }
                        break;
                    case "<=":
                        if ($total_chars_in_guild <= $cleanup_value) {
                            array_push($guild_output_array, $guild[0]);
                        }
                        break;
                    case ">":
                        if ($total_chars_in_guild > $cleanup_value) {
                            array_push($guild_output_array, $guild[0]);
                        }
                        break;
                    case ">=":
                        if ($total_chars_in_guild >= $cleanup_value) {
                            array_push($guild_output_array, $guild[0]);
                        }
                        break;
                    case "!=":
                        if ($total_chars_in_guild != $cleanup_value) {
                            array_push($guild_output_array, $guild[0]);
                        }
                        break;
                    default:
                        redirect("cleanup.php?error=1");
                }
            }
            $output .= "<center>";
            if ($guild_output_array) {
                $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
                $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n        <input type=\"hidden\" name=\"type\" value=\"guild\" />\r\n        <font class=\"bold\">{$lang_cleanup['guilds_id']}: ";
                $pass_array = "";
                for ($i = 0; $i < count($guild_output_array); $i++) {
                    $output .= "<a href=\"guild.php?action=view_guild&amp;error=3&amp;id={$guild_output_array[$i]}\" target=\"_blank\">{$guild_output_array[$i]}, </a>";
                    $pass_array .= "-{$guild_output_array[$i]}";
                }
                $output .= "<input type=\"hidden\" name=\"check\" value=\"{$pass_array}\" />";
                $output .= "<br />{$lang_cleanup['tot_of']} " . count($guild_output_array) . " {$lang_global['will_be_erased']}</font><br /><br />";
                $output .= " <table class=\"hidden\">\r\n           <tr><td>";
                makebutton($lang_global['yes'], "javascript:do_submit()", 120);
                makebutton($lang_global['no'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n          </table>\r\n      </form>";
            } else {
                $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
                $output .= "<table class=\"hidden\">\r\n          <tr><td>";
                makebutton($lang_global['go_back'], "cleanup.php", 120);
                $output .= "</td></tr>\r\n        </table>";
            }
            $output .= "</center><br />";
            break;
        default:
            redirect("Location: cleanup.php?error=1");
    }
    $sql->close();
    unset($sql);
}
Example #7
0
 $sqlc = new SQL();
 $sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
 // we have a different menu for guest account
 if ($allow_anony && empty($_SESSION['logged_in'])) {
     $lang_login = lang_login();
     $output .= '
                         <li><a href="#">' . $lang_header['account'] . '</a></li>
                         <li><a href="register.php">' . $lang_login['not_registrated'] . '</a></li>
                         <li><a href="login.php">' . $lang_login['login'] . '</a></li>';
     unset($lang_login);
 } else {
     $result = $sqlc->query('SELECT guid, name, race, class, level, gender
                         FROM characters 
                         WHERE account = ' . $user_id . '');
     // this puts links to user characters of active realm in "My Account" menu
     if ($sqlc->num_rows($result)) {
         $output .= '
                         <li><a href="#">' . $lang_header['my_characters'] . '</a></li>';
         while ($char = $sqlc->fetch_assoc($result)) {
             $output .= '
                         <li>
                             <a href="char.php?id=' . $char['guid'] . '">
                             <img src="img/c_icons/' . $char['race'] . '-' . $char['gender'] . '.gif" alt="" /><img src="img/c_icons/' . $char['class'] . '.gif" alt="" />' . $char['name'] . '
                             </a>
                         </li>';
         }
         unset($char);
     }
     $output .= '
                         <li><a href="#">' . $lang_header['account'] . '</a></li>
                         <li><a href="edit.php">' . $lang_header['edit_my_acc'] . '</a></li>
Example #8
0
function sql_table_dump($dbhost, $dbuser, $dbpass, $database, $table, $construct, $file)
{
    global $lang_global;
    $sql_0 = new SQL();
    $sql_0->connect($dbhost, $dbuser, $dbpass, $database, true);
    $fp = fopen($file, 'r+') or die(error($lang_backup['file_write_err']));
    fseek($fp, 0, SEEK_END);
    fwrite($fp, "--\n") or die(error($lang_backup['file_write_err']));
    fwrite($fp, "-- Dump of {$database}.{$table}\n") or die(error($lang_backup['file_write_err']));
    fwrite($fp, "-- Dump DATE : " . date("m.d.y H:i:s") . "\n--\n\n") or die(error($lang_backup['file_write_err']));
    if ($construct) {
        fwrite($fp, "-- Table structure for table {$database}.{$table}\n") or die(error($lang_backup['file_write_err']));
        if (!($fi = $sql_0->query("DESC " . $table))) {
            error($sql_0->error());
        }
        fwrite($fp, "DROP TABLE IF EXISTS {$table};\n") or die(error($lang_backup['file_write_err']));
        $pri = "";
        $creatinfo = array();
        while ($tmp = $sql_0->fetch_row($fi)) {
            $con = "`" . $tmp[0] . "` ";
            $con .= trim($tmp[1] . " ");
            if ($tmp[2] != "YES") {
                $con .= " NOT NULL";
            }
            if ($tmp[4]) {
                if ($tmp[4] == 'CURRENT_TIMESTAMP' || $tmp[4] == 'timestamp') {
                    $con .= " default " . $tmp[4];
                } else {
                    $con .= " default '" . $tmp[4] . "'";
                }
            } else {
                if ($tmp[4] === '' && $tmp[3] != "PRI") {
                    $con .= " default ''";
                } else {
                    if (strlen($tmp[4]) != 0) {
                        $con .= " default '0'";
                    }
                }
            }
            if (strtolower($tmp[5]) == "auto_increment") {
                $con .= " auto_increment";
            }
            $creatinfo[] = $con;
        }
        $fieldscon = implode(",\n\t", $creatinfo);
        fwrite($fp, "CREATE TABLE " . $table . " (") or die(error($lang_backup['file_write_err']));
        fwrite($fp, "\n\t{$fieldscon}") or die(error($lang_backup['file_write_err']));
        $qkey = $sql_0->query("SHOW INDEX FROM " . $table);
        if ($rkey = $sql_0->fetch_array($qkey)) {
            $knames = array();
            $keys = array();
            do {
                $keys[$rkey["Key_name"]]["nonunique"] = $rkey["Non_unique"];
                if (!$rkey["Sub_part"]) {
                    $keys[$rkey["Key_name"]]["order"][$rkey["Seq_in_index"] - 1] = $rkey["Column_name"];
                } else {
                    $keys[$rkey["Key_name"]]["order"][$rkey["Seq_in_index"] - 1] = $rkey["Column_name"] . "(" . $rkey["Sub_part"] . ")";
                }
                $flag = false;
                for ($l = 0; $l < sizeof($knames); $l++) {
                    if ($knames[$l] == $rkey["Key_name"]) {
                        $flag = true;
                    }
                }
                if (!$flag) {
                    $knames[] = $rkey["Key_name"];
                }
            } while ($rkey = $sql_0->fetch_array($qkey));
            for ($kl = 0; $kl < sizeof($knames); $kl++) {
                if ($knames[$kl] == "PRIMARY") {
                    fwrite($fp, ",\n\tPRIMARY KEY") or die(error($lang_backup['file_write_err']));
                } else {
                    if ($keys[$knames[$kl]]["nonunique"] == "0") {
                        fwrite($fp, ",\n\tUNIQUE `{$knames[$kl]}`") or die(error($lang_backup['file_write_err']));
                    } else {
                        fwrite($fp, ",\n\tKEY `{$knames[$kl]}`") or die(error($lang_backup['file_write_err']));
                    }
                }
                $a = @implode("`,`", $keys[$knames[$kl]]["order"]);
                fwrite($fp, " (`{$a}`)") or die(error($lang_backup['file_write_err']));
            }
        }
        $query_res = $sql_0->query("SHOW TABLE STATUS FROM {$database} WHERE Name = '{$table}'");
        $tmp = $sql_0->fetch_row($query_res);
        $query_charset = $sql_0->query("SHOW VARIABLES WHERE Variable_name = 'character_set_database'");
        $info = " ";
        if ($tmp[1]) {
            $info .= "ENGINE={$tmp['1']} ";
        }
        $info .= "DEFAULT CHARSET=" . $sql_0->result($query_charset, 0, 'Value') . " ";
        if ($tmp[16]) {
            $info .= strtoupper($tmp[16]) . " ";
        }
        if ($tmp[10]) {
            $info .= "AUTO_INCREMENT={$tmp['10']} ";
        }
        if ($tmp[17]) {
            $info .= "COMMENT='{$tmp['17']}'";
        }
        fwrite($fp, "\n){$info};\n\n") or die(error($lang_backup['file_write_err']));
    }
    $query = $sql_0->query("SELECT * FROM {$table}");
    $num_fields = $sql_0->num_fields($query);
    $numrow = $sql_0->num_rows($query);
    $row_counter = 0;
    if ($numrow) {
        fwrite($fp, "-- Dumping data for table {$database}.{$table}\n") or die(error($lang_backup['file_write_err']));
        fwrite($fp, "LOCK TABLES {$table} WRITE;\n") or die(error($lang_backup['file_write_err']));
        fwrite($fp, "DELETE FROM {$table};\n") or die(error($lang_backup['file_write_err']));
        fwrite($fp, "INSERT INTO {$table} (") or die(error($lang_backup['file_write_err']));
        for ($count = 0; $count < $num_fields; $count++) {
            fwrite($fp, "`" . $sql_0->field_name($query, $count) . "`") or die(error($lang_backup['file_write_err']));
            if ($count < $num_fields - 1) {
                fwrite($fp, ",") or die(error($lang_backup['file_write_err']));
            }
        }
        fwrite($fp, ") VALUES \n") or die(error($lang_backup['file_write_err']));
        for ($i = 0; $i < $numrow; $i++) {
            $row_counter++;
            fwrite($fp, "\t(") or die(error($lang_backup['file_write_err']));
            $row = $sql_0->fetch_row($query);
            for ($j = 0; $j < $num_fields; $j++) {
                $row[$j] = addslashes($row[$j]);
                $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
                if (isset($row[$j])) {
                    if ($sql_0->field_type($query, $j) == "int") {
                        fwrite($fp, "{$row[$j]}") or die(error($lang_backup['file_write_err']));
                    } else {
                        fwrite($fp, "'{$row[$j]}'") or die(error($lang_backup['file_write_err']));
                    }
                } else {
                    fwrite($fp, "''") or die(error($lang_backup['file_write_err']));
                }
                if ($j < $num_fields - 1) {
                    fwrite($fp, ",") or die(error($lang_backup['file_write_err']));
                }
            }
            if ($row_counter >= 10) {
                fwrite($fp, ");\n") or die(error($lang_backup['file_write_err']));
                fwrite($fp, "INSERT INTO {$table} (") or die(error($lang_backup['file_write_err']));
                for ($count = 0; $count < $num_fields; $count++) {
                    fwrite($fp, "`" . $sql_0->field_name($query, $count) . "`") or die(error($lang_backup['file_write_err']));
                    if ($count < $num_fields - 1) {
                        fwrite($fp, ",") or die(error($lang_backup['file_write_err']));
                    }
                }
                fwrite($fp, ") VALUES \n") or die(error($lang_backup['file_write_err']));
                $row_counter = 0;
            } elseif ($i < $numrow - 1) {
                fwrite($fp, "),\n") or die(error($lang_backup['file_write_err']));
            }
        }
        fwrite($fp, ");\n") or die(error($lang_backup['file_write_err']));
        fwrite($fp, "UNLOCK TABLES;\n") or die(error($lang_backup['file_write_err']));
    } else {
        fwrite($fp, "-- EMPTY\n") or die(error($lang_backup['file_write_err']));
    }
    $sql_0->close();
    fwrite($fp, "\n") or die(error($lang_backup['file_write_err']));
    fclose($fp);
}
Example #9
0
function do_search()
{
    global $lang_global, $lang_creature, $output, $world_db, $realm_id, $creature_datasite, $sql_search_limit, $creature_type, $creature_npcflag, $language;
    wowhead_tt();
    $sql = new SQL();
    $sql->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
    $where = '';
    // language // if $_POST['language'] > 0 also search locales_XXX
    // prepare sql_query
    if ($_POST['language'] != '0') {
        $loc_language = is_numeric($_POST['language']) ? $sql->quote_smart($_POST['language']) : redirect("creature.php?error=8");
    } else {
        $loc_language = '0';
    }
    // check input and prepare sql query
    if ($_POST['npcflag'] != '') {
        $npcflag = is_numeric($_POST['npcflag']) ? $sql->quote_smart($_POST['npcflag']) : redirect("creature.php?error=8");
        $where .= "ct.npcflag = '{$npcflag}' ";
    } else {
        if ($_POST['type'] != '') {
            $type = is_numeric($_POST['type']) ? $sql->quote_smart($_POST['type']) : redirect("creature.php?error=8");
            $where .= "ct.type = '{$type}' ";
        } else {
            if ($_POST['rank'] != '') {
                $rank = is_numeric($_POST['rank']) ? $sql->quote_smart($_POST['rank']) : redirect("creature.php?error=8");
                $where .= "ct.rank = '{$rank}' ";
            } else {
                if ($_POST['family'] != '') {
                    $family = is_numeric($_POST['family']) ? $sql->quote_smart($_POST['family']) : redirect("creature.php?error=8");
                    $where .= "ct.family = '{$family}' ";
                } else {
                    if ($_POST['entry'] != '') {
                        $entry = is_numeric($_POST['entry']) ? $sql->quote_smart($_POST['entry']) : redirect("creature.php?error=8");
                        $where .= "ct.entry = '{$entry}' ";
                    } else {
                        if ($_POST['name'] != '') {
                            $name = preg_match('/^[\\t\\v\\b\\f\\a\\n\\r\\\\"\\? <>[](){}_=+-|!@#$%^&*~`.,\\0]{1,30}$/', $_POST['name']) ? "test" : $sql->quote_smart($_POST['name']);
                            if ($loc_language) {
                                $where .= "lc.name_loc{$loc_language} LIKE '%{$name}%' ";
                            } else {
                                $where .= "ct.`name`LIKE '%{$name}%' ";
                            }
                        } else {
                            if ($_POST['level'] != '') {
                                $level = is_numeric($_POST['level']) ? $sql->quote_smart($_POST['level']) : redirect("creature.php?error=8");
                                $where .= "ct.minlevel <= {$level} AND ct.maxlevel >= {$level} ";
                            } else {
                                if ($_POST['faction_A'] != '') {
                                    $faction_A = is_numeric($_POST['faction_A']) ? $sql->quote_smart($_POST['faction_A']) : redirect("creature.php?error=8");
                                    $where .= "ct.faction_A = '{$faction_A}' ";
                                } else {
                                    if ($_POST['faction_H'] != '') {
                                        $faction_H = is_numeric($_POST['faction_H']) ? $sql->quote_smart($_POST['faction_H']) : redirect("creature.php?error=8");
                                        $where .= "ct.faction_H = '{$faction_H}' ";
                                    } else {
                                        if ($_POST['spell'] != '') {
                                            $spell = is_numeric($_POST['spell']) ? $sql->quote_smart($_POST['spell']) : redirect("creature.php?error=8");
                                            $where .= "(ct.spell1 = '{$spell}' OR ct.spell2 = '{$spell}' OR ct.spell3 = '{$spell}' OR ct.spell4 = '{$spell}') ";
                                        } else {
                                            if ($_POST['lootid'] != '') {
                                                $lootid = is_numeric($_POST['lootid']) ? $sql->quote_smart($_POST['lootid']) : redirect("creature.php?error=8");
                                                $where .= "ct.lootid = '{$lootid}' ";
                                            } else {
                                                if ($_POST['ScriptName'] != '') {
                                                    $ScriptName = preg_match("/^[_[:alpha:]]{1,32}\$/", $_POST['ScriptName']) ? $sql->quote_smart($_POST['ScriptName']) : "mob_generic";
                                                    $where .= "ct.ScriptName LIKE '%{$ScriptName}%' ";
                                                } else {
                                                    if ($_POST['heroic'] != '') {
                                                        $heroic = is_numeric($_POST['heroic']) ? $sql->quote_smart($_POST['heroic']) : redirect("creature.php?error=8");
                                                        $where .= "ct.heroic_entry = '{$heroic}'";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // additional search query
    if ($_POST['custom_search'] != '') {
        $custom_search = preg_match('/^[\\t\\v\\b\\f\\a\\n\\r\\\\"\\?[](){}=+-|!@#$%^&*~`.,\\0]{1,30}$/', $_POST['$custom_search']) ? 0 : $sql->quote_smart($_POST['$custom_search']);
        $where .= $where == '' ? "ct.{$custom_search}" : "AND ct.{$custom_search}";
    }
    /* no search value, go home! */
    if ($where == '') {
        redirect("creature.php?error=1");
    }
    if ($loc_language) {
        $db_query = "SELECT ct.entry, ct.name, ct.maxlevel, ct.rank, ct.npcflag, lc.name_loc{$loc_language} FROM creature_template ct LEFT OUTER JOIN locales_creature lc on lc.entry = ct.entry WHERE {$where} ORDER BY ct.entry LIMIT 100";
    } else {
        $db_query = "SELECT ct.entry, ct.name, ct.maxlevel, ct.rank, ct.npcflag FROM creature_template ct WHERE {$where} ORDER BY ct.entry LIMIT 100";
    }
    $result = $sql->query($db_query);
    $total_found = $sql->num_rows($result);
    $output .= "\r\n                <center>\r\n                    <table class=\"top_hidden\"></td>\r\n                        <tr>\r\n                            <td>";
    makebutton($lang_creature['new_search'], "creature.php", 160);
    $output .= "\r\n                            </td>\r\n                            <td align=\"right\">{$lang_creature['tot_found']} : {$total_found} : {$lang_global['limit']} {$sql_search_limit}</td>\r\n                        </tr>\r\n                    </table>\r\n                    <table class=\"lined\">\r\n                        <tr>\r\n                            <th>{$lang_creature['entry']}</th>\r\n                            <th>{$lang_creature['name']}</th>\r\n                            <th>{$lang_creature['level']}</th>\r\n                            <th>{$lang_creature['health']}</th>\r\n                            <th>{$lang_creature['rank']}</th>\r\n                            <th>{$lang_creature['npc_flag']}</th>\r\n                        </tr>";
    for ($i = 1; $i <= $total_found; $i++) {
        $creature = $sql->fetch_row($result);
        $output .= "\r\n                        <tr>\r\n                            <td><a href=\"{$creature_datasite}{$creature['0']}\" target=\"_blank\">{$creature['0']}</a></td>";
        if ($loc_language) {
            $output .= "\r\n                            <td><a href=\"creature.php?action=edit&amp;entry={$creature['0']}&amp;error=4\">" . htmlentities($creature[5]) . " ( {$creature[1]} )</a></td>";
        } else {
            $output .= "\r\n                            <td><a href=\"creature.php?action=edit&amp;entry={$creature['0']}&amp;error=4\">{$creature['1']}</a></td>";
        }
        $output .= "\r\n                            <td>{$creature['2']}</td>\r\n                            <td>" . round(get_additional_data($creature[0], 1), 0) . "</td>\r\n                            <td>{$creature_type[$creature[3]][1]}</td>\r\n                            <td>" . get_npcflag($creature[4]) . "</td>\r\n                        </tr>";
    }
    $output .= "\r\n                    </table>\r\n                </center><br />";
    $sql->close();
    unset($sql);
}
Example #10
0
function dobackup()
{
    global $lang_backup, $backup_dir, $tables_backup_realmd, $tables_backup_characters, $output, $realm_db, $characters_db, $realm_id, $tab_backup_user_realmd, $tab_backup_user_characters;
    if (empty($_GET['backup_action']) || empty($_GET['backup_from_to'])) {
        redirect("backup.php?error=1");
    } else {
        $backup_action = addslashes($_GET['backup_action']);
        $backup_from_to = addslashes($_GET['backup_from_to']);
    }
    if ("load" == $backup_action && "file" == $backup_from_to) {
        if (!eregi("(\\.(sql|qbquery))\$", $_FILES["uploaded_file"]["name"])) {
            error($lang_backup['upload_sql_file_only']);
        }
        $uploaded_filename = str_replace(" ", "_", $_FILES["uploaded_file"]["name"]);
        $uploaded_filename = preg_replace("/[^_A-Za-z0-9-\\.]/i", '', $uploaded_filename);
        $file_name_new = $uploaded_filename . "_" . date("m.d.y_H.i.s") . ".sql";
        move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "{$backup_dir}/{$file_name_new}") or die(error("{$lang_backup['upload_err_write_permission']} {$backup_dir}"));
        if (file_exists("{$backup_dir}/{$file_name_new}")) {
            require_once "libs/db_lib/sql_lib.php";
            $use_db = addslashes($_POST['use_db']);
            if ($use_db == $realm_db['name']) {
                $queries = run_sql_script($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name'], "{$backup_dir}/{$file_name_new}", true);
            } else {
                foreach ($characters_db as $db) {
                    if ($use_db == $db['name']) {
                        $queries = run_sql_script($db['addr'], $db['user'], $db['pass'], $db['name'], "{$backup_dir}/{$file_name_new}", true);
                    }
                }
            }
            redirect("backup.php?error=4&tot={$queries}");
        } else {
            error($lang_backup['file_not_found']);
        }
    } elseif ("load" == $backup_action && "web" == $backup_from_to) {
        if (empty($_POST['selected_file_name'])) {
            redirect("backup.php?error=1");
        } else {
            $file_name = addslashes($_POST['selected_file_name']);
        }
        if (file_exists("{$backup_dir}/{$file_name}")) {
            require_once "libs/db_lib/sql_lib.php";
            $use_db = addslashes($_POST['use_db']);
            if ($use_db == $realm_db['name']) {
                $queries = run_sql_script($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name'], "{$backup_dir}/{$file_name}", false);
            } else {
                foreach ($characters_db as $db) {
                    if ($use_db == $db['name']) {
                        $queries = run_sql_script($db['addr'], $db['user'], $db['pass'], $db['name'], "{$backup_dir}/{$file_name}", false);
                    }
                }
            }
            redirect("backup.php?error=4&tot={$queries}");
        } else {
            error($lang_backup['file_not_found']);
        }
    } elseif ("save" == $backup_action && "file" == $backup_from_to) {
        //save and send to user
        $struc_backup = addslashes($_GET['struc_backup']);
        $save_all_realms = addslashes($_GET['save_all_realms']);
        if ($save_all_realms) {
            $temp_id = "all_realms";
        } else {
            $temp_id = "realmid_" . $realm_id;
        }
        $file_name_new = $temp_id . "_backup_" . date("m.d.y_H.i.s") . ".sql";
        $fp = fopen("{$backup_dir}/{$file_name_new}", 'w') or die(error($lang_backup['file_write_err']));
        fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$realm_db['name']};\n") or die(error($lang_backup['file_write_err']));
        fwrite($fp, "USE {$realm_db['name']};\n\n") or die(error($lang_backup['file_write_err']));
        fclose($fp);
        require_once "libs/db_lib/sql_lib.php";
        foreach ($tables_backup_realmd as $value) {
            sql_table_dump($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
        }
        if ($save_all_realms) {
            foreach ($characters_db as $db) {
                $fp = fopen("{$backup_dir}/{$file_name_new}", 'r+') or die(error($lang_backup['file_write_err']));
                fseek($fp, 0, SEEK_END);
                fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$db['name']};\n") or die(error($lang_backup['file_write_err']));
                fwrite($fp, "USE {$db['name']};\n\n") or die(error($lang_backup['file_write_err']));
                fclose($fp);
                foreach ($tables_backup_characters as $value) {
                    sql_table_dump($db['addr'], $db['user'], $db['pass'], $db['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
                }
            }
        } else {
            $fp = fopen("{$backup_dir}/{$file_name_new}", 'r+') or die(error($lang_backup['file_write_err']));
            fseek($fp, 0, SEEK_END);
            fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$characters_db[$realm_id]['name']};\n") or die(error($lang_backup['file_write_err']));
            fwrite($fp, "USE {$characters_db[$realm_id]['name']};\n\n") or die(error($lang_backup['file_write_err']));
            fclose($fp);
            foreach ($tables_backup_characters as $value) {
                sql_table_dump($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
            }
        }
        Header("Content-type: application/octet-stream");
        Header("Content-Disposition: attachment; filename={$file_name_new}");
        $fp = fopen("{$backup_dir}/{$file_name_new}", 'r') or die(error($lang_backup['file_write_err']));
        while (!feof($fp)) {
            $output_file = fread($fp, 1024);
            echo $output_file;
        }
        fclose($fp);
        unlink("{$backup_dir}/{$file_name_new}");
        exit;
    } elseif ("save" == $backup_action && "web" == $backup_from_to) {
        //save backup to web/backup folder
        $struc_backup = addslashes($_GET['struc_backup']);
        $save_all_realms = addslashes($_GET['save_all_realms']);
        $file_name_new = $realm_db['name'] . "_backup_" . date("m.d.y_H.i.s") . ".sql";
        $fp = fopen("{$backup_dir}/{$file_name_new}", 'w') or die(error($lang_backup['file_write_err']));
        fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$realm_db['name']};\n") or die(error($lang_backup['file_write_err']));
        fwrite($fp, "USE {$realm_db['name']};\n\n") or die(error($lang_backup['file_write_err']));
        fclose($fp);
        require_once "libs/db_lib/sql_lib.php";
        foreach ($tables_backup_realmd as $value) {
            sql_table_dump($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
        }
        fclose($fp);
        if ($save_all_realms) {
            foreach ($characters_db as $db) {
                $file_name_new = $db['name'] . "_backup_" . date("m.d.y_H.i.s") . ".sql";
                $fp = fopen("{$backup_dir}/{$file_name_new}", 'w') or die(error($lang_backup['file_write_err']));
                fseek($fp, 0, SEEK_END);
                fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$db['name']};\n") or die(error($lang_backup['file_write_err']));
                fwrite($fp, "USE {$db['name']};\n\n") or die(error($lang_backup['file_write_err']));
                fclose($fp);
                foreach ($tables_backup_characters as $value) {
                    sql_table_dump($db['addr'], $db['user'], $db['pass'], $db['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
                }
                fclose($fp);
            }
        } else {
            $file_name_new = $characters_db[$realm_id]['name'] . "_backup_" . date("m.d.y_H.i.s") . ".sql";
            $fp = fopen("{$backup_dir}/{$file_name_new}", 'w') or die(error($lang_backup['file_write_err']));
            fseek($fp, 0, SEEK_END);
            fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$characters_db[$realm_id]['name']};\n") or die(error($lang_backup['file_write_err']));
            fwrite($fp, "USE {$characters_db[$realm_id]['name']};\n\n") or die(error($lang_backup['file_write_err']));
            fclose($fp);
            foreach ($tables_backup_characters as $value) {
                sql_table_dump($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
            }
            fclose($fp);
        }
        redirect("backup.php?error=2");
        exit;
    } elseif ("save" == $backup_action && "acc_on_file" == $backup_from_to) {
        //save evry account in different file
        $struc_backup = addslashes($_GET['struc_backup']);
        $save_all_realms = addslashes($_GET['save_all_realms']);
        $sql = new SQL();
        $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
        $query = $sql->query("SELECT id FROM account");
        $subdir = "{$backup_dir}/accounts/" . date("m_d_y_H_i_s");
        mkdir($subdir, 0750);
        while ($acc = $sql->fetch_array($query)) {
            $file_name_new = $acc[0] . "_{$realm_db['name']}.sql";
            $fp = fopen("{$subdir}/{$file_name_new}", 'w') or die(error($lang_backup['file_write_err']));
            fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$realm_db['name']};\n") or die(error($lang_backup['file_write_err']));
            fwrite($fp, "USE {$realm_db['name']};\n\n") or die(error($lang_backup['file_write_err']));
            $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
            foreach ($tab_backup_user_realmd as $value) {
                $acc_query = $sql->query("SELECT * FROM {$value['0']} WHERE {$value['1']} = {$acc['0']}");
                $num_fields = $sql->num_fields($acc_query);
                $numrow = $sql->num_rows($acc_query);
                $result = "-- Dumping data for {$value['0']} " . date("m.d.y_H.i.s") . "\n";
                $result .= "LOCK TABLES {$value['0']} WRITE;\n";
                $result .= "DELETE FROM {$value['0']} WHERE {$value['1']} = {$acc['0']};\n";
                if ($numrow) {
                    $result .= "INSERT INTO {$value['0']} (";
                    for ($count = 0; $count < $num_fields; $count++) {
                        $result .= "`" . $sql->field_name($acc_query, $count) . "`";
                        if ($count < $num_fields - 1) {
                            $result .= ",";
                        }
                    }
                    $result .= ") VALUES \n";
                    for ($i = 0; $i < $numrow; $i++) {
                        $result .= "\t(";
                        $row = $sql->fetch_row($acc_query);
                        for ($j = 0; $j < $num_fields; $j++) {
                            $row[$j] = addslashes($row[$j]);
                            $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
                            if (isset($row[$j])) {
                                if ($sql->field_type($acc_query, $j) == "int") {
                                    $result .= "{$row[$j]}";
                                } else {
                                    $result .= "'{$row[$j]}'";
                                }
                            } else {
                                $result .= "''";
                            }
                            if ($j < $num_fields - 1) {
                                $result .= ",";
                            }
                        }
                        if ($i < $numrow - 1) {
                            $result .= "),\n";
                        }
                    }
                    $result .= ");\n";
                }
                $result .= "UNLOCK TABLES;\n";
                $result .= "\n";
                fwrite($fp, $result) or die(error($lang_backup['file_write_err']));
            }
            fclose($fp);
            foreach ($characters_db as $db) {
                $file_name_new = $acc[0] . "_{$db['name']}.sql";
                $fp = fopen("{$subdir}/{$file_name_new}", 'w') or die(error($lang_backup['file_write_err']));
                fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$db['name']};\n") or die(error($lang_backup['file_write_err']));
                fwrite($fp, "USE {$db['name']};\n\n") or die(error($lang_backup['file_write_err']));
                $sql->connect($db['addr'], $db['user'], $db['pass'], $db['name']);
                $all_char_query = $sql->query("SELECT guid,name FROM `characters` WHERE account = {$acc['0']}");
                while ($char = $sql->fetch_array($all_char_query)) {
                    fwrite($fp, "-- Dumping data for character {$char['1']}\n") or die(error($lang_backup['file_write_err']));
                    foreach ($tab_backup_user_characters as $value) {
                        $char_query = $sql->query("SELECT * FROM {$value['0']} WHERE {$value['1']} = {$char['0']}");
                        $num_fields = $sql->num_fields($char_query);
                        $numrow = $sql->num_rows($char_query);
                        $result = "LOCK TABLES {$value['0']} WRITE;\n";
                        $result .= "DELETE FROM {$value['0']} WHERE {$value['1']} = {$char['0']};\n";
                        if ($numrow) {
                            $result .= "INSERT INTO {$value['0']} (";
                            for ($count = 0; $count < $num_fields; $count++) {
                                $result .= "`" . $sql->field_name($char_query, $count) . "`";
                                if ($count < $num_fields - 1) {
                                    $result .= ",";
                                }
                            }
                            $result .= ") VALUES \n";
                            for ($i = 0; $i < $numrow; $i++) {
                                $result .= "\t(";
                                $row = $sql->fetch_row($char_query);
                                for ($j = 0; $j < $num_fields; $j++) {
                                    $row[$j] = addslashes($row[$j]);
                                    $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
                                    if (isset($row[$j])) {
                                        if ($sql->field_type($char_query, $j) == "int") {
                                            $result .= "{$row[$j]}";
                                        } else {
                                            $result .= "'{$row[$j]}'";
                                        }
                                    } else {
                                        $result .= "''";
                                    }
                                    if ($j < $num_fields - 1) {
                                        $result .= ",";
                                    }
                                }
                                if ($i < $numrow - 1) {
                                    $result .= "),\n";
                                }
                            }
                            $result .= ");\n";
                        }
                        $result .= "UNLOCK TABLES;\n";
                        $result .= "\n";
                        fwrite($fp, $result) or die(error($lang_backup['file_write_err']));
                    }
                }
                fclose($fp);
            }
        }
        $sql->close();
        unset($sql);
        redirect("backup.php?error=2");
    } elseif ("load" == $backup_action && "acc_on_file" == $backup_from_to) {
        //load saved account
        if (empty($_POST['selected_file_name']) || empty($_POST['file_dir'])) {
            redirect("backup.php?error=1");
        } else {
            $file_name = addslashes($_POST['selected_file_name']);
            $file_dir = addslashes($_POST['file_dir']);
            $use_db = addslashes($_POST['use_db']);
        }
        $file_tmp = "{$backup_dir}/accounts/{$file_dir}/" . $file_name . "_{$use_db}.sql";
        if (file_exists($file_tmp)) {
            require_once "libs/db_lib/sql_lib.php";
            if ($use_db == $realm_db['name']) {
                $queries = run_sql_script($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name'], "{$backup_dir}/accounts/{$file_dir}/{$file_name}.sql", true);
            } else {
                foreach ($characters_db as $db) {
                    if ($use_db == $db['name']) {
                        $queries = run_sql_script($db['addr'], $db['user'], $db['pass'], $db['name'], "{$backup_dir}/accounts/{$file_dir}/{$file_name}.sql", true);
                    }
                }
            }
            redirect("backup.php?error=4&tot={$queries}");
        } else {
            error($lang_backup['file_not_found']);
        }
    } else {
        //non of the options = error
        redirect("backup.php?error=1");
    }
}
Example #11
0
function detectcore()
{
    global $logon_db;
    $sqll = new SQL();
    $sqll->connect($logon_db["addr"], $logon_db["user"], $logon_db["pass"], $logon_db["name"], $logon_db["encoding"]);
    // are we ArcEmu?
    $query = "SHOW TABLES FROM `" . $logon_db["name"] . "` LIKE 'accounts'";
    $result = $sqll->query($query);
    if ($sqll->num_rows($result) == 1) {
        return 1;
    }
    // we're ArcEmu
    // no? ...then are we Trinity?
    $query = "SHOW TABLES FROM `" . $logon_db["name"] . "` LIKE 'account_access'";
    $result = $sqll->query($query);
    if ($sqll->num_rows($result) == 1) {
        return 3;
    } else {
        return 2;
    }
    // we're MaNGOS
}
Example #12
0
function forum_index(&$sqlr, &$sqlm)
{
    global $enablesidecheck, $forum_skeleton, $forum_lang, $user_lvl, $output, $realm_db, $mmfpm_db;
    if ($enablesidecheck) {
        $side = get_side();
    }
    $sqlm = new SQL();
    $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
    $result = $sqlm->query('
		SELECT authorname, id, name, time, forum
		FROM mm_forum_posts
		WHERE id IN 
			(SELECT MAX(id)
			FROM mm_forum_posts
			GROUP BY forum)
		ORDER BY forum;');
    $lasts = array();
    if ($sqlm->num_rows($result) > 0) {
        while ($row = $sqlm->fetch_assoc($result)) {
            $lasts[$row['forum']] = $row;
        }
    }
    $output .= '
<div class="top">
	<h1>' . $forum_lang['forums'] . '</h1>
</div>
<center>
<fieldset>
	<legend><a href="forum.php">' . $forum_lang['forum_index'] . '</a></legend>
	<table class="lined">';
    $cid = $sqlm->query('
		SELECT category, name, description, side_access, level_post_topic, level_read, level_post
		FROM mm_forum_categories');
    while ($category = $sqlm->fetch_assoc($cid)) {
        if ($category['level_read'] > $user_lvl) {
            continue;
        }
        if ($user_lvl == 0 && $enablesidecheck) {
            if ($category['side_access'] != 'ALL') {
                // Not an all side forum
                if ($side == 'NO') {
                    // No char
                    continue;
                } else {
                    if ($category['side_access'] != $side) {
                        // Forumside different of the user side
                        continue;
                    }
                }
            }
        }
        $output .= '
		<tr>
			<th class="head" align="left">' . $category['name'] . '<br />' . $category['description'] . '</th>
			<th class="head">' . $forum_lang['topics'] . '</th>
			<th class="head">' . $forum_lang['replies'] . '</th>
			<th class="head" align="right">' . $forum_lang['last_post'] . '</th>
		</tr>';
        $fid = $sqlm->query('
		SELECT forum, category, name, description, side_access, level_post_topic, level_read, level_post
		FROM mm_forum_forums
		WHERE category = ' . $category['category'] . '');
        while ($forum = $sqlm->fetch_assoc($fid)) {
            if ($forum['level_read'] > $user_lvl) {
                continue;
            }
            if ($user_lvl == 0 && $enablesidecheck) {
                if ($forum['side_access'] != 'ALL') {
                    // Not an all side forum
                    if ($side == 'NO') {
                        // No char
                        continue;
                    } else {
                        if ($forum['side_access'] != $side) {
                            // Forumside different of the user side
                            continue;
                        }
                    }
                }
            }
            $totaltopics = $sqlm->query('
				SELECT id
				FROM mm_forum_posts
				WHERE forum = ' . $forum['forum'] . ' AND id = topic');
            $numtopics = $sqlm->num_rows($totaltopics);
            $totalreplies = $sqlm->query('
				SELECT id
				FROM mm_forum_posts
				WHERE forum = ' . $forum['forum'] . '');
            $numreplies = $sqlm->num_rows($totalreplies);
            $output .= '
		<tr>
			<td align="left"><a href="forum.php?action=view_forum&amp;id=' . $forum['forum'] . '">' . $forum['name'] . '</a><br />' . $forum['description'] . '</td>
			<td>' . $numtopics . '</td>
			<td>' . $numreplies . '</td>';
            if (isset($lasts[$forum['forum']])) {
                $lasts[$forum['forum']]['name'] = htmlspecialchars($lasts[$forum['forum']]['name']);
                $output .= '
			<td align="right">
				<a href="forum.php?action=view_topic&amp;postid=' . $lasts[$forum['forum']]['id'] . '">' . $lasts[$forum['forum']]['name'] . '</a>
				<br />by ' . $lasts[$forum['forum']]['authorname'] . '
				<br /> ' . $lasts[$forum['forum']]['time'] . '
			</td>
		</tr>';
            } else {
                $output .= '
			<td align="right">' . $forum_lang['no_topics'] . '</td>
		</tr>';
            }
        }
    }
    $output .= '
		<tr>
			<td align="right" class="hidden"></td>
		</tr>
	</table>
</fieldset>
</center>
<br/>';
    $sqlm->close();
    // Queries : 1
}
Example #13
0
function do_contests()
{
    global $sql, $core, $characters_db;
    $contests_query = "SELECT *, UNIX_TIMESTAMP(date_issued) AS issue_stamp FROM point_system_achievement_contests WHERE enabled='1' AND winner_guid='0' AND expiration>NOW()";
    $contests_result = $sql["mgr"]->query($contests_query);
    // luckily, the Achievement tables for ArcEmu and Trinity are based on MaNGOS
    // so we need fewer queries for this
    while ($contest = $sql["mgr"]->fetch_assoc($contests_result)) {
        // get the characters database for this contest
        $sqlc = new SQL();
        $sqlc->connect($characters_db[$contest["realm"]]["addr"], $characters_db[$contest["realm"]]["user"], $characters_db[$contest["realm"]]["pass"], $characters_db[$contest["realm"]]["name"], $characters_db[$contest["realm"]]["encoding"]);
        if ($contest["after_only"]) {
            $achieve_query = "SELECT * FROM character_achievement WHERE achievement='" . $contest["achievement"] . "' AND `date`>='" . $contest["issue_stamp"] . "' ORDER BY `date` ASC";
        } else {
            $achieve_query = "SELECT * FROM character_achievement WHERE achievement='" . $contest["achievement"] . "' ORDER BY `date` ASC";
        }
        $achieve_result = $sqlc->query($achieve_query);
        // set up a variable for the winner so we only have to do the reward code once
        $winner = 0;
        // now, find the winner
        if ($sqlc->num_rows($achieve_result) > 1) {
            // this triggers if multiple people unlock the achievement before we check
            // for winner.  We have to find the first
            // start by dumping all the unlocks, but skip any that ARE NOT duplicates
            $unlockers = array();
            while ($row = $sqlc->fetch_assoc($achieve_result)) {
                if (is_array($unlockers[0])) {
                    if ($row["date"] == $unlockers[0]["date"]) {
                        $unlockers[] = $row;
                    }
                } else {
                    $unlockers[] = $row;
                }
                // we need the first one
            }
            // see how many unlockers we have left
            if (count($unlockers) > 1) {
                // we have multiples, 'randomly' pick a winner
                $winners_row = rand(1, count($unlockers)) - 1;
                $winner = $unlockers[$winners_row]["guid"];
            } else {
                // otherwise, we had only one 'first' unlocker
                $winner = $unlockers[0]["guid"];
            }
        } elseif ($sqlc->num_rows($achieve_result) == 1) {
            // single player unlocked the achievement
            $unlocker = $sql["char"]->fetch_assoc($achieve_result);
            $winner = $unlocker["guid"];
        }
        // otherwise, no winner
        // reward
        if ($winner != 0) {
            // first, set the contest to reflect who won
            $query = "UPDATE point_system_achievement_contests SET winner_guid='" . $winner . "' WHERE entry='" . $contest["entry"] . "'";
            $sql["mgr"]->query($query);
            // winner is character guid.  Prize Bags and Coupons are account level.
            // we need the winner's account
            if ($core == 1) {
                $winner_acct_query = "SELECT acct AS account, name FROM characters WHERE guid='" . $winner . "'";
            } else {
                $winner_acct_query = "SELECT account, name FROM characters WHERE guid='" . $winner . "'";
            }
            $winner_acct_result = $sqlc->query($winner_acct_query);
            $winner_acct_result = $sqlc->fetch_assoc($winner_acct_result);
            $winner_acct = $winner_acct_result["account"];
            $winner_name = $winner_acct_result["name"];
            if ($contest["prize_bag"] > 0) {
                // update the prize bag to reflect its new owner
                $reward_query = "UPDATE point_system_prize_bags SET owner='" . $winner_acct . "'";
            } else {
                // update the coupon to reflect its new owner
                $reward_query = "UPDATE point_system_coupons SET target='" . $winner_acct . "'";
            }
            // update the prize bag / coupon record
            $sql["mgr"]->query($reward_query);
            // get the achievement's name
            $ach_query = "SELECT * FROM achievement WHERE id='" . $contest["achievement"] . "'";
            $ach_result = $sql["dbc"]->query($ach_query);
            $ach_result = $sql["dbc"]->fetch_assoc($ach_result);
            // create Server Message
            $msg = $contest["announce_msg"];
            $msg = str_replace("%1", $winner_name, $msg);
            $msg = str_replace("%2", $ach_result["name"], $msg);
            // insert message
            if ($contest["announce"] == 0) {
                $announce_query = "INSERT INTO motd (Message, Created, Enabled) VALUES ('" . $msg . "', NOW(), 1)";
            } else {
                $announce_query = "INSERT INTO motd (Message, Created, Target, Enabled) VALUES ('" . $msg . "', NOW(), '" . $winner_acct . "', 1)";
            }
            $sql["mgr"]->query($announce_query);
        }
    }
}
Example #14
0
function saveforum()
{
    global $corem_db;
    $sqlm = new SQL();
    $sqlm->connect($corem_db["addr"], $corem_db["user"], $corem_db["pass"], $corem_db["name"], $corem_db["encoding"]);
    $forum_item = $sqlm->quote_smart($_GET["forum_item"]);
    $forum = $sqlm->quote_smart($_GET["category"]);
    $name = $sqlm->quote_smart($_GET["name"]);
    $desc = $sqlm->quote_smart($_GET["desc"]);
    $sideaccess = $sqlm->quote_smart($_GET["sideaccess"]);
    $min_security_level_read = $sqlm->quote_smart($_GET["min_security_level_read"]);
    $min_security_level_post = $sqlm->quote_smart($_GET["min_security_level_post"]);
    $min_security_level_create_topic = $sqlm->quote_smart($_GET["min_security_level_create_topic"]);
    $result = $sqlm->query("SELECT * FROM config_forums WHERE `Index`='" . $forum_item . "'");
    if ($sqlm->num_rows($result)) {
        $result = $sqlm->query("UPDATE config_forums SET Category='" . $forum . "', Name='" . $name . "', `Desc`='" . $desc . "', Side_Access='" . $sideaccess . "', Min_Security_Level_Read='" . $min_security_level_read . "', Min_Security_Level_Post='" . $min_security_level_post . "', Min_Security_Level_Create_Topic='" . $min_security_level_create_topic . "' WHERE `Index`='" . $forum_item . "'");
    } else {
        $result = $sqlm->query("INSERT INTO config_forums (Category, Name, Desc, Side_Access, Min_Security_Level_Read, Min_Security_Level_Post, Min_Security_Level_Create_Topic) VALUES ('" . $forum . "', '" . $name . "', '" . $desc . "', '" . $sideaccess . "', '" . $min_security_level_read . "', '" . $min_security_level_post . "', '" . $min_security_level_create_topic . "')");
    }
    redirect("admin.php?section=forum");
}
Example #15
0
<?php

require_once "header.php";
require_once "libs/char_lib.php";
valid_login($action_permission['read']);
//global $lang_honor, $lang_global, $output, $characters_db, $realm_id, $itemperpage, $realm_db;
$sql = new SQL();
$sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
$start = isset($_GET['start']) ? $sql->quote_smart($_GET['start']) : 0;
$order_by = isset($_GET['order_by']) ? $sql->quote_smart($_GET['order_by']) : "honor";
$query = $sql->query("SELECT C.guid, C.name, C.race, C.class, C.totalHonorPoints AS honor , C.totalKills AS kills, C.level, C.arenaPoints AS arena, COALESCE(guild_member.guildid,0) as GNAME, C.gender FROM characters C LEFT JOIN guild_member ON C.guid = guild_member.guid WHERE race in (1,3,4,7,11) ORDER BY {$order_by} DESC LIMIT 25;");
$this_page = $sql->num_rows($query);
$output .= "\r\n                <script type=\"text/javascript\">\r\n                    answerbox.btn_ok='{$lang_global['yes_low']}';\r\n                    answerbox.btn_cancel='{$lang_global['no']}';\r\n                </script>\r\n                <center>\r\n                    <fieldset style=\"width: 776px;\">\r\n                        <legend><img src='img/alliance.gif' /></legend>\r\n                        <table class=\"lined\" style=\"width: 705px;\">\r\n                            <tr class=\"bold\">\r\n                                <td colspan=\"11\">{$lang_honor['allied']} {$lang_honor['browse_honor']}</td>\r\n                            </tr>\r\n                            <tr>\r\n                                <th width=\"30%\">{$lang_honor['guid']}</th>\r\n                                <th width=\"7%\">{$lang_honor['race']}</th>\r\n                                <th width=\"7%\">{$lang_honor['class']}</th>\r\n                                <th width=\"7%\">{$lang_honor['level']}</th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=honor\"" . ($order_by == 'honor' ? " class=DESC" : "") . ">{$lang_honor['honor']}</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=honor\"" . ($order_by == 'honor' ? " class=DESC" : "") . ">{$lang_honor['honor points']}</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=kills\"" . ($order_by == 'kills' ? " class=DESC" : "") . ">Kills</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=arena\"" . ($order_by == 'arena' ? " class=DESC" : "") . ">AP</a></th>\r\n                                <th width=\"30%\">{$lang_honor['guild']}</th>\r\n                            </tr>";
while ($char = $sql->fetch_row($query)) {
    $guild_name = $sql->fetch_row($sql->query("SELECT `name` FROM `guild` WHERE `guildid`=" . $char[8] . ";"));
    $output .= "\r\n                            <tr>\r\n                                <td><a href=\"char.php?id={$char['0']}\">" . htmlentities($char[1]) . "</a></td>\r\n                                <td><img src='img/c_icons/{$char[2]}-{$char[9]}.gif' onmousemove='toolTip(\"" . char_get_race_name($char[2]) . "\",\"item_tooltip\")' onmouseout='toolTip()'></td>\r\n                                <td><img src='img/c_icons/{$char[3]}.gif' onmousemove='toolTip(\"" . char_get_class_name($char[3]) . "\",\"item_tooltip\")' onmouseout='toolTip()'></td>\r\n                                <td>" . char_get_level_color($char[6]) . "</td>\r\n                                <td><span onmouseover='toolTip(\"" . char_get_pvp_rank_name($char[4], char_get_side_id($char[2])) . "\",\"item_tooltip\")' onmouseout='toolTip()' style='color: white;'><img src='img/ranks/rank" . char_get_pvp_rank_id($char[4], char_get_side_id($char[2])) . ".gif'></span></td>\r\n                                <td>{$char['4']}</td>\r\n                                <td>{$char['5']}</td>\r\n                                <td>{$char['7']}</td>\r\n                                <td><a href=\"guild.php?action=view_guild&amp;error=3&amp;id={$char['8']}\">" . htmlentities($guild_name[0]) . "</a></td>\r\n                            </tr>";
}
$output .= "\r\n                        </table>\r\n                        <br />\r\n                    </fieldset>";
$query = $sql->query("SELECT C.guid, C.name, C.race, C.class, C.todayHonorPoints AS honor , C.totalKills AS kills, C.level, C.arenaPoints AS arena, COALESCE(guild_member.guildid,0) as GNAME, C.gender FROM characters C LEFT JOIN guild_member ON C.guid = guild_member.guid WHERE race not in (1,3,4,7,11) ORDER BY {$order_by} DESC LIMIT 25;");
$this_page = $sql->num_rows($query);
$output .= "\r\n                <script type=\"text/javascript\">\r\n                    answerbox.btn_ok='{$lang_global['yes_low']}';\r\n                    answerbox.btn_cancel='{$lang_global['no']}';\r\n                </script>\r\n                <center>\r\n                    <fieldset style=\"width: 776px;\">\r\n                        <legend><img src='img/horde.gif' /></legend>\r\n                        <table class=\"lined\" style=\"width: 705px;\">\r\n                            <tr class=\"bold\">\r\n                                <td colspan=\"11\">{$lang_honor['horde']} {$lang_honor['browse_honor']}</td>\r\n                            </tr>\r\n                            <tr>\r\n                                <th width=\"30%\">{$lang_honor['guid']}</th>\r\n                                <th width=\"7%\">{$lang_honor['race']}</th>\r\n                                <th width=\"7%\">{$lang_honor['class']}</th>\r\n                                <th width=\"7%\">{$lang_honor['level']}</th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=honor\"" . ($order_by == 'honor' ? " class=DESC" : "") . ">{$lang_honor['honor']}</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=honor\"" . ($order_by == 'honor' ? " class=DESC" : "") . ">{$lang_honor['honor points']}</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=kills\"" . ($order_by == 'kills' ? " class=DESC" : "") . ">Kills</a></th>\r\n                                <th width=\"5%\"><a href=\"honor.php?order_by=arena\"" . ($order_by == 'arena' ? " class=DESC" : "") . ">AP</a></th>\r\n                                <th width=\"30%\">{$lang_honor['guild']}</th>\r\n                            </tr>";
while ($char = $sql->fetch_row($query)) {
    $guild_name = $sql->fetch_row($sql->query("SELECT `name` FROM `guild` WHERE `guildid`=" . $char[8] . ";"));
    $output .= "\r\n                            <tr>\r\n                                <td><a href=\"char.php?id={$char['0']}\">" . htmlentities($char[1]) . "</a></td>\r\n                                <td><img src='img/c_icons/{$char[2]}-{$char[9]}.gif' onmousemove='toolTip(\"" . char_get_race_name($char[2]) . "\",\"item_tooltip\")' onmouseout='toolTip()'></td>\r\n                                <td><img src='img/c_icons/{$char[3]}.gif' onmousemove='toolTip(\"" . char_get_class_name($char[3]) . "\",\"item_tooltip\")' onmouseout='toolTip()'></td>\r\n                                <td>" . char_get_level_color($char[6]) . "</td>\r\n                                <td><span onmouseover='toolTip(\"" . char_get_pvp_rank_name($char[4], char_get_side_id($char[2])) . "\",\"item_tooltip\")' onmouseout='toolTip()' style='color: white;'><img src='img/ranks/rank" . char_get_pvp_rank_id($char[4], char_get_side_id($char[2])) . ".gif'></span></td>\r\n                                <td>{$char['4']}</td>\r\n                                <td>{$char['5']}</td>\r\n                                <td>{$char['7']}</td>\r\n                                <td><a href=\"guild.php?action=view_guild&amp;error=3&amp;id={$char['8']}\">" . htmlentities($guild_name[0]) . "</a></td>\r\n                            </tr>";
}
$output .= "\r\n                        </table>\r\n                        <br />\r\n                    </fieldset>";
require_once "footer.php";
function forum_move_topic(&$sqlm)
{
    global $forum_skeleton, $forum_lang, $maxqueries, $user_lvl, $user_id, $output, $mmfpm_db;
    $sqlm = new SQL();
    $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
    if (!isset($_GET['id'])) {
        error($forum_lang['no_such_topic']);
    } else {
        $id = $sqlm->quote_smart($_GET['id']);
    }
    $topic = $sqlm->query('
		SELECT id, topic, authorid, forum, name
		FROM mm_forum_posts
		WHERE id = ' . $id . '');
    if ($sqlm->num_rows($topic) == 0) {
        error($forum_lang['no_such_topic']);
    }
    $topic = $sqlm->fetch_assoc($topic);
    if ($user_lvl == 0) {
        error($forum_lang['no_access']);
    }
    $fid = $topic['forum'];
    $cat = 0;
    foreach ($forum_skeleton as $cid => $category) {
        foreach ($category['forums'] as $fid_ => $forum) {
            if ($fid_ == $fid) {
                $cat = $cid;
            }
        }
    }
    if (empty($forum_skeleton[$cat]['forums'][$fid])) {
        // No such forum..
        error($forum_lang['no_such_forum']);
    }
    $forum = $forum_skeleton[$cat]["forums"][$fid];
    $output .= '
<div class="top">
	<h1>' . $forum_lang['forums'] . '</h1>
</div>
<center>
<table class="flat">
	<tr>
		<td align="left">
			<a href="forum.php">' . $forum_lang['forum_index'] . '</a> -> 
			<a href="forum.php?action=view_forum&amp;id=' . $fid . '">' . $forum['name'] . '</a> -> 
			<a href="forum.php?action=view_topic&amp;id=' . $topic['topic'] . '">' . $topic['name'] . '</a> -> 
			' . $forum_lang["move"] . '!
		</td>
	</tr>
</table>
<table class="lined">
	<tr>
		<td>' . $forum_lang['where'] . ' : 
		<form action="forum.php?action=do_move_topic" method="POST" name="form">
			<select name="forum">';
    foreach ($forum_skeleton as $category) {
        foreach ($category['forums'] as $fid_ => $forum) {
            if ($fid_ != $fid) {
                $output .= '
				<option value=' . $fid_ . '>' . $forum['name'] . '</option>';
            } else {
                $output .= '
				<option value=' . $fid_ . ' selected>' . $forum['name'] . '</option>';
            }
        }
    }
    $output .= '
			</select>
		<input type="hidden" name="id" value="' . $id . '">
		</form>
		</td>
	</tr>
</table>
<table class="hidden">
	<tr>
		<td>';
    makebutton($forum_lang['back'], "javascript:window.history.back()", 120);
    makebutton($forum_lang['confirm'], "javascript:do_submit()", 120);
    $output .= '
		</td>
	</tr>
</table>
</center>';
    $sqlm->close();
    // Queries : 1
}
function forum_edit_post(&$sqlm)
{
    global $forum_skeleton, $forum_lang, $maxqueries, $minfloodtime, $user_lvl, $user_id, $output, $mmfpm_db;
    $sqlm = new SQL();
    $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
    //==========================$_GET and SECURE=================================
    if (!isset($_GET['id'])) {
        error($forum_lang['no_such_post']);
    } else {
        $id = $sqlm->quote_smart($_GET['id']);
    }
    //==========================$_GET and SECURE end=============================
    $post = $sqlm->query('
		SELECT id, topic, authorid, forum, name, text
		FROM mm_forum_posts
		WHERE id = ' . $id . '');
    if ($sqlm->num_rows($post) == 0) {
        error($forum_lang['no_such_post']);
    }
    $post = $sqlm->fetch_assoc($post);
    if ($user_lvl == 0 && $user_id != $post['authorid']) {
        error($forum_lang['no_access']);
    }
    $cat = 0;
    foreach ($forum_skeleton as $cid => $category) {
        foreach ($category["forums"] as $fid_ => $forum) {
            if ($fid_ == $post['forum']) {
                $cat = $cid;
            }
        }
    }
    if (empty($forum_skeleton[$cat]['forums'][$post['forum']])) {
        // No such forum..
        error($forum_lang['no_such_forum']);
    }
    $forum = $forum_skeleton[$cat]['forums'][$post['forum']];
    $output .= '
<div class="top">
	<h1>' . $forum_lang['forums'] . '</h1>
</div>
<form action="forum.php?action=do_edit_post" method="POST" name="form">
<center>
<fieldset>
	<legend>
		<a href="forum.php">' . $forum_lang['forum_index'] . '</a> -> 
		<a href="forum.php?action=view_forum&amp;id=' . $post['forum'] . '">' . $forum['name'] . '</a> -> 
		<a href="forum.php?action=view_topic&amp;id=' . $post['topic'] . '">' . $post['name'] . '</a> -> 
		' . $forum_lang['edit'] . '
	</legend>';
    $output .= '
<table class="lined">
	<tr>';
    if ($post['id'] = $post['id']) {
        $output .= '
		<td align="left"><input type="hidden" name="topic" value="1">
			' . $forum_lang['topic_name'] . ': <input name="name" SIZE="50" value="' . $post['name'] . '">
		</td>
	</tr>';
    } else {
        $output .= '
		</td>
		<td align="left">' . $post['name'] . '</td>
	</tr>';
    }
    $post['text'] = str_replace('<br />', chr(10), $post['text']);
    $output .= '
	<tr>
		<td align="left" colspan="3">';
    bbcode_add_editor();
    $output .= '
		</td>
	</tr>
	<tr>
		<td colspan="3">
			<TEXTAREA ID="msg" NAME="msg" ROWS=8 COLS=93>' . $post['text'] . '</TEXTAREA>
			<input type="hidden" name="forum" value="' . $post['forum'] . '">
			<input type="hidden" name="post" value="' . $post['id'] . '">
		</td>
	</tr>
	<tr>
		<td align="left">';
    makebutton($forum_lang['post'], "javascript:do_submit()", 100);
    $output .= '
		</td>
	</tr>
</table>
</fieldset>';
    $output .= '
</center>
</form>
<br/>';
    $sqlm->close();
    // Queries : 1
}
Example #18
0
function do_add_entry()
{
    global $realm_db, $user_name, $output, $action_permission, $user_lvl;
    valid_login($action_permission['insert']);
    if (empty($_GET['ban_type']) || empty($_GET['entry']) || empty($_GET['bantime'])) {
        redirect("banned.php?error=1&action=add_entry");
    }
    $sqlr = new SQL();
    $sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    $ban_type = $sqlr->quote_smart($_GET['ban_type']);
    $entry = $sqlr->quote_smart($_GET['entry']);
    if ($ban_type == "account_banned") {
        $result1 = $sqlr->query("SELECT id FROM account WHERE username ='******'");
        if (!$sqlr->num_rows($result1)) {
            redirect("banned.php?error=4&action=add_entry");
        } else {
            $entry = $sqlr->result($result1, 0, 'id');
        }
    }
    $bantime = time() + 3600 * $sqlr->quote_smart($_GET['bantime']);
    $banreason = isset($_GET['banreason']) && $_GET['banreason'] != '' ? $sqlr->quote_smart($_GET['banreason']) : "none";
    if ($ban_type === "account_banned") {
        $result = $sqlr->query("SELECT count(*) FROM account_banned WHERE id = '{$entry}'");
        if (!$sqlr->result($result, 0)) {
            $sqlr->query("INSERT INTO account_banned (id, bandate, unbandate, bannedby, banreason, active)\r\n                            VALUES ('{$entry}'," . time() . ",{$bantime},'{$user_name}','{$banreason}', 1)");
        }
    } else {
        $sqlr->query("INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason)\r\n                        VALUES ('{$entry}'," . time() . ",{$bantime},'{$user_name}','{$banreason}')");
    }
    if ($sqlr->affected_rows()) {
        redirect("banned.php?error=3&ban_type={$ban_type}");
    } else {
        redirect("banned.php?error=2&ban_type={$ban_type}");
    }
}
function savemenu()
{
    global $corem_db;
    $sqlm = new SQL();
    $sqlm->connect($corem_db["addr"], $corem_db["user"], $corem_db["pass"], $corem_db["name"], $corem_db["encoding"]);
    $menu_item = $sqlm->quote_smart($_GET["menu_item"]);
    $menu = $sqlm->quote_smart($_GET["menu"]);
    $order = $sqlm->quote_smart($_GET["order"]);
    $name = $sqlm->quote_smart($_GET["name"]);
    $action = $sqlm->quote_smart($_GET["menu_action"]);
    $view = $sqlm->quote_smart($_GET["view"]);
    $insert = $sqlm->quote_smart($_GET["insert"]);
    $update = $sqlm->quote_smart($_GET["update"]);
    $delete = $sqlm->quote_smart($_GET["delete"]);
    $enabled = isset($_GET["enabled"]) ? 1 : 0;
    if (empty($order) || !isset($order)) {
        redirect("admin.php?section=menus&error=1");
    }
    $result = $sqlm->query("SELECT * FROM config_menus WHERE `Index`='" . $menu_item . "'");
    if ($sqlm->num_rows($result)) {
        $result = $sqlm->query("UPDATE config_menus SET Menu='" . $menu . "', `Order`='" . $order . "', Name='" . $name . "', Action='" . $action . "', View='" . $view . "', `Insert`='" . $insert . "', `Update`='" . $update . "', `Delete`='" . $delete . "', Enabled='" . $enabled . "' WHERE `Index`='" . $menu_item . "'");
    } else {
        $result = $sqlm->query("INSERT INTO config_menus (Menu, `Order`, Name, Action, View, Insert, Update, Delete, Enabled) VALUES ('" . $menu . "', '" . $order . "', '" . $name . "', '" . $action . "', '" . $view . "', '" . $insert . "', '" . $update . "', '" . $delete . "', '" . $enabled . "')");
    }
    redirect("admin.php?section=menus");
}
Example #20
0
function send_mail()
{
    global $lang_global, $output, $realm_db, $characters_db, $realm_id, $user_name, $from_mail, $mailer_type, $smtp_cfg;
    if (empty($_POST['body']) || empty($_POST['subject']) || empty($_POST['type']) || empty($_POST['group_sign']) || empty($_POST['group_send'])) {
        redirect("mail.php?error=1");
    }
    $sqlr = new SQL();
    $sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    $sqlc = new SQL();
    $sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
    $body = explode("\n", $_POST['body']);
    $subject = $sqlc->quote_smart($_POST['subject']);
    if (isset($_POST['to']) && $_POST['to'] != '') {
        $to = $sqlc->quote_smart($_POST['to']);
    } else {
        $to = 0;
        if (!isset($_POST['group_value']) || $_POST['group_value'] === '') {
            redirect("mail.php?error=1");
        } else {
            $group_value = $sqlc->quote_smart($_POST['group_value']);
            $group_sign = $sqlc->quote_smart($_POST['group_sign']);
            $group_send = $sqlc->quote_smart($_POST['group_send']);
        }
    }
    $type = addslashes($_POST['type']);
    $att_gold = $sqlc->quote_smart($_POST['money']);
    $att_item = $sqlc->quote_smart($_POST['att_item']);
    $att_stack = $sqlc->quote_smart($_POST['att_stack']);
    switch ($type) {
        case "email":
            require_once "libs/mailer/class.phpmailer.php";
            $mail = new PHPMailer();
            $mail->Mailer = $mailer_type;
            if ($mailer_type == "smtp") {
                $mail->Host = $smtp_cfg['host'];
                $mail->Port = $smtp_cfg['port'];
                if ($smtp_cfg['user'] != '') {
                    $mail->SMTPAuth = true;
                    $mail->Username = $smtp_cfg['user'];
                    $mail->Password = $smtp_cfg['pass'];
                }
            }
            $value = NULL;
            for ($i = 0; $i < count($body); $i++) {
                $value .= $body[$i] . "\r\n";
            }
            $body = $value;
            $mail->From = $from_mail;
            $mail->FromName = $user_name;
            $mail->Subject = $subject;
            $mail->IsHTML(true);
            $body = str_replace("\n", "<br />", $body);
            $body = str_replace("\r", " ", $body);
            $body = str_replace(array("\r\n", "\n", "\r"), '<br />', $body);
            $body = preg_replace("/([^\\/=\"\\]])((http|ftp)+(s)?:\\/\\/[^<>\\s]+)/i", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $body);
            $body = preg_replace('/([^\\/=\\"\\]])(www\\.)(\\S+)/', '\\1<a href="http://\\2\\3" target="_blank">\\2\\3</a>', $body);
            $mail->Body = $body;
            $mail->WordWrap = 50;
            if ($to) {
                //single Recipient
                $mail->AddAddress($to);
                if (!$mail->Send()) {
                    $mail->ClearAddresses();
                    redirect("mail.php?error=3&mail_err=" . $mail->ErrorInfo);
                } else {
                    $mail->ClearAddresses();
                    redirect("mail.php?error=2");
                }
            } elseif (isset($group_value)) {
                //group send
                $email_array = array();
                switch ($group_send) {
                    case "gm_level":
                        $result = $sqlr->query("SELECT email FROM account WHERE gmlevel {$group_sign} '{$group_value}'");
                        while ($user = $sqlr->fetch_row($result)) {
                            if ($user[0] != "") {
                                array_push($email_array, $user[0]);
                            }
                        }
                        break;
                    case "locked":
                        $result = $sqlr->query("SELECT email FROM account WHERE locked {$group_sign} '{$group_value}'");
                        while ($user = $sqlr->fetch_row($result)) {
                            if ($user[0] != "") {
                                array_push($email_array, $user[0]);
                            }
                        }
                        break;
                    case "banned":
                        $que = $sqlr->query("SELECT id FROM account_banned");
                        while ($banned = $sql->fetch_row($que)) {
                            $result = $sqlr->query("SELECT email FROM account WHERE id = '{$banned['0']}'");
                            if ($sqlr->result($result, 0, 'email')) {
                                array_push($email_array, $sql->result($result, 0, 'email'));
                            }
                        }
                        break;
                    default:
                        redirect("mail.php?error=5");
                        break;
                }
                foreach ($email_array as $mail_addr) {
                    $mail->AddAddress($mail_addr);
                    if (!$mail->Send()) {
                        $mail->ClearAddresses();
                        redirect("mail.php?error=3&mail_err=" . $mail->ErrorInfo);
                    } else {
                        $mail->ClearAddresses();
                    }
                }
                redirect("mail.php?error=2");
            } else {
                redirect("mail.php?error=1");
            }
            break;
        case "ingame_mail":
            $value = NULL;
            for ($i = 0; $i < count($body); $i++) {
                $value .= $body[$i] . " ";
            }
            $body = $value;
            $body = str_replace("\r", " ", $body);
            if ($to) {
                //single Recipient
                $result = $sqlc->query("SELECT name FROM characters WHERE name = '{$to}'");
                if ($sqlc->num_rows($result) == 1) {
                    $receiver = $sqlc->result($result, 0, 'name');
                    $mails = array();
                    array_push($mails, array($receiver, $subject, $body, $att_gold, $att_item, $att_stack));
                    send_ingame_mail($realm_id, $mails);
                } else {
                    redirect("mail.php?error=4");
                }
                redirect("mail.php?error=2");
                break;
            } elseif (isset($group_value)) {
                //group send
                $char_array = array();
                switch ($group_send) {
                    case "gm_level":
                        $result = $sqlr->query("SELECT id FROM account WHERE gmlevel {$group_sign} '{$group_value}'");
                        while ($acc = $sqlc->fetch_row($result)) {
                            $result_2 = $sqlc->query("SELECT name FROM `characters` WHERE account = '{$acc['0']}'");
                            while ($char = $sqlc->fetch_row($result_2)) {
                                array_push($char_array, $char[0]);
                            }
                        }
                        break;
                    case "online":
                        $result = $sqlc->query("SELECT name FROM `characters` WHERE online {$group_sign} '{$group_value}'");
                        while ($user = $sqlc->fetch_row($result)) {
                            array_push($char_array, $user[0]);
                        }
                        break;
                    case "char_level":
                        $result = $sqlc->query("SELECT name FROM `characters` WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) {$group_sign} '{$group_value}'");
                        while ($user = $sqlc->fetch_row($result)) {
                            array_push($char_array, $user[0]);
                        }
                        break;
                    default:
                        redirect("mail.php?error=5");
                }
                $mails = array();
                foreach ($char_array as $receiver) {
                    array_push($mails, array($receiver, $subject, $body, $att_gold, $att_item, $att_stack));
                }
                send_ingame_mail($realm_id, $mails);
                redirect("mail.php?error=2");
            }
            break;
        default:
            redirect("mail.php?error=1");
    }
}
Example #21
0
function do_pass_activate()
{
    global $lang_global, $realm_db;
    if (empty($_GET['h']) || empty($_GET['p'])) {
        redirect("register.php?action=pass_recovery&err=1");
    }
    $sql = new SQL();
    $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    $pass = $sql->quote_smart(trim($_GET['p']));
    $hash = $sql->quote_smart($_GET['h']);
    $result = $sql->query("SELECT id,username FROM account WHERE sha_pass_hash = '{$hash}'");
    if ($sql->num_rows($result) == 1) {
        $username = $sql->result($result, 0, 'username');
        $id = $sql->result($result, 0, 'id');
        if (substr(sha1(strtoupper($sql->result($result, 0, 'username'))), 0, 7) == $pass) {
            $sql->query("UPDATE account SET sha_pass_hash=SHA1(CONCAT(UPPER('{$username}'),':',UPPER('{$pass}'))), v=0, s=0 WHERE id = '{$id}'");
            redirect("login.php");
        }
    } else {
        redirect("register.php?action=pass_recovery&err=1");
    }
    redirect("register.php?action=pass_recovery&err=1");
}
function forum_do_add_topic(&$sqlm)
{
    global $enablesidecheck, $forum_skeleton, $forum_lang, $user_lvl, $user_name, $user_id, $mmfpm_db, $minfloodtime;
    if ($enablesidecheck) {
        $side = get_side();
    }
    // Better to use it here instead of call it many time in the loop :)
    $sqlm = new SQL();
    $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
    $userposts = $sqlm->query('
			SELECT time
			FROM mm_forum_posts
			WHERE authorid = ' . $user_id . '
			ORDER BY id DESC
			LIMIT 1');
    if ($sqlm->num_rows($userposts) != 0) {
        $mintimeb4post = $sqlm->fetch_assoc($userposts);
        $mintimeb4post = time() - strtotime($mintimeb4post['time']);
        if ($mintimeb4post < $minfloodtime) {
            error($forum_lang['please_wait']);
        }
    }
    //==========================$_POST and SECURE=================================
    if (!isset($_POST['forum'])) {
        error($forum_lang['no_such_forum']);
    } else {
        $forum = $sqlm->quote_smart($_POST['forum']);
    }
    //==========================$_POST and SECURE end=============================
    $cat = 0;
    foreach ($forum_skeleton as $cid => $category) {
        foreach ($category['forums'] as $fid => $forum_) {
            if ($fid == $forum) {
                $cat = $cid;
            }
        }
    }
    if (empty($forum_skeleton[$cat]['forums'][$forum])) {
        error($forum_lang['no_such_forum']);
    }
    $forum_ = $forum_skeleton[$cat]['forums'][$forum];
    if ($forum_skeleton[$cat]['level_post_topic'] > $user_lvl || $forum_['level_post_topic'] > $user_lvl) {
        error($forum_lang['no_access']);
    }
    if ($user_lvl == 0 && $enablesidecheck) {
        if ($forum_skeleton[$cat]['side_access'] != 'ALL') {
            // Not an all side forum
            if ($side == 'NO') {
                // No char
                continue;
            } else {
                if ($forum_skeleton[$cat]['side_access'] != $side) {
                    // Forumside different of the user side
                    continue;
                }
            }
        }
        if ($forum_['side_access'] != 'ALL') {
            // Not an all side forum
            if ($side == 'NO') {
                // No char
                continue;
            } else {
                if ($forum_['side_access'] != $side) {
                    // Forumside different of the user side
                    continue;
                }
            }
        }
    }
    //==========================$_POST and SECURE=================================
    //  $_POST['msg'] = htmlspecialchars($_POST['msg']);
    $msg = trim($sqlm->quote_smart($_POST['msg']), " ");
    //  $_POST['name'] = htmlspecialchars($_POST['name']);
    $name = trim($sqlm->quote_smart($_POST['name']), " ");
    //==========================$_POST and SECURE end=============================
    if (strlen($name) > 49) {
        $sqlm->close();
        error($forum_lang['name_too_long']);
    }
    if (strlen($name) < 5) {
        $sqlm->close();
        error($forum_lang['name_too_short']);
    }
    if (strlen($msg) < 5) {
        $sqlm->close();
        error($forum_lang['msg_too_short']);
    }
    $msg = str_replace('\\n', '<br />', $msg);
    //  $msg = str_replace('\r', '<br />', $msg);
    $time = date("m/d/y H:i:s");
    $sqlm->query('
		INSERT INTO mm_forum_posts
			(authorid, authorname, forum, name, text, time)
		VALUES
			(\'' . $user_id . '\', \'' . $user_name . '\', \'' . $forum . '\', \'' . $name . '\', \'' . $msg . '\', \'' . $time . '\')');
    $id = $sqlm->insert_id();
    $sqlm->query('
		UPDATE mm_forum_posts
		SET topic = ' . $id . ', lastpost = ' . $id . '
		WHERE id = ' . $id . '');
    $sqlm->close();
    redirect('forum.php?action=view_topic&id=' . $id . '');
    // Queries : 3
}
function saveacct()
{
    global $corem_db;
    $sqlm = new SQL();
    $sqlm->connect($corem_db["addr"], $corem_db["user"], $corem_db["pass"], $corem_db["name"], $corem_db["encoding"]);
    $acct = $sqlm->quote_smart($_GET["login"]);
    $sn = $sqlm->quote_smart($_GET["sn"]);
    $sec = isset($_GET["sec"]) ? $sqlm->quote_smart($_GET["sec"]) : 0;
    $acp = isset($_GET["acp"]) ? 1 : 0;
    if ($acp) {
        $sec += 1073741824;
    }
    $result = $sqlm->query("SELECT * FROM config_accounts WHERE Login='******'");
    if ($sqlm->num_rows($result)) {
        $result = $sqlm->query("UPDATE config_accounts SET ScreenName='" . $sn . "', SecurityLevel='" . $sec . "' WHERE Login='******'");
    } else {
        $result = $sqlm->query("INSERT INTO config_accounts (Login, ScreenName, SecurityLevel) VALUES ('" . $acct . "', '" . $sn . "', '" . $sec . "')");
    }
    redirect("admin.php?section=accounts");
}
Example #24
0
function general()
{
    global $output, $corem_db, $world_db, $core;
    // we need $core to be set
    if ($core == 0) {
        $core = detectcore();
    }
    $sqlm = new SQL();
    $sqlm->connect($corem_db["addr"], $corem_db["user"], $corem_db["pass"], $corem_db["name"], $corem_db["encoding"]);
    $sqlw = new SQL();
    $sqlw->connect($world_db[1]["addr"], $world_db[1]["user"], $world_db[1]["pass"], $world_db[1]["name"], $world_db[1]["encoding"]);
    $subsection = isset($_GET["subsection"]) ? $sqlm->quote_smart($_GET["subsection"]) : 1;
    $output .= '
        <table id="sidebar">
          <tr>
            <td ' . ($subsection == "more" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=more">' . lang("admin", "more") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "version" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=version">' . lang("admin", "version") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "mail" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=mail">' . lang("admin", "mail") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "irc" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=irc">' . lang("admin", "irc") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "proxy" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=proxy">' . lang("admin", "proxy") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "datasite" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=datasite">' . lang("admin", "datasite") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "acctcreation" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=acctcreation">' . lang("admin", "acct_creation") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "guests" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=guests">' . lang("admin", "guests") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "extratools" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=extratools">' . lang("admin", "extra_tools") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "internalmap" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=internalmap">' . lang("admin", "internal_map") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "validip" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=validip">' . lang("admin", "validip") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "ads" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=ads">' . lang("admin", "ads") . '</a>
            </td>
          </tr>
          <tr>
            <td ' . ($subsection == "gmlevels" ? 'class="current"' : '') . '>
              <a href="admin.php?section=general&amp;subsection=gmlevels">' . lang("admin", "gm_levels") . '</a>
            </td>
          </tr>
        </table>';
    if (isset($_GET["error"])) {
        $output .= '
      <div id="misc_error">';
    } else {
        $output .= '
      <div id="misc">';
    }
    $sub_action = isset($_GET["subaction"]) ? $_GET["subaction"] : '';
    switch ($subsection) {
        case "version":
            if (!$sub_action) {
                $show_version_show = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Show_Version_Show'"));
                $show_version_version = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Show_Version_Version'"));
                $show_version_version_lvl = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Show_Version_Version_Lvl'"));
                $show_version_revision = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Show_Version_SVNRev'"));
                $show_version_revision_lvl = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Show_Version_SVNRev_Lvl'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="saveversion" />
            <input type="hidden" name="subsection" value="version" />
          </div>
          <table class="simple">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "show_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "show") . '</a>:
              </td>
              <td>
                <select name="showversion" id="admin_showversion_field">
                  <option value="0" ' . ($show_version_show["Value"] == 0 ? 'selected="selected"' : '') . '>' . lang("admin", "dontshow") . '</option>
                  <option value="1" ' . ($show_version_show["Value"] == 1 ? 'selected="selected"' : '') . 'disabled="disabled">' . lang("admin", "version") . '</option>
                  <option value="2"' . ($show_version_show["Value"] == 2 ? 'selected="selected"' : '') . '>' . lang("admin", "verrev") . '</option>
                </select>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "version_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "version") . '</a>:
              </td>
              <td>
                <input type="text" name="version" value="' . $show_version_version["Value"] . '" readonly="readonly" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "versionlvl_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "versionlvl") . '</a>:
              </td>
              <td>
                <input type="text" name="versionlvl" value="' . $show_version_version_lvl["Value"] . '" readonly="readonly" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "revision_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "revision") . '</a>:
              </td>
              <td>
                <input type="text" name="revision" value="' . $show_version_revision["Value"] . '" readonly="readonly" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "revisionlvl_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "revisionlvl") . '</a>:
              </td>
              <td>
                <input type="text" name="revisionlvl" value="' . $show_version_revision_lvl["Value"] . '" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $show_version = $sqlm->quote_smart($_GET["showversion"]);
                $version = $sqlm->quote_smart($_GET["version"]);
                $version_lvl = $sqlm->quote_smart($_GET["versionlvl"]);
                $revision = $sqlm->quote_smart($_GET["revision"]);
                $revision_lvl = $sqlm->quote_smart($_GET["revisionlvl"]);
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $show_version . "' WHERE `Key`='Show_Version_Show'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $version . "' WHERE `Key`='Show_Version_Version'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $version_lvl . "' WHERE `Key`='Show_Version_Version_Lvl'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $revision . "' WHERE `Key`='Show_Version_SVNRev'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $revision_lvl . "' WHERE `Key`='Show_Version_SVNRev_Lvl'");
                redirect("admin.php?section=general&subsection=version");
            }
            break;
        case "mail":
            if (!$sub_action) {
                $mail_admin_email = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Mail_Admin_Email'"));
                $mail_mailer_type = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Mail_Mailer_Type'"));
                $mail_from_email = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Mail_From_Email'"));
                $mail_gmailsender = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Mail_GMailSender'"));
                $format_mail_html = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Format_Mail_HTML'"));
                $smtp_host = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='SMTP_Host'"));
                $smtp_port = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='SMTP_Port'"));
                $smtp_user = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='SMTP_User'"));
                $smtp_pass = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='SMTP_Pass'"));
                $pm_from_char = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='PM_From_Char'"));
                $pm_stationary = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='PM_Stationary'"));
                $url_path = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='URL_Path'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="savemail" />
            <input type="hidden" name="subsection" value="mail" />
          </div>
          <table class="simple">
            <tr>
              <td colspan="2"><b>' . lang("admin", "email") . '</b></td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "adminemail_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "adminemail") . '</a>:
              </td>
              <td>
                <input type="text" name="adminemail" value="' . $mail_admin_email["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "mailertype_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "mailertype") . '</a>:
              </td>
              <td>
                <select name="mailertype" id="admin_mailertype_field">
                  <option value="mail" ' . ($mail_mailer_type["Value"] == "mail" ? 'selected="selected" ' : '') . '>' . lang("admin", "mail") . '</option>
                  <option value="sendmail" ' . ($mail_mailer_type["Value"] == "sendmail" ? 'selected="selected" ' : '') . '>' . lang("admin", "sendmail") . '</option>
                  <option value="smtp"' . ($mail_mailer_type["Value"] == "smtp" ? 'selected="selected" ' : '') . '>' . lang("admin", "smtp") . '</option>
                  <option value="gmailsmtp"' . ($mail_gmailsender["Value"] == 1 ? 'selected="selected" ' : '') . '>' . lang("admin", "gmailsmtp") . '</option>
                </select>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "fromemail_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "fromemail") . '</a>:
              </td>
              <td>
                <input type="text" name="fromemail" value="' . $mail_from_email["Value"] . '" />
              </td>
            </tr>
            <!-- tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "usegmail_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "usegmail") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="gmail" ' . ($mail_gmailsender["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr -->
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "formathtml_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "formathtml") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="usehtml" ' . ($format_mail_html["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "urlpath_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "urlpath") . '</a>:
              </td>
              <td>
                <input type="text" name="urlpath" value="' . $url_path["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <b>' . lang("admin", "smtp") . '</b>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "smtphost_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "smtphost") . '</a>:
              </td>
              <td>
                <input type="text" name="smtphost" value="' . $smtp_host["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "smtpport_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "smtpport") . '</a>:
              </td>
              <td>
                <input type="text" name="smtpport" value="' . $smtp_port["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "smtpuser_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "smtpuser") . '</a>:
              </td>
              <td>
                <input type="text" name="smtpuser" value="' . $smtp_user["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "smtppass_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "smtppass") . '</a>:
              </td>
              <td>
                <input type="text" name="smtppass" value="' . $smtp_pass["Value"] . '" />
              </td>
            </tr>';
                if ($core == 1) {
                    $output .= '
            <tr>
              <td colspan="2">
                <b>' . lang("admin", "pm") . '</b>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "pmfrom_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "pmfrom") . '</a>:
              </td>
              <td>
                <input type="text" name="fromchar" value="' . $pm_from_char["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "pmstation_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "pmstation") . '</a>:
              </td>
              <td>
                <input type="text" name="stationary" value="' . $pm_stationary["Value"] . '" />
              </td>
            </tr>';
                }
                $output .= '
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $mail_admin_email = $sqlm->quote_smart($_GET["adminemail"]);
                $mail_mailer_type = $sqlm->quote_smart($_GET["mailertype"]);
                $mail_from_email = $sqlm->quote_smart($_GET["fromemail"]);
                if ($mail_mailer_type == "gmailsmtp") {
                    $mail_gmailsender = 1;
                } else {
                    $mail_gmailsender = 0;
                }
                $format_mail_html = isset($_GET["usehtml"]) ? 1 : 0;
                $smtp_host = $sqlm->quote_smart($_GET["smtphost"]);
                $smtp_port = $sqlm->quote_smart($_GET["smtpport"]);
                $smtp_user = $sqlm->quote_smart($_GET["smtpuser"]);
                $smtp_pass = $sqlm->quote_smart($_GET["smtppass"]);
                $pm_from_char = isset($_GET["fromchar"]) ? $sqlm->quote_smart($_GET["fromchar"]) : 1;
                $pm_stationary = isset($_GET["stationary"]) ? $sqlm->quote_smart($_GET["stationary"]) : 41;
                $url_path = $sqlm->quote_smart($_GET["urlpath"]);
                // clean up $url_path in case user can't read
                if ($url_path != "" && $url_path[0] != "/") {
                    $url_path = "/" . $url_path;
                }
                if ($url_path == "/") {
                    $url_path = "";
                }
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $mail_admin_email . "' WHERE `Key`='Mail_Admin_Email'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $mail_mailer_type . "' WHERE `Key`='Mail_Mailer_Type'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $mail_from_email . "' WHERE `Key`='Mail_From_Email'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $mail_gmailsender . "' WHERE `Key`='Mail_GMailSender'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $format_mail_html . "' WHERE `Key`='Format_Mail_HTML'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $smtp_host . "' WHERE `Key`='SMTP_Host'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $smtp_port . "' WHERE `Key`='SMTP_Port'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $smtp_user . "' WHERE `Key`='SMTP_User'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $smtp_pass . "' WHERE `Key`='SMTP_Pass'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $pm_from_char . "' WHERE `Key`='PM_From_Char'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $pm_stationary . "' WHERE `Key`='PM_Stationary'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $url_path . "' WHERE `Key`='URL_Path'");
                redirect("admin.php?section=general&subsection=mail");
            }
            break;
        case "irc":
            if (!$sub_action) {
                $irc_host = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='IRC_Server'"));
                $irc_port = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='IRC_Port'"));
                $irc_channel = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='IRC_Channel'"));
                $irc_helppage = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='IRC_HelpPage'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="saveirc" />
            <input type="hidden" name="subsection" value="irc" />
          </div>
          <table class="simple">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "irchost_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "irchost") . '</a>:
              </td>
              <td>
                <input type="text" name="irchost" value="' . $irc_host["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ircport_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ircport") . '</a>:
              </td>
              <td>
                <input type="text" name="ircport" value="' . $irc_port["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ircchannel_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ircchannel") . '</a>:
              </td>
              <td>
                <input type="text" name="ircchannel" value="' . $irc_channel["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "irchelppage_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "irchelppage") . '</a>:
              </td>
              <td>
                <input type="text" name="irchelppage" value="' . $irc_helppage["Value"] . '" readonly="readonly" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $irc_host = $sqlm->quote_smart($_GET["irchost"]);
                $irc_port = $sqlm->quote_smart($_GET["ircport"]);
                $irc_channel = $sqlm->quote_smart($_GET["ircchannel"]);
                $irc_helppage = $sqlm->quote_smart($_GET["irchelppage"]);
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $irc_host . "' WHERE `Key`='IRC_Server'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $irc_port . "' WHERE `Key`='IRC_Port'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $irc_channel . "' WHERE `Key`='IRC_Channel'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $irc_helppage . "' WHERE `Key`='IRC_HelpPage'");
                redirect("admin.php?section=general&subsection=irc");
            }
            break;
        case "proxy":
            if (!$sub_action) {
                $proxy_host = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Proxy_Addr'"));
                $proxy_port = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Proxy_Port'"));
                $proxy_user = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Proxy_User'"));
                $proxy_pass = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Proxy_Pass'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="saveproxy" />
            <input type="hidden" name="subsection" value="proxy" />
          </div>
          <table class="simple">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "proxyhost_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "proxyhost") . '</a>:
              </td>
              <td>
                <input type="text" name="proxyhost" value="' . $proxy_host["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "proxyport_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "proxyport") . '</a>:
              </td>
              <td>
                <input type="text" name="proxyport" value="' . $proxy_port["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "proxyuser_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "proxyuser") . '</a>:
              </td>
              <td>
                <input type="text" name="proxyuser" value="' . $proxy_user["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "proxypass_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "proxypass") . '</a>:
              </td>
              <td>
                <input type="text" name="proxypass" value="' . $proxy_pass["Value"] . '" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $proxy_host = $sqlm->quote_smart($_GET["proxyhost"]);
                $proxy_port = $sqlm->quote_smart($_GET["proxyport"]);
                $proxy_user = $sqlm->quote_smart($_GET["proxyuser"]);
                $proxy_pass = $sqlm->quote_smart($_GET["proxypass"]);
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $proxy_host . "' WHERE `Key`='Proxy_Addr'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $proxy_port . "' WHERE `Key`='Proxy_Port'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $proxy_user . "' WHERE `Key`='Proxy_User'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $proxy_pass . "' WHERE `Key`='Proxy_Pass'");
                redirect("admin.php?section=general&subsection=proxy");
            }
            break;
        case "datasite":
            if (!$sub_action) {
                $datasite_tooltip_script_src = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Tooltip_Script_Src'"));
                $datasite_base = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_Base'"));
                $datasite_name = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_Name'"));
                $datasite_item = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_Item'"));
                $datasite_quest = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_Quest'"));
                $datasite_creature = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_Creature'"));
                $datasite_spell = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_Spell'"));
                $datasite_skill = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_Skill'"));
                $datasite_go = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_GO'"));
                $datasite_achieve = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Datasite_Achievement'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="savedatasite" />
            <input type="hidden" name="subsection" value="datasite" />
          </div>
          <table class="simple" id="admin_datasite">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasitetooltipscriptsrc_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasitetooltipscriptsrc") . '</a>:
              </td>
              <td>
                <input type="text" name="datasitetooltipscriptsrc" value="' . $datasite_tooltip_script_src["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasitebase_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasitebase") . '</a>:
              </td>
              <td>
                <input type="text" name="datasitebase" value="' . $datasite_base["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasitename_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasitename") . '</a>:
              </td>
              <td>
                <input type="text" name="datasitename" value="' . $datasite_name["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasiteitem_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasiteitem") . '</a>:
              </td>
              <td>
                <input type="text" name="datasiteitem" value="' . $datasite_item["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasitequest_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasitequest") . '</a>:
              </td>
              <td>
                <input type="text" name="datasitequest" value="' . $datasite_quest["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasitecreature_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasitecreature") . '</a>:
              </td>
              <td>
                <input type="text" name="datasitecreature" value="' . $datasite_creature["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasitespell_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasitespell") . '</a>:
              </td>
              <td>
                <input type="text" name="datasitespell" value="' . $datasite_spell["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasiteskill_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasiteskill") . '</a>:
              </td>
              <td>
                <input type="text" name="datasiteskill" value="' . $datasite_skill["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasitego_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasitego") . '</a>:
              </td>
              <td>
                <input type="text" name="datasitego" value="' . $datasite_go["Value"] . '" size="50" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "datasiteachieve_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "datasiteachieve") . '</a>:
              </td>
              <td>
                <input type="text" name="datasiteachieve" value="' . $datasite_achieve["Value"] . '" size="50" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $datasite_tooltip_script_src = $sqlm->quote_smart($_GET["datasitetooltipscriptsrc"]);
                $datasite_base = $sqlm->quote_smart($_GET["datasitebase"]);
                $datasite_name = $sqlm->quote_smart($_GET["datasitename"]);
                $datasite_item = $sqlm->quote_smart($_GET["datasiteitem"]);
                $datasite_quest = $sqlm->quote_smart($_GET["datasitequest"]);
                $datasite_creature = $sqlm->quote_smart($_GET["datasitecreature"]);
                $datasite_spell = $sqlm->quote_smart($_GET["datasitespell"]);
                $datasite_skill = $sqlm->quote_smart($_GET["datasiteskill"]);
                $datasite_go = $sqlm->quote_smart($_GET["datasitego"]);
                $datasite_achieve = $sqlm->quote_smart($_GET["datasiteachieve"]);
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_tooltip_script_src . "' WHERE `Key`='Tooltip_Script_Src'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_base . "' WHERE `Key`='Datasite_Base'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_name . "' WHERE `Key`='Datasite_Name'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_item . "' WHERE `Key`='Datasite_Item'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_quest . "' WHERE `Key`='Datasite_Quest'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_creature . "' WHERE `Key`='Datasite_Creature'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_spell . "' WHERE `Key`='Datasite_Spell'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_skill . "' WHERE `Key`='Datasite_Skill'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_go . "' WHERE `Key`='Datasite_GO'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $datasite_achieve . "' WHERE `Key`='Datasite_Achievement'");
                redirect("admin.php?section=general&subsection=datasite");
            }
            break;
        case "acctcreation":
            if (!$sub_action) {
                $disable_acc_creation = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Disable_Acc_Creation'"));
                $invite_only = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Invitation_Only'"));
                $disable_reg_invite = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Disable_Invitation'"));
                $expansion_select = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Expansion_Select'"));
                $default_expansion = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Default_Expansion'"));
                $enabled_captcha = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Enabled_Captcha'"));
                $using_recaptcha = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Use_Recaptcha'"));
                $publickey = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Recaptcha_Public_Key'"));
                $privatekey = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Recaptcha_Private_Key'"));
                $send_mail_on_creation = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Send_Mail_On_Creation'"));
                $send_confirmation_mail_on_creation = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Send_Confirmation_Mail_On_Creation'"));
                $validate_mail_host = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Validate_Mail_Host'"));
                $limit_acc_per_ip = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Limit_Acc_Per_IP'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="saveacctcreation" />
            <input type="hidden" name="subsection" value="acctcreation" />
          </div>
          <table class="simple" id="admin_acct_creation">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "disableacccreation_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "disableacccreation") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="disableacccreation" ' . ($disable_acc_creation["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "inviteonly_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "inviteonly") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="inviteonly" ' . ($invite_only["Value"] == 1 ? 'checked="checked"' : '') . ' ' . ($disable_acc_creation["Value"] == 1 ? '' : 'disabled="disabled"') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "disablereginvite_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "disablereginvite") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="disablereginvite" ' . ($disable_reg_invite["Value"] == 1 ? 'checked="checked"' : '') . ' ' . ($invite_only["Value"] == 0 ? '' : 'disabled="disabled"') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "expansionselect_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "expansionselect") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="expansionselect" ' . ($expansion_select["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "defaultexpansion_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "defaultexpansion") . '</a>:
              </td>
              <td>
                <select name="defaultexpansion">';
                if ($core == 1) {
                    $output .= '
                  <option value="0" ' . ($default_expansion["Value"] == 0 ? 'selected="selected"' : '') . '>Classic</option>
                  <option value="8" ' . ($default_expansion["Value"] == 8 ? 'selected="selected"' : '') . '>BC</option>
                  <option value="16" ' . ($default_expansion["Value"] == 16 ? 'selected="selected"' : '') . '>WotLK</option>
                  <option value="24" ' . ($default_expansion["Value"] == 24 ? 'selected="selected"' : '') . '>WotLK+BC</option>';
                } else {
                    $output .= '
                  <option value="0" ' . ($default_expansion["Value"] == 0 ? 'selected="selected"' : '') . '>Classic</option>
                  <option value="1" ' . ($default_expansion["Value"] == 1 ? 'selected="selected"' : '') . '>BC</option>
                  <option value="2" ' . ($default_expansion["Value"] == 2 ? 'selected="selected"' : '') . '>WotLK+BC</option>';
                }
                $output .= '
                </select>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "enabledcaptcha_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "enabledcaptcha") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="enabledcaptcha" ' . ($enabled_captcha["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "userecaptcha_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "userecaptcha") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="userecaptcha" ' . ($using_recaptcha["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "publickey_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "publickey") . '</a>:
              </td>
              <td>
                <input type="text" name="publickey" value="' . $publickey["Value"] . '" size="52" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "privatekey_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "privatekey") . '</a>:
              </td>
              <td>
                <input type="text" name="privatekey" value="' . $privatekey["Value"] . '" size="52" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "sendmailoncreation_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "sendmailoncreation") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="sendmailoncreation" ' . ($send_mail_on_creation["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "sendconfirmmailoncreation_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "sendconfirmmailoncreation") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="sendconfirmmailoncreation" ' . ($send_confirmation_mail_on_creation["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "validatemailhost_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "validatemailhost") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="validatemailhost" ' . ($validate_mail_host["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "limitaccperip_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "limitaccperip") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="limitaccperip" ' . ($limit_acc_per_ip["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $disable_acc_creation = isset($_GET["disableacccreation"]) ? 1 : 0;
                $invite_only = isset($_GET["inviteonly"]) ? 1 : 0;
                $disable_reg_invite = isset($_GET["disablereginvite"]) ? 1 : 0;
                $expansion_select = isset($_GET["expansionselect"]) ? 1 : 0;
                $default_expansion = $sqlm->quote_smart($_GET["defaultexpansion"]);
                $enabled_captcha = isset($_GET["enabledcaptcha"]) ? 1 : 0;
                $using_recaptcha = isset($_GET["userecaptcha"]) ? 1 : 0;
                $publickey = $sqlm->quote_smart($_GET["publickey"]);
                $privatekey = $sqlm->quote_smart($_GET["privatekey"]);
                $send_mail_on_creation = isset($_GET["sendmailoncreation"]) ? 1 : 0;
                $send_confirmation_mail_on_creation = isset($_GET["sendconfirmmailoncreation"]) ? 1 : 0;
                $validate_mail_host = isset($_GET["validatemailhost"]) ? 1 : 0;
                $limit_acc_per_ip = isset($_GET["limitaccperip"]) ? 1 : 0;
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $disable_acc_creation . "' WHERE `Key`='Disable_Acc_Creation'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $invite_only . "' WHERE `Key`='Invitation_Only'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $disable_reg_invite . "' WHERE `Key`='Disable_Invitation'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $expansion_select . "' WHERE `Key`='Expansion_Select'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $default_expansion . "' WHERE `Key`='Default_Expansion'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $enabled_captcha . "' WHERE `Key`='Enabled_Captcha'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $using_recaptcha . "' WHERE `Key`='Use_Recaptcha'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $publickey . "' WHERE `Key`='Recaptcha_Public_Key'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $privatekey . "' WHERE `Key`='Recaptcha_Private_Key'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $send_mail_on_creation . "' WHERE `Key`='Send_Mail_On_Creation'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $send_confirmation_mail_on_creation . "' WHERE `Key`='Send_Confirmation_Mail_On_Creation'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $validate_mail_host . "' WHERE `Key`='Validate_Mail_Host'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $limit_acc_per_ip . "' WHERE `Key`='Limit_Acc_Per_IP'");
                redirect("admin.php?section=general&subsection=acctcreation");
            }
            break;
        case "guests":
            if (!$sub_action) {
                $acp_allow_anony = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Allow_Anony'"));
                $acp_anony_name = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Anony_Name'"));
                $acp_anony_realm_id = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Anony_Realm_ID'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="saveguests" />
            <input type="hidden" name="subsection" value="guests" />
          </div>
          <table class="simple">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "allowanony_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "allowanony") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="allowanony" ' . ($acp_allow_anony["Value"] == 1 ? 'checked="checked"' : '') . ' disabled="disabled" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "anonyname_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "anonyname") . '</a>:
              </td>
              <td>
                <input type="text" name="anonyname" value="' . $acp_anony_name["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "anonyrealmid_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "anonyrealmid") . '</a>:
              </td>
              <td>
                <input type="text" name="anonyrealmid" value="' . $acp_anony_realm_id["Value"] . '" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                // Allow Anonymous is disabled but must stay checked
                $acp_allow_anony = 1;
                $acp_anony_name = $sqlm->quote_smart($_GET["anonyname"]);
                $acp_anony_realm_id = $sqlm->quote_smart($_GET["anonyrealmid"]);
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $acp_allow_anony . "' WHERE `Key`='Allow_Anony'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $acp_anony_name . "' WHERE `Key`='Anony_Name'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $acp_anony_realm_id . "' WHERE `Key`='Anony_Realm_ID'");
                redirect("admin.php?section=general&subsection=guests");
            }
            break;
        case "extratools":
            if (!$sub_action) {
                if (isset($_GET["newdisable"])) {
                    $query = "INSERT IGNORE INTO ultravendor_disables VALUE ('" . $_GET["newdisable"] . "')";
                    $result = $sqlm->query($query);
                }
                if (isset($_GET["delete"])) {
                    $query = "DELETE FROM ultravendor_disables WHERE itemid='" . $_GET["delete"] . "'";
                    $result = $sqlm->query($query);
                }
                $quest_item_vendor_level_mul = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Quest_Item_Vendor_Level_Mul'"));
                $quest_item_vendor_rew_mul = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Quest_Item_Vendor_Rew_Mul'"));
                $ultra_vendor_mult_0 = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Mult_0'"));
                $ultra_vendor_mult_1 = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Mult_1'"));
                $ultra_vendor_mult_2 = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Mult_2'"));
                $ultra_vendor_mult_3 = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Mult_3'"));
                $ultra_vendor_mult_4 = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Mult_4'"));
                $ultra_vendor_mult_5 = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Mult_5'"));
                $ultra_vendor_mult_6 = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Mult_6'"));
                $ultra_vendor_mult_7 = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Mult_7'"));
                $ultra_vendor_base = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Base'"));
                $ultra_vendor_max_item_level = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Max_Item_Level'"));
                $ultra_vendor_max_item_req_level = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Ultra_Vendor_Max_Item_Req_Level'"));
                $dis_query = "SELECT * FROM ultravendor_disables";
                $dis_result = $sqlm->query($dis_query);
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="saveextratools" />
            <input type="hidden" name="subsection" value="extratools" />
          </div>
          <table class="simple">
            <tr>
              <td colspan="2">
                <b>' . lang("admin", "questitemvendor") . '</b>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "questitemvendorlevelmul_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "questitemvendorlevelmul") . '</a>:
              </td>
              <td>
                <input type="text" name="questitemvendorlevelmul" value="' . $quest_item_vendor_level_mul["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "questitemvendorrewmul_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "questitemvendorrewmul") . '</a>:
              </td>
              <td>
                <input type="text" name="questitemvendorrewmul" value="' . $quest_item_vendor_rew_mul["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <b>' . lang("admin", "ultravendor") . '</b>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormult0_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormult0") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormult0" value="' . $ultra_vendor_mult_0["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormult1_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormult1") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormult1" value="' . $ultra_vendor_mult_1["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormult2_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormult2") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormult2" value="' . $ultra_vendor_mult_2["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormult3_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormult3") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormult3" value="' . $ultra_vendor_mult_3["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormult4_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormult4") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormult4" value="' . $ultra_vendor_mult_4["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormult5_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormult5") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormult5" value="' . $ultra_vendor_mult_5["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormult6_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormult6") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormult6" value="' . $ultra_vendor_mult_6["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormult7_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormult7") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormult7" value="' . $ultra_vendor_mult_7["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendorbase_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendorbase") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendorbase" value="' . $ultra_vendor_base["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormaxitemlevel_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormaxitemlevel") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormaxitemlevel" value="' . $ultra_vendor_max_item_level["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "ultravendormaxitemreqlevel_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "ultravendormaxitemreqlevel") . '</a>:
              </td>
              <td>
                <input type="text" name="ultravendormaxitemreqlevel" value="' . $ultra_vendor_max_item_req_level["Value"] . '" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>
        <br />
        <div>
          <span>' . lang("admin", "disabledinfo") . ':</span>
          <table class="simple">
            <tr>
              <th class="disabled_remove_item_th">&nbsp;</th>
              <th class="disabled_item_th">' . lang("admin", "disableditem") . '</th>
              <th>&nbsp;</th>
            </tr>';
                while ($row = $sqlm->fetch_assoc($dis_result)) {
                    if ($core == 1) {
                        $item_query = "SELECT name1, name FROM items\r\n                             LEFT JOIN itemnames ON itemnames.entry=items.entry\r\n                           WHERE entry='" . $row["itemid"] . "'";
                    } else {
                        $item_query = "SELECT 0 AS name1, name FROM item_template\r\n                           WHERE entry='" . $row["itemid"] . "'";
                    }
                    $item_result = $sqlw->query($item_query);
                    $item_result = $sqlw->fetch_assoc($item_result);
                    // Trinity and MaNGOS will always follow the else
                    // (at least until we add locales_item support here)
                    if ($item_result["name1"] != 0) {
                        $item_name = $item_result["name1"];
                    } else {
                        $item_name = $item_result["name"];
                    }
                    $output .= '
            <tr>
              <td class="disabled_item_id_td">
                <a href="admin.php?section=general&subsection=extratools&delete=' . $row["itemid"] . '">
                  <img src="img/aff_cross.png" alt="" />
                </a>
              </td>
              <td class="disabled_item_id_td">' . $row["itemid"] . '</td>
              <td>' . $item_name . '</td>
            </tr>';
                }
                $output .= '
            <tr>
              <td colspan="2">
                <a id="link" href="#" onclick="admin_extratools_disable()">
                  <img src="img/add.png" alt="" />
                  <span>' . lang("admin", "disabledadd") . ':</span>
                </a>
              </td>
              <td>
                <input type="text" id="new_dis" />
              </td>
            </tr>
          </table>
        </div>';
            } else {
                $quest_item_vendor_level_mul = $sqlm->quote_smart($_GET["questitemvendorlevelmul"]);
                $quest_item_vendor_rew_mul = $sqlm->quote_smart($_GET["questitemvendorrewmul"]);
                $ultra_vendor_mult_0 = $sqlm->quote_smart($_GET["ultravendormult0"]);
                $ultra_vendor_mult_1 = $sqlm->quote_smart($_GET["ultravendormult1"]);
                $ultra_vendor_mult_2 = $sqlm->quote_smart($_GET["ultravendormult2"]);
                $ultra_vendor_mult_3 = $sqlm->quote_smart($_GET["ultravendormult3"]);
                $ultra_vendor_mult_4 = $sqlm->quote_smart($_GET["ultravendormult4"]);
                $ultra_vendor_mult_5 = $sqlm->quote_smart($_GET["ultravendormult5"]);
                $ultra_vendor_mult_6 = $sqlm->quote_smart($_GET["ultravendormult6"]);
                $ultra_vendor_mult_7 = $sqlm->quote_smart($_GET["ultravendormult7"]);
                $ultra_vendor_base = $sqlm->quote_smart($_GET["ultravendorbase"]);
                $ultra_vendor_max_item_level = $sqlm->quote_smart($_GET["ultravendormaxitemlevel"]);
                $ultra_vendor_max_item_req_level = $sqlm->quote_smart($_GET["ultravendormaxitemreqlevel"]);
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $quest_item_vendor_level_mul . "' WHERE `Key`='Quest_Item_Vendor_Level_Mul'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $quest_item_vendor_rew_mul . "' WHERE `Key`='Quest_Item_Vendor_Rew_Mul'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_mult_0 . "' WHERE `Key`='Ultra_Vendor_Mult_0'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_mult_1 . "' WHERE `Key`='Ultra_Vendor_Mult_1'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_mult_2 . "' WHERE `Key`='Ultra_Vendor_Mult_2'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_mult_3 . "' WHERE `Key`='Ultra_Vendor_Mult_3'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_mult_4 . "' WHERE `Key`='Ultra_Vendor_Mult_4'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_mult_5 . "' WHERE `Key`='Ultra_Vendor_Mult_5'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_mult_6 . "' WHERE `Key`='Ultra_Vendor_Mult_6'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_mult_7 . "' WHERE `Key`='Ultra_Vendor_Mult_7'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_base . "' WHERE `Key`='Ultra_Vendor_Base'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_max_item_level . "' WHERE `Key`='Ultra_Vendor_Max_Item_Level'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $ultra_vendor_max_item_req_level . "' WHERE `Key`='Ultra_Vendor_Max_Item_Req_Level'");
                redirect("admin.php?section=general&subsection=extratools");
            }
            break;
        case "internalmap":
            if (!$sub_action) {
                $map_gm_show_online_only_gmoff = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_GM_Show_Online_Only_GMOff'"));
                $map_gm_show_online_only_gmvisible = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_GM_Show_Online_Only_GMVisible'"));
                $map_gm_add_suffix = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_GM_Add_Suffix'"));
                $map_status_gm_include_all = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_Status_GM_Include_All'"));
                $map_show_status = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_Show_Status'"));
                $map_show_timer = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_Show_Timer'"));
                $map_timer = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_Timer'"));
                $map_show_online = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_Show_Online'"));
                $map_time_to_show_uptime = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_Time_To_Show_Uptime'"));
                $map_time_to_show_maxonline = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_Time_To_Show_MaxOnline'"));
                $map_time_to_show_gmonline = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Map_Time_To_Show_GMOnline'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="saveinternalmap" />
            <input type="hidden" name="subsection" value="internalmap" />
          </div>
          <table class="simple">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "statusgmincludeall_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "statusgmincludeall") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="statusgmincludeall" ' . ($map_status_gm_include_all["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <!-- tr>
              <td class="help"><a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "gmshowonlineonlygmoff_tip") . '\',\'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "gmshowonlineonlygmoff") . '</a>: </td>
              <td><input type="checkbox" name="gmshowonlineonlygmoff" ' . ($map_gm_show_online_only_gmoff["Value"] == 1 ? 'checked="checked"' : '') . ' /></td>
            </tr>
            <tr>
              <td class="help"><a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "gmshowonlineonlygmvisible_tip") . '\',\'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "gmshowonlineonlygmvisible") . '</a>: </td>
              <td><input type="checkbox" name="gmshowonlineonlygmvisible" ' . ($map_gm_show_online_only_gmvisible["Value"] == 1 ? 'checked="checked"' : '') . ' disabled="disabled" /></td>
            </tr -->
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "gmaddsuffix_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "gmaddsuffix") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="gmaddsuffix" ' . ($map_gm_add_suffix["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $map_gm_show_online_only_gmoff = isset($_GET["gmshowonlineonlygmoff"]) ? 1 : 0;
                $map_gm_show_online_only_gmvisible = isset($_GET["gmshowonlineonlygmvisible"]) ? 1 : 0;
                $map_gm_add_suffix = isset($_GET["gmaddsuffix"]) ? 1 : 0;
                $map_status_gm_include_all = isset($_GET["statusgmincludeall"]) ? 1 : 0;
                $map_show_status = isset($_GET["showstatus"]) ? 1 : 0;
                $map_show_timer = isset($_GET["showtimer"]) ? 1 : 0;
                $map_timer = $sqlm->quote_smart($_GET["timer"]);
                $map_show_online = isset($_GET["showonline"]) ? 1 : 0;
                $map_time_to_show_uptime = $sqlm->quote_smart($_GET["timetoshowuptime"]);
                $map_time_to_show_maxonline = $sqlm->quote_smart($_GET["timetoshowmaxonline"]);
                $map_time_to_show_gmonline = $sqlm->quote_smart($_GET["timetoshowgmonline"]);
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_gm_show_online_only_gmoff . "' WHERE `Key`='Map_GM_Show_Online_Only_GMOff'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_gm_show_online_only_gmvisible . "' WHERE `Key`='Map_GM_Show_Online_Only_GMVisible'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_gm_add_suffix . "' WHERE `Key`='Map_GM_Add_Suffix'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_status_gm_include_all . "' WHERE `Key`='Map_Status_GM_Include_All'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_show_status . "' WHERE `Key`='Map_Show_Status'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_gm_add_suffix . "' WHERE `Key`='Map_Show_Timer'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_timer . "' WHERE `Key`='Map_Timer'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_show_online . "' WHERE `Key`='Map_Show_Online'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_time_to_show_uptime . "' WHERE `Key`='Map_Time_To_Show_Uptime'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_time_to_show_maxonline . "' WHERE `Key`='Map_Time_To_Show_MaxOnline'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $map_time_to_show_gmonline . "' WHERE `Key`='Map_Time_To_Show_GMOnline'");
                redirect("admin.php?section=general&subsection=internalmap");
            }
            break;
        case "validip":
            if (!$sub_action) {
                $masks_query = $sqlm->query("SELECT * FROM config_valid_ip_mask");
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="editvalidip" />
            <input type="hidden" name="subsection" value="validip" />
          </div>
          <table class="simple">
            <tr>
              <th style="width: 10%;">&nbsp;</th>
              <th style="width: 20%;">
                <span style="text-align: center;">' . lang("admin", "index") . '</span>
              </th>
              <th>' . lang("admin", "validipmask") . '</th>
            </tr>';
                while ($mask = $sqlm->fetch_assoc($masks_query)) {
                    $output .= '
            <tr>
              <td>
                <input type="radio" name="index" value="' . $mask["Index"] . '" />
              </td>
              <td>
                <center>' . $mask["Index"] . '</center>
              </td>
              <td>' . $mask["ValidIPMask"] . '</td>
            </tr>';
                }
                $output .= '
          </table>
          <div>
            <input type="submit" name="edit" value="' . lang("admin", "editipmask") . '" />
            <input type="submit" name="add" value="' . lang("admin", "addipmask") . '" />
            <input type="submit" name="delete" value="' . lang("admin", "deleteipmask") . '" />
          </div>
        </form>';
            } elseif ($sub_action == "editvalidip") {
                if (isset($_GET["add"])) {
                    $lim = $sqlm->fetch_assoc($sqlm->query("SELECT MAX(`Index`) FROM config_valid_ip_mask"));
                    $lim = $lim["MAX(`Index`)"] + 1;
                    $sqlm->query("INSERT INTO config_valid_ip_mask SET `Index`='" . $lim . "', ValidIPMask=''");
                    redirect("admin.php?section=general&subsection=validip");
                } elseif (isset($_GET["delete"])) {
                    $index = $sqlm->quote_smart($_GET["index"]);
                    if (!is_numeric($index)) {
                        redirect("admin.php?section=general&subsection=validip&error=1");
                    }
                    $result = $sqlm->query("DELETE FROM config_valid_ip_mask WHERE `Index`='" . $index . "'");
                    redirect("admin.php?section=general&subsection=validip");
                } else {
                    $index = $sqlm->quote_smart($_GET["index"]);
                    if (!is_numeric($index)) {
                        redirect("admin.php?section=general&subsection=validip&error=1");
                    }
                    $mask = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_valid_ip_mask WHERE `Index`='" . $index . "'"));
                    $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="savevalidip" />
            <input type="hidden" name="subsection" value="validip" />
            <input type="hidden" name="index" value="' . $mask["Index"] . '" />
          </div>
          <table class="simple">
            <tr>
              <th width="20%">
                <center>' . lang("admin", "index") . '</center>
              </th>
              <th class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "validipmask_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "validipmask") . '</a>
              </th>
            </tr>
            <tr>
              <td>
                <center>' . $mask["Index"] . '</center>
              </td>
              <td>
                <input type="text" name="mask" value="' . $mask["ValidIPMask"] . '" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
                }
            } else {
                $index = $sqlm->quote_smart($_GET["index"]);
                $mask = $sqlm->quote_smart($_GET["mask"]);
                $result = $sqlm->query("UPDATE config_valid_ip_mask SET ValidIPMask='" . $mask . "' WHERE `Index`='" . $index . "'");
                redirect("admin.php?section=general&subsection=validip");
            }
            break;
        case "ads":
            if (!$sub_action) {
                $enable_bottom_ad = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Enable_Page_Bottom_Ad'"));
                $bottom_ad_content = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Page_Bottom_Ad_Content'"));
                $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="saveads" />
            <input type="hidden" name="subsection" value="ads" />
          </div>
          <table class="simple" id="admin_more">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "enablebottomad_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "enablebottomad") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="enablebottomad" ' . ($enable_bottom_ad["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "bottomadcontent_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "bottomadcontent") . '</a>:
              </td>
              <td>
                <textarea name="bottomadcontent" rows="5" cols="40">' . $bottom_ad_content["Value"] . '</textarea>
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $page_bottom_ad = isset($_GET["enablebottomad"]) ? 1 : 0;
                $page_bottom_ad_content = $sqlm->quote_smart($_GET["bottomadcontent"]);
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $page_bottom_ad . "' WHERE `Key`='Enable_Page_Bottom_Ad'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $page_bottom_ad_content . "' WHERE `Key`='Page_Bottom_Ad_Content'");
                redirect("admin.php?section=general&subsection=ads");
            }
            break;
        case "more":
            if (!$sub_action) {
                $sql_search_limit = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='SQL_Search_Limit'"));
                $item_icons = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Item_Icons'"));
                $remember_me_checked = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Remember_Me_Checked'"));
                $site_title = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Site_Title'"));
                $item_per_page = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Item_Per_Page'"));
                $show_country_flags = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Show_Country_Flags'"));
                $default_theme = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Default_Theme'"));
                $default_language = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Default_Language'"));
                $timezone = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Timezone'"));
                $timezone_offset = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Timezone_Offset'"));
                $player_online = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Player_Online'"));
                $gm_online = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='GM_Online'"));
                $gm_online_count = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='GM_Online_Count'"));
                $hide_uptime = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Hide_Uptime'"));
                $hide_max_players = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Hide_Max_Players'"));
                $hide_avg_latency = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Hide_Avg_Latency'"));
                $hide_server_mem = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Hide_Server_Mem'"));
                $hide_plr_latency = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Hide_Plr_Latency'"));
                $hide_coupons = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Hide_Coupons_Main_Page'"));
                $backup_dir = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Backup_Dir'"));
                $debug = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Debug'"));
                $test_mode = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Test_Mode'"));
                $multi_realm = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Multi_Realm'"));
                $show_emblem = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Show_Guild_Emblem'"));
                $language_locales_search_option = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Language_Locales_Search_Option'"));
                $language_site_encoding = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Language_Site_Encoding'"));
                $show_newest_user = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Show_Newest_User'"));
                $send_on_email = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Send_Mail_On_Email_Change'"));
                $use_custom_logo = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Use_Custom_Logo'"));
                $custom_logo = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Custom_Logo'"));
                $allow_caching = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Allow_Logo_Caching'"));
                $index_show_realms = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_misc WHERE `Key`='Index_Show_Realms'"));
                $custom_logos_result = $sqlm->query("SELECT * FROM custom_logos");
                $custom_logo_count = $sqlm->num_rows($custom_logos_result);
                $custom_logos = array();
                while ($row = $sqlm->fetch_assoc($custom_logos_result)) {
                    $custom_logos[] = $row;
                }
                $output .= '
        <form action="admin.php" method="get" enctype="multipart/form-data" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subaction" value="savemore" />
            <input type="hidden" name="subsection" value="more" />
          </div>
          <table class="simple" id="admin_more">
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "sqlsearchlimit_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "sqlsearchlimit") . '</a>:
              </td>
              <td>
                <input type="text" name="sqlsearchlimit" value="' . $sql_search_limit["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "itemicons_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "itemicons") . '</a>:
              </td>
              <td>
                <input type="text" name="itemicons" value="' . $item_icons["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "remembermechecked_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "remembermechecked") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="remembermechecked" ' . ($remember_me_checked["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "sitetitle_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "sitetitle") . '</a>:
              </td>
              <td>
                <input type="text" name="sitetitle" value="' . $site_title["Value"] . '" size="50"/>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "itemperpage_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "itemperpage") . '</a>:
              </td>
              <td>
                <input type="text" name="itemperpage" value="' . $item_per_page["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "showcountryflags_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "showcountryflags") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="showcountryflags" ' . ($show_country_flags["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "defaulttheme_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "defaulttheme") . '</a>:
              </td>
              <td>
                <input type="text" name="defaulttheme" value="' . $default_theme["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "defaultlanguage_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "defaultlanguage") . '</a>:
              </td>
              <td>
                <select name="defaultlanguage">';
                if (is_dir("./lang")) {
                    if ($dh = opendir("./lang")) {
                        while (($file = readdir($dh)) == true) {
                            $lang_temp = explode(".", $file);
                            if (isset($lang_temp[1]) && $lang_temp[1] == "php") {
                                $output .= '
                      <option value="' . $lang_temp[0] . '"' . ($default_language["Value"] == $lang_temp[0] ? ' selected="selected" ' : '') . '>' . lang("edit", $lang_temp[0]) . '</option>';
                            }
                        }
                        closedir($dh);
                    }
                }
                $output .= '
                </select>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "timezone_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "timezone") . '</a>:
              </td>
              <td>
                <select name="timezone">
                  <option value="-12.0" ' . ($timezone["Value"] == "-12.0" ? 'selected="selected"' : '') . '>(UTC -12:00) Eniwetok, Kwajalein</option>
                  <option value="-11.0" ' . ($timezone["Value"] == "-11.0" ? 'selected="selected"' : '') . '>(UTC -11:00) Midway Island, Samoa</option>
                  <option value="-10.0" ' . ($timezone["Value"] == "-10.0" ? 'selected="selected"' : '') . '>(UTC -10:00) Hawaii</option>
                  <option value="-9.0" ' . ($timezone["Value"] == "-9.0" ? 'selected="selected"' : '') . '>(UTC -9:00) Alaska</option>
                  <option value="-8.0" ' . ($timezone["Value"] == "-8.0" ? 'selected="selected"' : '') . '>(UTC -8:00) Pacific Time (US &amp; Canada)</option>
                  <option value="-7.0" ' . ($timezone["Value"] == "-7.0" ? 'selected="selected"' : '') . '>(UTC -7:00) Mountain Time (US &amp; Canada)</option>
                  <option value="-6.0" ' . ($timezone["Value"] == "-6.0" ? 'selected="selected"' : '') . '>(UTC -6:00) Central Time (US &amp; Canada), Mexico City</option>
                  <option value="-5.0" ' . ($timezone["Value"] == "-5.0" ? 'selected="selected"' : '') . '>(UTC -5:00) Eastern Time (US &amp; Canada), Bogota, Lima</option>
                  <option value="-4.5" ' . ($timezone["Value"] == "-4.5" ? 'selected="selected"' : '') . '>(UTC -4:30) Caracas</option>
                  <option value="-4.0" ' . ($timezone["Value"] == "-4.0" ? 'selected="selected"' : '') . '>(UTC -4:00) Atlantic Time (Canada), La Paz</option>
                  <option value="-3.5" ' . ($timezone["Value"] == "-3.5" ? 'selected="selected"' : '') . '>(UTC -3:30) Newfoundland</option>
                  <option value="-3.0" ' . ($timezone["Value"] == "-3.0" ? 'selected="selected"' : '') . '>(UTC -3:00) Brazil, Buenos Aires, Georgetown</option>
                  <option value="-2.0" ' . ($timezone["Value"] == "-2.0" ? 'selected="selected"' : '') . '>(UTC -2:00) Mid-Atlantic</option>
                  <option value="-1.0" ' . ($timezone["Value"] == "-1.0" ? 'selected="selected"' : '') . '>(UTC -1:00) Azores, Cape Verde Islands</option>
                  <option value="0.0" ' . ($timezone["Value"] == "0.0" ? 'selected="selected"' : '') . '>(UTC) Western Europe Time, London, Lisbon, Casablanca</option>
                  <option value="1.0" ' . ($timezone["Value"] == "1.0" ? 'selected="selected"' : '') . '>(UTC +1:00) Brussels, Copenhagen, Madrid, Paris</option>
                  <option value="2.0" ' . ($timezone["Value"] == "2.0" ? 'selected="selected"' : '') . '>(UTC +2:00) Kaliningrad, South Africa</option>
                  <option value="3.0" ' . ($timezone["Value"] == "3.0" ? 'selected="selected"' : '') . '>(UTC +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>
                  <option value="3.5" ' . ($timezone["Value"] == "3.5" ? 'selected="selected"' : '') . '>(UTC +3:30) Tehran</option>
                  <option value="4.0" ' . ($timezone["Value"] == "4.0" ? 'selected="selected"' : '') . '>(UTC +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
                  <option value="4.5" ' . ($timezone["Value"] == "4.5" ? 'selected="selected"' : '') . '>(UTC +4:30) Kabul</option>
                  <option value="5.0" ' . ($timezone["Value"] == "5.0" ? 'selected="selected"' : '') . '>(UTC +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
                  <option value="5.5" ' . ($timezone["Value"] == "5.5" ? 'selected="selected"' : '') . '>(UTC +5:30) Bombay, Calcutta, Madras, New Delhi</option>
                  <option value="5.75" ' . ($timezone["Value"] == "5.75" ? 'selected="selected"' : '') . '>(UTC +5:45) Kathmandu</option>
                  <option value="6.0" ' . ($timezone["Value"] == "6.0" ? 'selected="selected"' : '') . '>(UTC +6:00) Almaty, Dhaka, Colombo</option>
                  <option value="7.0" ' . ($timezone["Value"] == "7.0" ? 'selected="selected"' : '') . '>(UTC +7:00) Bangkok, Hanoi, Jakarta</option>
                  <option value="8.0" ' . ($timezone["Value"] == "8.0" ? 'selected="selected"' : '') . '>(UTC +8:00) Beijing, Perth, Singapore, Hong Kong</option>
                  <option value="9.0" ' . ($timezone["Value"] == "9.0" ? 'selected="selected"' : '') . '>(UTC +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
                  <option value="9.5" ' . ($timezone["Value"] == "9.5" ? 'selected="selected"' : '') . '>(UTC +9:30) Adelaide, Darwin</option>
                  <option value="10.0" ' . ($timezone["Value"] == "10.0" ? 'selected="selected"' : '') . '>(UTC +10:00) Eastern Australia, Guam, Vladivostok</option>
                  <option value="11.0" ' . ($timezone["Value"] == "11.0" ? 'selected="selected"' : '') . '>(UTC +11:00) Magadan, Solomon Islands, New Caledonia</option>
                  <option value="12.0" ' . ($timezone["Value"] == "12.0" ? 'selected="selected"' : '') . '>(UTC +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
                </select>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "timezone_offset_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "timezone_offset") . '</a>:
              </td>
              <td>
                <input type="text" name="timezone_offset" value="' . $timezone_offset["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "playeronline_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "playeronline") . '</a>:
              </td>
              <td>
                <select name="playeronline">';
                $sl_query = "SELECT * FROM config_gm_level_names";
                $sl_result = $sqlm->query($sl_query);
                while ($row = $sqlm->fetch_assoc($sl_result)) {
                    $output .= '
                          <option value="' . $row["Security_Level"] . '" ' . ($player_online["Value"] == $row["Security_Level"] ? 'selected="selected"' : '') . '>' . $row["Full_Name"] . ' (' . $row["Security_Level"] . ')</option>';
                }
                $output .= '
                </select>
                <!-- input type="checkbox" name="playeronline" ' . ($player_online["Value"] == 1 ? 'checked="checked"' : '') . ' / -->
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "gmonline_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "gmonline") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="gmonline" ' . ($gm_online["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "gmonlinecount_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "gmonlinecount") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="gmonlinecount" ' . ($gm_online_count["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "hideuptime_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "hideuptime") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="hideuptime" ' . ($hide_uptime["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "hidemaxplayers_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "hidemaxplayers") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="hidemaxplayers" ' . ($hide_max_players["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "hideavglatency_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "hideavglatency") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="hideavglatency" ' . ($hide_avg_latency["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>';
                if ($core == 1) {
                    $output .= '
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "hideservermem_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "hideservermem") . '</a>:
              </td>
              <td>
                <select name="hideservermem">
                  <option value="0" ' . ($hide_server_mem["Value"] == 0 ? 'selected="selected"' : '') . '>' . lang("admin", "hide") . '</option>
                  <option value="1" ' . ($hide_server_mem["Value"] == 1 ? 'selected="selected"' : '') . '>' . lang("admin", "showtogmsonly") . '</option>
                  <option value="2" ' . ($hide_server_mem["Value"] == 2 ? 'selected="selected"' : '') . '>' . lang("admin", "showall") . '</option>
                </select>
              </td>
            </tr>';
                }
                $output .= '
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "hideplrlatency_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "hideplrlatency") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="hideplrlatency" ' . ($hide_plr_latency["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "hidecoupons_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "hidecoupons") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="hidecoupons" ' . ($hide_coupons["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "backupdir_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "backupdir") . '</a>:
              </td>
              <td>
                <input type="text" name="backupdir" value="' . $backup_dir["Value"] . '" readonly="readonly" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "debug_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "debug") . '</a>:
              </td>
              <td>
                <input type="text" name="debug" value="' . $debug["Value"] . '" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "testmode_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "testmode") . '</a>:
              </td>
              <td>
                <input type="text" name="testmode" value="' . $test_mode["Value"] . '" readonly="readonly" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "multirealm_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "multirealm") . '</a>:
              </td>
              <td>
                <input type="text" name="multirealm" value="' . $multi_realm["Value"] . '" readonly="readonly" />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "showemblem_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "showemblem") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="showemblem" ' . ($show_emblem["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "shownewuser_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "shownewuser") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="shownewuser" ' . ($show_newest_user["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "sendonemail_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "sendonemail") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="sendonemail" ' . ($send_on_email["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "indexshowrealms_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "indexshowrealms") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="indexshowrealms" ' . ($index_show_realms["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <b>' . lang("admin", "customlogos") . '</b>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "usecustomlogo_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "usecustomlogo") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="usecustomlogo" ' . ($use_custom_logo["Value"] == 1 ? 'checked="checked"' : '') . ' ' . ($custom_logo_count > 0 ? '' : 'disabled="disabled"') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "customlogo_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "customlogo") . '</a>:
              </td>
              <td>
                <select name="customlogo" ' . ($custom_logo_count > 0 ? '' : 'disabled="disabled"') . '>';
                foreach ($custom_logos as $row) {
                    $output .= '
                      <option value="' . $row["id"] . '" ' . ($row["id"] == $custom_logo["Value"] ? 'selected="selected"' : '') . '>' . $row["filename"] . '</option>';
                }
                $output .= '
                </select>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "deleteselectedlogo_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "deleteselectedlogo") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="deleteselectedlogo" ' . ($custom_logo_count > 0 ? '' : 'disabled="disabled"') . ' />
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "uploadlogo_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "uploadlogo") . '</a>:
              </td>
              <td>
                <a href="admin.php?section=general&amp;subsection=upload_logo">' . lang("admin", "upload") . '</a>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "allowcaching_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "allowcaching") . '</a>:
              </td>
              <td>
                <input type="checkbox" name="allowcaching" ' . ($allow_caching["Value"] == 1 ? 'checked="checked"' : '') . ' />
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <b>' . lang("admin", "language") . '</b>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "languagelocalessearchoption_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "languagelocalessearchoption") . '</a>:
              </td>
              <td>
                <select name="languagelocalessearchoption">
                  <option value="0" ' . ($language_locales_search_option["Value"] == 0 ? 'selected="selected" ' : '') . '>' . lang("global", "language_0") . '</option>
                  <option value="1" ' . ($language_locales_search_option["Value"] == 1 ? 'selected="selected" ' : '') . '>' . lang("global", "language_1") . '</option>
                  <option value="2" ' . ($language_locales_search_option["Value"] == 2 ? 'selected="selected" ' : '') . '>' . lang("global", "language_2") . '</option>
                  <option value="3" ' . ($language_locales_search_option["Value"] == 3 ? 'selected="selected" ' : '') . '>' . lang("global", "language_3") . '</option>
                  <option value="4" ' . ($language_locales_search_option["Value"] == 4 ? 'selected="selected" ' : '') . '>' . lang("global", "language_4") . '</option>
                  <option value="5" ' . ($language_locales_search_option["Value"] == 5 ? 'selected="selected" ' : '') . '>' . lang("global", "language_5") . '</option>
                  <option value="6" ' . ($language_locales_search_option["Value"] == 6 ? 'selected="selected" ' : '') . '>' . lang("global", "language_6") . '</option>
                  <option value="7" ' . ($language_locales_search_option["Value"] == 7 ? 'selected="selected" ' : '') . '>' . lang("global", "language_7") . '</option>
                  <option value="8" ' . ($language_locales_search_option["Value"] == 8 ? 'selected="selected" ' : '') . '>' . lang("global", "language_8") . '</option>
                </select>
              </td>
            </tr>
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "languagesiteencoding_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "languagesiteencoding") . '</a>:
              </td>
              <td>
                <input type="text" name="languagesiteencoding" value="' . $language_site_encoding["Value"] . '" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
            } else {
                $sql_search_limit = $sqlm->quote_smart($_GET["sqlsearchlimit"]);
                $item_icons = $sqlm->quote_smart($_GET["itemicons"]);
                $remember_me_checked = isset($_GET["remembermechecked"]) ? 1 : 0;
                $site_title = $sqlm->quote_smart($_GET["sitetitle"]);
                $item_per_page = $sqlm->quote_smart($_GET["itemperpage"]);
                $show_country_flags = isset($_GET["showcountryflags"]) ? 1 : 0;
                $default_theme = $sqlm->quote_smart($_GET["defaulttheme"]);
                $default_language = $sqlm->quote_smart($_GET["defaultlanguage"]);
                $timezone = $sqlm->quote_smart($_GET["timezone"]);
                $timezone_offset = $sqlm->quote_smart($_GET["timezone_offset"]);
                $player_online = $sqlm->quote_smart($_GET["playeronline"]);
                $gm_online = isset($_GET["gmonline"]) ? 1 : 0;
                $gm_online_count = isset($_GET["gmonlinecount"]) ? 1 : 0;
                $hide_uptime = isset($_GET["hideuptime"]) ? 1 : 0;
                $hide_max_players = isset($_GET["hidemaxplayers"]) ? 1 : 0;
                $hide_avg_latency = isset($_GET["hideavglatency"]) ? 1 : 0;
                $hide_plr_latency = isset($_GET["hideplrlatency"]) ? 1 : 0;
                $hide_coupons = isset($_GET["hidecoupons"]) ? 1 : 0;
                $backup_dir = $sqlm->quote_smart($_GET["backupdir"]);
                $debug = $sqlm->quote_smart($_GET["debug"]);
                $test_mode = $sqlm->quote_smart($_GET["testmode"]);
                $multi_realm = $sqlm->quote_smart($_GET["multirealm"]);
                $show_emblem = isset($_GET["showemblem"]) ? 1 : 0;
                $language_locales_search_option = $sqlm->quote_smart($_GET["languagelocalessearchoption"]);
                $language_site_encoding = $sqlm->quote_smart($_GET["languagesiteencoding"]);
                $hide_server_mem = $sqlm->quote_smart($_GET["hideservermem"]);
                $show_newest_user = isset($_GET["shownewuser"]) ? 1 : 0;
                $send_on_email = isset($_GET["sendonemail"]) ? 1 : 0;
                $index_show_realms = isset($_GET["indexshowrealms"]) ? 1 : 0;
                $use_custom_logo = isset($_GET["usecustomlogo"]) ? 1 : 0;
                $custom_logo = isset($_GET["customlogo"]) ? $sqlm->quote_smart($_GET["customlogo"]) : NULL;
                $delete_selected = isset($_GET["deleteselectedlogo"]) ? 1 : 0;
                $allow_caching = isset($_GET["allowcaching"]) ? 1 : 0;
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $sql_search_limit . "' WHERE `Key`='SQL_Search_Limit'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $item_icons . "' WHERE `Key`='Item_Icons'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $remember_me_checked . "' WHERE `Key`='Remember_Me_Checked'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $site_title . "' WHERE `Key`='Site_Title'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $item_per_page . "' WHERE `Key`='Item_Per_Page'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $show_country_flags . "' WHERE `Key`='Show_Country_Flags'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $default_theme . "' WHERE `Key`='Default_Theme'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $default_language . "' WHERE `Key`='Default_Language'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $timezone . "' WHERE `Key`='Timezone'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $timezone_offset . "' WHERE `Key`='Timezone_Offset'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $player_online . "' WHERE `Key`='Player_Online'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $gm_online . "' WHERE `Key`='GM_Online'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $gm_online_count . "' WHERE `Key`='GM_Online_Count'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $hide_uptime . "' WHERE `Key`='Hide_Uptime'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $hide_max_players . "' WHERE `Key`='Hide_Max_Players'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $hide_avg_latency . "' WHERE `Key`='Hide_Avg_Latency'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $hide_server_mem . "' WHERE `Key`='Hide_Server_Mem'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $hide_plr_latency . "' WHERE `Key`='Hide_Plr_Latency'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $hide_coupons . "' WHERE `Key`='Hide_Coupons_Main_Page'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $backup_dir . "' WHERE `Key`='Backup_Dir'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $debug . "' WHERE `Key`='Debug'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $test_mode . "' WHERE `Key`='Test_Mode'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $multi_realm . "' WHERE `Key`='Multi_Realm'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $show_emblem . "' WHERE `Key`='Show_Guild_Emblem'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $language_locales_search_option . "' WHERE `Key`='Language_Locales_Search_Option'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $language_site_encoding . "' WHERE `Key`='Language_Site_Encoding'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $show_newest_user . "' WHERE `Key`='Show_Newest_User'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $send_on_email . "' WHERE `Key`='Send_Mail_On_Email_Change'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $index_show_realms . "' WHERE `Key`='Index_Show_Realms'");
                if ($delete_selected) {
                    $result = $sqlm->query("DELETE FROM custom_logos WHERE id='" . $custom_logo . "'");
                    // if we have no more logos, then we don't want Use Custom Logos checked.
                    $result = $sqlm->query("SELECT * FROM custom_logos");
                    $logo_count = $sqlm->num_rows($result);
                    if ($logo_count == 0) {
                        $use_custom_logo = 0;
                    } else {
                        // we don't want the Custom_Logo field set to the one we just deleted
                        // so we'll set it to the first one on the list
                        $temp = $sqlm->fetch_assoc($result);
                        $custom_logo = $temp["id"];
                    }
                }
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $use_custom_logo . "' WHERE `Key`='Use_Custom_Logo'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $custom_logo . "' WHERE `Key`='Custom_Logo'");
                $result = $sqlm->query("UPDATE config_misc SET Value='" . $allow_caching . "' WHERE `Key`='Allow_Logo_Caching'");
                redirect("admin.php?section=general&subsection=more");
            }
            break;
        case "upload_logo":
            if (!$sub_action) {
                $upload_err = isset($_GET["up_err"]) ? $_GET["up_err"] : NULL;
                $output .= '
        <form action="admin.php?section=general&subsection=upload_logo&subaction=upload" method="post" enctype="multipart/form-data" id="form">
          <table class="simple" id="admin_more">';
                if (isset($upload_err)) {
                    $msg = lang("admin", "uploaderror" . abs($upload_err));
                    $output .= '
            <td colspan="2">
              <span class="error" style="display: block; width: 100%; text-align: center;">' . $msg . '</span>
            </td>';
                }
                $output .= '
            <tr>
              <td class="help">
                <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "uploadlogo_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "uploadlogo") . '</a>:
              </td>
              <td>
                <input type="file" name="image" />
              </td>
            </tr>
          </table>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
            <input type="button" name="cancel" value="' . lang("admin", "cancel") . '" onclick="window.location=\'admin.php?section=general&subsection=more\'"/>
          </div>
        </form>';
            } else {
                if (!array_key_exists("image", $_FILES)) {
                    redirect("admin.php?section=general&subsection=upload_logo&error=1");
                }
                $image = $_FILES["image"];
                $err = checkValidUpload($image["error"]);
                if ($err < 0) {
                    redirect("admin.php?section=general&subsection=upload_logo&up_err=" . $err);
                } else {
                    if (!is_uploaded_file($image["tmp_name"])) {
                        redirect("admin.php?section=general&subsection=upload_logo&up_err=-8");
                    }
                    $info = getImageSize($image["tmp_name"]);
                    if (!$info) {
                        redirect("admin.php?section=general&subsection=upload_logo&up_err=-9");
                    }
                    $name = $sqlm->quote_smart($image["name"]);
                    $mime = $sqlm->quote_smart($info["mime"]);
                    $data = $sqlm->quote_smart(file_get_contents($image["tmp_name"]));
                    $upload_query = "INSERT INTO custom_logos (filename, mime_type, file_size, file_data) VALUES ('" . $name . "', '" . $mime . "', '" . $image['size'] . "', '" . $data . "')";
                    $sqlm->query($upload_query);
                    redirect("admin.php?section=general&subsection=more");
                }
            }
            break;
        case "gmlevels":
            if (!$sub_action) {
                $gm_lvls = $sqlm->query("SELECT * FROM config_gm_level_names");
                if (!isset($_GET["edit_btn"])) {
                    $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subsection" value="gmlevels" />
            <input type="hidden" name="edit_btn" value="edit" />
          </div>
          <table class="simple">
            <tr>
              <th>' . lang("admin", "edit") . '</th>
              <th>' . lang("admin", "remove") . '</th>
              <th>' . lang("admin", "seclvl") . '</th>
              <th>' . lang("admin", "fullname") . '</th>
              <th>' . lang("admin", "shortname") . '</th>
            </tr>';
                    $color = "#EEEEEE";
                    while ($gm_lvl = $sqlm->fetch_assoc($gm_lvls)) {
                        $output .= '
            <tr>
              <td style="background-color:' . $color . '; text-align: center;">
                <a href="admin.php?section=general&amp;subsection=gmlevels&amp;edit=' . $gm_lvl["Index"] . '&amp;edit_btn=Edit">
                  <img src="img/edit.png" alt="" />
                </a>
              </td>
              <td style="background-color:' . $color . '; text-align: center;">
                <a href="admin.php?section=general&amp;subsection=gmlevels&amp;delrow=deleterow&amp;edit=' . $gm_lvl["Index"] . '&amp;edit_btn=Edit">
                  <img src="img/aff_cross.png" alt="" />
                </a>
              </td>
              <td style="background-color:' . $color . '">' . $gm_lvl["Security_Level"] . '</td>
              <td style="background-color:' . $color . '">' . $gm_lvl["Full_Name"] . '</td>
              <td style="background-color:' . $color . '">' . $gm_lvl["Short_Name"] . '</td>
            </tr>';
                        if ($color == "#EEEEEE") {
                            $color = "#FFFFFF";
                        } else {
                            $color = "#EEEEEE";
                        }
                    }
                    $output .= '
            <tr>
              <td style="background-color:' . $color . '; text-align: center;">
                <a href="admin.php?section=general&amp;subsection=gmlevels&amp;edit_btn=Edit&amp;addrow=addrow">
                  <img src="img/add.png" alt="" />
                </a>
              </td>
              <td style="background-color:' . $color . ';" colspan="4">
                <a href="admin.php?section=general&amp;subsection=gmlevels&amp;edit_btn=Edit&amp;addrow=addrow">' . lang("admin", "addrow") . '</a>
              </td>
            </tr>';
                    $output .= '
          </table>
        </form>';
                } else {
                    if (!isset($_GET["edit"])) {
                        if (!isset($_GET["addrow"])) {
                            redirect("admin.php?section=general&subsection=gmlevels");
                        }
                    }
                    $del_row = isset($_GET["delrow"]) ? $_GET["delrow"] : "";
                    $add_row = isset($_GET["addrow"]) ? $_GET["addrow"] : "";
                    $edit_row = $sqlm->quote_smart($_GET["edit"]);
                    if ($add_row) {
                        $add_result = $sqlm->query("INSERT INTO config_gm_level_names (Security_Level) VALUES ('-1')");
                        redirect("admin.php?section=general&subsection=gmlevels");
                    }
                    if ($del_row) {
                        $del_result = $sqlm->query("DELETE FROM config_gm_level_names WHERE `Index`='" . $edit_row . "'");
                        redirect("admin.php?section=general&subsection=gmlevels");
                    }
                    $gm_level = $sqlm->fetch_assoc($sqlm->query("SELECT * FROM config_gm_level_names WHERE `Index`='" . $edit_row . "'"));
                    $output .= '
        <form action="admin.php" method="get" id="form">
          <div>
            <input type="hidden" name="section" value="general" />
            <input type="hidden" name="subsection" value="gmlevels" />
            <input type="hidden" name="subaction" value="savegms" />
            <input type="hidden" name="index" value="' . $gm_level["Index"] . '" />
          </div>
          <fieldset id="admin_gm_level">
            <table class="center">
              <tr>
                <td class="help">
                  <a href="#" onmouseover="oldtoolTip(\'' . lang("admin", "seclvl_tip") . '\', \'info_tooltip\')" onmouseout="oldtoolTip()">' . lang("admin", "seclvl") . '</a>:
                </td>
                <td>
                  <input type="text" name="seclvl" value="' . $gm_level["Security_Level"] . '" />
                </td>
              </tr>
              <tr>
                <td>' . lang("admin", "fullname") . ': </td>
                <td>
                  <input type="text" name="fullname" value="' . $gm_level["Full_Name"] . '" />
                </td>
              </tr>
              <tr>
                <td>' . lang("admin", "shortname") . ': </td>
                <td>
                  <input type="text" name="shortname" value="' . $gm_level["Short_Name"] . '" />
                </td>
              </tr>
            </table>
          </fieldset>
          <div>
            <input type="submit" name="save" value="' . lang("admin", "save") . '" />
          </div>
        </form>';
                }
            } else {
                $index = $sqlm->quote_smart($_GET["index"]);
                $sec_lvl = $sqlm->quote_smart($_GET["seclvl"]);
                $full_name = $sqlm->quote_smart($_GET["fullname"]);
                $short_name = $sqlm->quote_smart($_GET["shortname"]);
                $result = $sqlm->query("UPDATE config_gm_level_names SET Security_Level='" . $sec_lvl . "', Full_Name='" . $full_name . "', Short_Name='" . $short_name . "' WHERE `Index`='" . $index . "'");
                redirect("admin.php?section=general&subsection=gmlevels");
            }
            break;
    }
    $output .= '
      </div>';
}
Example #25
0
function edit()
{
    global $lang_global, $lang_item_templ, $lang_item, $lang_item_edit, $output, $world_db, $realm_id, $item_datasite, $lang_id_tab, $quest_datasite, $action_permission, $user_lvl, $creature_datasite;
    wowhead_tt();
    valid_login($action_permission['read']);
    if (!isset($_GET['entry'])) {
        redirect("item.php?error=1");
    }
    $sql = new SQL();
    $sql->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
    $entry = $sql->quote_smart($_GET['entry']);
    $deplang = get_lang_id();
    $result = $sql->query("SELECT `item_template`.`entry`,`class`,`subclass`,`unk0`,IFNULL(" . ($deplang != 0 ? "name_loc{$deplang}" : "NULL") . ",`name`) as name,`displayid`,`Quality`,`Flags`,`BuyCount`,`BuyPrice`,`SellPrice`,`InventoryType`,`AllowableClass`,`AllowableRace`,`ItemLevel`,`RequiredLevel`,`RequiredSkill`,`RequiredSkillRank`,`requiredspell`,`requiredhonorrank`,`RequiredCityRank`,`RequiredReputationFaction`,`RequiredReputationRank`,`maxcount`,`stackable`,`ContainerSlots`,`stat_type1`,`stat_value1`,`stat_type2`,`stat_value2`,`stat_type3`,`stat_value3`,`stat_type4`,`stat_value4`,`stat_type5`,`stat_value5`,`stat_type6`,`stat_value6`,`stat_type7`,`stat_value7`,`stat_type8`,`stat_value8`,`stat_type9`,`stat_value9`,`stat_type10`,`stat_value10`,`dmg_min1`,`dmg_max1`,`dmg_type1`,`dmg_min2`,`dmg_max2`,`dmg_type2`,`armor`,`holy_res`,`fire_res`,`nature_res`,`frost_res`,`shadow_res`,`arcane_res`,`delay`,`ammo_type`,`RangedModRange`,`spellid_1`,`spelltrigger_1`,`spellcharges_1`,`spellppmRate_1`,`spellcooldown_1`,`spellcategory_1`,`spellcategorycooldown_1`,`spellid_2`,`spelltrigger_2`,`spellcharges_2`,`spellppmRate_2`,`spellcooldown_2`,`spellcategory_2`,`spellcategorycooldown_2`,`spellid_3`,`spelltrigger_3`,`spellcharges_3`,`spellppmRate_3`,`spellcooldown_3`,`spellcategory_3`,`spellcategorycooldown_3`,`spellid_4`,`spelltrigger_4`,`spellcharges_4`,`spellppmRate_4`,`spellcooldown_4`,`spellcategory_4`,`spellcategorycooldown_4`,`spellid_5`,`spelltrigger_5`,`spellcharges_5`,`spellppmRate_5`,`spellcooldown_5`,`spellcategory_5`,`spellcategorycooldown_5`,`bonding`,`description`,`PageText`,`LanguageID`,`PageMaterial`,`startquest`,`lockid`,`Material`,`sheath`,`RandomProperty`,`RandomSuffix`,`block`,`itemset`,`MaxDurability`,`area`,`Map`,`BagFamily`,`TotemCategory`,`socketColor_1`,`socketContent_1`,`socketColor_2`,`socketContent_2`,`socketColor_3`,`socketContent_3`,`socketBonus`,`GemProperties`,`RequiredDisenchantSkill`,`ArmorDamageModifier`,`ScriptName`,`DisenchantID`,`FoodType`,`minMoneyLoot`,`maxMoneyLoot` FROM item_template LEFT JOIN locales_item ON item_template.entry = locales_item.entry WHERE item_template.entry = '{$entry}'");
    if ($result) {
        $item = $sql->fetch_assoc($result);
        require_once "scripts/get_lib.php";
        //$tooltip = get_item_tooltip($entry);
        $output .= "<script type=\"text/javascript\" src=\"libs/js/tab.js\"></script>\n   <center>\n    <br /><br /><br />\n    <form method=\"post\" action=\"item.php?action=do_update\" name=\"form1\">\n    <input type=\"hidden\" name=\"backup_op\" value=\"0\"/>\n    <input type=\"hidden\" name=\"type\" value=\"edit\"/>\n    <input type=\"hidden\" name=\"entry\" value=\"{$entry}\"/>\n\n<div class=\"jtab-container\" id=\"container\">\n  <ul class=\"jtabs\">\n    <li><a href=\"#\" onclick=\"return showPane('pane1', this)\" id=\"tab1\">{$lang_item_edit['general_tab']}</a></li>\n    <li><a href=\"#\" onclick=\"return showPane('pane2', this)\">{$lang_item_edit['additional_tab']}</a></li>\n    <li><a href=\"#\" onclick=\"return showPane('pane3', this)\">{$lang_item_edit['stats_tab']}</a></li>\n  <li><a href=\"#\" onclick=\"return showPane('pane4', this)\">{$lang_item_edit['damage_tab']}</a></li>\n  <li><a href=\"#\" onclick=\"return showPane('pane5', this)\">{$lang_item_edit['spell_tab']}</a></li>\n  <li><a href=\"#\" onclick=\"return showPane('pane7', this)\">{$lang_item_edit['sock_tab']}</a></li>\n  <li><a href=\"#\" onclick=\"return showPane('pane6', this)\">{$lang_item_edit['req_tab']}</a></li>\n  <li><a href=\"#\" onclick=\"return showPane('pane8', this)\">{$lang_item_edit['info']}</a></li>";
        if ($item['DisenchantID']) {
            $output .= "<li><a href=\"#\" onclick=\"return showPane('pane9', this)\">{$lang_item_edit['disenchant_tab']}</a></li>";
        }
        $output .= "</ul>\n  <div class=\"jtab-panes\">";
        $output .= "<div id=\"pane1\">\n    <br /><br />\n<table class=\"lined\" style=\"width: 720px;\">\n<tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['general']}:</td></tr>\n<tr>\n <td>" . makeinfocell($lang_item_edit['entry'], $lang_item_edit['entry_desc']) . "</td>\n <td>";
        //$output .= maketooltip($entry, "$item_datasite$entry", $tooltip, "item_tooltip");
        $output .= "</td>\n <td>" . makeinfocell($lang_item_edit['display_id'], $lang_item_edit['display_id_desc']) . "</td>\n <td><input type=\"text\" name=\"displayid\" size=\"8\" maxlength=\"11\" value=\"{$item['displayid']}\" /></td>\n\n <td>" . makeinfocell($lang_item_edit['req_level'], $lang_item_edit['req_level_desc']) . "</td>\n <td><input type=\"text\" name=\"RequiredLevel\" size=\"8\" maxlength=\"4\" value=\"{$item['RequiredLevel']}\" /></td>\n\n <td>" . makeinfocell($lang_item_edit['item_level'], $lang_item_edit['item_level_desc']) . "</td>\n <td><input type=\"text\" name=\"ItemLevel\" size=\"8\" maxlength=\"4\" value=\"{$item['ItemLevel']}\" /></td>\n</tr>\n\n<tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['names']}:</td></tr>\n<tr>\n <td>" . makeinfocell($lang_item_edit['item_name'], $lang_item_edit['item_name_desc']) . "</td>\n <td colspan=\"3\"><input type=\"text\" name=\"name\" size=\"30\" maxlength=\"225\" value=\"{$item['name']}\" /></td>\n\n <td>" . makeinfocell($lang_item_edit['script_name'], $lang_item_edit['script_name_desc']) . "</td>\n <td colspan=\"3\"><input type=\"text\" name=\"ScriptName\" size=\"30\" maxlength=\"100\" value=\"{$item['ScriptName']}\" /></td>\n</tr>\n\n<tr>\n <td>" . makeinfocell($lang_item_edit['description'], $lang_item_edit['description_desc']) . "</td>\n <td colspan=\"3\"><input type=\"text\" name=\"description\" size=\"30\" maxlength=\"225\" value=\"{$item['description']}\" /></td>\n <td colspan=\"4\"></td>\n</tr>\n\n<tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['type']}:</td></tr>\n   <tr>";
        $class = array(0 => "", 1 => "", 2 => "", 4 => "", 5 => "", 6 => "", 7 => "", 9 => "", 11 => "", 12 => "", 13 => "", 14 => "", 15 => "");
        $class[$item['class']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['class'], $lang_item_edit['class_desc']) . "</td>\n  <td colspan=\"3\"><select name=\"class\">\n    <option value=\"0\" {$class[0]}>0 - {$lang_item['consumable']}</option>\n    <option value=\"1\" {$class[1]}>1 - {$lang_item['bag']}</option>\n    <option value=\"2\" {$class[2]}>2 - {$lang_item['weapon']}</option>\n    <option value=\"4\" {$class[4]}>4 - {$lang_item['armor']}</option>\n    <option value=\"5\" {$class[5]}>5 - {$lang_item['reagent']}</option>\n    <option value=\"6\" {$class[6]}>6 - {$lang_item['projectile']}</option>\n    <option value=\"7\" {$class[7]}>7 - {$lang_item['trade_goods']}s</option>\n    <option value=\"9\" {$class[9]}>9 - {$lang_item['recipe']}</option>\n    <option value=\"11\" {$class[11]}>11 - {$lang_item['quiver']}</option>\n    <option value=\"12\" {$class[12]}>12 - {$lang_item['quest']}</option>\n    <option value=\"13\" {$class[13]}>13 - {$lang_item['key']}</option>\n    <option value=\"14\" {$class[14]}>14 - {$lang_item['permanent']}</option>\n    <option value=\"15\" {$class[15]}>15 - {$lang_item['misc_short']}</option>\n     </select></td>";
        unset($class);
        $subclass = array(0 => array(0 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => ""), 1 => array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => ""), 2 => array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "", 8 => "", 10 => "", 11 => "", 12 => "", 13 => "", 14 => "", 15 => "", 16 => "", 17 => "", 18 => "", 19 => "", 20 => ""), 4 => array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "", 8 => "", 9 => ""), 6 => array(2 => "", 3 => ""), 7 => array(0 => "", 1 => "", 2 => "", 3 => ""), 9 => array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "", 8 => "", 9 => "", 10 => ""), 11 => array(2 => "", 3 => ""), 13 => array(0 => "", 1 => ""));
        $subclass[$item['class']][$item['subclass']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['subclass'], $lang_item_edit['subclass_desc']) . "</td>\n  <td colspan=\"3\"><select name=\"subclass\">\n    <option value=\"0\" {$subclass[0][0]}>0 - {$lang_item['none']}</option>\n    <optgroup label=\"Class 0: {$lang_item['consumable']}\">\n    <option value=\"0\" {$subclass[0][0]}>0 - {$lang_item['consumable']}</option>\n    <option value=\"3\" {$subclass[0][3]}>3 - {$lang_item['potion']}</option>\n    <option value=\"4\" {$subclass[0][4]}>4 - {$lang_item['scroll']}</option>\n    <option value=\"5\" {$subclass[0][5]}>5 - {$lang_item['bandage']}</option>\n    <option value=\"6\" {$subclass[0][6]}>6 - {$lang_item['healthstone']}</option>\n    <option value=\"7\" {$subclass[0][7]}>7 - {$lang_item['combat_effect']}</option>\n  <optgroup label=\"Class 1: {$lang_item['bag']}\">\n    <option value=\"0\" {$subclass[1][0]}>0 - {$lang_item['bag']}</option>\n    <option value=\"1\" {$subclass[1][1]}>1 - {$lang_item['soul_shards']}</option>\n    <option value=\"2\" {$subclass[1][2]}>2 - {$lang_item['herbs']}</option>\n    <option value=\"3\" {$subclass[1][3]}>3 - {$lang_item['enchanting']}</option>\n    <option value=\"4\" {$subclass[1][4]}>4 - {$lang_item['engineering']}</option>\n    <option value=\"5\" {$subclass[1][5]}>5 - {$lang_item['gems']}</option>\n    <option value=\"6\" {$subclass[1][6]}>6 - {$lang_item['mining']}</option>\n  <optgroup label=\"Class 2: {$lang_item['weapon']}\">\n    <option value=\"0\" {$subclass[2][0]}>0 - {$lang_item['axe_1h']}</option>\n    <option value=\"1\" {$subclass[2][2]}>1 - {$lang_item['axe_2h']}</option>\n    <option value=\"2\" {$subclass[2][2]}>2 - {$lang_item['bow']}</option>\n    <option value=\"3\" {$subclass[2][2]}>3 - {$lang_item['rifle']}</option>\n    <option value=\"4\" {$subclass[2][4]}>4 - {$lang_item['mace_1h']}</option>\n    <option value=\"5\" {$subclass[2][5]}>5 - {$lang_item['mace_2h']}</option>\n    <option value=\"6\" {$subclass[2][6]}>6 - {$lang_item['polearm']}</option>\n    <option value=\"7\" {$subclass[2][7]}>7 - {$lang_item['sword_1h']}</option>\n    <option value=\"8\" {$subclass[2][8]}>8 - {$lang_item['sword_2h']}</option>\n    <option value=\"10\" {$subclass[2][10]}>10 - {$lang_item['staff']}</option>\n    <option value=\"11\" {$subclass[2][11]}>11 - {$lang_item['exotic_1h']}</option>\n    <option value=\"12\" {$subclass[2][12]}>12 - {$lang_item['exotic_2h']}</option>\n    <option value=\"13\" {$subclass[2][13]}>13 - {$lang_item['fist_weapon']}</option>\n    <option value=\"14\" {$subclass[2][14]}>14 - {$lang_item['misc_weapon']}</option>\n    <option value=\"15\" {$subclass[2][15]}>15 - {$lang_item['dagger']}</option>\n    <option value=\"16\" {$subclass[2][16]}>16 - {$lang_item['thrown']}</option>\n    <option value=\"17\" {$subclass[2][17]}>17 - {$lang_item['spear']}</option>\n    <option value=\"18\" {$subclass[2][18]}>18 - {$lang_item['crossbow']}</option>\n    <option value=\"19\" {$subclass[2][19]}>19 - {$lang_item['wand']}</option>\n    <option value=\"20\" {$subclass[2][20]}>20 - {$lang_item['fishing_pole']}</option>\n  </optgroup>\n  <optgroup label=\"Class 4: {$lang_item['armor']}\">\n    <option value=\"0\" {$subclass[4][0]}>0 - {$lang_item['misc']}</option>\n    <option value=\"1\" {$subclass[4][1]}>1 - {$lang_item['cloth']}</option>\n    <option value=\"2\" {$subclass[4][2]}>2 - {$lang_item['leather']}</option>\n    <option value=\"3\" {$subclass[4][3]}>3 - {$lang_item['mail']}</option>\n    <option value=\"4\" {$subclass[4][4]}>4 - {$lang_item['plate']}</option>\n    <option value=\"5\" {$subclass[4][5]}>5 - {$lang_item['buckler']}</option>\n    <option value=\"6\" {$subclass[4][6]}>6 - {$lang_item['shield']}</option>\n    <option value=\"7\" {$subclass[4][7]}>7 - {$lang_item['libram']}</option>\n    <option value=\"8\" {$subclass[4][8]}>8 - {$lang_item['idol']}</option>\n    <option value=\"9\" {$subclass[4][9]}>9 - {$lang_item['totem']}</option>\n  </optgroup>\n  <optgroup label=\"Class 6: {$lang_item['projectile']}\">\n    <option value=\"2\" {$subclass[6][2]}>2 - {$lang_item['arrows']}</option>\n    <option value=\"3\" {$subclass[6][3]}>3 - {$lang_item['bullets']}</option>\n  </optgroup>\n  <optgroup label=\"Class 7: {$lang_item['trade_goods']}\">\n    <option value=\"0\" {$subclass[7][0]}>0 - {$lang_item['trade_goods']}</option>\n    <option value=\"1\" {$subclass[7][1]}>1 - {$lang_item['parts']}</option>\n    <option value=\"2\" {$subclass[7][2]}>2 - {$lang_item['explosives']}</option>\n    <option value=\"3\" {$subclass[7][3]}>3 - {$lang_item['devices']}</option>\n  </optgroup>\n  <optgroup label=\"Class 9: {$lang_item['recipe']}\">\n    <option value=\"0\" {$subclass[9][0]}>0 - {$lang_item['book']}</option>\n    <option value=\"1\" {$subclass[9][1]}>1 - {$lang_item['LW_pattern']}</option>\n    <option value=\"2\" {$subclass[9][2]}>2 - {$lang_item['tailoring_pattern']}</option>\n    <option value=\"3\" {$subclass[9][3]}>3 - {$lang_item['ENG_Schematic']}</option>\n    <option value=\"4\" {$subclass[9][4]}>4 - {$lang_item['BS_plans']}</option>\n    <option value=\"5\" {$subclass[9][5]}>5 - {$lang_item['cooking_recipe']}</option>\n    <option value=\"6\" {$subclass[9][6]}>6 - {$lang_item['alchemy_recipe']}</option>\n    <option value=\"7\" {$subclass[9][7]}>7 - {$lang_item['FA_manual']}</option>\n    <option value=\"8\" {$subclass[9][8]}>8 - {$lang_item['ench_formula']}</option>\n    <option value=\"9\" {$subclass[9][9]}>9 - {$lang_item['fishing_manual']}</option>\n    <option value=\"10\" {$subclass[9][10]}>10 - {$lang_item['JC_formula']}</option>\n  </optgroup>\n  <optgroup label=\"Class 11: {$lang_item['quiver']}\">\n    <option value=\"2\" {$subclass[11][2]}>2 - {$lang_item['quiver']}</option>\n    <option value=\"3\" {$subclass[11][3]}>3 - {$lang_item['ammo_pouch']}</option>\n  </optgroup>\n  <optgroup label=\"Class 13: {$lang_item['key']}\">\n    <option value=\"0\" {$subclass[13][0]}>0 - {$lang_item['key']}</option>\n    <option value=\"1\" {$subclass[13][1]}>1 - {$lang_item['lockpick']}</option>\n  </optgroup>\n </select></td>\n</tr>\n<tr>";
        unset($subclass);
        $quality = array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "");
        $quality[$item['Quality']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['quality'], $lang_item_edit['quality_desc']) . "</td>\n   <td colspan=\"2\"><select name=\"Quality\">\n    <option value=\"0\" {$quality[0]}>0 - {$lang_item['poor']}</option>\n    <option value=\"1\" {$quality[1]}>1 - {$lang_item['common']}</option>\n    <option value=\"2\" {$quality[2]}>2 - {$lang_item['uncommon']}</option>\n    <option value=\"3\" {$quality[3]}>3 - {$lang_item['rare']}</option>\n    <option value=\"4\" {$quality[4]}>4 - {$lang_item['epic']}</option>\n    <option value=\"5\" {$quality[5]}>5 - {$lang_item['legendary']}</option>\n    <option value=\"6\" {$quality[6]}>6 - {$lang_item['artifact']}</option>\n     </select></td>";
        unset($quality);
        $inv_type = array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "", 8 => "", 9 => "", 10 => "", 11 => "", 12 => "", 13 => "", 14 => "", 15 => "", 16 => "", 17 => "", 18 => "", 19 => "", 20 => "", 21 => "", 22 => "", 23 => "", 24 => "", 25 => "", 26 => "");
        $inv_type[$item['InventoryType']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['inv_type'], $lang_item_edit['inv_type_desc']) . "</td>\n    <td colspan=\"2\"><select name=\"InventoryType\">\n    <option value=\"0\" {$inv_type[0]}>0 - {$lang_item['other']}</option>\n    <option value=\"1\" {$inv_type[1]}>1 - {$lang_item['head']}</option>\n    <option value=\"2\" {$inv_type[2]}>2 - {$lang_item['neck']}</option>\n    <option value=\"3\" {$inv_type[3]}>3 - {$lang_item['shoulder']}</option>\n    <option value=\"4\" {$inv_type[4]}>4 - {$lang_item['shirt']}</option>\n    <option value=\"5\" {$inv_type[5]}>5 - {$lang_item['chest']}</option>\n    <option value=\"6\" {$inv_type[6]}>6 - {$lang_item['belt']}</option>\n    <option value=\"7\" {$inv_type[7]}>7 - {$lang_item['legs']}</option>\n    <option value=\"8\" {$inv_type[8]}>8 - {$lang_item['feet']}</option>\n    <option value=\"9\" {$inv_type[9]}>9 - {$lang_item['belt']}</option>\n    <option value=\"10\" {$inv_type[10]}>10 - {$lang_item['gloves']}</option>\n    <option value=\"11\" {$inv_type[11]}>11 - {$lang_item['finger']}</option>\n    <option value=\"12\" {$inv_type[12]}>12 - {$lang_item['trinket']}</option>\n    <option value=\"13\" {$inv_type[13]}>13 - {$lang_item['one_hand']}</option>\n    <option value=\"14\" {$inv_type[14]}>14 - {$lang_item['off_hand']}</option>\n    <option value=\"15\" {$inv_type[15]}>15 - {$lang_item['bow']}</option>\n    <option value=\"16\" {$inv_type[16]}>16 - {$lang_item['back']}</option>\n    <option value=\"17\" {$inv_type[17]}>17 - {$lang_item['two_hand']}</option>\n    <option value=\"18\" {$inv_type[18]}>18 - {$lang_item['bag']}</option>\n    <option value=\"19\" {$inv_type[19]}>19 - {$lang_item['tabard']}</option>\n    <option value=\"20\" {$inv_type[20]}>20 - {$lang_item['robe']}</option>\n    <option value=\"21\" {$inv_type[21]}>21 - {$lang_item['main_hand']}</option>\n    <option value=\"22\" {$inv_type[22]}>22 - {$lang_item['off_misc']}</option>\n    <option value=\"23\" {$inv_type[23]}>23 - {$lang_item['tome']}</option>\n    <option value=\"24\" {$inv_type[24]}>24 - {$lang_item['projectile']}</option>\n    <option value=\"25\" {$inv_type[25]}>25 - {$lang_item['thrown']}</option>\n    <option value=\"26\" {$inv_type[26]}>26 - {$lang_item['rifle']}</option>\n     </select></td>\n\n     <td>" . makeinfocell($lang_item_edit['flags'], $lang_item_edit['flags_desc']) . "</td>\n     <td><input type=\"text\" name=\"Flags\" size=\"10\" maxlength=\"30\" value=\"{$item['Flags']}\" /></td>\n     </tr>\n\n     <tr>\n     <td>" . makeinfocell($lang_item_edit['item_set'], $lang_item_edit['item_set_desc']) . "</td>\n     <td><input type=\"text\" name=\"itemset\" size=\"10\" maxlength=\"30\" value=\"{$item['itemset']}\" /></td>";
        unset($inv_type);
        $bonding = array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "");
        $bonding[$item['bonding']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['bonding'], $lang_item_edit['bonding_desc']) . "</td>\n   <td colspan=\"3\"><select name=\"bonding\">\n    <option value=\"0\" {$bonding[0]}>0 - {$lang_item['no_bind']}</option>\n    <option value=\"1\" {$bonding[1]}>1 - {$lang_item['bop']}</option>\n    <option value=\"2\" {$bonding[2]}>2 - {$lang_item['boe']}</option>\n    <option value=\"3\" {$bonding[3]}>3 - {$lang_item['bou']}</option>\n    <option value=\"4\" {$bonding[4]}>4 - {$lang_item['quest_item']}</option>\n    <option value=\"5\" {$bonding[5]}>5 - {$lang_item['quest_item']}1</option>\n     </select></td>\n\n<td>" . makeinfocell($lang_item_edit['start_quest'], $lang_item_edit['start_quest_desc']) . "</td>\n<td><input type=\"text\" name=\"startquest\" size=\"10\" maxlength=\"30\" value=\"{$item['startquest']}\" /></td>\n\n</tr>\n</table>\n<br />{$lang_item_edit['short_rules_desc']}<br /><br />\n</div>";
        unset($bonding);
        $output .= "<div id=\"pane2\">\n  <br /><br /><table class=\"lined\" style=\"width: 720px;\">\n  <tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['vendor']}:</td></tr>\n  <tr>\n   <td>" . makeinfocell($lang_item_edit['buy_count'], $lang_item_edit['buy_count_desc']) . "</td>\n   <td><input type=\"text\" name=\"BuyCount\" size=\"8\" maxlength=\"3\" value=\"{$item['BuyCount']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['buy_price'], $lang_item_edit['buy_price_desc']) . "</td>\n   <td><input type=\"text\" name=\"BuyPrice\" size=\"8\" maxlength=\"30\" value=\"{$item['BuyPrice']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['sell_price'], $lang_item_edit['sell_price_desc']) . "</td>\n   <td><input type=\"text\" name=\"SellPrice\" size=\"8\" maxlength=\"30\" value=\"{$item['SellPrice']}\" /></td>\n   <td></td><td></td>\n  </tr>\n\n  <tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['container']}:</td></tr>\n  <tr>\n\n    <td>" . makeinfocell($lang_item_edit['max_count'], $lang_item_edit['max_count_desc']) . "</td>\n    <td><input type=\"text\" name=\"maxcount\" size=\"6\" maxlength=\"5\" value=\"{$item['maxcount']}\" /></td>\n\n    <td>" . makeinfocell($lang_item_edit['stackable'], $lang_item_edit['stackable_desc']) . "</td>\n    <td><input type=\"text\" name=\"stackable\" size=\"6\" maxlength=\"5\" value=\"{$item['stackable']}\" /></td>\n\n    <td>" . makeinfocell($lang_item_edit['bag_family'], $lang_item_edit['bag_family_desc']) . "</td>";
        $bagfamily = array(0 => "", 1 => "", 2 => "", 3 => "", 6 => "", 7 => "", 8 => "", 9 => "", 10 => "", 12 => "");
        $bagfamily[$item['BagFamily']] = " selected=\"selected\" ";
        $output .= "<td><select name=\"BagFamily\">\n    <option value=\"0\" {$bagfamily[0]}>0 - {$lang_item['none']}</option>\n    <option value=\"1\" {$bagfamily[1]}>1 - {$lang_item['arrows']}</option>\n    <option value=\"2\" {$bagfamily[2]}>2 - {$lang_item['bullets']}</option>\n    <option value=\"3\" {$bagfamily[3]}>3 - {$lang_item['soul_shards']}</option>\n    <option value=\"6\" {$bagfamily[6]}>6 - {$lang_item['herbs']}</option>\n    <option value=\"7\" {$bagfamily[7]}>7 - {$lang_item['enchanting']}</option>\n    <option value=\"8\" {$bagfamily[8]}>8 - {$lang_item['engineering']}</option>\n    <option value=\"9\" {$bagfamily[9]}>9 - {$lang_item['keys']}</option>\n    <option value=\"10\" {$bagfamily[10]}>10 - {$lang_item['gems']}</option>\n    <option value=\"12\" {$bagfamily[12]}>12 - {$lang_item['mining']}</option>\n     </select></td>\n  <td>" . makeinfocell($lang_item_edit['bag_slots'], $lang_item_edit['bag_slots_desc']) . "</td>\n  <td><input type=\"text\" name=\"ContainerSlots\" size=\"10\" maxlength=\"3\" value=\"{$item['ContainerSlots']}\" /></td>\n  </tr>\n  <tr>\n\n  <tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['materials']}:</td></tr>";
        unset($bagfamily);
        $Material = array(-1 => "", 0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "", 8 => "");
        $Material[$item['Material']] = " selected=\"selected\" ";
        $output .= "<tr>\n  <td>" . makeinfocell($lang_item_edit['material'], $lang_item_edit['material_desc']) . "</td>\n   <td colspan=\"2\"><select name=\"Material\">\n    <option value=\"-1\" {$Material[-1]}>-1 - {$lang_item_edit['consumables']}</option>\n    <option value=\"0\" {$Material[0]}>0 - {$lang_item_edit['none']}</option>\n    <option value=\"1\" {$Material[1]}>1 - {$lang_item_edit['metal']}</option>\n    <option value=\"2\" {$Material[2]}>2 - {$lang_item_edit['wood']}</option>\n    <option value=\"3\" {$Material[3]}>3 - {$lang_item_edit['liquid']}</option>\n    <option value=\"4\" {$Material[4]}>4 - {$lang_item_edit['jewelry']}</option>\n    <option value=\"5\" {$Material[5]}>5 - {$lang_item_edit['chain']}</option>\n    <option value=\"6\" {$Material[6]}>6 - {$lang_item_edit['plate']}</option>\n    <option value=\"7\" {$Material[7]}>7 - {$lang_item_edit['cloth']}</option>\n    <option value=\"8\" {$Material[8]}>8 - {$lang_item_edit['leather']}</option>\n     </select></td>";
        unset($Material);
        $PageMaterial = array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "");
        $PageMaterial[$item['PageMaterial']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['page_material'], $lang_item_edit['page_material_desc']) . "</td>\n   <td colspan=\"2\"><select name=\"PageMaterial\">\n    <option value=\"0\" {$PageMaterial[0]}>0 - {$lang_item_edit['none']}</option>\n    <option value=\"1\" {$PageMaterial[1]}>1 - {$lang_item_edit['parchment']}</option>\n    <option value=\"2\" {$PageMaterial[2]}>2 - {$lang_item_edit['stone']}</option>\n    <option value=\"3\" {$PageMaterial[3]}>3 - {$lang_item_edit['marble']}</option>\n    <option value=\"4\" {$PageMaterial[4]}>4 - {$lang_item_edit['silver']}</option>\n    <option value=\"5\" {$PageMaterial[5]}>5 - {$lang_item_edit['bronze']}</option>\n     </select></td>";
        unset($PageMaterial);
        $output .= "<td>" . makeinfocell($lang_item_edit['max_durability'], $lang_item_edit['max_durability_desc']) . "</td>\n  <td><input type=\"text\" name=\"MaxDurability\" size=\"8\" maxlength=\"30\" value=\"{$item['MaxDurability']}\" /></td>\n</tr>\n\n<tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['RandomProperty']}:</td></tr>\n<tr>\n   <td colspan=\"2\">" . makeinfocell($lang_item_edit['RandomProperty'], $lang_item_edit['RandomProperty_desc']) . "</td>\n   <td colspan=\"2\"><input type=\"text\" name=\"RandomProperty\" size=\"8\" maxlength=\"30\" value=\"{$item['RandomProperty']}\" /></td>\n\n   <td colspan=\"2\">" . makeinfocell($lang_item_edit['RandomSuffix'], $lang_item_edit['RandomSuffix_desc']) . "</td>\n   <td colspan=\"2\"><input type=\"text\" name=\"RandomSuffix\" size=\"8\" maxlength=\"10\" value=\"{$item['RandomSuffix']}\" /></td>\n</tr>\n\n\n<tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['other']}:</td></tr>\n  <tr>\n   <td>" . makeinfocell($lang_item_edit['area'], $lang_item_edit['area_desc']) . "</td>\n   <td><input type=\"text\" name=\"area\" size=\"8\" maxlength=\"10\" value=\"{$item['area']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['map'], $lang_item_edit['map_desc']) . "</td>\n   <td><input type=\"text\" name=\"Map\" size=\"8\" maxlength=\"10\" value=\"{$item['Map']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['page_text'], $lang_item_edit['page_text_desc']) . "</td>\n   <td><input type=\"text\" name=\"PageText\" size=\"6\" maxlength=\"30\" value=\"{$item['PageText']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['unk0'], $lang_item_edit['unk0_desc']) . "</td>\n   <td><input type=\"text\" name=\"unk0\" size=\"8\" maxlength=\"10\" value=\"{$item['unk0']}\" /></td>\n  </tr>\n  <tr>\n\n    <tr>\n   <td colspan=\"2\">" . makeinfocell($lang_item_edit['disenchant_id'], $lang_item_edit['disenchant_id_desc']) . "</td>\n   <td><input type=\"text\" name=\"DisenchantID\" size=\"10\" maxlength=\"10\" value=\"{$item['DisenchantID']}\" /></td>\n\n   <td colspan=\"2\">" . makeinfocell($lang_item_edit['req_skill_disenchant'], $lang_item_edit['req_skill_disenchant_desc']) . "</td>\n   <td><input type=\"text\" name=\"RequiredDisenchantSkill\" size=\"10\" maxlength=\"10\" value=\"{$item['RequiredDisenchantSkill']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['lock_id'], $lang_item_edit['lock_id_desc']) . "</td>\n   <td><input type=\"text\" name=\"lockid\" size=\"8\" maxlength=\"30\" value=\"{$item['lockid']}\" /></td>\n  </tr>";
        $LanguageID = array(0 => "", 1 => "", 2 => "", 3 => "", 6 => "", 7 => "", 8 => "", 9 => "", 10 => "", 11 => "", 12 => "", 13 => "", 14 => "", 33 => "");
        $LanguageID[$item['LanguageID']] = " selected=\"selected\" ";
        $output .= "<tr>\n  <td>" . makeinfocell($lang_item_edit['lang_id'], $lang_item_edit['lang_id_desc']) . "</td>\n   <td colspan=\"2\"><select name=\"LanguageID\">\n    <option value=\"0\" {$LanguageID[0]}>0 - {$lang_item_edit['other']}</option>\n    <option value=\"1\" {$LanguageID[1]}>1 - Orcish</option>\n    <option value=\"2\" {$LanguageID[2]}>2 - Darnassian</option>\n    <option value=\"3\" {$LanguageID[3]}>3 - Taurahe</option>\n    <option value=\"6\" {$LanguageID[6]}>6 - Dwarvish</option>\n    <option value=\"7\" {$LanguageID[7]}>7 - Common</option>\n    <option value=\"8\" {$LanguageID[8]}>8 - Demonic</option>\n    <option value=\"9\" {$LanguageID[9]}>9 - Titan</option>\n    <option value=\"10\" {$LanguageID[10]}>10 - Thelassian</option>\n    <option value=\"11\" {$LanguageID[11]}>11 - Draconic</option>\n    <option value=\"12\" {$LanguageID[12]}>12 - Kalimag</option>\n    <option value=\"13\" {$LanguageID[13]}>13 - Gnomish</option>\n    <option value=\"14\" {$LanguageID[14]}>14 - Troll</option>\n    <option value=\"33\" {$LanguageID[33]}>33 - Gutterspeak</option>\n     </select></td>";
        unset($LanguageID);
        $sheath = array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 7 => "");
        $sheath[$item['sheath']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['sheath'], $lang_item_edit['sheath_desc']) . "</td>\n   <td colspan=\"2\"><select name=\"sheath\">\n    <option value=\"0\" {$sheath[0]}>0 - {$lang_item_edit['other']}</option>\n    <option value=\"1\" {$sheath[1]}>1 - {$lang_item['sword_2h']}</option>\n    <option value=\"2\" {$sheath[2]}>2 - {$lang_item['staff']}</option>\n    <option value=\"3\" {$sheath[3]}>3 - {$lang_item['sword_1h']}</option>\n    <option value=\"4\" {$sheath[4]}>4 - {$lang_item['shield']}</option>\n    <option value=\"5\" {$sheath[5]}>5 - {$lang_item['rod']}</option>\n    <option value=\"7\" {$sheath[7]}>7 - {$lang_item['off_hand']}</option>\n     </select></td>\n\n   <td>" . makeinfocell($lang_item_edit['totem_category'], $lang_item_edit['totem_category_desc']) . "</td>\n   <td><input type=\"text\" name=\"TotemCategory\" size=\"8\" maxlength=\"10\" value=\"{$item['TotemCategory']}\" /></td>\n  </tr>\n\n   </table><br /><br />\n    </div>";
        unset($sheath);
        $output .= "<div id=\"pane3\">\n   <br /><br /><table class=\"lined\" style=\"width: 720px;\">\n  <tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['stats']}:</td></tr>\n  <tr>\n\n  <td>" . makeinfocell($lang_item_edit['stat_type'] . " 1", $lang_item_edit['stat_type_desc']) . "</td>\n   <td><select name=\"stat_type1\">";
        output_status_options($item['stat_type1']);
        $output .= "</select></td>\n\n  <td><input type=\"text\" name=\"stat_value1\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value1']}\" /></td>\n  <td>" . makeinfocell($lang_item_edit['stat_type'] . " 2", $lang_item_edit['stat_type_desc']) . "</td>\n   <td><select name=\"stat_type2\">";
        output_status_options($item['stat_type2']);
        $output .= "</select></td>\n\n   <td><input type=\"text\" name=\"stat_value2\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value2']}\" /></td>\n  </tr>\n <tr>\n  <td>" . makeinfocell($lang_item_edit['stat_type'] . " 3", $lang_item_edit['stat_type_desc']) . "</td>\n  <td><select name=\"stat_type3\">";
        output_status_options($item['stat_type3']);
        $output .= "</select></td>\n\n  <td><input type=\"text\" name=\"stat_value3\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value3']}\" /></td>\n  <td>" . makeinfocell($lang_item_edit['stat_type'] . " 4", $lang_item_edit['stat_type_desc']) . "</td>\n   <td><select name=\"stat_type4\">";
        output_status_options($item['stat_type4']);
        $output .= "</select></td>\n\n   <td><input type=\"text\" name=\"stat_value4\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value4']}\" /></td>\n  </tr>\n<tr>\n <td>" . makeinfocell($lang_item_edit['stat_type'] . " 5", $lang_item_edit['stat_type_desc']) . "</td>\n <td><select name=\"stat_type5\">";
        output_status_options($item['stat_type5']);
        $output .= "</select></td>\n\n   <td><input type=\"text\" name=\"stat_value5\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value5']}\" /></td>\n  <td>" . makeinfocell($lang_item_edit['stat_type'] . " 6", $lang_item_edit['stat_type_desc']) . "</td>\n   <td><select name=\"stat_type6\">";
        output_status_options($item['stat_type1']);
        $output .= "</select></td>\n\n   <td><input type=\"text\" name=\"stat_value6\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value6']}\" /></td>\n  </tr>\n<tr>\n <td>" . makeinfocell($lang_item_edit['stat_type'] . " 7", $lang_item_edit['stat_type_desc']) . "</td>\n   <td><select name=\"stat_type7\">";
        output_status_options($item['stat_type7']);
        $output .= "</select></td>\n  <td><input type=\"text\" name=\"stat_value7\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value7']}\" /></td>\n  <td>" . makeinfocell($lang_item_edit['stat_type'] . " 8", $lang_item_edit['stat_type_desc']) . "</td>\n   <td><select name=\"stat_type8\">";
        output_status_options($item['stat_type8']);
        $output .= "</select></td>\n\n   <td><input type=\"text\" name=\"stat_value8\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value8']}\" /></td>\n  </tr>\n<tr>\n  <td>" . makeinfocell($lang_item_edit['stat_type'] . " 9", $lang_item_edit['stat_type_desc']) . "</td>\n  <td><select name=\"stat_type9\">";
        output_status_options($item['stat_type9']);
        $output .= "</select></td>\n  <td><input type=\"text\" name=\"stat_value9\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value9']}\" /></td>\n  <td>" . makeinfocell($lang_item_edit['stat_type'] . " 10", $lang_item_edit['stat_type_desc']) . "</td>\n   <td><select name=\"stat_type10\">";
        output_status_options($item['stat_type10']);
        $output .= "</select></td>\n\n   <td><input type=\"text\" name=\"stat_value10\" size=\"10\" maxlength=\"6\" value=\"{$item['stat_value10']}\" /></td>\n  </tr>\n\n  <tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['resis_armor']}:</td></tr>\n   <tr>\n   <td colspan=\"2\">" . makeinfocell($lang_item['armor'], $lang_item_edit['armor_desc']) . "</td>\n   <td><input type=\"text\" name=\"armor\" size=\"10\" maxlength=\"30\" value=\"{$item['armor']}\" /></td>\n\n   <td colspan=\"2\">" . makeinfocell($lang_item['block'], $lang_item_edit['block_desc']) . "</td>\n   <td><input type=\"text\" name=\"block\" size=\"10\" maxlength=\"30\" value=\"{$item['block']}\" /></td>\n   </tr>\n   <tr>\n   <td colspan=\"2\">" . makeinfocell($lang_item['res_holy'], $lang_item_edit['res_holy_desc']) . "</td>\n   <td><input type=\"text\" name=\"holy_res\" size=\"10\" maxlength=\"30\" value=\"{$item['holy_res']}\" /></td>\n\n   <td colspan=\"2\">" . makeinfocell($lang_item['res_fire'], $lang_item_edit['res_fire_desc']) . "</td>\n   <td><input type=\"text\" name=\"fire_res\" size=\"10\" maxlength=\"30\" value=\"{$item['fire_res']}\" /></td>\n   </tr>\n   <tr>\n   <td colspan=\"2\">" . makeinfocell($lang_item['res_nature'], $lang_item_edit['res_nature_desc']) . "</td>\n   <td><input type=\"text\" name=\"nature_res\" size=\"10\" maxlength=\"30\" value=\"{$item['nature_res']}\" /></td>\n\n   <td colspan=\"2\">" . makeinfocell($lang_item['res_frost'], $lang_item_edit['res_frost_desc']) . "</td>\n   <td><input type=\"text\" name=\"frost_res\" size=\"10\" maxlength=\"30\" value=\"{$item['frost_res']}\" /></td>\n   </tr>\n   <tr>\n   <td colspan=\"2\">" . makeinfocell($lang_item['res_shadow'], $lang_item_edit['res_shadow_desc']) . "</td>\n   <td><input type=\"text\" name=\"shadow_res\" size=\"10\" maxlength=\"30\" value=\"{$item['shadow_res']}\" /></td>\n\n   <td colspan=\"2\">" . makeinfocell($lang_item['res_arcane'], $lang_item_edit['res_arcane_desc']) . "</td>\n   <td><input type=\"text\" name=\"arcane_res\" size=\"10\" maxlength=\"30\" value=\"{$item['arcane_res']}\" /></td>\n   </tr>\n\n    </table><br /><br />\n    </div>";
        $output .= "<div id=\"pane4\">\n     <br /><br /><table class=\"lined\" style=\"width: 720px;\">\n  <tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['weapon_properties']}:</td></tr>\n<tr>\n <td>" . makeinfocell($lang_item_edit['delay'], $lang_item_edit['delay_desc']) . "</td>\n <td colspan=\"2\"><input type=\"text\" name=\"delay\" size=\"10\" maxlength=\"11\" value=\"{$item['delay']}\" /></td>\n\n <td>" . makeinfocell($lang_item_edit['ranged_mod'], $lang_item_edit['ranged_mod_desc']) . "</td>\n <td colspan=\"2\"><input type=\"text\" name=\"RangedModRange\" size=\"10\" maxlength=\"40\" value=\"{$item['RangedModRange']}\" /></td>\n</tr>\n<tr>\n <td>" . makeinfocell($lang_item_edit['armor_dmg_mod'], $lang_item_edit['armor_dmg_mod_desc']) . "</td>\n <td colspan=\"2\"><input type=\"text\" name=\"ArmorDamageModifier\" size=\"10\" maxlength=\"40\" value=\"{$item['ArmorDamageModifier']}\" /></td>";
        $ammo_type = array(0 => "", 2 => "", 3 => "");
        $ammo_type[$item['ammo_type']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['ammo_type'], $lang_item_edit['ammo_type_desc']) . "</td>\n   <td colspan=\"2\"><select name=\"ammo_type\">\n    <option value=\"0\" {$ammo_type[0]}>0 - {$lang_item['none']}</option>\n    <option value=\"2\" {$ammo_type[2]}>2 - {$lang_item['arrows']}</option>\n    <option value=\"3\" {$ammo_type[3]}>3 - {$lang_item['bullets']}</option>\n     </select></td>\n</tr>\n<tr class=\"large_bold\"><td colspan=\"8\" class=\"hidden\" align=\"left\">{$lang_item_edit['weapon_damage']}:</td></tr>\n<tr>";
        unset($ammo_type);
        $output .= "<td>" . makeinfocell($lang_item_edit['damage_type'] . " 1", $lang_item_edit['damage_type_desc']) . "</td>\n   <td colspan=\"2\"><select name=\"dmg_type1\">";
        output_dmgtype_options($item['dmg_type1']);
        $output .= "</select></td>\n\n   <td>" . makeinfocell($lang_item_edit['dmg_min_max'], $lang_item_edit['dmg_min_max_desc']) . "</td>\n   <td colspan=\"4\"><input type=\"text\" name=\"dmg_min1\" size=\"8\" maxlength=\"45\" value=\"{$item['dmg_min1']}\" /> - <input type=\"text\" name=\"dmg_max1\" size=\"8\" maxlength=\"45\" value=\"{$item['dmg_max1']}\" /></td>\n\n</tr>\n<tr>\n  <td>" . makeinfocell($lang_item_edit['damage_type'] . " 2", $lang_item_edit['damage_type_desc']) . "</td>\n   <td colspan=\"2\"><select name=\"dmg_type2\">";
        output_dmgtype_options($item['dmg_type2']);
        $output .= "</select></td>\n\n   <td>" . makeinfocell($lang_item_edit['dmg_min_max'], $lang_item_edit['dmg_min_max_desc']) . "</td>\n   <td colspan=\"4\"><input type=\"text\" name=\"dmg_min2\" size=\"8\" maxlength=\"45\" value=\"{$item['dmg_min2']}\" /> - <input type=\"text\" name=\"dmg_max2\" size=\"8\" maxlength=\"45\" value=\"{$item['dmg_max2']}\" /></td>\n\n</tr>\n</table><br /><br />\n    </div>";
        $output .= "<div id=\"pane5\">\n     <br /><br /><table class=\"lined\" style=\"width: 720px;\">\n<tr>\n   <td colspan=\"2\">{$lang_item_edit['item_spell']} 1</td>\n   <td>" . makeinfocell($lang_item_edit['spell_id'], $lang_item_edit['spell_id_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellid_1\" size=\"6\" maxlength=\"30\" value=\"{$item['spellid_1']}\" /></td>";
        $spelltrigger_1 = array(0 => "", 1 => "", 2 => "", 4 => "");
        $spelltrigger_1[$item['spelltrigger_1']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['spell_trigger'], $lang_item_edit['spell_trigger_desc']) . "</td>\n   <td><select name=\"spelltrigger_1\">\n    <option value=\"0\" {$spelltrigger_1[0]}>0: {$lang_item['spell_use']}</option>\n    <option value=\"1\" {$spelltrigger_1[1]}>1: {$lang_item['spell_equip']}</option>\n    <option value=\"2\" {$spelltrigger_1[2]}>2: {$lang_item['spell_coh']}</option>\n    <option value=\"4\" {$spelltrigger_1[4]}>4: {$lang_item['soul_stone']}</option>\n    </select></td>\n   <td>" . makeinfocell($lang_item_edit['spell_charges'], $lang_item_edit['spell_charges_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcharges_1\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcharges_1']}\" /></td>\n</tr>\n<tr>\n   <td>" . makeinfocell($lang_item_edit['spell_cooldown'], $lang_item_edit['spell_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcooldown_1\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcooldown_1']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category'], $lang_item_edit['spell_category_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategory_1\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategory_1']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category_cooldown'], $lang_item_edit['spell_category_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategorycooldown_1\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategorycooldown_1']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['ppm_rate'], $lang_item_edit['ppm_rate_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellppmRate_1\" size=\"6\" maxlength=\"30\" value=\"{$item['spellppmRate_1']}\" /></td>\n</tr>\n<tr><td colspan=\"6\" class=\"hidden\"></td></tr>\n<tr>\n   <td colspan=\"2\">{$lang_item_edit['item_spell']} 2</td>\n   <td>" . makeinfocell($lang_item_edit['spell_id'], $lang_item_edit['spell_id_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellid_2\" size=\"6\" maxlength=\"30\" value=\"{$item['spellid_2']}\" /></td>";
        unset($spelltrigger_1);
        $spelltrigger_2 = array(0 => "", 1 => "", 2 => "", 4 => "");
        $spelltrigger_2[$item['spelltrigger_2']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['spell_trigger'], $lang_item_edit['spell_trigger_desc']) . "</td>\n   <td><select name=\"spelltrigger_2\">\n    <option value=\"0\" {$spelltrigger_2[0]}>0: {$lang_item['spell_use']}</option>\n    <option value=\"1\" {$spelltrigger_2[1]}>1: {$lang_item['spell_equip']}</option>\n    <option value=\"2\" {$spelltrigger_2[2]}>2: {$lang_item['spell_coh']}</option>\n    <option value=\"4\" {$spelltrigger_2[4]}>4: {$lang_item['soul_stone']}</option>\n    </select></td>\n   <td>" . makeinfocell($lang_item_edit['spell_charges'], $lang_item_edit['spell_charges_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcharges_2\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcharges_2']}\" /></td>\n</tr>\n<tr>\n   <td>" . makeinfocell($lang_item_edit['spell_cooldown'], $lang_item_edit['spell_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcooldown_2\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcooldown_2']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category'], $lang_item_edit['spell_category_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategory_2\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategory_2']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category_cooldown'], $lang_item_edit['spell_category_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategorycooldown_2\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategorycooldown_2']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['ppm_rate'], $lang_item_edit['ppm_rate_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellppmRate_2\" size=\"6\" maxlength=\"30\" value=\"{$item['spellppmRate_2']}\" /></td>\n</tr>\n<tr><td colspan=\"6\" class=\"hidden\"></td></tr>\n<tr>\n   <td colspan=\"2\">{$lang_item_edit['item_spell']} 3</td>\n   <td>" . makeinfocell($lang_item_edit['spell_id'], $lang_item_edit['spell_id_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellid_3\" size=\"6\" maxlength=\"30\" value=\"{$item['spellid_3']}\" /></td>";
        unset($spelltrigger_2);
        $spelltrigger_3 = array(0 => "", 1 => "", 2 => "", 4 => "");
        $spelltrigger_3[$item['spelltrigger_3']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['spell_trigger'], $lang_item_edit['spell_trigger_desc']) . "</td>\n   <td><select name=\"spelltrigger_3\">\n    <option value=\"0\" {$spelltrigger_3[0]}>0: {$lang_item['spell_use']}</option>\n    <option value=\"1\" {$spelltrigger_3[1]}>1: {$lang_item['spell_equip']}</option>\n    <option value=\"2\" {$spelltrigger_3[2]}>2: {$lang_item['spell_coh']}</option>\n    <option value=\"4\" {$spelltrigger_3[4]}>4: {$lang_item['soul_stone']}</option>\n    </select></td>\n   <td>" . makeinfocell($lang_item_edit['spell_charges'], $lang_item_edit['spell_charges_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcharges_3\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcharges_3']}\" /></td>\n</tr>\n<tr>\n   <td>" . makeinfocell($lang_item_edit['spell_cooldown'], $lang_item_edit['spell_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcooldown_3\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcooldown_3']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category'], $lang_item_edit['spell_category_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategory_3\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategory_3']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category_cooldown'], $lang_item_edit['spell_category_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategorycooldown_3\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategorycooldown_3']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['ppm_rate'], $lang_item_edit['ppm_rate_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellppmRate_3\" size=\"6\" maxlength=\"30\" value=\"{$item['spellppmRate_3']}\" /></td>\n</tr>\n<tr><td colspan=\"6\" class=\"hidden\"></td></tr>\n<tr>\n   <td colspan=\"2\">{$lang_item_edit['item_spell']} 4</td>\n   <td>" . makeinfocell($lang_item_edit['spell_id'], $lang_item_edit['spell_id_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellid_4\" size=\"6\" maxlength=\"30\" value=\"{$item['spellid_4']}\" /></td>";
        unset($spelltrigger_3);
        $spelltrigger_4 = array(0 => "", 1 => "", 2 => "", 4 => "");
        $spelltrigger_4[$item['spelltrigger_4']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['spell_trigger'], $lang_item_edit['spell_trigger_desc']) . "</td>\n   <td><select name=\"spelltrigger_4\">\n    <option value=\"0\" {$spelltrigger_4[0]}>0: {$lang_item['spell_use']}</option>\n    <option value=\"1\" {$spelltrigger_4[1]}>1: {$lang_item['spell_equip']}</option>\n    <option value=\"2\" {$spelltrigger_4[2]}>2: {$lang_item['spell_coh']}</option>\n    <option value=\"4\" {$spelltrigger_4[4]}>4: {$lang_item['soul_stone']}</option>\n    </select></td>\n   <td>" . makeinfocell($lang_item_edit['spell_charges'], $lang_item_edit['spell_charges_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcharges_4\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcharges_4']}\" /></td>\n</tr>\n<tr>\n   <td>" . makeinfocell($lang_item_edit['spell_cooldown'], $lang_item_edit['spell_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcooldown_4\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcooldown_4']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category'], $lang_item_edit['spell_category_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategory_4\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategory_4']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category_cooldown'], $lang_item_edit['spell_category_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategorycooldown_4\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategorycooldown_4']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['ppm_rate'], $lang_item_edit['ppm_rate_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellppmRate_4\" size=\"6\" maxlength=\"30\" value=\"{$item['spellppmRate_4']}\" /></td>\n</tr>\n<tr><td colspan=\"6\" class=\"hidden\"></td></tr>\n<tr>\n   <td colspan=\"2\">{$lang_item_edit['item_spell']} 5</td>\n   <td>" . makeinfocell($lang_item_edit['spell_id'], $lang_item_edit['spell_id_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellid_5\" size=\"6\" maxlength=\"30\" value=\"{$item['spellid_5']}\" /></td>";
        unset($spelltrigger_4);
        $spelltrigger_5 = array(0 => "", 1 => "", 2 => "", 4 => "");
        $spelltrigger_5[$item['spelltrigger_5']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['spell_trigger'], $lang_item_edit['spell_trigger_desc']) . "</td>\n   <td><select name=\"spelltrigger_5\">\n    <option value=\"0\" {$spelltrigger_5[0]}>0: {$lang_item['spell_use']}</option>\n    <option value=\"1\" {$spelltrigger_5[1]}>1: {$lang_item['spell_equip']}</option>\n    <option value=\"2\" {$spelltrigger_5[2]}>2: {$lang_item['spell_coh']}</option>\n    <option value=\"4\" {$spelltrigger_5[4]}>4: {$lang_item['soul_stone']}</option>\n    </select></td>\n   <td>" . makeinfocell($lang_item_edit['spell_charges'], $lang_item_edit['spell_charges_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcharges_5\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcharges_5']}\" /></td>\n</tr>\n<tr>\n   <td>" . makeinfocell($lang_item_edit['spell_cooldown'], $lang_item_edit['spell_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcooldown_5\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcooldown_5']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category'], $lang_item_edit['spell_category_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategory_5\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategory_5']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['spell_category_cooldown'], $lang_item_edit['spell_category_cooldown_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellcategorycooldown_5\" size=\"6\" maxlength=\"30\" value=\"{$item['spellcategorycooldown_5']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['ppm_rate'], $lang_item_edit['ppm_rate_desc']) . "</td>\n   <td><input type=\"text\" name=\"spellppmRate_5\" size=\"6\" maxlength=\"30\" value=\"{$item['spellppmRate_5']}\" /></td>\n</tr>\n\n</table>\n    </div>";
        unset($spelltrigger_5);
        $output .= "<div id=\"pane6\">\n    <br /><br /><table class=\"lined\" style=\"width: 720px;\">\n   <tr>";
        $AllowableClass = array(-1 => "", 1 => "", 2 => "", 4 => "", 8 => "", 16 => "", 32 => "", 64 => "", 128 => "", 256 => "", 512 => "", 1024 => "");
        if ($item['AllowableClass'] == -1) {
            $AllowableClass[-1] = " selected=\"selected\" ";
        } else {
            if ($item['AllowableClass'] & 1) {
                $AllowableClass[1] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 2) {
                $AllowableClass[2] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 4) {
                $AllowableClass[4] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 8) {
                $AllowableClass[8] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 16) {
                $AllowableClass[16] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 32) {
                $AllowableClass[32] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 64) {
                $AllowableClass[64] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 128) {
                $AllowableClass[128] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 256) {
                $AllowableClass[256] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 512) {
                $AllowableClass[512] = " selected=\"selected\" ";
            }
            if ($item['AllowableClass'] & 1024) {
                $AllowableClass[1024] = " selected=\"selected\" ";
            }
        }
        $output .= "<td>" . makeinfocell($lang_item_edit['allow_class'], $lang_item_edit['allow_class_desc']) . "</td>\n   <td><select multiple=\"multiple\" name=\"AllowableClass[]\" size=\"5\">\n    <option value=\"-1\" {$AllowableClass[-1]}>-1 - {$lang_item_edit['all']}</option>\n    <option value=\"1\" {$AllowableClass[1]}>1 - {$lang_id_tab['warrior']}</option>\n    <option value=\"2\" {$AllowableClass[2]}>2 - {$lang_id_tab['paladin']}</option>\n    <option value=\"4\" {$AllowableClass[4]}>4 - {$lang_id_tab['hunter']}</option>\n    <option value=\"8\" {$AllowableClass[8]}>8 - {$lang_id_tab['rogue']}</option>\n    <option value=\"16\" {$AllowableClass[16]}>16 - {$lang_id_tab['priest']}</option>\n    <option value=\"32\" {$AllowableClass[32]}>32 - FUTURE_1</option>\n    <option value=\"64\" {$AllowableClass[64]}>64 - {$lang_id_tab['shaman']}</option>\n    <option value=\"128\" {$AllowableClass[128]}>128 - {$lang_id_tab['mage']}</option>\n    <option value=\"256\" {$AllowableClass[256]}>256 - {$lang_id_tab['warlock']}</option>\n    <option value=\"512\" {$AllowableClass[512]}>512 - FUTURE_2</option>\n    <option value=\"1024\" {$AllowableClass[1024]}>1024 - {$lang_id_tab['druid']}</option>\n     </select></td>";
        unset($AllowableClass);
        $AllowableRace = array(-1 => "", 1 => "", 2 => "", 4 => "", 8 => "", 16 => "", 32 => "", 64 => "", 128 => "", 256 => "", 512 => "");
        if ($item['AllowableRace'] == -1) {
            $AllowableRace[-1] = " selected=\"selected\" ";
        } else {
            if ($item['AllowableRace'] & 1) {
                $AllowableRace[1] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 2) {
                $AllowableRace[2] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 4) {
                $AllowableRace[4] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 8) {
                $AllowableRace[8] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 16) {
                $AllowableRace[16] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 32) {
                $AllowableRace[32] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 64) {
                $AllowableRace[64] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 128) {
                $AllowableRace[128] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 256) {
                $AllowableRace[256] = " selected=\"selected\" ";
            }
            if ($item['AllowableRace'] & 512) {
                $AllowableRace[512] = " selected=\"selected\" ";
            }
        }
        $output .= "<td>" . makeinfocell($lang_item_edit['allow_race'], $lang_item_edit['allow_race_desc']) . "</td>\n   <td><select multiple=\"multiple\" name=\"AllowableRace[]\" size=\"5\">\n    <option value=\"-1\" {$AllowableRace[-1]}>-1 - {$lang_item_edit['all']}</option>\n    <option value=\"1\" {$AllowableRace[1]}>1 - {$lang_id_tab['human']}</option>\n    <option value=\"2\" {$AllowableRace[2]}>2 - {$lang_id_tab['orc']}</option>\n    <option value=\"4\" {$AllowableRace[4]}>4 - {$lang_id_tab['dwarf']}</option>\n    <option value=\"8\" {$AllowableRace[8]}>8 - {$lang_id_tab['nightelf']}</option>\n    <option value=\"16\" {$AllowableRace[16]}>16 - {$lang_id_tab['undead']}</option>\n    <option value=\"32\" {$AllowableRace[32]}>32 - {$lang_id_tab['tauren']}</option>\n    <option value=\"64\" {$AllowableRace[64]}>64 - {$lang_id_tab['gnome']}</option>\n    <option value=\"128\" {$AllowableRace[128]}>128 - {$lang_id_tab['troll']}</option>\n    <option value=\"256\" {$AllowableRace[256]}>256 - {$lang_id_tab['draenei']}</option>\n    <option value=\"512\" {$AllowableRace[512]}>512 - {$lang_id_tab['bloodelf']}</option>\n     </select></td>\n</tr>\n<tr>\n   <td>" . makeinfocell($lang_item_edit['req_skill'], $lang_item_edit['req_skill_desc']) . "</td>\n   <td><input type=\"text\" name=\"RequiredSkill\" size=\"15\" maxlength=\"30\" value=\"{$item['RequiredSkill']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['req_skill_rank'], $lang_item_edit['req_skill_rank_desc']) . "</td>\n   <td><input type=\"text\" name=\"RequiredSkillRank\" size=\"15\" maxlength=\"30\" value=\"{$item['RequiredSkillRank']}\" /></td>\n</tr>\n<tr>\n   <td>" . makeinfocell($lang_item_edit['req_spell'], $lang_item_edit['req_spell_desc']) . "</td>\n   <td><input type=\"text\" name=\"requiredspell\" size=\"15\" maxlength=\"30\" value=\"{$item['requiredspell']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['req_honor_rank'], $lang_item_edit['req_honor_rank_desc']) . "</td>\n   <td><input type=\"text\" name=\"requiredhonorrank\" size=\"15\" maxlength=\"30\" value=\"{$item['requiredhonorrank']}\" /></td>\n</tr>\n<tr>\n   <td>" . makeinfocell($lang_item_edit['req_rep_faction'], $lang_item_edit['req_rep_faction_desc']) . "</td>\n   <td><input type=\"text\" name=\"RequiredReputationFaction\" size=\"15\" maxlength=\"30\" value=\"{$item['RequiredReputationFaction']}\" /></td>";
        unset($AllowableRace);
        $RequiredReputationRank = array(0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "");
        $RequiredReputationRank[$item['RequiredReputationRank']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['req_rep_rank'], $lang_item_edit['req_rep_rank_desc']) . "</td>\n      <td><select name=\"RequiredReputationRank\">\n    <option value=\"0\" {$RequiredReputationRank[0]}>0 - {$lang_item_edit['hated']}</option>\n    <option value=\"1\" {$RequiredReputationRank[1]}>1 - {$lang_item_edit['hostile']}</option>\n    <option value=\"2\" {$RequiredReputationRank[2]}>2 - {$lang_item_edit['unfriendly']}</option>\n    <option value=\"3\" {$RequiredReputationRank[3]}>3 - {$lang_item_edit['neutral']}</option>\n    <option value=\"4\" {$RequiredReputationRank[4]}>4 - {$lang_item_edit['friendly']}</option>\n    <option value=\"5\" {$RequiredReputationRank[5]}>5 - {$lang_item_edit['honored']}</option>\n    <option value=\"6\" {$RequiredReputationRank[6]}>6 - {$lang_item_edit['reverted']}</option>\n    <option value=\"7\" {$RequiredReputationRank[7]}>7 - {$lang_item_edit['exalted']}</option>\n     </select></td>\n</tr>\n<tr>\n   <td colspan=\"2\">" . makeinfocell($lang_item_edit['req_city_rank'], $lang_item_edit['req_city_rank_desc']) . "</td>\n   <td colspan=\"2\"><input type=\"text\" name=\"RequiredCityRank\" size=\"15\" maxlength=\"30\" value=\"{$item['RequiredCityRank']}\" /></td>\n</tr>\n\n   </table><br /><br />\n    </div>";
        unset($RequiredReputationRank);
        $output .= "<div id=\"pane7\">\n    <br /><br /><table class=\"lined\" style=\"width: 720px;\">\n<tr>";
        $socketColor_1 = array(0 => "", 1 => "", 2 => "", 4 => "", 8 => "");
        $socketColor_1[$item['socketColor_1']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['socket_color'] . " 1", $lang_item_edit['socket_color_desc']) . "</td>\n      <td><select name=\"socketColor_1\">\n        <option value=\"0\" {$socketColor_1[0]}>0: {$lang_item['none']}</option>\n        <option value=\"1\" {$socketColor_1[1]}>1: {$lang_item['socket_meta']}</option>\n        <option value=\"2\" {$socketColor_1[2]}>2: {$lang_item['socket_red']}</option>\n        <option value=\"4\" {$socketColor_1[4]}>4: {$lang_item['socket_yellow']}</option>\n        <option value=\"8\" {$socketColor_1[8]}>8: {$lang_item['socket_blue']}</option>\n      </select></td>\n   <td>" . makeinfocell($lang_item_edit['socket_content'] . " 1", $lang_item_edit['socket_content_desc']) . "</td>\n   <td><input type=\"text\" name=\"socketContent_1\" size=\"15\" maxlength=\"10\" value=\"{$item['socketContent_1']}\" /></td>\n</tr>\n<tr>";
        unset($socketColor_1);
        $socketColor_2 = array(0 => "", 1 => "", 2 => "", 4 => "", 8 => "");
        $socketColor_2[$item['socketColor_2']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['socket_color'] . " 2", $lang_item_edit['socket_color_desc']) . "</td>\n      <td><select name=\"socketColor_2\">\n        <option value=\"0\" {$socketColor_2[0]}>0: {$lang_item['none']}</option>\n        <option value=\"1\" {$socketColor_2[1]}>1: {$lang_item['socket_meta']}</option>\n        <option value=\"2\" {$socketColor_2[2]}>2: {$lang_item['socket_red']}</option>\n        <option value=\"4\" {$socketColor_2[4]}>4: {$lang_item['socket_yellow']}</option>\n        <option value=\"8\" {$socketColor_2[8]}>8: {$lang_item['socket_blue']}</option>\n      </select></td>\n\n   <td>" . makeinfocell($lang_item_edit['socket_content'] . " 2", $lang_item_edit['socket_content_desc']) . "</td>\n   <td><input type=\"text\" name=\"socketContent_2\" size=\"15\" maxlength=\"10\" value=\"{$item['socketContent_2']}\" /></td>\n</tr>\n<tr>";
        unset($socketColor_2);
        $socketColor_3 = array(0 => "", 1 => "", 2 => "", 4 => "", 8 => "");
        $socketColor_3[$item['socketColor_3']] = " selected=\"selected\" ";
        $output .= "<td>" . makeinfocell($lang_item_edit['socket_color'] . " 3", $lang_item_edit['socket_color_desc']) . "</td>\n      <td><select name=\"socketColor_3\">\n        <option value=\"0\" {$socketColor_3[0]}>0: {$lang_item['none']}</option>\n        <option value=\"1\" {$socketColor_3[1]}>1: {$lang_item['socket_meta']}</option>\n        <option value=\"2\" {$socketColor_3[2]}>2: {$lang_item['socket_red']}</option>\n        <option value=\"4\" {$socketColor_3[4]}>4: {$lang_item['socket_yellow']}</option>\n        <option value=\"8\" {$socketColor_3[8]}>8: {$lang_item['socket_blue']}</option>\n      </select></td>\n\n   <td>" . makeinfocell($lang_item_edit['socket_content'] . " 3", $lang_item_edit['socket_content_desc']) . "</td>\n   <td><input type=\"text\" name=\"socketContent_3\" size=\"15\" maxlength=\"10\" value=\"{$item['socketContent_3']}\" /></td>\n</tr>\n\n<tr>\n   <td>" . makeinfocell($lang_item_edit['socket_bonus'], $lang_item_edit['socket_bonus_desc']) . "</td>\n   <td><input type=\"text\" name=\"socketBonus\" size=\"15\" maxlength=\"10\" value=\"{$item['socketBonus']}\" /></td>\n\n   <td>" . makeinfocell($lang_item_edit['gem_properties'], $lang_item_edit['gem_properties_desc']) . "</td>\n   <td><input type=\"text\" name=\"GemProperties\" size=\"15\" maxlength=\"10\" value=\"{$item['GemProperties']}\" /></td>\n</tr>\n\n   </table><br /><br />\n    </div>";
        $output .= "<div id=\"pane8\">\n    <br /><br /><table class=\"lined\" style=\"width: 720px;\">\n  <tr class=\"large_bold\"><td colspan=\"5\" class=\"hidden\" align=\"left\">{$lang_item_edit['dropped_by']}: {$lang_item_edit['top_x']}</td></tr>\n  <tr>\n    <th width=\"1%\">ID</th>\n    <th width=\"35%\">{$lang_item_edit['mob_name']}</th>\n    <th width=\"10%\">{$lang_item_edit['mob_level']}</th>\n    <th width=\"25%\">{$lang_item_edit['mob_drop_chance']}</th>\n    <th width=\"25%\">{$lang_item_edit['mob_quest_drop_chance']}</th>\n  </tr>";
        $result2 = $sql->query("SELECT entry,ChanceOrQuestChance,`groupid` FROM creature_loot_template WHERE item = {$item['entry']} ORDER BY `groupid`,ChanceOrQuestChance DESC LIMIT 5");
        while ($info = $sql->fetch_row($result2)) {
            $result3 = $sql->query("SELECT creature_template.entry,IFNULL(" . ($deplang != 0 ? "name_loc{$deplang}" : "NULL") . ",`name`) as name,maxlevel FROM creature_template LEFT JOIN locales_creature ON creature_template.entry = locales_creature.entry WHERE lootid = {$info[0]} LIMIT 1");
            while ($mob = $sql->fetch_row($result3)) {
                $output .= "<tr><td>";
                if ($user_lvl >= $action_permission['delete']) {
                    $output .= "<a class=\"tooltip\" href=\"creature.php?action=edit&amp;entry={$mob['0']}&amp;error=4\" target=\"_blank\">{$mob['0']}</a>";
                } else {
                    $output .= "{$mob['0']}";
                }
                $output .= "</td>\n          <td><a class=\"tooltip\" href=\"{$creature_datasite}{$mob['0']}\" target=\"_blank\">{$mob['1']}</a></td>\n          <td>{$mob['2']}</td>\n          <td>{$info['1']}%</td>\n          <td>{$info['2']}%</td></tr>";
            }
        }
        $result2 = $sql->query("SELECT creature_template.entry,IFNULL(" . ($deplang != 0 ? "name_loc{$deplang}" : "NULL") . ",`name`) as name,maxlevel FROM creature_template LEFT JOIN locales_creature ON creature_template.entry = locales_creature.entry WHERE creature_template.entry IN (SELECT entry FROM npc_vendor WHERE item = {$item['entry']}) ORDER BY maxlevel DESC LIMIT 5");
        if ($sql->num_rows($result2)) {
            $output .= "<tr class=\"large_bold\"><td colspan=\"4\" class=\"hidden\" align=\"left\">{$lang_item_edit['sold_by']}: {$lang_item_edit['limit_x']}</td></tr>";
            while ($mob = $sql->fetch_row($result2)) {
                $output .= "<tr>\n        <td width=\"10%\">";
                if ($user_lvl >= $action_permission['delete']) {
                    $output .= "<a class=\"tooltip\" href=\"creature.php?action=edit&amp;entry={$mob['0']}&amp;error=4\" target=\"_blank\">{$mob['0']}</a>";
                } else {
                    $output .= "{$mob['0']}";
                }
                $output .= "\n        <td width=\"10%\">{$mob['2']}</td>\n        <td width=\"80%\" colspan=\"2\" align=\"left\">\n          <a class=\"tooltip\" href=\"{$creature_datasite}{$mob['0']}\" target=\"_blank\">{$mob['1']}</a></td>\n        </td></tr>";
            }
        }
        $result2 = $sql->query("SELECT quest_template.entry,IFNULL(" . ($deplang != 0 ? "title_loc{$deplang}" : "NULL") . ",`title`) as title,QuestLevel FROM quest_template LEFT JOIN locales_quest ON quest_template.entry = locales_quest.entry WHERE ( SrcItemId = {$item['entry']} OR ReqItemId1 = {$item['entry']} OR\n              ReqItemId2 = {$item['entry']} OR ReqItemId3 = {$item['entry']} OR ReqItemId4 = {$item['entry']} OR RewItemId1 = {$item['entry']} OR\n              RewItemId2 = {$item['entry']} OR RewItemId3 = {$item['entry']} OR RewItemId4 = {$item['entry']} ) ORDER BY QuestLevel DESC");
        if ($sql->num_rows($result2)) {
            $output .= "<tr class=\"large_bold\"><td colspan=\"4\" class=\"hidden\" align=\"left\">{$lang_item_edit['involved_in_quests']}:</td></tr>";
            while ($quest = $sql->fetch_row($result2)) {
                $output .= "<tr><td width=\"20%\">id: {$quest['0']}</td>\n        <td width=\"80%\" colspan=\"3\" align=\"left\"><a class=\"tooltip\" href=\"{$quest_datasite}{$quest['0']}\" target=\"_blank\">({$quest['2']}) {$quest['1']}</a></td></tr>";
            }
        }
        $result2 = $sql->query("SELECT quest_template.entry,IFNULL(" . ($deplang != 0 ? "title_loc{$deplang}" : "NULL") . ",`title`) as title,QuestLevel FROM quest_template LEFT JOIN locales_quest ON quest_template.entry = locales_quest.entry WHERE ( RewChoiceItemId1 = {$item['entry']} OR RewChoiceItemId2 = {$item['entry']} OR\n              RewChoiceItemId3 = {$item['entry']} OR RewChoiceItemId4 = {$item['entry']} OR RewChoiceItemId5 = {$item['entry']} OR RewChoiceItemId6 = {$item['entry']} )\n              ORDER BY QuestLevel DESC");
        if ($sql->num_rows($result2)) {
            $output .= "<tr class=\"large_bold\"><td colspan=\"4\" class=\"hidden\" align=\"left\">{$lang_item_edit['reward_from_quest']}:</td></tr>";
            while ($quest = $sql->fetch_row($result2)) {
                $output .= "<tr><td width=\"20%\">id: {$quest['0']}</td>\n        <td width=\"80%\" colspan=\"3\" align=\"left\"><a class=\"tooltip\" href=\"{$quest_datasite}{$quest['0']}\" target=\"_blank\">({$quest['2']}) {$quest['1']}</a></td></tr>";
            }
        }
        $output .= "</tr></table><br /><br />\n    </div>";
        if ($item['DisenchantID']) {
            $output .= "<div id=\"pane9\">\n  <br /><br /><table class=\"lined\" style=\"width: 720px;\">\n  <tr class=\"large_bold\"><td colspan=\"6\" class=\"hidden\" align=\"left\">{$lang_item_edit['disenchant_templ']}: {$item['DisenchantID']}</td></tr>\n  <tr><td colspan=\"6\">";
            $cel_counter = 0;
            $row_flag = 0;
            $output .= "<table class=\"hidden\" align=\"center\"><tr>";
            $result1 = $sql->query("SELECT item,ChanceOrQuestChance,`groupid`,mincountOrRef,maxcount,lootcondition,condition_value1, condition_value2 FROM disenchant_loot_template WHERE entry = {$item['DisenchantID']} ORDER BY ChanceOrQuestChance DESC");
            while ($item = $sql->fetch_row($result1)) {
                $cel_counter++;
                $tooltip = get_item_name($item[0]) . " ({$item['0']})<br />{$lang_item_edit['drop_chance']}: {$item['1']}%<br />{$lang_item_edit['quest_drop_chance']}: {$item['2']}%<br />{$lang_item_edit['drop_chance']}: {$item['3']}-{$item['4']}<br />{$lang_item_edit['lootcondition']}: {$item['5']}<br />{$lang_item_edit['condition_value1']}: {$item['6']}<br />{$lang_item_edit['condition_value2']}: {$item['7']}";
                $output .= "<td>";
                $output .= maketooltip("<img src=\"" . get_item_icon($item[0]) . "\" class=\"icon_border\" alt=\"\" />", "{$item_datasite}{$item['0']}", $tooltip, "item_tooltip");
                $output .= "<br /><input type=\"checkbox\" name=\"del_de_items[]\" value=\"{$item['0']}\" /></td>";
                if ($cel_counter >= 16) {
                    $cel_counter = 0;
                    $output .= "</tr><tr>";
                    $row_flag++;
                }
            }
            if ($row_flag) {
                $output .= "<td colspan=\"" . (16 - $cel_counter) . "\"></td>";
            }
            $output .= "</td></tr></table>\n </td>\n</tr>\n<tr class=\"large_bold\"><td colspan=\"6\" class=\"hidden\" align=\"left\">{$lang_item_edit['add_items_to_templ']}:</td></tr>\n<tr>\n<td>" . makeinfocell($lang_item_edit['loot_item_id'], $lang_item_edit['loot_item_id_desc']) . "</td>\n  <td><input type=\"text\" name=\"de_item\" size=\"8\" maxlength=\"10\" value=\"\" /></td>\n<td>" . makeinfocell($lang_item_edit['loot_drop_chance'], $lang_item_edit['loot_drop_chance_desc']) . "</td>\n  <td><input type=\"text\" name=\"de_ChanceOrQuestChance\" size=\"8\" maxlength=\"11\" value=\"0\" /></td>\n<td>" . makeinfocell($lang_item_edit['loot_quest_drop_chance'], $lang_item_edit['loot_quest_drop_chance_desc']) . "</td>\n  <td><input type=\"text\" name=\"de_groupid\" size=\"8\" maxlength=\"10\" value=\"0\" /></td>\n</tr>\n<tr>\n<td>" . makeinfocell($lang_item_edit['min_count'], $lang_item_edit['min_count_desc']) . "</td>\n  <td><input type=\"text\" name=\"de_mincountOrRef\" size=\"8\" maxlength=\"3\" value=\"1\" /></td>\n<td>" . makeinfocell($lang_item_edit['max_count'], $lang_item_edit['max_count_desc']) . "</td>\n  <td><input type=\"text\" name=\"de_maxcount\" size=\"8\" maxlength=\"3\" value=\"1\" /></td>\n</tr>\n<tr>\n<td>" . makeinfocell($lang_item_edit['lootcondition'], $lang_item_edit['lootcondition_desc']) . "</td>\n  <td><input type=\"text\" name=\"de_lootcondition\" size=\"8\" maxlength=\"3\" value=\"0\" /></td>\n<td>" . makeinfocell($lang_item_edit['condition_value1'], $lang_item_edit['condition_value1_desc']) . "</td>\n  <td><input type=\"text\" name=\"de_condition_value1\" size=\"8\" maxlength=\"3\" value=\"0\" /></td>\n<td>" . makeinfocell($lang_item_edit['condition_value2'], $lang_item_edit['condition_value2_desc']) . "</td>\n  <td><input type=\"text\" name=\"de_condition_value2\" size=\"8\" maxlength=\"3\" value=\"0\" /></td>\n</tr>\n</table>\n</div>";
        }
        $output .= "</div>\n</div>\n<br />\n</form>\n\n<script type=\"text/javascript\">setupPanes(\"container\", \"tab1\")</script>";
        unset($socketColor_3);
        $output .= "\n          <table class=\"hidden\">\n            <tr>\n              <td>";
        if ($user_lvl >= $action_permission['delete']) {
            makebutton($lang_item_edit['del_item'], "item.php?action=delete&amp;entry={$entry}\" type=\"wrn", 180);
        }
        $output .= "\n              </td>\n              <td>";
        if ($user_lvl >= $action_permission['update']) {
            makebutton($lang_item_edit['update'], "javascript:do_submit('form1',0)\" type=\"wrn", 180);
        }
        $output .= "\n              </td>\n              <td>";
        if ($user_lvl >= $action_permission['insert']) {
            makebutton($lang_item_edit['export_sql'], "javascript:do_submit('form1',1)", 180);
        }
        $output .= "\n              </td>\n              <td>";
        makebutton($lang_global['back'], "javascript:window.history.back()", 130);
        $output .= "\n              </td>\n              <td>";
        makebutton($lang_item_edit['new_search'], "item.php", 130);
        $output .= "\n              </td>\n            </tr>\n          </table>\n        </center>\n";
    } else {
        error($lang_item_edit['item_not_found']);
        exit;
    }
}
Example #26
0
function backup_user(&$sqlr, &$sqlc)
{
    global $lang_global, $lang_user, $output, $realm_db, $characters_db, $realm_id, $user_lvl, $backup_dir, $action_permission;
    valid_login($action_permission['insert']);
    $sqlr = new SQL();
    $sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    if (isset($_GET['check'])) {
        $check = $sqlr->quote_smart($_GET['check']);
    } else {
        redirect("accounts.php?error=1");
    }
    require_once "libs/tab_lib.php";
    $subdir = "{$backup_dir}/accounts/" . date("m_d_y_H_i_s") . "_partial";
    mkdir($subdir, 0777);
    for ($t = 0; $t < count($check); $t++) {
        if ($check[$t] != "") {
            $query = $sqlr->query("SELECT id FROM account WHERE id = {$check[$t]}");
            $acc = $sqlr->fetch_array($query);
            $file_name_new = $acc[0] . "_{$realm_db['name']}.sql";
            $fp = fopen("{$subdir}/{$file_name_new}", 'w') or die($lang_backup['file_write_err']);
            fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$realm_db['name']};\n") or die(error($lang_backup['file_write_err']));
            fwrite($fp, "USE {$realm_db['name']};\n\n") or die($lang_backup['file_write_err']);
            foreach ($tab_backup_user_realmd as $value) {
                $acc_query = $sqlr->query("SELECT * FROM {$value['0']} WHERE {$value['1']} = {$acc['0']}");
                $num_fields = $sqlr->num_fields($acc_query);
                $numrow = $sqlr->num_rows($acc_query);
                $result = "-- Dumping data for {$value['0']} " . date("m.d.y_H.i.s") . "\n";
                $result .= "LOCK TABLES {$value['0']} WRITE;\n";
                $result .= "DELETE FROM {$value['0']} WHERE {$value['1']} = {$acc['0']};\n";
                if ($numrow) {
                    $result .= "INSERT INTO {$value['0']} (";
                    for ($count = 0; $count < $num_fields; $count++) {
                        $result .= "`" . $sqlr->field_name($acc_query, $count) . "`";
                        if ($count < $num_fields - 1) {
                            $result .= ",";
                        }
                    }
                    $result .= ") VALUES \n";
                    for ($i = 0; $i < $numrow; $i++) {
                        $result .= "\t(";
                        $row = $sqlr->fetch_row($acc_query);
                        for ($j = 0; $j < $num_fields; $j++) {
                            $row[$j] = addslashes($row[$j]);
                            $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
                            if (isset($row[$j])) {
                                if ($sqlr->field_type($acc_query, $j) == "int") {
                                    $result .= "{$row[$j]}";
                                } else {
                                    $result .= "'{$row[$j]}'";
                                }
                            } else {
                                $result .= "''";
                            }
                            if ($j < $num_fields - 1) {
                                $result .= ",";
                            }
                        }
                        if ($i < $numrow - 1) {
                            $result .= "),\n";
                        }
                    }
                    $result .= ");\n";
                }
                $result .= "UNLOCK TABLES;\n";
                $result .= "\n";
                fwrite($fp, $result) or die(error($lang_backup['file_write_err']));
            }
            fclose($fp);
            foreach ($characters_db as $db) {
                $file_name_new = $acc[0] . "_{$db[$realm_id]['name']}.sql";
                $fp = fopen("{$subdir}/{$file_name_new}", 'w') or die(error($lang_backup['file_write_err']));
                fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$db[$realm_id]['name']};\n") or die(error($lang_backup['file_write_err']));
                fwrite($fp, "USE {$db[$realm_id]['name']};\n\n") or die(error($lang_backup['file_write_err']));
                $all_char_query = $sqlc->query("SELECT guid,name FROM `characters` WHERE account = {$acc['0']}");
                while ($char = $sqlc->fetch_array($all_char_query)) {
                    fwrite($fp, "-- Dumping data for character {$char['1']}\n") or die(error($lang_backup['file_write_err']));
                    foreach ($tab_backup_user_characters as $value) {
                        $char_query = $sqlc->query("SELECT * FROM {$value['0']} WHERE {$value['1']} = {$char['0']}");
                        $num_fields = $sqlc->num_fields($char_query);
                        $numrow = $sqlc->num_rows($char_query);
                        $result = "LOCK TABLES {$value['0']} WRITE;\n";
                        $result .= "DELETE FROM {$value['0']} WHERE {$value['1']} = {$char['0']};\n";
                        if ($numrow) {
                            $result .= "INSERT INTO {$value['0']} (";
                            for ($count = 0; $count < $num_fields; $count++) {
                                $result .= "`" . $sqlc->field_name($char_query, $count) . "`";
                                if ($count < $num_fields - 1) {
                                    $result .= ",";
                                }
                            }
                            $result .= ") VALUES \n";
                            for ($i = 0; $i < $numrow; $i++) {
                                $result .= "\t(";
                                $row = $sqlc->fetch_row($char_query);
                                for ($j = 0; $j < $num_fields; $j++) {
                                    $row[$j] = addslashes($row[$j]);
                                    $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
                                    if (isset($row[$j])) {
                                        if ($sqlc->field_type($char_query, $j) == "int") {
                                            $result .= "{$row[$j]}";
                                        } else {
                                            $result .= "'{$row[$j]}'";
                                        }
                                    } else {
                                        $result .= "''";
                                    }
                                    if ($j < $num_fields - 1) {
                                        $result .= ",";
                                    }
                                }
                                if ($i < $numrow - 1) {
                                    $result .= "),\n";
                                }
                            }
                            $result .= ");\n";
                        }
                        $result .= "UNLOCK TABLES;\n";
                        $result .= "\n";
                        fwrite($fp, $result) or die(error($lang_backup['file_write_err']));
                    }
                }
                fclose($fp);
            }
        }
    }
    redirect("accounts.php?error=15");
}
Example #27
0
function edit_user()
{
    global $lang_global, $lang_user, $output, $realm_db, $characters_db, $realm_id, $mmfpm_db, $user_lvl, $user_name, $gm_level_arr, $action_permission, $expansion_select, $developer_test_mode, $multi_realm_mode, $server;
    $active_realm_id_pq = "active_realm_id";
    if (empty($_GET['id'])) {
        redirect("user.php?error=10");
    }
    $sqlr = new SQL();
    $sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    $sqlm = new SQL();
    $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
    $sqlc = new SQL();
    $sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
    $id = $sqlr->quote_smart($_GET['id']);
    $result = $sqlr->query("SELECT id,username,gmlevel,email,joindate,last_ip,failed_logins,locked,last_login,{$active_realm_id_pq},expansion FROM account WHERE id = '{$id}'");
    $data = $sqlr->fetch_assoc($result);
    $refguid = $sqlm->fetch_assoc($sqlm->query('SELECT InvitedBy FROM mm_point_system_invites WHERE PlayersAccount = ' . $data['id'] . ''));
    $refguid = $refguid['InveitedBy'];
    $referred_by = $sqlc->fetch_assoc($sqlc->query("SELECT name FROM characters WHERE guid = '{$refguid}'"));
    unset($refguid);
    $referred_by = $referred_by['name'];
    if ($sqlr->num_rows($result)) {
        $output .= '
        <center>
          <script type="text/javascript" src="libs/js/sha1.js"></script>
          <script type="text/javascript">
            // <![CDATA[
              function do_submit_data ()
              {
                if ((document.form.username.value != "' . $data['username'] . '") && (document.form.new_pass.value == "******"))
                {
                  alert("If you are changing Username, The password must be changed too.");
                  return;
                }
                else
                {
                  document.form.pass.value = hex_sha1(document.form.username.value.toUpperCase()+":"+document.form.new_pass.value.toUpperCase());
                  document.form.new_pass.value = "0";
                  do_submit();
                }
              }
            // ]]>
          </script>
          <fieldset style="width: 550px;">
            <legend>' . $lang_user['edit_acc'] . '</legend>
            <form method="post" action="user.php?action=doedit_user" name="form">
            <input type="hidden" name="pass" value="" maxlength="256" />
            <input type="hidden" name="id" value="' . $id . '" />
            <table class="flat">
              <tr>
                <td>' . $lang_user['id'] . '</td>
                <td>' . $data['id'] . '</td>
              </tr>
              <tr>
                <td>' . $lang_user['username'] . '</td>';
        if ($user_lvl >= $action_permission['update']) {
            $output .= '
                <td><input type="text" name="username" size="42" maxlength="15" value="' . $data['username'] . '" /></td>';
        } else {
            $output .= '
                <td>' . $data['username'] . '</td>';
        }
        $output .= '
              </tr>
              <tr>
                <td>' . $lang_user['password'] . '</td>';
        if ($user_lvl >= $action_permission['update']) {
            $output .= "\r\n                <td><input type=\"text\" name=\"new_pass\" size=\"42\" maxlength=\"40\" value=\"******\" /></td>";
        } else {
            $output .= "\r\n                <td>********</td>";
        }
        $output .= "\r\n              </tr>\r\n              <tr>\r\n                <td>{$lang_user['email']}</td>";
        if ($user_lvl >= $action_permission['update']) {
            $output .= '
                <td><input type="text" name="mail" size="42" maxlength="225" value="' . $data['email'] . '" /></td>';
        } else {
            $output .= "\r\n                <td>***@***.***</td>";
        }
        $output .= "\r\n              </tr>\r\n              <tr>\r\n                <td>{$lang_user['invited_by']}:</td>\r\n                <td>";
        if ($user_lvl >= $action_permission['update'] && !$referred_by != NULL) {
            $output .= "\r\n                  <input type=\"text\" name=\"referredby\" size=\"42\" maxlength=\"12\" value=\"{$referred_by}\" />";
        } else {
            $output .= "\r\n                  {$referred_by}";
        }
        $output .= "\r\n                </td>\r\n              </tr>\r\n              <tr>\r\n                <td>{$lang_user['gm_level_long']}</td>";
        if ($user_lvl >= $action_permission['update']) {
            $output .= "\r\n                <td>\r\n                  <select name=\"gmlevel\">";
            foreach ($gm_level_arr as $level) {
                if ($level[0] > -1 && $level[0] < $user_lvl) {
                    $output .= "\r\n                    <option value=\"{$level[0]}\" ";
                    if ($data['gmlevel'] == $level[0]) {
                        $output .= "selected=\"selected\" ";
                    }
                    $output .= ">{$level[1]}</option>";
                }
            }
            $output .= "\r\n                  </select>\r\n                </td>";
        } else {
            $output .= '
                <td>' . id_get_gm_level($data['gmlevel']) . ' ( ' . $data['gmlevel'] . ' )</td>';
        }
        $output .= '
              </tr>
              <tr>
                <td>' . $lang_user['join_date'] . '</td>
                <td>' . $data['joindate'] . '</td>
              </tr>
              <tr>
                <td>' . $lang_user['last_ip'] . '</td>';
        if ($user_lvl >= $action_permission['update']) {
            $output .= '
                <td>' . $data['last_ip'] . '<a href="banned.php?action=do_add_entry&amp;entry=' . $data['last_ip'] . '&amp;bantime=3600&amp;ban_type=ip_banned"> &lt;- ' . $lang_user['ban_this_ip'] . '</a></td>';
        } else {
            $output .= "\r\n                <td>***.***.***.***</td>";
        }
        $output .= "\r\n              </tr>\r\n              <tr>\r\n                <td>{$lang_user['banned']}</td>";
        $que = $sqlr->query("SELECT bandate, unbandate, bannedby, banreason FROM account_banned WHERE id = {$id}");
        if ($sqlr->num_rows($que)) {
            $banned = $sqlr->fetch_row($que);
            $ban_info = " From:" . date('d-m-Y G:i', $banned[0]) . " till:" . date('d-m-Y G:i', $banned[1]) . "<br />by {$banned['2']}";
            $ban_checked = " checked=\"checked\"";
        } else {
            $ban_checked = "";
            $ban_info = "";
            $banned[3] = "";
        }
        if ($user_lvl >= $action_permission['update']) {
            $output .= "\r\n                <td><input type=\"checkbox\" name=\"banned\" value=\"1\" {$ban_checked}/>{$ban_info}</td>";
        } else {
            $output .= "\r\n                <td>{$ban_info}</td>";
        }
        $output .= "\r\n              </tr>\r\n              <tr>\r\n                <td>{$lang_user['banned_reason']}</td>";
        if ($user_lvl >= $action_permission['update']) {
            $output .= "\r\n                <td><input type=\"text\" name=\"banreason\" size=\"42\" maxlength=\"255\" value=\"{$banned['3']}\" /></td>";
        } else {
            $output .= "\r\n                <td>{$banned['3']}</td>";
        }
        if ($expansion_select) {
            $output .= "\r\n              </tr>\r\n              <tr>";
            if ($user_lvl >= $action_permission['update']) {
                $output .= "\r\n                <td>{$lang_user['client_type']}</td>";
                $output .= "\r\n                <td>\r\n                  <select name=\"expansion\">";
                $output .= "\r\n                    <option value=\"0\">{$lang_user['classic']}</option>\r\n                    <option value=\"1\" ";
                if ($data['expansion'] == 1) {
                    $output .= "selected=\"selected\" ";
                }
                $output .= ">{$lang_user['tbc']}</option>\r\n                   <option value=\"2\" ";
                if ($data['expansion'] == 2) {
                    $output .= "selected=\"selected\" ";
                }
                $output .= ">{$lang_user['wotlk']}</option>\r\n                  </select>\r\n                </td>";
            } else {
                $output .= "\r\n                <td>{$lang_user['classic']}</td>";
            }
        }
        $output .= "\r\n              </tr>\r\n              <tr>\r\n                <td>{$lang_user['failed_logins_long']}</td>";
        if ($user_lvl >= $action_permission['update']) {
            $output .= '
                <td><input type="text" name="failed" size="42" maxlength="3" value="' . $data['failed_logins'] . '" /></td>';
        } else {
            $output .= '
                <td>' . $data['failed_logins'] . '</td>';
        }
        $output .= "\r\n              </tr>\r\n              <tr>\r\n                <td>{$lang_user['locked']}</td>";
        $lock_checked = $data['locked'] ? " checked=\"checked\"" : "";
        if ($user_lvl >= $action_permission['update']) {
            $output .= "\r\n                <td><input type=\"checkbox\" name=\"locked\" value=\"1\" {$lock_checked}/></td>";
        } else {
            $output .= "\r\n                <td></td>";
        }
        $output .= '
              </tr>
              <tr>
                <td>' . $lang_user['last_login'] . '</td>
                <td>' . $data['last_login'] . '</td>
              </tr>
              <tr>
                <td>' . $lang_user['online'] . '</td>';
        $output .= "\r\n                <td>" . ($data['active_realm_id'] ? $lang_global['yes'] : $lang_global['no']) . "</td>\r\n              </tr>";
        $query = $sqlr->query("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '{$id}'");
        $tot_chars = $sqlr->result($query, 0);
        $query = $sqlc->query("SELECT count(*) FROM `characters` WHERE account = {$id}");
        $chars_on_realm = $sqlc->result($query, 0);
        $output .= "\r\n              <tr>\r\n                <td>{$lang_user['tot_chars']}</td>\r\n                <td>{$tot_chars}</td>\r\n              </tr>";
        $realms = $sqlr->query("SELECT id, name FROM realmlist");
        if ($developer_test_mode && $multi_realm_mode && ($sqlr->num_rows($realms) > 1 && count($server) > 1 && count($characters_db) > 1)) {
            require_once "scripts/get_lib.php";
            while ($realm = $sqlr->fetch_array($realms)) {
                $sqlc->connect($characters_db[$realm[0]]['addr'], $characters_db[$realm[0]]['user'], $characters_db[$realm[0]]['pass'], $characters_db[$realm[0]]['name']);
                $query = $sqlc->query("SELECT count(*) FROM `characters` WHERE account = {$id}");
                $chars_on_realm = $sqlc->result($query, 0);
                $output .= "\r\n              <tr>\r\n                <td>{$lang_user['chars_on_realm']} " . get_realm_name($realm[0]) . "</td>\r\n                <td>{$chars_on_realm}</td>\r\n              </tr>";
                if ($chars_on_realm) {
                    $char_array = $sqlc->query("SELECT guid, name, race, class, level, gender\r\n          FROM `characters` WHERE account = {$id}");
                    while ($char = $sqlc->fetch_array($char_array)) {
                        $output .= "\r\n              <tr>\r\n                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'---></td>\r\n                <td>\r\n                      <a href=\"char.php?id={$char['0']}&amp;realm={$realm['0']}\">{$char['1']}  - <img src='img/c_icons/{$char[2]}-{$char[5]}.gif' onmousemove='toolTip(\"" . char_get_race_name($char[2]) . "\",\"item_tooltip\")' onmouseout='toolTip()' alt=\"\" />\r\n                      <img src='img/c_icons/{$char[3]}.gif' onmousemove='toolTip(\"" . char_get_class_name($char[3]) . "\",\"item_tooltip\")' onmouseout='toolTip()' alt=\"\"/> - lvl " . char_get_level_color($char[4]) . "</a>\r\n                </td>\r\n              </tr>";
                    }
                }
            }
        } else {
            $query = $sqlc->query("SELECT count(*) FROM `characters` WHERE account = {$id}");
            $chars_on_realm = $sqlc->result($query, 0);
            $output .= "\r\n              <tr>\r\n                <td>{$lang_user['chars_on_realm']}</td>\r\n                <td>{$chars_on_realm}</td>\r\n              </tr>";
            if ($chars_on_realm) {
                $char_array = $sqlc->query("SELECT guid,name,race,class, level, gender FROM `characters` WHERE account = {$id}");
                while ($char = $sqlc->fetch_array($char_array)) {
                    $output .= "\r\n                <tr>\r\n                  <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'---></td>\r\n                  <td>\r\n                    <a href=\"char.php?id={$char['0']}\">{$char['1']}  - <img src='img/c_icons/{$char[2]}-{$char[5]}.gif' onmousemove='toolTip(\"" . char_get_race_name($char[2]) . "\",\"item_tooltip\")' onmouseout='toolTip()' alt=\"\" />\r\n                    <img src='img/c_icons/{$char[3]}.gif' onmousemove='toolTip(\"" . char_get_class_name($char[3]) . "\",\"item_tooltip\")' onmouseout='toolTip()' alt=\"\"/> - lvl " . char_get_level_color($char[4]) . "</a>\r\n                  </td>\r\n                </tr>";
                }
            }
        }
        $output .= "\r\n              <tr>\r\n                <td>";
        if ($user_lvl >= $action_permission['delete']) {
            makebutton($lang_user['del_acc'], "user.php?action=del_user&amp;check%5B%5D={$id}\" type=\"wrn", 130);
        }
        $output .= "\r\n                </td>\r\n                <td>";
        if ($user_lvl >= $action_permission['update']) {
            makebutton($lang_user['update_data'], "javascript:do_submit_data()", 130);
        }
        makebutton($lang_global['back'], "javascript:window.history.back()\" type=\"def", 130);
        $output .= "\r\n                </td>\r\n                </tr>\r\n              </table>\r\n            </form>\r\n          </fieldset>\r\n          <br /><br />\r\n        </center>\r\n";
    } else {
        error($lang_global['err_no_user']);
    }
}
Example #28
0
function do_search()
{
    global $lang_global, $lang_game_object, $output, $world_db, $realm_id, $go_datasite, $sql_search_limit, $go_type;
    wowhead_tt();
    require_once "./scripts/get_lib.php";
    $deplang = get_lang_id();
    if ((!isset($_POST['entry']) || $_POST['entry'] === '') && (!isset($_POST['name']) || $_POST['name'] === '') && (!isset($_POST['ScriptName']) || $_POST['ScriptName'] === '') && (!isset($_POST['displayId']) || $_POST['displayId'] === '') && (!isset($_POST['faction']) || $_POST['faction'] === '') && (!isset($_POST['flags']) || $_POST['flags'] === '') && (!isset($_POST['custom_search']) || $_POST['custom_search'] === '') && $_POST['type'] == -1) {
        redirect("game_object.php?error=1");
    }
    $sql = new SQL();
    $sql->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
    if ($_POST['entry'] != '') {
        $entry = $sql->quote_smart($_POST['entry']);
    }
    if ($_POST['name'] != '') {
        $name = $sql->quote_smart($_POST['name']);
    }
    if ($_POST['type'] != -1) {
        $type = $sql->quote_smart($_POST['type']);
    }
    if ($_POST['ScriptName'] != '') {
        $ScriptName = $sql->quote_smart($_POST['ScriptName']);
    }
    if ($_POST['displayId'] != '') {
        $displayId = $sql->quote_smart($_POST['displayId']);
    }
    if ($_POST['faction'] != '') {
        $faction = $sql->quote_smart($_POST['faction']);
    }
    if ($_POST['flags'] != '') {
        $flags = $sql->quote_smart($_POST['flags']);
    }
    if ($_POST['custom_search'] != '') {
        $custom_search = $sql->quote_smart($_POST['custom_search']);
    } else {
        $custom_search = "";
    }
    $where = "WHERE gameobject_template.entry > 0 ";
    if ($custom_search != "") {
        $where .= " {$custom_search} ";
    }
    if (isset($entry)) {
        $where .= "AND gameobject_template.entry = '{$entry}' ";
    }
    if (isset($name)) {
        $where .= "AND IFNULL(" . ($deplang != 0 ? "name_loc{$deplang}" : "NULL") . ",`name`) LIKE '%{$name}%' ";
    }
    if (isset($type)) {
        $where .= "AND type = '{$type}' ";
    }
    if (isset($ScriptName)) {
        $where .= "AND ScriptName LIKE '%{$ScriptName}%' ";
    }
    if (isset($displayId)) {
        $where .= "AND displayId = '{$displayId}' ";
    }
    if (isset($faction)) {
        $where .= "AND faction = '{$faction}' ";
    }
    if (isset($flags)) {
        $where .= "AND flags = '{$flags}' ";
    }
    if ($where == "WHERE gameobject_template.entry > 0 ") {
        redirect("game_object.php?error=1");
    }
    $result = $sql->query("SELECT gameobject_template.entry, type, displayId, IFNULL(" . ($deplang != 0 ? "name_loc{$deplang}" : "NULL") . ",`name`) as name, faction FROM gameobject_template LEFT JOIN locales_gameobject ON gameobject_template.entry = locales_gameobject.entry {$where} ORDER BY gameobject_template.entry LIMIT {$sql_search_limit}");
    $total_found = $sql->num_rows($result);
    $output .= "<center>\r\n  <table class=\"top_hidden\"></td>\r\n       <tr><td>";
    makebutton($lang_game_object['new_search'], "game_object.php", 160);
    $output .= "</td>\r\n     <td align=\"right\">{$lang_game_object['tot_found']} : {$total_found} : {$lang_global['limit']} {$sql_search_limit}</td>\r\n   </tr></table>";
    $output .= "<table class=\"lined\">\r\n   <tr>\r\n  <th width=\"10%\">{$lang_game_object['entry']}</th>\r\n  <th width=\"40%\">{$lang_game_object['name']}</th>\r\n  <th width=\"20%\">{$lang_game_object['type']}</th>\r\n  <th width=\"15%\">{$lang_game_object['displayId']}</th>\r\n  <th width=\"15%\">{$lang_game_object['faction']}</th>\r\n  </tr>";
    for ($i = 1; $i <= $total_found; $i++) {
        $go = $sql->fetch_row($result);
        $output .= "<tr>\r\n        <td><a href=\"{$go_datasite}{$go['0']}\" target=\"_blank\">{$go['0']}</a></td>\r\n        <td><a href=\"game_object.php?action=edit&amp;entry={$go['0']}&amp;error=4\">" . htmlentities($go[3]) . "</a></td>\r\n        <td>" . get_go_type($go[1]) . "</td>\r\n        <td>{$go['2']}</td>\r\n        <td>{$go['4']}</td>\r\n      </tr>";
    }
    $output .= "</table></center><br />";
    $sql->close();
}
Example #29
0
function view_guild()
{
    global $lang_guild, $lang_global, $output, $realm_db, $characters_db, $mmfpm_db, $realm_id, $itemperpage, $action_permission, $user_lvl, $user_id, $showcountryflag;
    if (!isset($_GET['id'])) {
        redirect("guild.php?error=1&amp;realm={$realmid}");
    }
    $sqlr = new SQL();
    $sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    if (empty($_GET['realm'])) {
        $realmid = $realm_id;
    } else {
        $realmid = $sqlr->quote_smart($_GET['realm']);
        if (!is_numeric($realmid)) {
            $realmid = $realm_id;
        }
    }
    $sqlc = new SQL();
    $sqlc->connect($characters_db[$realmid]['addr'], $characters_db[$realmid]['user'], $characters_db[$realmid]['pass'], $characters_db[$realmid]['name']);
    $guild_id = $sqlc->quote_smart($_GET['id']);
    if (is_numeric($guild_id)) {
    } else {
        redirect("guild.php?error=6&amp;realm={$realmid}");
    }
    //==========================SQL INGUILD and GUILDLEADER======================
    $q_inguild = $sqlc->query("select 1 from guild_member where guildid = '{$guild_id}' and guid in (select guid from characters where account = '{$user_id}')");
    $inguild = $sqlc->result($q_inguild, 0, '1');
    if ($user_lvl < $action_permission['update'] && !$inguild) {
        redirect("guild.php?error=6&amp;realm={$realmid}");
    }
    $q_amIguildleader = $sqlc->query("select 1 from guild where guildid = '{$guild_id}' and leaderguid in (select guid from characters where account = '{$user_id}')");
    $amIguildleader = $sqlc->result($q_amIguildleader, 0, '1');
    $q_guildmemberCount = $sqlc->query("SELECT 1 from guild_member where guildid = '{$guild_id}'");
    $guildmemberCount = $sqlc->num_rows($q_guildmemberCount);
    //====================SQL INGUILD and GUILDLEADER end========================
    //==========================$_GET and SECURE=================================
    $start = isset($_GET['start']) ? $sqlc->quote_smart($_GET['start']) : 0;
    if (is_numeric($start)) {
    } else {
        $start = 0;
    }
    $order_by = isset($_GET['order_by']) ? $sqlc->quote_smart($_GET['order_by']) : "mrank";
    if (!preg_match("/^[_[:lower:]]{1,10}\$/", $order_by)) {
        $order_by = "mrank";
    }
    $dir = isset($_GET['dir']) ? $sqlc->quote_smart($_GET['dir']) : 1;
    if (!preg_match("/^[01]{1}\$/", $dir)) {
        $dir = 1;
    }
    $order_dir = $dir ? "ASC" : "DESC";
    $dir = $dir ? 0 : 1;
    //==========================$_GET and SECURE end=============================
    $query = $sqlc->query("SELECT guildid, name, info, MOTD, createdate,\r\n    (select count(*) from guild_member where guildid = '{$guild_id}') as mtotal,\r\n    (select count(*) from guild_member where guildid = '{$guild_id}' and guid in\r\n    (select guid from characters where online = 1)) as monline\r\n    FROM guild WHERE guildid = '{$guild_id}'");
    $guild_data = $sqlc->fetch_row($query);
    $output .= "\r\n<center>\r\n\t<div id=\"tab_content\">\r\n\t\t<div id=\"tab\">\r\n\t\t\t<ul>\r\n\t\t\t\t<li id=\"selected\"><a href=\"guild.php?action=view_guild&amp;realm={$realmid}&amp;error=3&amp;id={$guild_data['0']}\">" . $lang_guild['members'] . "</a></li>\r\n\t\t\t\t<li><a href=\"guildbank.php?id={$guild_id}&amp;realm={$realmid}\">" . $lang_guild['guildbank'] . "</a></li>\r\n\t\t\t</ul>\r\n\t\t</div>\r\n";
    $output .= "\r\n        <script type=\"text/javascript\">\r\n          answerbox.btn_ok='{$lang_global['yes']}';\r\n          answerbox.btn_cancel='{$lang_global['no']}';\r\n        </script>\r\n\t\t<div id=\"tab_content2\">\r\n\t\t\t<table class=\"hidden\" style=\"width: 100%;\">\r\n              <tr>\r\n                <td>\r\n                  <table class=\"lined\"style=\"width: 100%;\">\r\n                    <tr>\r\n                      <td width=\"25%\"><b>{$lang_guild['create_date']}:</b><br />" . date('o-m-d', $guild_data[4]) . "</td>\r\n                      <td width=\"50%\" class=\"bold\">{$guild_data['1']}</td>\r\n                      <td width=\"25%\"><b>{$lang_guild['tot_m_online']}:</b><br />{$guild_data['6']} / {$guild_data['5']}</td>\r\n                    </tr>";
    if ($guild_data[2] != '') {
        $output .= "\r\n                    <tr>\r\n                      <td colspan=\"3\"><b>{$lang_guild['info']}:</b><br />{$guild_data['2']}</td>\r\n                    </tr>";
    }
    if ($guild_data[3] != '') {
        $output .= "\r\n                    <tr>\r\n                      <td colspan=\"3\"><b>{$lang_guild['motd']}:</b><br />{$guild_data['3']}</td>\r\n                    </tr>";
    }
    $output .= "\r\n                  </table>\r\n                </td>\r\n              </tr>\r\n              <tr>\r\n                <td align=\"right\">" . generate_pagination("guild.php?action=view_guild&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by={$order_by}&amp;dir=" . ($dir ? 0 : 1) . "", $guildmemberCount, $itemperpage, $start) . "</td>\r\n              </tr>\r\n              <tr>\r\n                <td>\r\n                  <table class=\"lined\" style=\"width: 100%;\">\r\n                    <tr>\r\n                      <th width=\"1%\">{$lang_guild['remove']}</th>\r\n                      <th width=\"20%\"><a href=\"guild.php?action=view_guild&amp;error=3&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by=cname&amp;start={$start}&amp;dir={$dir}\">" . ($order_by == 'cname' ? "<img src=\"img/arr_" . ($dir ? "up" : "dw") . ".gif\" alt=\"\" /> " : "") . "{$lang_guild['name']}</a></th>\r\n                      <th width=\"1%\"><a href=\"guild.php?action=view_guild&amp;error=3&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by=crace&amp;start={$start}&amp;dir={$dir}\">" . ($order_by == 'crace' ? "<img src=\"img/arr_" . ($dir ? "up" : "dw") . ".gif\" alt=\"\" /> " : "") . "{$lang_guild['race']}</a></th>\r\n                      <th width=\"1%\"><a href=\"guild.php?action=view_guild&amp;error=3&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by=class&amp;start={$start}&amp;dir={$dir}\">" . ($order_by == 'cclass' ? "<img src=\"img/arr_" . ($dir ? "up" : "dw") . ".gif\" alt=\"\" /> " : "") . "{$lang_guild['class']}</a></th>\r\n                      <th width=\"1%\"><a href=\"guild.php?action=view_guild&amp;error=3&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by=clevel&amp;start={$start}&amp;dir={$dir}\">" . ($order_by == 'clevel' ? "<img src=\"img/arr_" . ($dir ? "up" : "dw") . ".gif\" alt=\"\" /> " : "") . "{$lang_guild['level']}</a></th>\r\n                      <th width=\"23%\"><a href=\"guild.php?action=view_guild&amp;error=3&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by=mrank&amp;start={$start}&amp;dir={$dir}\">" . ($order_by == 'mrank' ? "<img src=\"img/arr_" . ($dir ? "up" : "dw") . ".gif\" alt=\"\" /> " : "") . "{$lang_guild['rank']}</a></th>\r\n                      <th width=\"25%\">{$lang_guild['pnote']}</th>\r\n                      <th width=\"25%\">{$lang_guild['offnote']}</th>\r\n                      <th width=\"1%\"><a href=\"guild.php?action=view_guild&amp;error=3&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by=clogout&amp;start={$start}&amp;dir={$dir}\">" . ($order_by == 'clogout' ? "<img src=\"img/arr_" . ($dir ? "up" : "dw") . ".gif\" alt=\"\" /> " : "") . "{$lang_guild['llogin']}</a></th>\r\n                      <th width=\"1%\"><a href=\"guild.php?action=view_guild&amp;error=3&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by=conline&amp;start={$start}&amp;dir={$dir}\">" . ($order_by == 'conline' ? "<img src=\"img/arr_" . ($dir ? "up" : "dw") . ".gif\" alt=\"\" /> " : "") . "{$lang_guild['online']}</a></th>";
    if ($showcountryflag) {
        require_once 'libs/misc_lib.php';
        $sqlm = new SQL();
        $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
        $output .= "\r\n                      <th width=\"1%\">{$lang_global['country']}</th>";
    }
    $output .= "\r\n                    </tr>";
    $members = $sqlc->query("SELECT gm.guid as cguid, c.name as cname, c.`race` as crace ,c.`class` as cclass,\r\n    c.`level` AS clevel,\r\n    gm.rank AS mrank, (SELECT rname FROM guild_rank WHERE guildid ='{$guild_id}' AND rid = mrank) AS rname,\r\n    gm.Pnote, gm.OFFnote, gender,\r\n    c.`online` as conline, c.`account`, c.`logout_time` as clogout\r\n    FROM guild_member as gm left outer join characters as c on c.guid = gm.guid\r\n    WHERE gm.guildid = '{$guild_id}' ORDER BY {$order_by} {$order_dir} LIMIT {$start}, {$itemperpage}");
    while ($member = $sqlr->fetch_row($members)) {
        $result = $sqlr->query("SELECT gmlevel FROM account WHERE id ='{$member['11']}'");
        $owner_gmlvl = $sqlr->result($result, 0, 'gmlevel');
        $output .= "\r\n                    <tr>";
        // gm, gildleader or own account! are allowed to remove from guild
        $output .= $user_lvl >= $action_permission['delete'] || $amIguildleader || $member[11] == $user_id ? "\r\n                      <td>\r\n                        <img src=\"img/aff_cross.png\" alt=\"\" onclick=\"answerBox('{$lang_global['delete']}: &lt;font color=white&gt;{$member[1]}&lt;/font&gt;&lt;br /&gt;{$lang_global['are_you_sure']}', 'guild.php?action=rem_char_from_guild&amp;realm={$realmid}&amp;id={$member['0']}&amp;guld_id={$guild_id}');\" style=\"cursor:pointer;\" />\r\n                      </td>" : "\r\n                      <td>\r\n                      </td>";
        $output .= $user_lvl < $owner_gmlvl ? "\r\n                      <td>" . htmlentities($member[1]) . "</td>" : "\r\n                      <td><a href=\"char.php?id={$member['0']}&amp;realm={$realmid}\">" . htmlentities($member[1]) . "</a></td>";
        $output .= "\r\n                      <td><img src='img/c_icons/{$member[2]}-{$member[9]}.gif' onmousemove='toolTip(\"" . char_get_race_name($member[2]) . "\",\"item_tooltip\")' onmouseout='toolTip()' alt=\"\" /></td>\r\n                      <td><img src='img/c_icons/{$member[3]}.gif' onmousemove='toolTip(\"" . char_get_class_name($member[3]) . "\",\"item_tooltip\")' onmouseout='toolTip()' alt=\"\" /></td>\r\n                      <td>" . char_get_level_color($member[4]) . "</td>\r\n                      <td>" . htmlentities($member[6]) . " (" . $member[5] . ")</td>\r\n                      <td>" . htmlentities($member[7]) . "</td>\r\n                      <td>" . htmlentities($member[8]) . "</td>\r\n                      <td>" . get_days_with_color($member[12]) . "</td>\r\n                      <td>" . ($member[10] ? "<img src=\"img/up.gif\" alt=\"\" />" : "-") . "</td>";
        if ($showcountryflag) {
            $country = misc_get_country_by_account($member[11], $sqlr, $sqlm);
            $output .= "\r\n                      <td>" . ($country['code'] ? "<img src='img/flags/" . $country['code'] . ".png' onmousemove='toolTip(\"" . $country['country'] . "\",\"item_tooltip\")' onmouseout='toolTip()' alt=\"\" />" : "-") . "</td>";
        }
        $output .= "\r\n                    </tr>";
    }
    unset($member);
    $output .= "\r\n                  </table>\r\n                </td>\r\n              </tr>\r\n              <tr>\r\n                <td align=\"right\">" . generate_pagination("guild.php?action=view_guild&amp;error=3&amp;realm={$realmid}&amp;id={$guild_id}&amp;order_by={$order_by}&amp;dir=" . !$dir, $guildmemberCount, $itemperpage, $start) . "</td>\r\n              </tr>\r\n            </table>\r\n\t\t</div>\r\n\t</div>\r\n            <br />";
    $output .= "\r\n            <table class=\"hidden\">\r\n              <tr>\r\n                <td>";
    if ($user_lvl >= $action_permission['delete'] || $amIguildleader) {
        makebutton($lang_guild['del_guild'], "guild.php?action=del_guild&amp;realm={$realmid}&amp;id={$guild_id}\" type=\"wrn", 130);
        $output .= "\r\n                </td>\r\n                <td>";
    }
    makebutton($lang_guild['show_guilds'], "guild.php?realm={$realmid}\" type=\"def", 130);
    $output .= "\r\n                </td>\r\n              </tr>\r\n            </table>\r\n\t</center>\r\n";
}
Example #30
0
function edit_tele()
{
    global $lang_tele, $lang_global, $output, $world_db, $realm_id, $mmfpm_db, $action_permission, $user_lvl;
    valid_login($action_permission['update']);
    if (!isset($_GET['id'])) {
        redirect("Location: tele.php?error=1");
    }
    $sqlw = new SQL();
    $sqlw->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
    $sqlm = new SQL();
    $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
    $id = $sqlw->quote_smart($_GET['id']);
    if (is_numeric($id)) {
    } else {
        redirect("tele.php?error=1");
    }
    $query = $sqlw->query("SELECT id, name, map, position_x, position_y, position_z, orientation FROM game_tele WHERE id = '{$id}'");
    if ($sqlw->num_rows($query) == 1) {
        $tele = $sqlw->fetch_row($query);
        $output .= "\n        <script type=\"text/javascript\">\n          answerbox.btn_ok='{$lang_global['yes']}';\n          answerbox.btn_cancel='{$lang_global['no']}';\n        </script>\n        <center>\n          <fieldset class=\"half_frame\">\n            <legend>{$lang_tele['edit_tele']}</legend>\n            <form method=\"get\" action=\"tele.php\" name=\"form\">\n            <input type=\"hidden\" name=\"action\" value=\"do_edit_tele\" />\n            <input type=\"hidden\" name=\"id\" value=\"{$id}\" />\n            <table class=\"flat\">\n              <tr>\n                <td>{$lang_tele['loc_id']}</td>\n                <td>{$tele['0']}</td>\n              </tr>\n              <tr>\n                <td>{$lang_tele['loc_name']}</td>\n                <td><input type=\"text\" name=\"new_name\" size=\"42\" maxlength=\"98\" value=\"{$tele['1']}\" /></td>\n              </tr>\n              <tr>\n                <td>{$lang_tele['on_map']}</td>\n                <td>\n                  <select name=\"new_map\">";
        $map_query = $sqlm->query("SELECT id, name01 from dbc_map order by id");
        while ($map = $sqlm->fetch_row($map_query)) {
            $output .= "\n                    <option value=\"{$map[0]}\" ";
            if ($tele[2] == $map[0]) {
                $output .= "selected=\"selected\" ";
            }
            $output .= ">{$map[0]} : {$map[1]}</option>";
        }
        unset($map);
        unset($map_query);
        $output .= "\n                   </select>\n                 </td>\n               </tr>\n               <tr>\n                 <td>{$lang_tele['position_x']}</td>\n                 <td><input type=\"text\" name=\"new_x\" size=\"42\" maxlength=\"36\" value=\"{$tele['3']}\" /></td>\n               </tr>\n               <tr>\n                 <td>{$lang_tele['position_y']}</td>\n                 <td><input type=\"text\" name=\"new_y\" size=\"42\" maxlength=\"36\" value=\"{$tele['4']}\" /></td>\n               </tr>\n               <tr>\n                 <td>{$lang_tele['position_z']}</td>\n                 <td><input type=\"text\" name=\"new_z\" size=\"42\" maxlength=\"36\" value=\"{$tele['5']}\" /></td>\n               </tr>\n               <tr>\n                 <td>{$lang_tele['orientation']}</td>\n                 <td><input type=\"text\" name=\"new_orientation\" size=\"42\" maxlength=\"36\" value=\"{$tele['6']}\" /></td>\n               </tr>\n               <tr>\n                 <td>";
        if ($user_lvl >= $action_permission['delete']) {
            makebutton($lang_tele['delete_tele'], "#\" onclick=\"answerBox('{$lang_global['delete']}: &lt;font color=white&gt;{$tele[1]}&lt;/font&gt; &lt;br /&gt; {$lang_global['are_you_sure']}', 'tele.php?action=del_tele&amp;id={$id}');\" type=\"wrn", 130);
        }
        $output .= "\n                 </td>\n                 <td>";
        makebutton($lang_tele['update_tele'], "javascript:do_submit()", 130);
        makebutton($lang_global['back'], "tele.php\" type=\"def", 130);
        $output .= "\n                 </td>";
        $output .= "\n               </tr>\n             </table>\n           </form>\n         </fieldset>\n         <br /><br />\n       </center>";
    } else {
        error($lang_global['err_no_records_found']);
    }
}