author | Dan |
Fri, 18 Dec 2009 19:06:49 -0500 | |
changeset 1175 | 1e2c9819ede3 |
parent 1165 | ce8aaa2956d1 |
child 1184 | 2cb6d7086776 |
permissions | -rw-r--r-- |
1 | 1 |
<?php |
2 |
||
3 |
/* |
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
1081
745200a9cc2a
Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents:
973
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Dan Fuhry |
1 | 6 |
* |
7 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
11 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
12 |
*/ |
|
13 |
||
14 |
function db_error_handler($errno, $errstr, $errfile = false, $errline = false, $errcontext = Array() ) |
|
15 |
{ |
|
16 |
if ( !defined('ENANO_DEBUG') ) |
|
17 |
return; |
|
18 |
$e = error_reporting(0); |
|
19 |
error_reporting($e); |
|
20 |
if ( $e < $errno ) |
|
21 |
return; |
|
22 |
$errtype = 'Notice'; |
|
23 |
switch ( $errno ) |
|
24 |
{ |
|
25 |
case E_ERROR: case E_USER_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: $errtype = 'Error'; break; |
|
26 |
case E_WARNING: case E_USER_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: $errtype = 'Warning'; break; |
|
27 |
} |
|
28 |
$debug = debug_backtrace(); |
|
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
29 |
if ( !isset($debug[0]['file']) ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
30 |
return false; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
31 |
$debug = $debug[0]['file'] . ', line ' . $debug[0]['line']; |
1 | 32 |
echo "<b>$errtype:</b> $errstr<br />Error source:<pre>$debug</pre>"; |
33 |
} |
|
592 | 34 |
|
35 |
global $db_sql_parse_time; |
|
36 |
$db_sql_parse_time = 0; |
|
37 |
||
1 | 38 |
class mysql { |
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
39 |
var $num_queries, $query_backtrace, $query_times, $query_sources, $latest_result, $latest_query, $_conn, $sql_stack_fields, $sql_stack_values, $debug; |
1 | 40 |
var $row = array(); |
41 |
var $rowset = array(); |
|
42 |
var $errhandler; |
|
809
ae4ef502f742
DBAL: Fixed issues with die_json() and multiline responses from {mysql,pg_last}_error()
Dan
parents:
801
diff
changeset
|
43 |
var $dbms_name = 'MySQL'; |
1 | 44 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
45 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
46 |
* Get a flat textual list of queries that have been made. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
47 |
*/ |
1 | 48 |
|
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
49 |
function sql_backtrace() |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
50 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
51 |
return implode("\n-------------------------------------------------------------------\n", $this->query_backtrace); |
1 | 52 |
} |
53 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
54 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
55 |
* Connect to the database, but only if a connection isn't already up. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
56 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
57 |
|
1 | 58 |
function ensure_connection() |
59 |
{ |
|
60 |
if(!$this->_conn) |
|
61 |
{ |
|
62 |
$this->connect(); |
|
63 |
} |
|
64 |
} |
|
65 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
66 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
67 |
* Exit Enano, dumping out a friendly error message indicating a database error on the way out. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
68 |
* @param string Description or location of error; defaults to none |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
69 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
70 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
71 |
function _die($t = '') |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
72 |
{ |
940
645727469415
DBAL: _die() now detects installation environment and, if present, calls installer UI library for error display chrome
Dan
parents:
902
diff
changeset
|
73 |
if ( defined('ENANO_HEADERS_SENT') ) |
1 | 74 |
ob_clean(); |
940
645727469415
DBAL: _die() now detects installation environment and, if present, calls installer UI library for error display chrome
Dan
parents:
902
diff
changeset
|
75 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
76 |
$internal_text = $this->get_error($t); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
77 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
78 |
if ( defined('ENANO_CONFIG_FETCHED') ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
79 |
// config is in, we can show a slightly nicer looking error page |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
80 |
die_semicritical('Database error', $internal_text); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
81 |
else |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
82 |
// no config, display using no-DB template engine |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
83 |
grinding_halt('Database error', $internal_text); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
84 |
|
1 | 85 |
exit; |
86 |
} |
|
87 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
88 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
89 |
* Get the internal text used for a database error message. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
90 |
* @param string Description or location of error; defaults to none |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
91 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
92 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
93 |
function get_error($t = '') |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
94 |
{ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
95 |
@header('HTTP/1.1 500 Internal Server Error'); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
96 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
97 |
$bt = $this->latest_query; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
98 |
$e = htmlspecialchars($this->sql_error()); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
99 |
if ( empty($e) ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
100 |
$e = '<none>'; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
101 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
102 |
global $email; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
103 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
104 |
// As long as the admin's e-mail is accessible, display it. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
105 |
$email_info = ( defined('ENANO_CONFIG_FETCHED') && is_object($email) ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
106 |
? ', at <' . $email->jscode() . $email->encryptEmail(getConfig('contact_email')) . '>' |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
107 |
: ''; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
108 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
109 |
$internal_text = "<h3>The site was unable to finish serving your request.</h3> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
110 |
<p>We apologize for the inconveience, but an error occurred in the Enano database layer. Please report the full text of this page to the administrator of this site{$email_info}.</p> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
111 |
<p>Description or location of error: $t<br /> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
112 |
Error returned by $this->dbms_name extension: $e</p> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
113 |
<p>Most recent SQL query:</p> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
114 |
<pre>$bt</pre>"; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
115 |
return $internal_text; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
116 |
} |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
117 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
118 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
119 |
* Exit Enano and output a JSON format datbase error. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
120 |
* @param string Description or location of error; defaults to none |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
121 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
122 |
|
475
51386f1852b8
Fixed $db->die_json(), should now produce standards-compliant output.
Dan
parents:
468
diff
changeset
|
123 |
function die_json($loc = false) |
1 | 124 |
{ |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
125 |
$e = str_replace("\n", "\\n", addslashes(htmlspecialchars($this->sql_error()))); |
468
194a19711346
Fixed the fact that cron just didn't work at all (brain fart that day or something)
Dan
parents:
424
diff
changeset
|
126 |
$q = str_replace("\n", "\\n", addslashes($this->latest_query)); |
475
51386f1852b8
Fixed $db->die_json(), should now produce standards-compliant output.
Dan
parents:
468
diff
changeset
|
127 |
$loc = ( $loc ) ? addslashes("\n\nDescription or location of error: $loc") : ""; |
51386f1852b8
Fixed $db->die_json(), should now produce standards-compliant output.
Dan
parents:
468
diff
changeset
|
128 |
$loc .= "\n\nPlease report the full text of this error to the administrator of the site. If you believe that this is a bug with the software, please contact support@enanocms.org."; |
51386f1852b8
Fixed $db->die_json(), should now produce standards-compliant output.
Dan
parents:
468
diff
changeset
|
129 |
$loc = str_replace("\n", "\\n", $loc); |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
130 |
$t = "{\"mode\":\"error\",\"error\":\"An error occurred during database query.\\nQuery was:\\n $q\\n\\nError returned by {$this->dbms_name}: $e$loc\"}"; |
1 | 131 |
die($t); |
132 |
} |
|
133 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
134 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
135 |
* Connect to the database. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
136 |
* @param bool If true, enables all other parameters. Defaults to false, which emans that you can call this function with no arguments and it will fetch information from the config file. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
137 |
* @param string Database server hostname |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
138 |
* @param string Database server username |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
139 |
* @param string Database server password |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
140 |
* @param string Name of the database |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
141 |
* @param int Optional port number to connect over |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
142 |
*/ |
1 | 143 |
|
857
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
144 |
function connect($manual_credentials = false, $dbhost = false, $dbuser = false, $dbpasswd = false, $dbname = false, $dbport = false) |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
145 |
{ |
483 | 146 |
if ( !defined('ENANO_SQL_CONSTANTS') ) |
147 |
{ |
|
148 |
define('ENANO_SQL_CONSTANTS', ''); |
|
149 |
define('ENANO_DBLAYER', 'MYSQL'); |
|
150 |
define('ENANO_SQLFUNC_LOWERCASE', 'lcase'); |
|
151 |
define('ENANO_SQL_MULTISTRING_PRFIX', ''); |
|
152 |
define('ENANO_SQL_BOOLEAN_TRUE', 'true'); |
|
153 |
define('ENANO_SQL_BOOLEAN_FALSE', 'false'); |
|
154 |
} |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
155 |
|
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
156 |
if ( !$manual_credentials ) |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
157 |
{ |
1143
e271ae801c62
common_cli and dbal: Fixed lack of ENANO_INSTALLED check in determining config path
Dan
parents:
1081
diff
changeset
|
158 |
if ( defined('IN_ENANO_INSTALL') && !defined('IN_ENANO_UPGRADE') && !defined('ENANO_INSTALLED') ) |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
159 |
{ |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
160 |
@include(ENANO_ROOT.'/config.new.php'); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
161 |
} |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
162 |
else |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
163 |
{ |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
164 |
@include(ENANO_ROOT.'/config.php'); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
165 |
} |
857
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
166 |
|
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
167 |
if ( isset($crypto_key) ) |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
168 |
unset($crypto_key); // Get this sucker out of memory fast |
857
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
169 |
if ( empty($dbport) ) |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
170 |
$dbport = 3306; |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
171 |
|
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
172 |
if ( !defined('ENANO_INSTALLED') && !defined('MIDGET_INSTALLED') && !defined('IN_ENANO_INSTALL') ) |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
268
diff
changeset
|
173 |
{ |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
174 |
// scriptPath isn't set yet - we need to autodetect it to avoid infinite redirects |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
175 |
if ( !defined('scriptPath') ) |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
268
diff
changeset
|
176 |
{ |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
177 |
if ( isset($_SERVER['PATH_INFO']) && !preg_match('/index\.php$/', $_SERVER['PATH_INFO']) ) |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
178 |
{ |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
179 |
$_SERVER['REQUEST_URI'] = preg_replace(';' . preg_quote($_SERVER['PATH_INFO']) . '$;', '', $_SERVER['REQUEST_URI']); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
180 |
} |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
181 |
if ( !preg_match('/\.php$/', $_SERVER['REQUEST_URI']) ) |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
182 |
{ |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
183 |
// user requested http://foo/enano as opposed to http://foo/enano/index.php |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
184 |
$_SERVER['REQUEST_URI'] .= '/index.php'; |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
185 |
} |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
186 |
$sp = dirname($_SERVER['REQUEST_URI']); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
187 |
if($sp == '/' || $sp == '\\') $sp = ''; |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
188 |
define('scriptPath', $sp); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
189 |
define('contentPath', "$sp/index.php?title="); |
288
9a1a32bc2050
Hopefully once again fix scriptPath detection in dbal.php
Dan
parents:
286
diff
changeset
|
190 |
} |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
191 |
$loc = scriptPath . '/install/index.php'; |
331 | 192 |
define('IN_ENANO_INSTALL', 1); |
193 |
$GLOBALS['lang'] = new Language('eng'); |
|
194 |
global $lang; |
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
195 |
$lang->load_file('./language/english/core.json'); |
331 | 196 |
$lang->load_file('./language/english/install.json'); |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
197 |
// header("Location: $loc"); |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
198 |
redirect($loc, 'Enano not installed', 'We can\'t seem to find an Enano installation (valid config file). You will be transferred to the installation wizard momentarily...', 0); |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
199 |
exit; |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
268
diff
changeset
|
200 |
} |
1 | 201 |
} |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
202 |
|
857
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
203 |
if ( !$dbport ) |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
204 |
$dbport = 3306; |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
205 |
|
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
206 |
if ( $dbhost && !empty($dbport) && $dbport != 3306 ) |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
207 |
$dbhost = '127.0.0.1'; |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
208 |
|
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
209 |
$host_line = ( preg_match('/^:/', $dbhost) ) ? $dbhost : "{$dbhost}:{$dbport}"; |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
210 |
|
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
211 |
$this->_conn = @mysql_connect($host_line, $dbuser, $dbpasswd); |
1 | 212 |
unset($dbuser); |
213 |
unset($dbpasswd); // Security |
|
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
214 |
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
215 |
if ( !$this->_conn && !$manual_credentials ) |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
216 |
{ |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
217 |
grinding_halt('Enano is having a problem', '<p>Error: couldn\'t connect to MySQL.<br />'.mysql_error().'</p>'); |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
218 |
} |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
219 |
else if ( !$this->_conn && $manual_credentials ) |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
220 |
{ |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
221 |
return false; |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
222 |
} |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
223 |
|
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
224 |
// Reset some variables |
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
225 |
$this->query_backtrace = array(); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
226 |
$this->query_times = array(); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
227 |
$this->query_sources = array(); |
1 | 228 |
$this->num_queries = 0; |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
229 |
|
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
230 |
$this->debug = ( defined('ENANO_DEBUG') ); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
231 |
|
973
451141c834fe
Replaced the USE with a mysql_select_db() to cut out one query
Dan
parents:
953
diff
changeset
|
232 |
$q = @mysql_select_db($dbname); |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
233 |
|
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
234 |
if ( !$q ) |
352
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
348
diff
changeset
|
235 |
{ |
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
348
diff
changeset
|
236 |
if ( $manual_credentials ) |
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
348
diff
changeset
|
237 |
return false; |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
238 |
$this->_die('The database could not be selected.'); |
352
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
348
diff
changeset
|
239 |
} |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
240 |
|
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
241 |
// We're in! |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
242 |
return true; |
1 | 243 |
} |
244 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
245 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
246 |
* Make a SQL query. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
247 |
* @param string Query |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
248 |
* @param bool If false, skips all checks and logging stages. If you're doing a ton of queries, set this to true; in all other cases, leave at the default of false. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
249 |
* @return resource or false on failure |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
250 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
251 |
|
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
252 |
function sql_query($q, $log_query = true) |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
253 |
{ |
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
254 |
if ( $this->debug && function_exists('debug_backtrace') ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
255 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
256 |
$backtrace = @debug_backtrace(); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
257 |
if ( is_array($backtrace) ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
258 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
259 |
$bt = $backtrace[0]; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
260 |
if ( isset($backtrace[1]['class']) ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
261 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
262 |
if ( $backtrace[1]['class'] == 'sessionManager' ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
263 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
264 |
$bt = $backtrace[1]; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
265 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
266 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
267 |
$this->query_sources[$q] = substr($bt['file'], strlen(ENANO_ROOT) + 1) . ', line ' . $bt['line']; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
268 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
269 |
unset($backtrace); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
270 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
271 |
|
1 | 272 |
$this->num_queries++; |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
273 |
if ( $log_query || defined('ENANO_DEBUG') ) |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
274 |
{ |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
275 |
$this->query_backtrace[] = $q; |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
276 |
$this->latest_query = $q; |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
277 |
} |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
278 |
// First make sure we have a connection |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
279 |
if ( !$this->_conn ) |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
280 |
{ |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
281 |
$this->_die('A database connection has not yet been established.'); |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
282 |
} |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
283 |
// Start the timer |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
284 |
if ( $log_query || defined('ENANO_DEBUG') ) |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
285 |
$time_start = microtime_float(); |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
286 |
// Does this query look malicious? |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
287 |
if ( $log_query || defined('ENANO_DEBUG') ) |
1 | 288 |
{ |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
289 |
if ( !$this->check_query($q) ) |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
290 |
{ |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
291 |
$this->report_query($q); |
681
424ea7aac0ca
SECURITY: Full query is no longer shown on SQL injection attempt; silenced calls to mysql_unbuffered_query() due to some untraceable yet harmless errors
Dan
parents:
636
diff
changeset
|
292 |
$debug = ( defined('ENANO_DEBUG') ) ? '<p>Query was:</p><pre>'.htmlspecialchars($q).'</pre>' : ''; |
424ea7aac0ca
SECURITY: Full query is no longer shown on SQL injection attempt; silenced calls to mysql_unbuffered_query() due to some untraceable yet harmless errors
Dan
parents:
636
diff
changeset
|
293 |
grinding_halt('SQL Injection attempt', '<p>Enano has caught and prevented an SQL injection attempt. Your IP address has been recorded and the administrator has been notified.</p>' . $debug); |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
294 |
} |
1 | 295 |
} |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
296 |
|
619
80fa6fa6bf3a
Oops, somehow changed mysql_query() to pg_query() in MySQL DBAL
Dan
parents:
616
diff
changeset
|
297 |
$r = mysql_query($q, $this->_conn); |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
298 |
|
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
299 |
if ( $log_query ) |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
300 |
$this->query_times[$q] = microtime_float() - $time_start; |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
301 |
|
1 | 302 |
$this->latest_result = $r; |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
303 |
|
1 | 304 |
return $r; |
305 |
} |
|
306 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
307 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
308 |
* Make a SQL query, but do not have PHP buffer all the results. Useful for queries that are expected to return a huge number of results. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
309 |
* @param string Query |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
310 |
* @param bool If false, skips all checks and logging stages. If you're doing a ton of queries, set this to true; in all other cases, leave at the default of false. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
311 |
* @return resource or false on failure |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
312 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
313 |
|
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
314 |
function sql_unbuffered_query($q, $log_query = true) |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
315 |
{ |
1 | 316 |
$this->num_queries++; |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
317 |
if ( $log_query || defined('ENANO_DEBUG') ) |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
374
diff
changeset
|
318 |
$this->query_backtrace[] = '(UNBUFFERED) ' . $q; |
1 | 319 |
$this->latest_query = $q; |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
320 |
// First make sure we have a connection |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
321 |
if ( !$this->_conn ) |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
322 |
{ |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
323 |
$this->_die('A database connection has not yet been established.'); |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
324 |
} |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
325 |
// Does this query look malicious? |
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
326 |
if ( !$this->check_query($q) ) |
1 | 327 |
{ |
328 |
$this->report_query($q); |
|
681
424ea7aac0ca
SECURITY: Full query is no longer shown on SQL injection attempt; silenced calls to mysql_unbuffered_query() due to some untraceable yet harmless errors
Dan
parents:
636
diff
changeset
|
329 |
$debug = ( defined('ENANO_DEBUG') ) ? '<p>Query was:</p><pre>'.htmlspecialchars($q).'</pre>' : ''; |
424ea7aac0ca
SECURITY: Full query is no longer shown on SQL injection attempt; silenced calls to mysql_unbuffered_query() due to some untraceable yet harmless errors
Dan
parents:
636
diff
changeset
|
330 |
grinding_halt('SQL Injection attempt', '<p>Enano has caught and prevented an SQL injection attempt. Your IP address has been recorded and the administrator has been notified.</p>' . $debug); |
1 | 331 |
} |
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
parents:
256
diff
changeset
|
332 |
|
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
333 |
$time_start = microtime_float(); |
681
424ea7aac0ca
SECURITY: Full query is no longer shown on SQL injection attempt; silenced calls to mysql_unbuffered_query() due to some untraceable yet harmless errors
Dan
parents:
636
diff
changeset
|
334 |
$r = @mysql_unbuffered_query($q, $this->_conn); |
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
335 |
$this->query_times[$q] = microtime_float() - $time_start; |
1 | 336 |
$this->latest_result = $r; |
337 |
return $r; |
|
338 |
} |
|
339 |
||
340 |
/** |
|
592 | 341 |
* Performs heuristic analysis on a SQL query to check for known attack patterns. |
1 | 342 |
* @param string $q the query to check |
343 |
* @return bool true if query passed check, otherwise false |
|
344 |
*/ |
|
345 |
||
346 |
function check_query($q, $debug = false) |
|
347 |
{ |
|
592 | 348 |
global $db_sql_parse_time; |
349 |
$ts = microtime_float(); |
|
350 |
||
351 |
// remove properly escaped quotes |
|
812
68060328e9c6
Added CLI installer. Supports interactive, command-line, and internal-call installation. Fixed a few bugs related to anti-SQL injection parser and plugin installation.
Dan
parents:
809
diff
changeset
|
352 |
$q = str_replace('\\\\', '', $q); |
592 | 353 |
$q = str_replace(array("\\\"", "\\'"), '', $q); |
354 |
||
355 |
// make sure quotes match |
|
616
e311f5e6f904
Got the installer working. Fixed a few bugs including a nasty-to-debug issue where the lang_id was being hardcoded during installation, resulting in strings being inserted with the wrong lang_id causing an infinfinite loop with fetch() throwing a "no strings" error and using template (which calls fetch()) to complain
Dan
parents:
592
diff
changeset
|
356 |
foreach ( array("'", '"') as $quote ) |
1 | 357 |
{ |
812
68060328e9c6
Added CLI installer. Supports interactive, command-line, and internal-call installation. Fixed a few bugs related to anti-SQL injection parser and plugin installation.
Dan
parents:
809
diff
changeset
|
358 |
$n_quotes = get_char_count($q, $quote); |
68060328e9c6
Added CLI installer. Supports interactive, command-line, and internal-call installation. Fixed a few bugs related to anti-SQL injection parser and plugin installation.
Dan
parents:
809
diff
changeset
|
359 |
if ( $n_quotes % 2 == 1 ) |
1 | 360 |
{ |
592 | 361 |
// mismatched quotes |
812
68060328e9c6
Added CLI installer. Supports interactive, command-line, and internal-call installation. Fixed a few bugs related to anti-SQL injection parser and plugin installation.
Dan
parents:
809
diff
changeset
|
362 |
if ( $debug ) echo "Found mismatched quotes in query; parsed:\n$q\n"; |
1 | 363 |
return false; |
364 |
} |
|
592 | 365 |
// this quote is now confirmed to be matching; we can safely move all quoted strings out and replace with a token |
366 |
$q = preg_replace("/$quote(.*?)$quote/s", 'SAFE_QUOTE', $q); |
|
1 | 367 |
} |
592 | 368 |
$q = preg_replace("/(SAFE_QUOTE)+/", 'SAFE_QUOTE', $q); |
369 |
||
370 |
// quotes are now matched out. does this string have a comment marker in it? |
|
371 |
if ( strstr($q, '--') ) |
|
372 |
{ |
|
373 |
return false; |
|
374 |
} |
|
375 |
||
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
91
diff
changeset
|
376 |
if ( preg_match('/[\s]+(SAFE_QUOTE|[\S]+)=\\1($|[\s]+)/', $q, $match) ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
91
diff
changeset
|
377 |
{ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
91
diff
changeset
|
378 |
if ( $debug ) echo 'Found always-true test in query, injection attempt caught, match:<br />' . '<pre>' . print_r($match, true) . '</pre>'; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
91
diff
changeset
|
379 |
return false; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
91
diff
changeset
|
380 |
} |
592 | 381 |
|
382 |
$ts = microtime_float() - $ts; |
|
383 |
$db_sql_parse_time += $ts; |
|
1 | 384 |
return true; |
385 |
} |
|
386 |
||
387 |
/** |
|
388 |
* Set the internal result pointer to X |
|
389 |
* @param int $pos The number of the row |
|
390 |
* @param resource $result The MySQL result resource - if not given, the latest cached query is assumed |
|
391 |
* @return true on success, false on failure |
|
392 |
*/ |
|
393 |
||
394 |
function sql_data_seek($pos, $result = false) |
|
395 |
{ |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
396 |
if ( !$result ) |
1 | 397 |
$result = $this->latest_result; |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
398 |
if ( !$result ) |
1 | 399 |
return false; |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
400 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
401 |
return mysql_data_seek($result, $pos) ? true : false; |
1 | 402 |
} |
403 |
||
404 |
/** |
|
405 |
* Reports a bad query to the admin |
|
406 |
* @param string $query the naughty query |
|
407 |
* @access private |
|
408 |
*/ |
|
409 |
||
410 |
function report_query($query) |
|
411 |
{ |
|
412 |
global $session; |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
413 |
if ( is_object($session) && defined('ENANO_MAINSTREAM') ) |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
414 |
{ |
1 | 415 |
$username = $session->username; |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
416 |
$user_id = $session->user_id; |
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
417 |
} |
1 | 418 |
else |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
419 |
{ |
1 | 420 |
$username = 'Unavailable'; |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
421 |
$user_id = 1; |
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
422 |
} |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
423 |
|
1 | 424 |
$query = $this->escape($query); |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
425 |
$q = $this->sql_query('INSERT INTO '.table_prefix.'logs(log_type, action, time_id, date_string, page_text, author, author_uid, edit_summary) |
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
426 |
VALUES(\'security\', \'sql_inject\', '.time().', \'\', \''.$query.'\', \''.$username.'\', ' . $user_id . ', \''.$_SERVER['REMOTE_ADDR'].'\');'); |
1 | 427 |
} |
428 |
||
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
429 |
/** |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
430 |
* Returns the ID of the row last inserted. |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
431 |
* @return int |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
432 |
*/ |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
433 |
|
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
434 |
function insert_id() |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
435 |
{ |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
436 |
return @mysql_insert_id(); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
437 |
} |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
21
diff
changeset
|
438 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
439 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
440 |
* Fetch one row from the given query as an associative array. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
441 |
* @param resource The resource returned from sql_query; if this isn't provided, the last result resource is used. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
442 |
* @return array |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
443 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
444 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
445 |
function fetchrow($r = false) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
446 |
{ |
953
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
447 |
if ( !$this->_conn ) |
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
448 |
return false; |
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
449 |
|
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
450 |
if ( !$r ) |
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
451 |
$r = $this->latest_result; |
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
452 |
|
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
453 |
if ( !$r ) |
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
454 |
$this->_die('$db->fetchrow(): an invalid MySQL resource was passed.'); |
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
455 |
|
1 | 456 |
$row = mysql_fetch_assoc($r); |
953
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents:
940
diff
changeset
|
457 |
|
770
62fed244fa1c
Fixed timezone preference setting not fully implemented; added ability for users to select their own rank from a list of possible ranks based on group membership and user level
Dan
parents:
685
diff
changeset
|
458 |
return integerize_array($row); |
1 | 459 |
} |
460 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
461 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
462 |
* Fetch one row from the given query as a numeric array. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
463 |
* @param resource The resource returned from sql_query; if this isn't provided, the last result resource is used. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
464 |
* @return array |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
465 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
466 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
467 |
function fetchrow_num($r = false) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
468 |
{ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
469 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
470 |
$r = $this->latest_result; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
471 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
472 |
$this->_die('$db->fetchrow(): an invalid MySQL resource was passed.'); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
473 |
|
1 | 474 |
$row = mysql_fetch_row($r); |
770
62fed244fa1c
Fixed timezone preference setting not fully implemented; added ability for users to select their own rank from a list of possible ranks based on group membership and user level
Dan
parents:
685
diff
changeset
|
475 |
return integerize_array($row); |
1 | 476 |
} |
477 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
478 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
479 |
* Get the number of results for a given query. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
480 |
* @param resource The resource returned from sql_query; if this isn't provided, the last result resource is used. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
481 |
* @return array |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
482 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
483 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
484 |
function numrows($r = false) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
485 |
{ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
486 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
487 |
$r = $this->latest_result; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
488 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
489 |
$this->_die('$db->fetchrow(): an invalid MySQL resource was passed.'); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
490 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
491 |
return mysql_num_rows($r); |
1 | 492 |
} |
493 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
494 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
495 |
* Escape a string so that it may safely be included in a SQL query. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
496 |
* @param string String to escape |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
497 |
* @return string Escaped string |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
498 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
499 |
|
1 | 500 |
function escape($str) |
501 |
{ |
|
502 |
$str = mysql_real_escape_string($str); |
|
503 |
return $str; |
|
504 |
} |
|
505 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
506 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
507 |
* Free the given result from memory. Use this when completely finished with a result resource. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
508 |
* @param resource The resource returned from sql_query; if this isn't provided, the last result resource is used. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
509 |
* @return null |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
510 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
511 |
|
1 | 512 |
function free_result($result = false) |
513 |
{ |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
514 |
if ( !$result ) |
1 | 515 |
$result = $this->latest_result; |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
516 |
if ( !$result ) |
1 | 517 |
return null; |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
518 |
|
374
5c740e430a05
[minor] silenced errors to mysql_free_result() and pg_free_result()
Dan
parents:
352
diff
changeset
|
519 |
@mysql_free_result($result); |
1 | 520 |
return null; |
521 |
} |
|
522 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
523 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
524 |
* Close the database connection |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
525 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
526 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
527 |
function close() |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
528 |
{ |
503 | 529 |
@mysql_close($this->_conn); |
1 | 530 |
unset($this->_conn); |
531 |
} |
|
532 |
||
1147
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
533 |
/** |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
534 |
* Get a list of columns in the given table |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
535 |
* @param string Table |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
536 |
* @return array |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
537 |
*/ |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
538 |
|
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
539 |
function columns_in($table) |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
540 |
{ |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
541 |
if ( !is_string($table) ) |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
542 |
return false; |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
543 |
$q = $this->sql_query("SHOW COLUMNS IN $table;"); |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
544 |
if ( !$q ) |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
545 |
$this->_die(); |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
546 |
|
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
547 |
$columns = array(); |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
548 |
while ( $row = $this->fetchrow_num() ) |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
549 |
{ |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
550 |
$columns[] = $row[0]; |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
551 |
} |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
552 |
return $columns; |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
553 |
} |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
554 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
555 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
556 |
* Get the text of the most recent error. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
557 |
* @return string |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
558 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
559 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
560 |
function sql_error() |
1 | 561 |
{ |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
562 |
return mysql_error(); |
1 | 563 |
} |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
564 |
|
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
565 |
/** |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
566 |
* Generates and outputs a report of all the SQL queries made during execution. Should only be called after everything's over with. |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
567 |
*/ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
568 |
|
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
569 |
function sql_report() |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
570 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
571 |
global $db, $session, $paths, $template, $plugins; // Common objects |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
572 |
if ( !$session->get_permissions('mod_misc') ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
573 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
574 |
die_friendly('Access denied', '<p>You are not authorized to generate a SQL backtrace.</p>'); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
575 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
576 |
// Create copies of variables that may be changed after header is called |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
577 |
$backtrace = $this->query_backtrace; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
578 |
$times = $this->query_times; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
579 |
$template->header(); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
580 |
echo '<h3>SQL query log and timetable</h3>'; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
581 |
echo '<div class="tblholder"> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
582 |
<table border="0" cellspacing="1" cellpadding="4">'; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
583 |
$i = 0; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
584 |
foreach ( $backtrace as $query ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
585 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
586 |
$i++; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
587 |
$unbuffered = false; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
588 |
if ( substr($query, 0, 13) == '(UNBUFFERED) ' ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
589 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
590 |
$query = substr($query, 13); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
591 |
$unbuffered = true; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
592 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
593 |
if ( $i == 1 ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
594 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
595 |
echo '<tr> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
596 |
<th colspan="2">SQL backtrace for a normal page load of ' . htmlspecialchars($paths->cpage['urlname']) . '</th> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
597 |
</tr>'; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
598 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
599 |
else |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
600 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
601 |
echo '<tr> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
602 |
<th class="subhead" colspan="2"> </th> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
603 |
</tr>'; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
604 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
605 |
echo '<tr> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
606 |
<td class="row2">Query:</td> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
607 |
<td class="row1"><pre>' . htmlspecialchars($query) . '</pre></td> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
608 |
</tr> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
609 |
<tr> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
610 |
<td class="row2">Time:</td> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
611 |
<td class="row1">' . number_format($this->query_times[$query], 6) . ' seconds</td> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
612 |
</tr> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
613 |
<tr> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
614 |
<td class="row2">Unbuffered:</td> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
615 |
<td class="row1">' . ( $unbuffered ? 'Yes' : 'No' ) . '</td> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
616 |
</tr>'; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
617 |
if ( isset($this->query_sources[$query]) ) |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
618 |
{ |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
619 |
echo '<tr> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
620 |
<td class="row2">Called from:</td> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
621 |
<td class="row1">' . $this->query_sources[$query] . '</td> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
622 |
</tr>'; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
623 |
} |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
624 |
} |
293
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
625 |
if ( function_exists('array_sum') ) |
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
626 |
{ |
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
627 |
$query_time_total = array_sum($this->query_times); |
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
628 |
echo '<tr> |
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
629 |
<th class="subhead" colspan="2"> |
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
630 |
Total time taken for SQL queries: ' . round( $query_time_total, 6 ) . ' seconds |
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
631 |
</th> |
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
632 |
</tr>'; |
3f98d4ba1e33
Added OpenDocument MIME types and extensions; make sql_report page show total time taken for SQL queries
Dan
parents:
289
diff
changeset
|
633 |
} |
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
634 |
echo ' </table> |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
635 |
</div>'; |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
636 |
$template->footer(); |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
637 |
} |
1 | 638 |
} |
639 |
||
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
640 |
class postgresql |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
641 |
{ |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
642 |
var $num_queries, $query_backtrace, $query_times, $query_sources, $latest_result, $latest_query, $_conn, $sql_stack_fields, $sql_stack_values, $debug; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
643 |
var $row = array(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
644 |
var $rowset = array(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
645 |
var $errhandler; |
809
ae4ef502f742
DBAL: Fixed issues with die_json() and multiline responses from {mysql,pg_last}_error()
Dan
parents:
801
diff
changeset
|
646 |
var $dbms_name = 'PostgreSQL'; |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
647 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
648 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
649 |
* Get a flat textual list of queries that have been made. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
650 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
651 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
652 |
function sql_backtrace() |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
653 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
654 |
return implode("\n-------------------------------------------------------------------\n", $this->query_backtrace); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
655 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
656 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
657 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
658 |
* Connect to the database, but only if a connection isn't already up. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
659 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
660 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
661 |
function ensure_connection() |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
662 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
663 |
if(!$this->_conn) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
664 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
665 |
$this->connect(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
666 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
667 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
668 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
669 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
670 |
* Exit Enano, dumping out a friendly error message indicating a database error on the way out. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
671 |
* @param string Description or location of error; defaults to none |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
672 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
673 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
674 |
function _die($t = '') |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
675 |
{ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
676 |
if ( defined('ENANO_HEADERS_SENT') ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
677 |
ob_clean(); |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
678 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
679 |
$internal_text = $this->get_error($t); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
680 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
681 |
if ( defined('ENANO_CONFIG_FETCHED') ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
682 |
// config is in, we can show a slightly nicer looking error page |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
683 |
die_semicritical('Database error', $internal_text); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
684 |
else |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
685 |
// no config, display using no-DB template engine |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
686 |
grinding_halt('Database error', $internal_text); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
687 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
688 |
exit; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
689 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
690 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
691 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
692 |
* Get the internal text used for a database error message. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
693 |
* @param string Description or location of error; defaults to none |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
694 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
695 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
696 |
function get_error($t = '') |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
697 |
{ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
698 |
@header('HTTP/1.1 500 Internal Server Error'); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
699 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
700 |
$bt = $this->latest_query; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
701 |
$e = htmlspecialchars($this->sql_error()); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
702 |
if ( empty($e) ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
703 |
$e = '<none>'; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
704 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
705 |
global $email; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
706 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
707 |
// As long as the admin's e-mail is accessible, display it. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
708 |
$email_info = ( defined('ENANO_CONFIG_FETCHED') && is_object($email) ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
709 |
? ', at <' . $email->jscode() . $email->encryptEmail(getConfig('contact_email')) . '>' |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
710 |
: ''; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
711 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
712 |
$internal_text = "<h3>The site was unable to finish serving your request.</h3> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
713 |
<p>We apologize for the inconveience, but an error occurred in the Enano database layer. Please report the full text of this page to the administrator of this site{$email_info}.</p> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
714 |
<p>Description or location of error: $t<br /> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
715 |
Error returned by $this->dbms_name extension: $e</p> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
716 |
<p>Most recent SQL query:</p> |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
717 |
<pre>$bt</pre>"; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
718 |
return $internal_text; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
719 |
} |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
720 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
721 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
722 |
* Exit Enano and output a JSON format datbase error. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
723 |
* @param string Description or location of error; defaults to none |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
724 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
725 |
|
860 | 726 |
function die_json($loc = false) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
727 |
{ |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
728 |
$e = str_replace("\n", "\\n", addslashes(htmlspecialchars($this->sql_error()))); |
809
ae4ef502f742
DBAL: Fixed issues with die_json() and multiline responses from {mysql,pg_last}_error()
Dan
parents:
801
diff
changeset
|
729 |
$q = str_replace("\n", "\\n", addslashes($this->latest_query)); |
ae4ef502f742
DBAL: Fixed issues with die_json() and multiline responses from {mysql,pg_last}_error()
Dan
parents:
801
diff
changeset
|
730 |
$loc = ( $loc ) ? addslashes("\n\nDescription or location of error: $loc") : ""; |
ae4ef502f742
DBAL: Fixed issues with die_json() and multiline responses from {mysql,pg_last}_error()
Dan
parents:
801
diff
changeset
|
731 |
$loc .= "\n\nPlease report the full text of this error to the administrator of the site. If you believe that this is a bug with the software, please contact support@enanocms.org."; |
ae4ef502f742
DBAL: Fixed issues with die_json() and multiline responses from {mysql,pg_last}_error()
Dan
parents:
801
diff
changeset
|
732 |
$loc = str_replace("\n", "\\n", $loc); |
879
9788f2b7e08a
Corrected a few display issues in Postgres DBAL. Thanks Neal.
Dan
parents:
860
diff
changeset
|
733 |
$t = "{\"mode\":\"error\",\"error\":\"An error occurred during database query.\\nQuery was:\\n $q\\n\\nError returned by {$this->dbms_name}: $e$loc\"}"; |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
734 |
die($t); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
735 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
736 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
737 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
738 |
* Connect to the database. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
739 |
* @param bool If true, enables all other parameters. Defaults to false, which emans that you can call this function with no arguments and it will fetch information from the config file. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
740 |
* @param string Database server hostname |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
741 |
* @param string Database server username |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
742 |
* @param string Database server password |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
743 |
* @param string Name of the database |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
744 |
* @param int Optional port number to connect over |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
745 |
*/ |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
746 |
|
857
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
747 |
function connect($manual_credentials = false, $dbhost = false, $dbuser = false, $dbpasswd = false, $dbname = false, $dbport = false) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
748 |
{ |
483 | 749 |
if ( !defined('ENANO_SQL_CONSTANTS') ) |
750 |
{ |
|
751 |
define('ENANO_SQL_CONSTANTS', ''); |
|
752 |
define('ENANO_DBLAYER', 'PGSQL'); |
|
753 |
define('ENANO_SQLFUNC_LOWERCASE', 'lower'); |
|
754 |
define('ENANO_SQL_MULTISTRING_PRFIX', 'E'); |
|
755 |
define('ENANO_SQL_BOOLEAN_TRUE', '1'); |
|
756 |
define('ENANO_SQL_BOOLEAN_FALSE', '0'); |
|
757 |
} |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
758 |
|
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
759 |
if ( !$manual_credentials ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
760 |
{ |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
761 |
if ( defined('IN_ENANO_INSTALL') && !defined('IN_ENANO_UPGRADE') ) |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
762 |
{ |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
763 |
@include(ENANO_ROOT.'/config.new.php'); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
764 |
} |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
765 |
else |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
766 |
{ |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
767 |
@include(ENANO_ROOT.'/config.php'); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
768 |
} |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
769 |
|
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
770 |
if ( isset($crypto_key) ) |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
771 |
unset($crypto_key); // Get this sucker out of memory fast |
857
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
772 |
if ( empty($dbport) ) |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
773 |
$dbport = 5432; |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
774 |
|
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
775 |
if ( !defined('ENANO_INSTALLED') && !defined('MIDGET_INSTALLED') && !defined('IN_ENANO_INSTALL') ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
776 |
{ |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
777 |
// scriptPath isn't set yet - we need to autodetect it to avoid infinite redirects |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
778 |
if ( !defined('scriptPath') ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
779 |
{ |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
780 |
if ( isset($_SERVER['PATH_INFO']) && !preg_match('/index\.php$/', $_SERVER['PATH_INFO']) ) |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
781 |
{ |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
782 |
$_SERVER['REQUEST_URI'] = preg_replace(';' . preg_quote($_SERVER['PATH_INFO']) . '$;', '', $_SERVER['REQUEST_URI']); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
783 |
} |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
784 |
if ( !preg_match('/\.php$/', $_SERVER['REQUEST_URI']) ) |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
785 |
{ |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
786 |
// user requested http://foo/enano as opposed to http://foo/enano/index.php |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
787 |
$_SERVER['REQUEST_URI'] .= '/index.php'; |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
788 |
} |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
789 |
$sp = dirname($_SERVER['REQUEST_URI']); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
790 |
if($sp == '/' || $sp == '\\') $sp = ''; |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
791 |
define('scriptPath', $sp); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
792 |
define('contentPath', "$sp/index.php?title="); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
793 |
} |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
794 |
$loc = scriptPath . '/install.php'; |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
795 |
// header("Location: $loc"); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
796 |
redirect($loc, 'Enano not installed', 'We can\'t seem to find an Enano installation (valid config file). You will be transferred to the installation wizard momentarily...', 3); |
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
797 |
exit; |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
798 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
799 |
} |
857
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
800 |
|
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
801 |
if ( empty($dbport) ) |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
802 |
$dbport = 5432; |
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
803 |
|
f3a5a276208c
Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents:
812
diff
changeset
|
804 |
$this->_conn = @pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpasswd"); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
805 |
unset($dbuser); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
806 |
unset($dbpasswd); // Security |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
807 |
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
808 |
if ( !$this->_conn && !$manual_credentials ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
809 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
810 |
grinding_halt('Enano is having a problem', '<p>Error: couldn\'t connect to PostgreSQL.<br />'.pg_last_error().'</p>'); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
811 |
} |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
812 |
else if ( !$this->_conn && $manual_credentials ) |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
813 |
{ |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
814 |
return false; |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
815 |
} |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
816 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
817 |
// Reset some variables |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
818 |
$this->query_backtrace = array(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
819 |
$this->query_times = array(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
820 |
$this->query_sources = array(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
821 |
$this->num_queries = 0; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
822 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
823 |
$this->debug = ( defined('ENANO_DEBUG') ); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
824 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
825 |
// We're in! |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
826 |
return true; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
827 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
828 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
829 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
830 |
* Make a SQL query. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
831 |
* @param string Query |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
832 |
* @param bool If false, skips all checks and logging stages. If you're doing a ton of queries, set this to true; in all other cases, leave at the default of false. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
833 |
* @return resource or false on failure |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
834 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
835 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
836 |
function sql_query($q) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
837 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
838 |
if ( $this->debug && function_exists('debug_backtrace') ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
839 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
840 |
$backtrace = @debug_backtrace(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
841 |
if ( is_array($backtrace) ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
842 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
843 |
$bt = $backtrace[0]; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
844 |
if ( isset($backtrace[1]['class']) ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
845 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
846 |
if ( $backtrace[1]['class'] == 'sessionManager' ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
847 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
848 |
$bt = $backtrace[1]; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
849 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
850 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
851 |
$this->query_sources[$q] = substr($bt['file'], strlen(ENANO_ROOT) + 1) . ', line ' . $bt['line']; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
852 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
853 |
unset($backtrace); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
854 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
855 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
856 |
$this->num_queries++; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
857 |
$this->query_backtrace[] = $q; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
858 |
$this->latest_query = $q; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
859 |
// First make sure we have a connection |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
860 |
if ( !$this->_conn ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
861 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
862 |
$this->_die('A database connection has not yet been established.'); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
863 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
864 |
// Does this query look malicious? |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
865 |
if ( !$this->check_query($q) ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
866 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
867 |
$this->report_query($q); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
868 |
grinding_halt('SQL Injection attempt', '<p>Enano has caught and prevented an SQL injection attempt. Your IP address has been recorded and the administrator has been notified.</p><p>Query was:</p><pre>'.htmlspecialchars($q).'</pre>'); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
869 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
870 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
871 |
$time_start = microtime_float(); |
902
e7c6f1aa7b6a
Cleared up a few warnings that appeared under the Phalanger PHP interpreter.
Dan
parents:
879
diff
changeset
|
872 |
$r = @pg_query($this->_conn, $q); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
873 |
$this->query_times[$q] = microtime_float() - $time_start; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
874 |
$this->latest_result = $r; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
875 |
return $r; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
876 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
877 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
878 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
879 |
* Make a SQL query, but do not have PHP buffer all the results. Useful for queries that are expected to return a huge number of results. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
880 |
* @param string Query |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
881 |
* @param bool If false, skips all checks and logging stages. If you're doing a ton of queries, set this to true; in all other cases, leave at the default of false. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
882 |
* @return resource or false on failure |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
883 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
884 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
885 |
function sql_unbuffered_query($q) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
886 |
{ |
616
e311f5e6f904
Got the installer working. Fixed a few bugs including a nasty-to-debug issue where the lang_id was being hardcoded during installation, resulting in strings being inserted with the wrong lang_id causing an infinfinite loop with fetch() throwing a "no strings" error and using template (which calls fetch()) to complain
Dan
parents:
592
diff
changeset
|
887 |
return $this->sql_query($q); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
888 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
889 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
890 |
/** |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
891 |
* Checks a SQL query for possible signs of injection attempts |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
892 |
* @param string $q the query to check |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
893 |
* @return bool true if query passed check, otherwise false |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
894 |
*/ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
895 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
896 |
function check_query($q, $debug = false) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
897 |
{ |
592 | 898 |
global $db_sql_parse_time; |
899 |
$ts = microtime_float(); |
|
900 |
||
901 |
// remove properly escaped quotes |
|
902 |
$q = str_replace(array("\\\"", "\\'"), '', $q); |
|
903 |
||
904 |
// make sure quotes match |
|
616
e311f5e6f904
Got the installer working. Fixed a few bugs including a nasty-to-debug issue where the lang_id was being hardcoded during installation, resulting in strings being inserted with the wrong lang_id causing an infinfinite loop with fetch() throwing a "no strings" error and using template (which calls fetch()) to complain
Dan
parents:
592
diff
changeset
|
905 |
foreach ( array("'", '"') as $quote ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
906 |
{ |
592 | 907 |
if ( get_char_count($q, $quote) % 2 == 1 ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
908 |
{ |
592 | 909 |
// mismatched quotes |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
910 |
return false; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
911 |
} |
592 | 912 |
// this quote is now confirmed to be matching; we can safely move all quoted strings out and replace with a token |
913 |
$q = preg_replace("/$quote(.*?)$quote/s", 'SAFE_QUOTE', $q); |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
914 |
} |
592 | 915 |
$q = preg_replace("/(SAFE_QUOTE)+/", 'SAFE_QUOTE', $q); |
916 |
||
917 |
// quotes are now matched out. does this string have a comment marker in it? |
|
918 |
if ( strstr($q, '--') ) |
|
919 |
{ |
|
920 |
return false; |
|
921 |
} |
|
922 |
||
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
923 |
if ( preg_match('/[\s]+(SAFE_QUOTE|[\S]+)=\\1($|[\s]+)/', $q, $match) ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
924 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
925 |
if ( $debug ) echo 'Found always-true test in query, injection attempt caught, match:<br />' . '<pre>' . print_r($match, true) . '</pre>'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
926 |
return false; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
927 |
} |
592 | 928 |
|
929 |
$ts = microtime_float() - $ts; |
|
930 |
$db_sql_parse_time += $ts; |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
931 |
return true; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
932 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
933 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
934 |
/** |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
935 |
* Set the internal result pointer to X |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
936 |
* @param int $pos The number of the row |
879
9788f2b7e08a
Corrected a few display issues in Postgres DBAL. Thanks Neal.
Dan
parents:
860
diff
changeset
|
937 |
* @param resource $result The PostgreSQL result resource - if not given, the latest cached query is assumed |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
938 |
* @return true on success, false on failure |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
939 |
*/ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
940 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
941 |
function sql_data_seek($pos, $result = false) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
942 |
{ |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
943 |
if ( !$result ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
944 |
$result = $this->latest_result; |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
945 |
if ( !$result ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
946 |
return false; |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
947 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
948 |
return pg_result_seek($result, $pos) ? true : false; |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
949 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
950 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
951 |
/** |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
952 |
* Reports a bad query to the admin |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
953 |
* @param string $query the naughty query |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
954 |
* @access private |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
955 |
*/ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
956 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
957 |
function report_query($query) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
958 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
959 |
global $session; |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
960 |
if ( is_object($session) && defined('ENANO_MAINSTREAM') ) |
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
961 |
{ |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
962 |
$username = $session->username; |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
963 |
$user_id = $session->user_id; |
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
964 |
} |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
965 |
else |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
966 |
{ |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
967 |
$username = 'Unavailable'; |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
968 |
$user_id = 1; |
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
969 |
} |
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
970 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
971 |
$query = $this->escape($query); |
1175
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
972 |
$q = $this->sql_query('INSERT INTO '.table_prefix.'logs(log_type, action, time_id, date_string, page_text, author, author_uid, edit_summary) |
1e2c9819ede3
Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents:
1165
diff
changeset
|
973 |
VALUES(\'security\', \'sql_inject\', '.time().', \'\', \''.$query.'\', \''.$username.'\', ' . $user_id . ', \''.$_SERVER['REMOTE_ADDR'].'\');'); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
974 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
975 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
976 |
/** |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
977 |
* Returns the ID of the row last inserted. |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
978 |
* @return int |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
979 |
*/ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
980 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
981 |
function insert_id() |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
982 |
{ |
628
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
983 |
// list of primary keys in Enano tables |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
984 |
// this is a bit hackish, but not much choice. |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
985 |
static $primary_keys = false; |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
986 |
if ( !is_array($primary_keys) ) |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
987 |
{ |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
988 |
$primary_keys = array( |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
989 |
table_prefix . 'comments' => 'comment_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
990 |
table_prefix . 'logs' => 'log_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
991 |
table_prefix . 'users' => 'user_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
992 |
table_prefix . 'banlist' => 'ban_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
993 |
table_prefix . 'files' => 'file_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
994 |
table_prefix . 'buddies' => 'buddy_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
995 |
table_prefix . 'privmsgs' => 'message_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
996 |
table_prefix . 'sidebar' => 'item_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
997 |
table_prefix . 'hits' => 'hit_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
998 |
table_prefix . 'groups' => 'group_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
999 |
table_prefix . 'group_members' => 'member_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1000 |
table_prefix . 'acl' => 'rule_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1001 |
table_prefix . 'page_groups' => 'pg_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1002 |
table_prefix . 'page_group_members' => 'pg_member_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1003 |
table_prefix . 'tags' => 'tag_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1004 |
table_prefix . 'lockout' => 'id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1005 |
table_prefix . 'language' => 'lang_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1006 |
table_prefix . 'language_strings' => 'string_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1007 |
table_prefix . 'ranks' => 'rank_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1008 |
table_prefix . 'captcha' => 'code_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1009 |
table_prefix . 'diffiehellman' => 'key_id', |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1010 |
table_prefix . 'plugins' => 'plugin_id' |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1011 |
); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1012 |
// allow plugins to patch this if needed |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1013 |
global $plugins; |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1014 |
$code = $plugins->setHook('pgsql_set_serial_list'); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1015 |
foreach ( $code as $cmd ) |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1016 |
{ |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1017 |
eval($cmd); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1018 |
} |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1019 |
} |
636
c9ea830a211f
Fixed a few more PostgreSQL bugs with insert_id() and an issue with setting SERIAL columns manually. May break things if installed into a database without first dropping tables.
Dan
parents:
628
diff
changeset
|
1020 |
$last_was_insert = preg_match('/^INSERT INTO ([a-z0-9_]+)/i', $this->latest_query, $match); |
628
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1021 |
if ( $last_was_insert ) |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1022 |
{ |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1023 |
// trick based on PunBB's PostgreSQL driver |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1024 |
$table =& $match[1]; |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1025 |
if ( isset($primary_keys[$table]) ) |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1026 |
{ |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1027 |
$primary_key = "{$table}_{$primary_keys[$table]}_seq"; |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1028 |
$q = pg_query("SELECT CURRVAL('$primary_key');"); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1029 |
return ( $q ) ? intval(@pg_fetch_result($q, 0)) : false; |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1030 |
} |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1031 |
} |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
619
diff
changeset
|
1032 |
return false; |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1033 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1034 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1035 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1036 |
* Fetch one row from the given query as an associative array. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1037 |
* @param resource The resource returned from sql_query; if this isn't provided, the last result resource is used. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1038 |
* @return array |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1039 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1040 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1041 |
function fetchrow($r = false) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1042 |
{ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1043 |
if ( !$this->_conn ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1044 |
return false; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1045 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1046 |
$r = $this->latest_result; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1047 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1048 |
$this->_die('$db->fetchrow(): an invalid ' . $this->dbms_name . ' resource was passed.'); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1049 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1050 |
$row = pg_fetch_assoc($r); |
770
62fed244fa1c
Fixed timezone preference setting not fully implemented; added ability for users to select their own rank from a list of possible ranks based on group membership and user level
Dan
parents:
685
diff
changeset
|
1051 |
return integerize_array($row); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1052 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1053 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1054 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1055 |
* Fetch one row from the given query as a numeric array. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1056 |
* @param resource The resource returned from sql_query; if this isn't provided, the last result resource is used. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1057 |
* @return array |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1058 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1059 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1060 |
function fetchrow_num($r = false) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1061 |
{ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1062 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1063 |
$r = $this->latest_result; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1064 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1065 |
$this->_die('$db->fetchrow(): an invalid ' . $this->dbms_name . ' resource was passed.'); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1066 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1067 |
$row = pg_fetch_row($r); |
770
62fed244fa1c
Fixed timezone preference setting not fully implemented; added ability for users to select their own rank from a list of possible ranks based on group membership and user level
Dan
parents:
685
diff
changeset
|
1068 |
return integerize_array($row); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1069 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1070 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1071 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1072 |
* Get the number of results for a given query. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1073 |
* @param resource The resource returned from sql_query; if this isn't provided, the last result resource is used. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1074 |
* @return array |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1075 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1076 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1077 |
function numrows($r = false) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1078 |
{ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1079 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1080 |
$r = $this->latest_result; |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1081 |
if ( !$r ) |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1082 |
$this->_die('$db->fetchrow(): an invalid ' . $this->dbms_name . ' resource was passed.'); |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1083 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1084 |
$n = pg_num_rows($r); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1085 |
return $n; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1086 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1087 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1088 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1089 |
* Escape a string so that it may safely be included in a SQL query. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1090 |
* @param string String to escape |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1091 |
* @return string Escaped string |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1092 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1093 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1094 |
function escape($str) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1095 |
{ |
860 | 1096 |
$str = pg_escape_string($this->_conn, $str); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1097 |
return $str; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1098 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1099 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1100 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1101 |
* Free the given result from memory. Use this when completely finished with a result resource. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1102 |
* @param resource The resource returned from sql_query; if this isn't provided, the last result resource is used. |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1103 |
* @return null |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1104 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1105 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1106 |
function free_result($result = false) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1107 |
{ |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1108 |
if ( !$result ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1109 |
$result = $this->latest_result; |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1110 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1111 |
if ( !$result ) |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1112 |
return null; |
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1113 |
|
374
5c740e430a05
[minor] silenced errors to mysql_free_result() and pg_free_result()
Dan
parents:
352
diff
changeset
|
1114 |
@pg_free_result($result); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1115 |
return null; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1116 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1117 |
|
1165
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1118 |
/** |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1119 |
* Close the database connection |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1120 |
*/ |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1121 |
|
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1122 |
function close() |
ce8aaa2956d1
DBAL: Majorly cleaned up and improved coding standards/documentation
Dan
parents:
1147
diff
changeset
|
1123 |
{ |
503 | 1124 |
@pg_close($this->_conn); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1125 |
unset($this->_conn); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1126 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1127 |
|
1147
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1128 |
/** |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1129 |
* Get a list of columns in the given table |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1130 |
* @param string Table |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1131 |
* @return array |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1132 |
*/ |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1133 |
|
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1134 |
function columns_in($table) |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1135 |
{ |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1136 |
if ( !is_string($table) ) |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1137 |
return false; |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1138 |
$q = $this->sql_query("SELECT * FROM $table LIMIT 1 OFFSET 0;"); |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1139 |
if ( !$q ) |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1140 |
$this->_die(); |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1141 |
if ( $this->numrows() < 1 ) |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1142 |
{ |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1143 |
// FIXME: Have another way to do this if the table is empty |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1144 |
return false; |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1145 |
} |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1146 |
|
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1147 |
$row = $this->fetchrow(); |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1148 |
$this->free_result(); |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1149 |
return array_keys($row); |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1150 |
} |
7ddd475bc661
PostgreSQL: Fixed user pages. Also added a columns_in() method to the DBAL to list columns in a table
Dan
parents:
1143
diff
changeset
|
1151 |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1152 |
function sql_error() |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1153 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1154 |
if ( $this->_conn ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1155 |
{ |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
1156 |
return pg_last_error(); |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1157 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1158 |
else |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1159 |
{ |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
331
diff
changeset
|
1160 |
return ( defined('IN_ENANO_INSTALL') ) ? $GLOBALS["lang"]->get('dbpgsql_msg_err_auth') : 'Access to the database was denied. Ensure that your database exists and that your username and password are correct.'; |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1161 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1162 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1163 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1164 |
/** |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1165 |
* Generates and outputs a report of all the SQL queries made during execution. Should only be called after everything's over with. |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1166 |
*/ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1167 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1168 |
function sql_report() |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1169 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1170 |
global $db, $session, $paths, $template, $plugins; // Common objects |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1171 |
if ( !$session->get_permissions('mod_misc') ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1172 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1173 |
die_friendly('Access denied', '<p>You are not authorized to generate a SQL backtrace.</p>'); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1174 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1175 |
// Create copies of variables that may be changed after header is called |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1176 |
$backtrace = $this->query_backtrace; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1177 |
$times = $this->query_times; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1178 |
$template->header(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1179 |
echo '<h3>SQL query log and timetable</h3>'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1180 |
echo '<div class="tblholder"> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1181 |
<table border="0" cellspacing="1" cellpadding="4">'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1182 |
$i = 0; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1183 |
foreach ( $backtrace as $query ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1184 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1185 |
$i++; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1186 |
$unbuffered = false; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1187 |
if ( substr($query, 0, 13) == '(UNBUFFERED) ' ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1188 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1189 |
$query = substr($query, 13); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1190 |
$unbuffered = true; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1191 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1192 |
if ( $i == 1 ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1193 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1194 |
echo '<tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1195 |
<th colspan="2">SQL backtrace for a normal page load of ' . htmlspecialchars($paths->cpage['urlname']) . '</th> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1196 |
</tr>'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1197 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1198 |
else |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1199 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1200 |
echo '<tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1201 |
<th class="subhead" colspan="2"> </th> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1202 |
</tr>'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1203 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1204 |
echo '<tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1205 |
<td class="row2">Query:</td> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1206 |
<td class="row1"><pre>' . htmlspecialchars($query) . '</pre></td> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1207 |
</tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1208 |
<tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1209 |
<td class="row2">Time:</td> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1210 |
<td class="row1">' . number_format($this->query_times[$query], 6) . ' seconds</td> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1211 |
</tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1212 |
<tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1213 |
<td class="row2">Unbuffered:</td> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1214 |
<td class="row1">' . ( $unbuffered ? 'Yes' : 'No' ) . '</td> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1215 |
</tr>'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1216 |
if ( isset($this->query_sources[$query]) ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1217 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1218 |
echo '<tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1219 |
<td class="row2">Called from:</td> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1220 |
<td class="row1">' . $this->query_sources[$query] . '</td> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1221 |
</tr>'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1222 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1223 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1224 |
if ( function_exists('array_sum') ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1225 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1226 |
$query_time_total = array_sum($this->query_times); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1227 |
echo '<tr> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1228 |
<th class="subhead" colspan="2"> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1229 |
Total time taken for SQL queries: ' . round( $query_time_total, 6 ) . ' seconds |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1230 |
</th> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1231 |
</tr>'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1232 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1233 |
echo ' </table> |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1234 |
</div>'; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1235 |
$template->footer(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1236 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1237 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
1238 |
|
1 | 1239 |
?> |