public function Invoke(http\Request $request, http\Response $response)
{
$response->body = 'Hello World';
+ $response->body .= Bugdar::$db->ConstructHTMLDebugBlock();
}
}
*
* This class wraps PDO-MySQL in the old DB_Abstract ISSO API.
*
-* Constants:
-* ISSO_SHOW_QUERIES_LIVE - Show queries in page output as they are sent
-*
* @author Blue Static
* @copyright Copyright (c)2002 - [#]year[#], Blue Static
* @version $Revision$
*/
var $querystr = '';
- /**
- * History of all executed queryies
- * @var array
- * @access protected
- */
- var $history = array();
-
// ###################################################################
/**
* Constructor
*
* @access public
*
- * @param string Server name
- * @param string User name
- * @param string Password
- * @param string Database name
- * @param bool Use p-connect?
+ * @param PDO The database link.
*
* @return bool Result of connect
*/
- function connect($server, $user, $password, $database, $pconnect)
+ function connect($dblink)
{
define('ISSO_DB_LAYER', 'db_mysql_pdo');
if ($this->dblink == false)
{
- $this->dblink = new PDO("mysql:dbname=$database;host=$server", $user, $password);
+ $this->dblink = $dblink;
if ($this->dblink == false)
{
$this->error('DB-Link == false, cannot connect');
$this->error('Invalid SQL query');
}
- $this->history[] = $history = array('query' => $string, 'time' => ($this->registry->is_loaded('functions') ? $this->registry->modules['functions']->fetch_microtime_diff($time) : 0), 'trace' => $this->registry->format_debug_trace(debug_backtrace()));
-
- if (defined('ISSO_SHOW_QUERIES_LIVE'))
- {
- if (constant('ISSO_SHOW_QUERIES_LIVE'))
- {
- print($this->construct_query_debug($history));
- }
- }
-
return $this->result;
}
return $result->rowCount();
}
- // ###################################################################
- /**
- * Constructs a table of query information output that is used in some
- * other modules to display a list of queries. This merely formats
- * a DB->history array entry nicely
- *
- * @access public
- *
- * @param array An entry from DB->history
- *
- * @return string A formatted table block
- */
- function construct_query_debug($query)
- {
- $block = "<strong>Query:</strong>\n\n<div>" . $this->registry->entity_encode($query['query']) . "</div>\n";
- $block .= "<tr style=\"background-color: #FFFFFF; text-align: left\">\n\t<td>\n\t\t";
- $block .= "<strong>Time:</strong> $query[time]<br />\n\t\t<br />\n\t\t";
- $block .= "<strong>Backtrace:</strong>\n\t\t<div>" . implode("<br />\n", $query['trace']) . "</div>\n\t</td>\n</tr>";
-
- return $this->registry->message('Query Debug', $block, 1, true, false, 0);
- }
-
// ###################################################################
/**
* Error wrapper for ISSO->message()
$debug .= "\n\t<li><strong style=\"color: red\">Uncached Template(s):</strong> $sizeof ( " . implode(' ', $optlist) . " )</li>";
}
}
-
- // source control
- $scinfo = 'Not Under Source Control';
- if (defined('SVN'))
- {
- $scinfo = constant('SVN');
-
- if (preg_match('#\$Id:?\s*\$#', $scinfo))
- {
- $scinfo = 'Not Under Source Control';
- }
- else
- {
- $scinfo = preg_replace('#\$' . '(Head)?URL: (.+?) \$#e', "end(explode('/', '\\2'))", $scinfo);
- $scinfo = preg_replace('#\$' . '(LastModified)?Revision: (.+?) \$#', 'SVN \\2', $scinfo);
- $scinfo = preg_replace('#\$' . 'Id: (.+?) ([0-9].+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', '\\1 - SVN \\2', $scinfo);
- }
- }
-
- $scinfo = trim($scinfo);
- $debug .= "\n\t<li><strong>Source Control:</strong> $scinfo</li>";
-
- // query information
- if (is_object($this->modules[ISSO_DB_LAYER]))
- {
- $debug .= "\n\t<li><strong>Total Queries:</strong> " . sizeof($this->modules[ISSO_DB_LAYER]->history) . " (<a href=\"" . $this->sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&query=1' : '?query=1') . "\">?</a>)</li>";
-
- $queries = $this->modules[ISSO_DB_LAYER]->history;
- $querydebug = "<br />\n" . '<table cellpadding="4" cellspacing="1" border="0" align="center" width="30%" style="background-color: rgb(60, 60, 60); color: white">' . "\n\t" . '<tr><td><strong>Query Debug</strong></td></tr>';
- foreach ($queries AS $query)
- {
- $querydebug .= "\n\t<tr style=\"background-color: rgb(230, 230, 230); color: black\">";
- $querydebug .= "\n\t\t<td>";
- $querydebug .= "\n\t\t\t$query[query]\n\n\t\t\t<div style=\"font-size: 9px;\">($query[time])</div>\n<!--\n" . implode("\n", $query[trace]) . "\n-->\n\t\t</td>\n\t</tr>";
- }
-
- $querydebug .= "\n</table>\n\n\n";
- }
-
+
// total execution time
if (defined('ISSO_MT_START'))
{
$debug .= "\n</ul>";
- $debug = "\n\n<!-- dev debug -->\n<div align=\"center\">\n\n<hr />\n" . $this->message('Debug Information', $debug, 1, true, false) . "\n</div>$querydebug\n<!-- / dev debug -->\n\n";
+ $debug = "\n\n<!-- dev debug -->\n<div align=\"center\">\n\n<hr />\n" . $this->message('Debug Information', $debug, 1, true, false) . "\n</div>\n<!-- / dev debug -->\n\n";
}
return $debug;
*/
function page_end()
{
- if ($this->registry->debug AND isset($_GET['query']))
- {
- ob_clean();
- ob_end_clean();
-
- if (is_array($this->registry->modules[ISSO_DB_LAYER]->history))
- {
- foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query)
- {
- echo $this->registry->modules[ISSO_DB_LAYER]->construct_query_debug($query);
- }
- }
- exit;
- }
-
if ($this->registry->is_loaded('printer_navigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true)))
{
echo $this->registry->modules['printer_navigation']->generate_footer_html();
{
echo "\n$copyright";
echo $this->registry->construct_debug_block(false);
+ echo $this->registry->modules[ISSO_DB_LAYER]->dblink->ConstructHTMLDebugBlock();
}
echo "\n\n</body>\n</html>";
exit;
}
- if ($this->registry->debug AND isset($_GET['query']))
- {
- if (is_array($this->registry->modules[ISSO_DB_LAYER]->history))
- {
- foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query)
- {
- echo $this->registry->modules[ISSO_DB_LAYER]->construct_query_debug($query);
- }
- }
- exit;
- }
-
if ($this->doneflush)
{
trigger_error('A template has already been sent to the output buffer', E_USER_ERROR);
exit;
}
- $template = str_replace('</body>', $this->registry->construct_debug_block(true) . '</body>', $template);
+ $template = str_replace('</body>', $this->registry->construct_debug_block(true) . $this->registry->modules[ISSO_DB_LAYER]->dblink->ConstructHTMLDebugBlock() . '</body>', $template);
print($template);
}
-Subproject commit 632096709e0976f7c1a58dddce4dce9cb1699592
+Subproject commit 27dda14dbe778b3d448ad82218e97611bee9302d
define('ISSO_MT_START', microtime());
define('ISSO_CHECK_POST_REFERER', 1);
+// TODO(port): Define this in index.php instead.
+define('BUGDAR_ROOT', dirname(dirname(__FILE__)));
+
require_once('./includes/version.php');
require_once('./framework/kernel.php');
require_once('./includes/config.php');
$bugsys->setDebug($debug);
+define('DEVDEBUG', $debug);
+unset($debug);
+
+// ###################################################################
+// init the big three
+$bugsys->options = array();
+$bugsys->userinfo = array();
+
+class Bugdar
+{
+ /*! @var \PDO The database connection instance. */
+ static $db = NULL;
+
+ /*! @var \hoplite\http\Input Input filter for the new stack. */
+ static $input = NULL;
+
+ static $options = array();
+ static $user = array();
+ static $datastore = array();
+}
+
+// ###################################################################
+// Hoplite early initialization.
+
+define('HOPLITE_ROOT', dirname(__FILE__) . '/hoplite');
+
+if (DEVDEBUG) {
+ require_once HOPLITE_ROOT . '/base/profiling.php';
+ \hoplite\base\Profiling::EnableProfiling();
+}
+
+// ###################################################################
+// Connect to the database.
+
+$pdo_class = '\\PDO';
+if (DEVDEBUG) {
+ require_once HOPLITE_ROOT . '/data/profiling_pdo.php';
+ $pdo_class = '\\hoplite\\data\\ProfilingPDO';
+}
+Bugdar::$db = new $pdo_class("mysql:dbname=$database;host=$servername", $username, $password);
+unset($database, $servername, $username, $password);
+// Let ISSO handle the database connection failure message.
$bugsys->load('db_mysql_pdo', 'db', true);
-$db->connect($servername, $username, $password, $database, $usepconnect);
+$db->connect(Bugdar::$db);
+
+Bugdar::$db->SetAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
+
if ($utf8)
{
$db->query("SET NAMES utf8");
// change cookie expiration to one hour
$funct->cookieexp = 3600;
-define('DEVDEBUG', $debug);
define('TABLE_PREFIX', $tableprefix);
define('COOKIE_PREFIX', $cookieprefix);
-unset($database, $servername, $theuser, $password, $thepass, $usepconnect, $tableprefix, $cookieprefix);
+unset($usepconnect, $tableprefix, $cookieprefix);
require_once('./includes/functions_datastore.php');
require_once('./includes/functions.php');
require_once('./includes/language.php');
// ###################################################################
-// init the big three
-$bugsys->options = array();
-$bugsys->userinfo = array();
-Bugdar::$datastore = array();
-
-class Bugdar
-{
- /*! @var \PDO The database connection instance. */
- static $db = NULL;
-
- /*! @var \hoplite\http\Input Input filter for the new stack. */
- static $input = NULL;
-
- static $options = array();
- static $user = array();
- static $datastore = array();
-}
-
-// TODO(port): Define this in index.php instead.
-define('BUGDAR_ROOT', dirname(dirname(__FILE__)));
-
-// ###################################################################
-// Initialize Hoplite concurrently with ISSO 2.x.
-
-define('HOPLITE_ROOT', dirname(__FILE__) . '/hoplite');
+// Hoplite late initialization.
require_once HOPLITE_ROOT . '/data/model.php';
-\hoplite\data\Model::set_db($db->dblink);
+\hoplite\data\Model::set_db(Bugdar::$db);
require_once HOPLITE_ROOT . '/http/input.php';
Bugdar::$input = new \hoplite\http\Input(\hoplite\http\Input::TYPE_HTML);
-Bugdar::$db = $db->dblink;
-
-Bugdar::$db->SetAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
-
// ###################################################################
// send nocache
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");