2 include_once("conf.php");
3 include_once("include/DbSimple/Generic.php");
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;
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']);
35 //*****************************************************************************
37 //*****************************************************************************
38 if ($config['show_db_error'])
40 function databaseErrorHandler($message, $info)
42 if (!error_reporting())
44 echo "<table class = report>";
46 echo "<tr><td>SQL Error: $message<br><pre>".print_r($info, true)."</pre></td></tr>";
50 $dDB->setErrorHandler('databaseErrorHandler');
51 $wDB->setErrorHandler('databaseErrorHandler');
52 $cDB->setErrorHandler('databaseErrorHandler');
53 $rDB->setErrorHandler('databaseErrorHandler');
55 function databaseLogger($info, $query, $cached)
58 $db_log.=$query.'<br>';
60 $dDB->setLogger('databaseLogger');
61 $wDB->setLogger('databaseLogger');
62 $cDB->setLogger('databaseLogger');
63 $rDB->setLogger('databaseLogger');
67 //*****************************************************************************
68 // Include cache functions
69 //*****************************************************************************
70 $cacheArray = array();
71 function databaseCacher($hash, $array)
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 // Подключаем модуль если найден
91 echo "<br><div id=debug></div><TABLE class=back>";
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>";
98 echo "</TBODY></TABLE>";
100 //*****************************************************************************
101 // Show timers (for debug)
102 //*****************************************************************************
103 if ($config['show_sql_timings'])
105 $time = microtime(true) - $time;
107 echo "<br><table class = report width=500>";
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>";
126 echo '<div style="text-align:left; font-size: 11px">'.$db_log.'</div>';
129 <script type
="text/javascript">parseHref(document
);</script
>