forked from mangostools/aowow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.php
102 lines (93 loc) · 3.01 KB
/
ajax.php
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/*
* UDWBase: WOWDB Web Interface
*
* © UDW 2009-2011
*
* Released under the terms and conditions of the
* GNU General Public License (http://gnu.org).
*
*/
header('Content-type: application/x-javascript');
error_reporting(E_ALL | E_STRICT);
ini_set('serialize_precision', 4);
session_start();
if (isset($_GET['admin-loader']) && $_SESSION['roles'] == 2) {
include 'templates/wowhead/js/admin.js';
exit;
}
// Настройки
require_once 'configs/config.php';
// Для Ajax отключаем debug
$UDWBaseconf['debug'] = false;
// Для Ajax ненужен реалм
$UDWBaseconf['realmd'] = false;
// Настройка БД
global $DB;
require_once('includes/db.php');
function str_normalize($string) {
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/'));
}
// Параметры передаваемые скрипту
@list($what, $id) = explode("=", $_SERVER['QUERY_STRING']);
$id = intval($id);
$x = '';
switch ($what) {
case 'item':
if (!$item = load_cache(6, $id)) {
require_once('includes/allitems.php');
$item = allitemsinfo($id, 1);
save_cache(6, $id, $item);
}
$x .= '$WowheadPower.registerItem(' . $id . ', 0, {';
if ($item['name'])
$x .= 'name: \'' . str_normalize($item['name']) . '\',';
if ($item['quality'])
$x .= 'quality: ' . $item['quality'] . ',';
if ($item['icon'])
$x .= 'icon: \'' . str_normalize($item['icon']) . '\',';
if ($item['info'])
$x .= 'tooltip: \'' . str_normalize($item['info']) . '\'';
$x .= '});';
break;
case 'spell':
if (!$spell = load_cache(14, $id)) {
require_once('includes/allspells.php');
$spell = allspellsinfo($id, 1);
save_cache(14, $id, $spell);
}
$x .= '$WowheadPower.registerSpell(' . $id . ', 0,{';
if ($spell['name'])
$x .= 'name: \'' . str_normalize($spell['name']) . '\',';
if ($spell['icon'])
$x .= 'icon: \'' . str_normalize($spell['icon']) . '\',';
if ($spell['info'])
$x .= 'tooltip: \'' . str_normalize($spell['info']) . '\'';
$x .= '});';
break;
case 'quest':
if (!$quest = load_cache(11, $id)) {
require_once('includes/allquests.php');
$quest = GetDBQuestInfo($id, QUEST_DATAFLAG_AJAXTOOLTIP);
$quest['tooltip'] = GetQuestTooltip($quest);
save_cache(11, $id, $quest);
}
$x .= '$WowheadPower.registerQuest(' . $id . ', 0,{';
if (isset($quest['Title']))
{
$x .= 'name: \'' . str_normalize($quest['Title']) . '\',';
}
else
{
$x .= 'name: \'' . 'error' . '\',';
}
if ($quest['tooltip'])
{
$x .= 'tooltip: \'' . str_normalize($quest['tooltip']) . '\'';
}
$x .= '});';
break;
default:
break;
}
echo $x;