Поиск квестов по типам классов...
[cswowd.git] / main.php
blob9fdb3a84b207a5513902d039d977be1503e93f3e
1 <?php
2 include_once("conf.php");
3 include_once("include/DbSimple/Generic.php");
4 // Режим запроса
5 $ajaxmode = 0;
7 // Получаем что строку запроса
8 $_SESSION['last_page'] = $_SERVER["QUERY_STRING"];
9 $mode = $_SERVER["QUERY_STRING"];
10 $pos = strpos($mode, "=");
11 $pos1 = strpos($mode, "&");
13 if ($pos > $pos1 AND $pos1!=NULL) $pos = $pos1;
14 if ($pos != NULL)
15 $mode = substr($mode, 0, $pos);
17 $time = microtime(true);
18 //*****************************************************************************
19 // Connect to databases
20 //*****************************************************************************
21 $dDB = DbSimple_Generic::connect("mysql://$config[username]:$config[password]@$config[hostname]/$config[dbName]");
22 $wDB = DbSimple_Generic::connect("mysql://$config[wusername]:$config[wpassword]@$config[whostname]/$config[wdbName]");
23 $cDB = DbSimple_Generic::connect("mysql://$config[cusername]:$config[cpassword]@$config[chostname]/$config[cdbName]");
24 $rDB = DbSimple_Generic::connect("mysql://$config[rusername]:$config[rpassword]@$config[rhostname]/$config[rdbName]");
26 //*****************************************************************************
27 // Set client codepage
28 //*****************************************************************************
29 $dDB->query("SET NAMES ?s", $config['client_charset']);
30 $wDB->query("SET NAMES ?s", $config['client_charset']);
31 $cDB->query("SET NAMES ?s", $config['client_charset']);
32 $rDB->query("SET NAMES ?s", $config['client_charset']);
34 $db_log='';
35 //*****************************************************************************
36 // Error log function
37 //*****************************************************************************
38 if ($config['show_db_error'])
40 function databaseErrorHandler($message, $info)
42 if (!error_reporting())
43 return;
44 echo "<table class = report>";
45 echo "<tbody>";
46 echo "<tr><td>SQL Error: $message<br><pre>".print_r($info, true)."</pre></td></tr>";
47 echo "</tbody>";
48 echo "</table>";
50 $dDB->setErrorHandler('databaseErrorHandler');
51 $wDB->setErrorHandler('databaseErrorHandler');
52 $cDB->setErrorHandler('databaseErrorHandler');
53 $rDB->setErrorHandler('databaseErrorHandler');
55 function databaseLogger($info, $query, $cached)
57 global $db_log;
58 $db_log.=$query.'<br>';
60 $dDB->setLogger('databaseLogger');
61 $wDB->setLogger('databaseLogger');
62 $cDB->setLogger('databaseLogger');
63 $rDB->setLogger('databaseLogger');
64 /**/
67 //*****************************************************************************
68 // Include cache functions
69 //*****************************************************************************
70 $cacheArray = array();
71 function databaseCacher($hash, $array)
73 global $cacheArray;
74 if ($array===null)
75 return isset($cacheArray[$hash]) ? $cacheArray[$hash] : null;
76 $cacheArray[$hash] = $array;
78 $dDB->setCacher('databaseCacher');
79 $wDB->setCacher('databaseCacher');
80 $cDB->setCacher('databaseCacher');
81 $rDB->setCacher('databaseCacher');
83 //*****************************************************************************
84 // Include site module
85 //*****************************************************************************
86 $module = isset($modules[$mode]) ? $modules[$mode] : (isset($modules["default"]) ? $modules["default"] : NULL);
87 // Подключаем модуль если найден
88 if ($module!=NULL)
89 include($module);
91 echo "<br><div id=debug></div><TABLE class=back>";
92 echo "<TBODY>";
93 echo "<TR>";
94 echo "<TD align=left width=\"33%\"><A href=\"javascript:history.back(1)\">$lang[back]</A></TD>";
95 echo "<TD align=center width=\"34%\"></TD>";
96 echo "<TD align=right width=\"33%\"></TD>";
97 echo "</TR>";
98 echo "</TBODY></TABLE>";
100 //*****************************************************************************
101 // Show timers (for debug)
102 //*****************************************************************************
103 if ($config['show_sql_timings'])
105 $time = microtime(true) - $time;
106 $sqlTime = 0;
107 echo "<br><table class = report width=500>";
108 echo "<tbody>";
109 echo "<tr><td class=left>Total execution time: $time</td></tr>";
110 $stat = $dDB->getStatistics();$sqlTime+=$stat['time'];
111 echo "<tr><td class=left>SQL dDB: $stat[count] in $stat[time] (cached $stat[cache])</td></tr>";
112 $stat = $wDB->getStatistics();$sqlTime+=$stat['time'];
113 echo "<tr><td class=left>SQL wDB: $stat[count] in $stat[time] (cached $stat[cache])</td></tr>";
114 $stat = $cDB->getStatistics();$sqlTime+=$stat['time'];
115 echo "<tr><td class=left>SQL cDB: $stat[count] in $stat[time] (cached $stat[cache])</td></tr>";
116 $stat = $rDB->getStatistics();
117 echo "<tr><td class=left>SQL rDB: $stat[count] in $stat[time] (cached $stat[cache])</td></tr>";
118 $executeTime = $time - $sqlTime;
119 echo "<tr><td class=left>PHP time: $executeTime</td></tr>";
120 echo "<tr><td class=left>SQL time: $sqlTime</td></tr>";
121 echo "</tbody>";
122 echo "</table>";
124 // Dump sql log
125 if ($db_log)
126 echo '<div style="text-align:left; font-size: 11px">'.$db_log.'</div>';
129 <script type="text/javascript">parseHref(document);</script>