Skip to content

Commit

Permalink
[363] Check search string length and display error message if string …
Browse files Browse the repository at this point in the history
…have less than 2 symbols; Blizzlike character search (use `name=NAME` instead of `name LIKE %NAME%` in SearchMgr::SearchCharacters()
  • Loading branch information
Shadez committed Aug 18, 2010
1 parent a4e1a15 commit 3ed7a5a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
13 changes: 10 additions & 3 deletions includes/classes/class.search.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 361
* @revision 363
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand All @@ -30,9 +30,13 @@
public $heirloom = false;
private $boss_loot_ids;
private $results;
public $itemSearchSkip = false;
private $type_results;

public function DoSearchItems($count = false, $findUpgrade = false, $player_level = 80) {
if($this->itemSearchSkip == true) {
return false;
}
if(!$this->searchQuery && !$findUpgrade && !$this->heirloom) {
$this->Log()->writeError('%s : unable to start search: no data provided', __METHOD__);
return false;
Expand Down Expand Up @@ -130,6 +134,9 @@ public function DoSearchItems($count = false, $findUpgrade = false, $player_leve
}

public function AdvancedItemsSearch($count = false) {
if($this->itemSearchSkip == true) {
return false;
}
if((!$this->get_array || !is_array($this->get_array)) && !$this->searchQuery ) {
$this->Log()->writeError('%s : start failed', __METHOD__);
return false;
Expand Down Expand Up @@ -554,7 +561,7 @@ public function SearchCharacters($num = false) {
foreach($this->realmData as $realm_info) {
$count_results_currrent_realm = 0;
$db = new ArmoryDatabaseHandler($realm_info['host_characters'], $realm_info['user_characters'], $realm_info['pass_characters'], $realm_info['name_characters'], $realm_info['charset_characters'], $this->Log());
$characters_data[] = $db->select("SELECT `guid`, `level`, `account` FROM `characters` WHERE `name` LIKE '%s' AND `level` >= %d LIMIT 200", '%' . $this->searchQuery . '%', $this->armoryconfig['minlevel']);
$characters_data[] = $db->select("SELECT `guid`, `level`, `account` FROM `characters` WHERE `name`='%s' AND `level` >= %d LIMIT 200", $this->searchQuery, $this->armoryconfig['minlevel']);
}
for($ii = 0; $ii < $countRealmData; $ii++) {
$count_result_chars = count($characters_data[$ii]);
Expand All @@ -572,7 +579,7 @@ public function SearchCharacters($num = false) {
if(!$db) {
continue;
}
$current_realm = $db->select("SELECT `guid`, `name`, `class` AS `classId`, `gender` AS `genderId`, `race` AS `raceId`, `level`, `account` FROM `characters` WHERE `name` LIKE '%s'", '%'.$this->searchQuery.'%');
$current_realm = $db->select("SELECT `guid`, `name`, `class` AS `classId`, `gender` AS `genderId`, `race` AS `raceId`, `level`, `account` FROM `characters` WHERE `name` = '%s'", $this->searchQuery);
if(!$current_realm) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/revision_nr.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('ARMORY_REVISION', 362);
define('ARMORY_REVISION', 363);
define('DB_VERSION', 'armory_r361');
define('CONFIG_VERSION', '0708201001');
?>
17 changes: 16 additions & 1 deletion search.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 345
* @revision 363
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -34,6 +34,21 @@
$advancedItemsSearch = false;
$findGearUpgrade = false;
if(isset($_GET['searchQuery'])) {
if(mb_strlen(urldecode($_GET['searchQuery']), 'UTF-8') < 2) {
$xml->LoadXSLT('error/error.xsl');
$xml->XMLWriter()->startElement('page');
$xml->XMLWriter()->writeAttribute('globalSearch', 1);
$xml->XMLWriter()->writeAttribute('lang', $armory->GetLocale());
$xml->XMLWriter()->startElement('errorhtml');
$xml->XMLWriter()->endElement(); //errorhtml
$xml->XMLWriter()->endElement(); //page
echo $xml->StopXML();
exit;
}
elseif(mb_strlen(urldecode($_GET['searchQuery']), 'UTF-8') < 4) {
// Search items with mb_strlen() > 4 only (offlike).
$search->itemSearchSkip = true;
}
$search->searchQuery = $utils->escape($_GET['searchQuery']);
}
if(isset($_GET['source'])) {
Expand Down

0 comments on commit 3ed7a5a

Please sign in to comment.