source: aowow/ajax.php

Last change on this file was 170, checked in by maron, 15 years ago
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1<?php
2
3header('Content-type: application/x-javascript');
4error_reporting(2039);
5// Для локализации
6session_start();
7
8if(isset($_GET['admin-loader']) && $_SESSION['roles'] == 2)
9{
10 include 'templates/wowhead/js/admin.js';
11 exit;
12}
13
14// Настройки
15require_once 'configs/config.php';
16// Для Ajax отключаем debug
17$AoWoWconf['debug'] = false;
18// Для Ajax ненужен реалм
19$AoWoWconf['realmd'] = false;
20// Настройка БД
21global $DB;
22require_once('includes/db.php');
23
24function str_normalize($string)
25{
26 return strtr($string, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/'));
27}
28
29// Параметры передаваемые скрипту
30@list($what, $id) = explode("=", $_SERVER['QUERY_STRING']);
31$id = intval($id);
32
33$x = '';
34
35switch($what)
36{
37 case 'item':
38 if(!$item = load_cache(6, $id))
39 {
40 require_once('includes/allitems.php');
41 $item = allitemsinfo($id, 1);
42 save_cache(6, $id, $item);
43 }
44 $x .= '$WowheadPower.registerItem('.$id.', 0, {';
45 if ($item['name'])
46 $x .= 'name: \''.str_normalize($item['name']).'\',';
47 if ($item['quality'])
48 $x .= 'quality: '.$item['quality'].',';
49 if ($item['icon'])
50 $x .= 'icon: \''.str_normalize($item['icon']).'\',';
51 if ($item['info'])
52 $x .= 'tooltip: \''.str_normalize($item['info']).'\'';
53 $x .= '});';
54 break;
55 case 'spell':
56 if(!$spell = load_cache(14, $id))
57 {
58 require_once('includes/allspells.php');
59 $spell = allspellsinfo($id, 1);
60 save_cache(14, $id, $spell);
61 }
62 $x .= '$WowheadPower.registerSpell('.$id.', 0,{';
63 if ($spell['name'])
64 $x .= 'name: \''.str_normalize($spell['name']).'\',';
65 if ($spell['icon'])
66 $x .= 'icon: \''.str_normalize($spell['icon']).'\',';
67 if ($spell['info'])
68 $x .= 'tooltip: \''.str_normalize($spell['info']).'\'';
69 $x .= '});';
70 break;
71 case 'quest':
72 if(!$quest = load_cache(11, $id))
73 {
74 require_once('includes/allquests.php');
75 $quest = GetDBQuestInfo($id, QUEST_DATAFLAG_AJAXTOOLTIP);
76 $quest['tooltip'] = GetQuestTooltip($quest);
77 save_cache(11, $id, $quest);
78 }
79 $x .= '$WowheadPower.registerQuest('.$id.', 0,{';
80 if($quest['name'])
81 $x .= 'name: \''.str_normalize($quest['name']).'\',';
82 if($quest['tooltip'])
83 $x .= 'tooltip: \''.str_normalize($quest['tooltip']).'\'';
84 $x .= '});';
85 break;
86 default:
87 break;
88}
89
90echo $x;
91
92?>
Note: See TracBrowser for help on using the repository browser.