/**
  * Generates random enchantments for $item_entry and $item_guid (if provided)
  * @category Items class
  * @access   public
  * @param    int $item_entry
  * @param    int $owner_guid
  * @param    int $item_guid
  * @return   array
  **/
 public function GetRandomPropertiesData($item_entry, $owner_guid, $item_guid = 0, $rIdOnly = false, $serverType = 1, $item = null, $item_data = null)
 {
     // I have no idea how it works but it works :D
     // Do not touch anything in this method (at least until somebody will explain me what the f**k am I did here).
     $enchId = 0;
     $use = 'property';
     switch ($serverType) {
         case SERVER_MANGOS:
             if ($item_guid > 0) {
                 if (is_object($item) && $item->IsCorrect()) {
                     if (is_array($item_data) && $item_data['RandomProperty'] > 0) {
                         $enchId = $item->GetItemRandomPropertyId();
                     } elseif (is_array($item_data) && $item_data['RandomSuffix'] > 0) {
                         $suffix_enchants = $item->GetRandomSuffixData();
                         if (!is_array($suffix_enchants) || !isset($suffix_enchants[0]) || $suffix_enchants[0] == 0) {
                             WoW_Log::WriteError('%s : suffix_enchants not found', __METHOD__);
                             return false;
                         }
                         $enchId = DB::Wow()->selectCell("SELECT `id` FROM `DBPREFIX_randomsuffix` WHERE `ench_1` = %d AND `ench_2` = %d AND `ench_3` = %d LIMIT 1", $suffix_enchants[0], $suffix_enchants[1], $suffix_enchants[2]);
                         $use = 'suffix';
                     }
                 } else {
                     $enchId = self::GetItemDataField(ITEM_FIELD_RANDOM_PROPERTIES_ID, 0, $owner_guid, $item_guid);
                 }
             } else {
                 $enchId = self::GetItemDataField(ITEM_FIELD_RANDOM_PROPERTIES_ID, $item_entry, $owner_guid);
             }
             break;
         case SERVER_TRINITY:
             if ($item_guid > 0) {
                 if (is_object($item) && $item->IsCorrect()) {
                     $enchId = $item->GetItemRandomPropertyId();
                     if ($enchId < 0) {
                         $use = 'suffix';
                         $enchId = abs($enchId);
                     }
                 } else {
                     $enchId = DB::Characters()->selectCell("SELECT `randomPropertyId` FROM `item_instance` WHERE `guid`=%d", $item_guid);
                 }
             } else {
                 $item_guid = self::GetItemGUIDByEntry($item_entry, $owner_guid);
                 $enchId = DB::Characters()->selectCell("SELECT `randomPropertyId` FROM `item_instance` WHERE `guid`=%d", $item_guid);
             }
             break;
     }
     if ($rIdOnly == true) {
         return $enchId;
     }
     $return_data = array();
     $table = 'randomproperties';
     if ($use == 'property') {
         $rand_data = DB::Wow()->selectRow("SELECT `name_%s` AS `name`, `ench_1`, `ench_2`, `ench_3` FROM `DBPREFIX_randomproperties` WHERE `id`=%d", Wow_Locale::GetLocale(), $enchId);
     } elseif ($use == 'suffix') {
         $table = 'randomsuffix';
     }
     if ($table == 'randomproperties') {
         if (!$rand_data) {
             WoW_Log::WriteLog('%s : unable to get rand_data FROM `%s_%s` for id %d (itemGuid: %d, ownerGuid: %d)', __METHOD__, $this->wow->armoryconfig['db_prefix'], $table, $enchId, $item_guid, $owner_guid);
             return false;
         }
         $return_data['suffix'] = $rand_data['name'];
         $return_data['data'] = array();
         for ($i = 1; $i < 4; $i++) {
             if ($rand_data['ench_' . $i] > 0) {
                 $return_data['data'][$i] = DB::Wow()->selectCell("SELECT `text_%s` FROM `DBPREFIX_enchantment` WHERE `id`=%d", Wow_Locale::GetLocale(), $rand_data['ench_' . $i]);
             }
         }
     } elseif ($table == 'randomsuffix') {
         $enchant = DB::Wow()->selectRow("SELECT `id`, `name_%s` AS `name`, `ench_1`, `ench_2`, `ench_3`, `pref_1`, `pref_2`, `pref_3` FROM `DBPREFIX_randomsuffix` WHERE `id`=%d", Wow_Locale::GetLocale(), $enchId);
         if (!$enchant) {
             return false;
         }
         $return_data['suffix'] = $enchant['name'];
         $return_data['data'] = array();
         $item_data = DB::World()->selectRow("SELECT `InventoryType`, `ItemLevel`, `Quality` FROM `item_template` WHERE `entry`=%d", $item_entry);
         $points = self::GetRandomPropertiesPoints($item_data['ItemLevel'], $item_data['InventoryType'], $item_data['Quality']);
         $return_data = array('suffix' => $enchant['name'], 'data' => array());
         $k = 1;
         for ($i = 1; $i < 4; $i++) {
             if (isset($enchant['ench_' . $i]) && $enchant['ench_' . $i] > 0) {
                 $cur = DB::Wow()->selectCell("SELECT `text_%s` FROM `DBPREFIX_enchantment` WHERE `id` = %d", Wow_Locale::GetLocale(), $enchant['ench_' . $i]);
                 $return_data['data'][$k] = str_replace('$i', round(floor($points * $enchant['pref_' . $i] / 10000), 0), $cur);
             }
             $k++;
         }
     }
     return $return_data;
 }
					<div class="selection">
						<label for="filter-minLvl"><?php 
echo WoW_Locale::GetString('template_search_table_level');
?>
</label>
						<input type="text" name="minLvl" id="filter-minLvl" class="input level" value="1" maxlength="2" data-min="1" data-filter="range" data-column="3" /> -
						<input type="text" name="maxLvl" id="filter-maxLvl" class="input level" value="80" maxlength="2" data-max="80" data-filter="range" data-column="3" />
		</div>
					<div class="selection">
						<label for="filter-race"><?php 
echo WoW_Locale::GetString('template_search_table_race');
?>
</label>
						<select name="race" class="input class" id="filter-race" data-column="1" data-filter="column">
							    <option value=""><?php 
echo Wow_Locale::GetString('template_guild_roster_all_races');
?>
</option>
                                <?php 
switch (WoW_Guild::GetGuildFactionID()) {
    default:
    case FACTION_ALLIANCE:
        $allowed_races = array(RACE_HUMAN, RACE_DWARF, RACE_NIGHTELF, RACE_GNOME, RACE_DRAENEI);
        break;
    case FACTION_HORDE:
        $allowed_races = array(RACE_ORC, RACE_UNDEAD, RACE_TAUREN, RACE_TROLL, RACE_BLOODELF);
        break;
}
foreach ($allowed_races as $race) {
    echo sprintf('<option value="%d">%s</option>', $race, WoW_Locale::GetString('character_race_' . $race, GENDER_MALE));
}