function zoneSortSelect()
{
    global $lang, $config, $dDB, $wDB;
    $cacheFilename = 'quest_zone_sort_' . $config['lang'] . '.html';
    if (checkUseCacheHtml($cacheFilename, 24 * 60 * 60)) {
        $zone_sort = $dDB->selectCol("SELECT `ZoneOrSort` FROM `quest_template` GROUP BY `ZoneOrSort`");
        $areas = $wDB->select("SELECT `id` AS ARRAY_KEY, `map_id`, `zone_id`, `name` FROM `wowd_zones` WHERE `id` IN (?a)", $zone_sort);
        $q_zones = array();
        $q_sort = array();
        foreach ($zone_sort as $z) {
            if ($z > 0) {
                $area = @$areas[$z];
                $map = $area['map_id'];
                if (!isset($q_zones[$map])) {
                    $q_zones[$map]['name'] = getMapName($map);
                    $q_zones[$map]['areas'] = array();
                }
                $q_zones[$map]['areas'][$z] = $area['name'];
            } else {
                if ($z < 0) {
                    $q_sort[-$z] = getQuestSort(-$z);
                }
            }
        }
        // Sort it
        uasort($q_zones, 'cmpZones');
        uasort($q_sort, 'strcmp');
        echo '<select name="ZoneID" style="width: 49%">';
        echo '<option value=0>' . $lang['anything'] . '</option>' . "\n";
        foreach ($q_zones as $map => $z) {
            if (count($z['areas']) > 1) {
                uasort($z['areas'], 'strcmp');
                echo '<optgroup label="' . $z['name'] . '">';
                foreach ($z['areas'] as $id => $name) {
                    echo '<option value=' . $id . '>' . $name . '</option>' . "\n";
                }
                echo '</optgroup>';
            } else {
                foreach ($z['areas'] as $id => $name) {
                    echo '<option value=' . $id . '>' . $name . '</option>' . "\n";
                }
            }
        }
        echo "</select>\n";
        echo '<select name="SortID" style="width: 49%">';
        echo '<option value=0>' . $lang['anything'] . '</option>' . "\n";
        foreach ($q_sort as $id => $name) {
            echo '<option value=' . $id . '>' . $name . '</option>' . "\n";
        }
        echo "</select>";
        flushHtmlCache($cacheFilename);
    }
}
     echo '<br><FONT color=#008800>' . $game_text['allowable_race'] . '&nbsp;' . getAllowableRace(1791) . '</FONT>';
 }
 if (getAllowableClass($quest['RequiredClasses'])) {
     echo '<br><FONT color=#000000>' . $game_text['allowable_class'] . '&nbsp;' . getQAllowableClass($quest['RequiredClasses']) . '</FONT>';
 }
 if ($entry == getQuestOld($entry)) {
     echo '<br><FONT color=#ff0000><b>' . $lang['quest_marked'] . '</FONT></b>';
 }
 echo "</th></tr>";
 echo "</th></tr>";
 echo '<tr><td>';
 if ($quest['ZoneOrSort'] > 0) {
     echo "<a style='float: right;' href=\"?s=q&ZoneID=" . $quest['ZoneOrSort'] . "\">" . getAreaName($quest['ZoneOrSort'], 0) . "</a>";
 } else {
     if ($quest['ZoneOrSort'] < 0 and (-$quest['ZoneOrSort'] >= 374 or -$quest['ZoneOrSort'] == 221 or -$quest['ZoneOrSort'] == 241 or -$quest['ZoneOrSort'] >= 344 and -$quest['ZoneOrSort'] < 371 or -$quest['ZoneOrSort'] == 284 or -$quest['ZoneOrSort'] == 25 or -$quest['ZoneOrSort'] == 41 or -$quest['ZoneOrSort'] < 24)) {
         echo "<a style='float: right;' href=\"?s=q&SortID=" . -$quest['ZoneOrSort'] . "\">" . getQuestSort(-$quest['ZoneOrSort'], 0) . "</a>";
     }
 }
 echo "{$lang['quest_level']}&nbsp;{$quest['QuestLevel']}<br>";
 if ($quest['RequiredSkill']) {
     echo "<a style='float: right;' href=\"?s=q&SkillID=" . $quest['RequiredSkill'] . "\">" . getSkillName($quest['RequiredSkill'], 0) . "&nbsp;({$quest['RequiredSkillValue']})</a>";
 }
 if ($quest['MinLevel']) {
     echo "{$lang['obtained_at_level']}&nbsp;{$quest['MinLevel']}</td></tr>";
 }
 if ($quest['SuggestedPlayers']) {
     echo "<tr><td>{$lang['suggestedplayers']}&nbsp;<b>{$quest['SuggestedPlayers']}</b></td></tr>";
 }
 if ($quest['LimitTime']) {
     echo '<tr><td>' . $lang['qlimittime'] . '&nbsp;' . getTimeText($quest['LimitTime']) . '</td></tr>';
 }
