Вывод иконок сторон в цепочках квестов...
[cswow.git] / ajax.php
blob4001d840e8faf6027908ae8d0e40432b6e564c9e
1 <?php
2 @session_start();
3 include_once("conf.php");
4 include_once("include/DbSimple/Generic.php");
5 include("lang/lang.".$config['lang'].".php");
6 include("lang/game_text.".$config['lang'].".php");
7 // Режим запроса
8 $ajaxmode = 1;
10 // Получаем имя первой переменной запроса
11 $mode = $_SERVER["QUERY_STRING"];
12 $pos = strpos($mode, "=");
13 $pos1 = strpos($mode, "&");
14 if ($pos > $pos1 AND $pos1!=NULL) $pos = $pos1;
15 if ($pos != NULL)
16 $mode = substr($mode, 0, $pos);
18 $time = microtime(true);
19 // Соединяемся к базам
20 $dDB = DbSimple_Generic::connect("mysql://$config[username]:$config[password]@$config[hostname]/$config[dbName]");
21 $wDB = DbSimple_Generic::connect("mysql://$config[wusername]:$config[wpassword]@$config[whostname]/$config[wdbName]");
22 $cDB = DbSimple_Generic::connect("mysql://$config[cusername]:$config[cpassword]@$config[chostname]/$config[cdbName]");
23 // Выставляем кодировку клиента
24 $dDB->query("SET NAMES ?s", $config['client_charset']);
25 $wDB->query("SET NAMES ?s", $config['client_charset']);
26 $cDB->query("SET NAMES ?s", $config['client_charset']);
28 //*****************************************************************************
29 // Include cache functions
30 //*****************************************************************************
31 $cacheArray = array();
32 function databaseCacher($hash, $array)
34 global $cacheArray;
35 if ($array===null)
36 return isset($cacheArray[$hash]) ? $cacheArray[$hash] : null;
37 $cacheArray[$hash] = $array;
39 $dDB->setCacher('databaseCacher');
40 $wDB->setCacher('databaseCacher');
41 $cDB->setCacher('databaseCacher');
43 $ajax_module = @$ajax_modules[$mode];
44 $module = @$modules[$mode];
46 // Подключаем модуль если найден
47 if ($ajax_module)
48 include($ajax_module);
49 else if ($module)
50 include($module);
51 else
52 echo "Module ($mode) error";
54 if ($config['show_ajax_sql_timings'])
56 $time = microtime(true) - $time;
57 $sqlTime = 0;
58 echo "<br><table class=report width=100%>";
59 echo "<tbody>";
60 echo "<tr><td>Total execution time: $time</td></tr>";
61 $stat = $dDB->getStatistics();$sqlTime+=$stat['time'];
62 echo "<tr><td>SQL dDB: $stat[count] in $stat[time]</td></tr>";
63 $stat = $wDB->getStatistics();$sqlTime+=$stat['time'];
64 echo "<tr><td>SQL wDB: $stat[count] in $stat[time]</td></tr>";
65 $stat = $cDB->getStatistics();$sqlTime+=$stat['time'];
66 echo "<tr><td>SQL cDB: $stat[count] in $stat[time]</td></tr>";
67 // $stat = $rDB->getStatistics();
68 // echo "<tr><td>SQL rDB: $stat[count] in $stat[time]</td></tr>";
69 $executeTime = $time - $sqlTime;
70 echo "<tr><td>PHP time: $executeTime</td></tr>";
71 echo "<tr><td>SQL time: $sqlTime</td></tr>";
72 echo "</tbody>";
73 echo "</table>";