Skip to content

Commit

Permalink
[17] Function of search now is tested.
Browse files Browse the repository at this point in the history
Please, use stable version: 16

Signed-off-by: Ivan <Dfyztimy@list.ru>
  • Loading branch information
Hantet committed Jul 6, 2010
1 parent ebd95a4 commit c8b2d51
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 3 deletions.
6 changes: 5 additions & 1 deletion config.php
Expand Up @@ -9,12 +9,14 @@ function get($id)
## dbhost: IP-address or domain name where is started server MySQL.
## dbuser: Username for connect to server MySQL.
## dbpass: Password for connect to server MySQL.
## mangos: Name database of world.
## realmd: Name database of account.
## characters: Name database of characters.
##################################################################################################*/
"dbhost" => "localhost",
"dbuser" => "mangos",
"dbpass" => "mangos",
"mangos" => "mangos"
"realmd" => "realmd",
"characters" => "characters",
/*##################################################################################################
Expand All @@ -27,6 +29,7 @@ function get($id)
## anim: Animation progress-bar in list-page (boolean).
## LinkAccount: Link to page on deatil view account or false if it is not necessary.
## LinkPlayer: Link to page on deatil view character or false if it is not necessary.
## searchlimit: Limit of query for search (query, creature, item, etc).
##################################################################################################*/
"title" => "Баг-трекер",
"mingm" => 3,
Expand All @@ -36,14 +39,15 @@ function get($id)
"anim" => false,
"LinkAccount" => "http://localhost/admin/account.php?id=",
"LinkPlayer" => "http://localhost/admin/player.php?guid=",
"searchlimit" => 10,
/*##################################################################################################
## Announce of updates
## CheckVersion: Check new version in git page of project (boolean).
## version: Current version of bug-tracker. Do not change!
## checkdiff: Different in days for recheck updates.
##################################################################################################*/
"CheckVersion" => false,
"version" => 16,
"version" => 17,
"checkdiff" => 2
);

Expand Down
2 changes: 1 addition & 1 deletion lib/html.php
Expand Up @@ -55,7 +55,7 @@ public function send()
<tr id="var4" style="display:none;">
<td class="block2">Название: </td>
<td align="right">
<input id="name" onFocus="this.style.backgroundColor=\'#CCC\'" onBlur="this.style.backgroundColor=\'#FFF\'" class="input" type="text">
<input id="name" onKeyUp="if(this.value.length > 2)searchfor(this.value)" onFocus="this.style.backgroundColor=\'#CCC\'" onBlur="this.style.backgroundColor=\'#FFF\'" class="input" type="text">
</td>
</tr>
<tr id="var5" style="display:none;">
Expand Down
59 changes: 59 additions & 0 deletions lib/main.js
Expand Up @@ -3,6 +3,65 @@ var detail_view = false;
var m_viewdiv = 0;
var m_nowview = -1;

function searchresult(id)
{
var tmp = document.getElementById("type");
var type = tmp.options[tmp.selectedIndex].value;
var link;
switch(type)
{
case "2":
link = "http://ru.wowhead.com/quest=";
break;
case "3":
link = "http://ru.wowhead.com/item=";
break;
case "4":
link = "http://ru.wowhead.com/npc=";
break;
case "5":
link = "http://ru.wowhead.com/object=";
break;
default:
return;
}
document.getElementById("db").value = link+id;
}

function searchfor(val)
{
var tmp = document.getElementById("type");
var type = tmp.options[tmp.selectedIndex].value;
var table;
switch(type)
{
case "2":
table = "quest";
break;
case "3":
table = "item";
break;
case "4":
table = "creature";
break;
case "5":
table = "gameobject";
break;
default:
return;
}
$.ajax({
type: "POST",
data: "table="+table+"&string="+type,
url: "search.php",
cache: false,
success: function(html)
{
alert(html);
}
});
}

function fastchangestatus(id)
{
var list = document.getElementById("fastchange0");
Expand Down
40 changes: 40 additions & 0 deletions search.php
@@ -0,0 +1,40 @@
<?php
if($_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" &&
!empty($_POST['table']) &&
!empty($_POST['string']))
{
require_once("config.php");
require_once("lib/classes.php");

$sql = new sql;
$main = new main;
$cfg = new config;

$string = htmlspecialchars($_POST['string'], ENT_QUOTES);
$table = htmlspecialchars($_POST['table'], ENT_QUOTES);

$query = "";
switch($table)
{
case "2":
$query = "SELECT `name`,`id` FROM `quest_template` WHERE `name` LIKE '".$string."%';
break;
case "3":
$query = "SELECT `name`,`id` FROM `item_template` WHERE `name` LIKE '".$string."%';
break;
case "4":
$query = "SELECT `name`,`entry` FROM `creature_template` WHERE `name` LIKE '".$string."%';
break;
case "5":
$query = "SELECT `name`,`entry` FROM `gameobject_template` WHERE `name` LIKE '".$string."%'";
break;
}
$result = $sql->exe($cfg->get("mangos"),$query." LIMIT ".$cfg->get("searchlimit"));
$text = '';
while($row=$sql->fetch($result))
{
$text.= '<div class="search"><a href="#" onClick="searchresult('.$row[1].')">'.$row[0].'</a></div>';
}
echo $text;
}
?>
2 changes: 1 addition & 1 deletion sql/realmd_bugtracker.sql
@@ -1,4 +1,4 @@
SET FOREIGN_KEY_CHECKS=0;
SET FOREIGN_KEY_CHECKS=0;

DROP TABLE IF EXISTS `bt_map_id`;
CREATE TABLE `bt_map_id` (
Expand Down

0 comments on commit c8b2d51

Please sign in to comment.