function r_questName($data)
{
    global $lang;
    $name = @$data['Title_loc'] ? $data['Title_loc'] : $data['Title'];
    if (getAllowableRace($data['RequiredRaces']) && $data['RequiredRaces'] & 1101 && $data['RequiredRaces'] != 1791) {
        echo "<img width=22 height=22 src='images/player_info/factions_img/alliance.gif'>&nbsp;";
    }
    if (getAllowableRace($data['RequiredRaces']) && $data['RequiredRaces'] & 690 && $data['RequiredRaces'] != 1791) {
        echo "<img width=22 height=22 src='images/player_info/factions_img/horde.gif'>&nbsp;";
    }
    echo '<a href="?quest=' . $data['entry'] . '">' . ($name ? $name : 'no name') . '</a><br>';
    if ($data['ZoneOrSort'] > 0) {
        echo '<div class=areaname><a href="?s=q&ZoneID=' . $data['ZoneOrSort'] . '">' . getAreaName($data['ZoneOrSort']) . '</a></div>';
    } else {
        if ($data['ZoneOrSort'] < 0 and (-$data['ZoneOrSort'] >= 374 or -$data['ZoneOrSort'] == 221 or -$data['ZoneOrSort'] == 241 or -$data['ZoneOrSort'] >= 344 and -$data['ZoneOrSort'] < 371 or -$data['ZoneOrSort'] == 284 or -$data['ZoneOrSort'] == 25 or -$data['ZoneOrSort'] == 41 or -$data['ZoneOrSort'] < 24)) {
            echo '<div class=areaname><a href="?s=q&SortID=' . -$data['ZoneOrSort'] . '">' . getQuestSort(-$data['ZoneOrSort']) . '</a></div>';
        }
    }
    if ($data['RequiredClasses']) {
        echo '<div class=classqname>' . getQAllowableClass($data['RequiredClasses']) . '</div>';
    }
    if ($data['RequiredSkill']) {
        echo '<div class=areaname><a href="?s=q&SkillID=' . $data['RequiredSkill'] . '">' . getSkillName($data['RequiredSkill'], 0) . '(' . $data['RequiredSkillValue'] . ')</a></div>';
    }
    if ($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY) {
        echo '<div class=areaname><a href="?s=q&Sfm=' . $data['SpecialFlags'] . '">' . $lang['quest_type3'] . '</a></div>';
    }
    if ($data['QuestFlags'] & QUEST_FLAGS_WEEKLY) {
        echo '<div class=areaname><a href="?s=q&Sfw=' . $data['QuestFlags'] . '">' . $lang['quest_type2'] . '</a></div>';
    }
    if ($data['QuestFlags'] & QUEST_FLAGS_DAILY) {
        echo '<div class=areaname><a href="?s=q&Sfd=' . $data['QuestFlags'] . '">' . $lang['quest_type1'] . '</a></div>';
    }
    if ($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_REPEATABLE && ($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY) == 0 && ($data['QuestFlags'] & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) == 0) {
        echo '<div class=areaname><a href="?s=q&Sfr=' . $data['SpecialFlags'] . '">' . $lang['quest_type0'] . '</a></div>';
    }
}