'mysql',
'db_server' => 'localhost',
'db_name' => 'test',
'db_user' => 'root',
'db_pass' => 'toor',
'db_charset' => 'latin2',
'page_charset' => 'iso-8859-2',
'remember' => 1
);
foreach ($cookie as $k => $v) {
if ('db_pass' == $k) { $v = base64_encode($v); }
$k = COOKIE_PREFIX.$k;
if (!isset($_COOKIE[$k])) {
$_COOKIE[$k] = $v;
}
}
require './dbkiss.php';
---------------------------------------------------------------------
*/
/*
Changelog:
1.14
* IIS server fixes: $_SERVER['SERVER_ADDR'] missing
1.13
* Table names and column names may start with numeric values ex. `52-644` as table name is now allowed.
1.12
* Fixed "order by" bug in views.
1.11
* Links in data output are now clickable. Clicking them does not reveal the location of your dbkiss script to external sites.
1.10
* Support for views in Postgresql (mysql had it already).
* Views are now displayed in a seperate listing, to the right of the tables on main page.
* Secure redirection - no referer header sent - when clicking external links (ex. powered by), so that the location of the dbkiss script on your site is not revealed.
1.09
* CSV export in sql editor and table view (feature sponsored by Patrick McGovern)
1.08
* date.timezone E_STRICT error fixed
1.07
* mysql tables with dash in the name generated errors, now all tables in mysql driver are
enquoted with backtick.
1.06
* postgresql fix
1.05
* export of all structure and data does take into account the table name filter on the main page,
so you can filter the tables that you want to export.
1.04
* exporting all structure/data didn't work (ob_gzhandler flush bug)
* cookies are now set using httponly option
* text editor complained about bad cr/lf in exported sql files
(mysql create table uses \n, so insert queries need to be seperated by \n and not \r\n)
1.03
* re-created array_walk_recursive for php4 compatibility
* removed stripping slashes from displayed content
* added favicon (using base64_encode to store the icon in php code, so it is still one-file database browser)
1.02
* works with short_open_tag disabled
* code optimizations/fixes
* postgresql error fix for large tables
1.01
* fix for mysql 3.23, which doesnt understand "LIMIT x OFFSET z"
1.00
* bug fixes
* minor feature enhancements
* this release is stable and can be used in production environment
0.61
* upper casing keywords in submitted sql is disabled (it also modified quoted values)
* sql error when displaying table with 0 rows
* could not connect to database that had upper case characters
*/
// todo: php error handler which cancels buffer output and exits on error
// todo: XSS and CSRF protection.
// todo: connect screen: [x] create database (if not exists) [charset]
// todo: connect screen: database (optional, if none provided will select the first database the user has access to)
// todo: mysqli driver (check if mysql extension is loaded, if not try to use mysqli)
// todo: support for the enum field type when editing row
// todo: search whole database form should appear also on main page
// todo: improve detecting primary keys when editing row (querying information_schema , for mysql > 4)
// todo: when dbkiss_sql dir is missing, display a message in sql editor that some features won't work (templates, pagination) currently it displays a message to create that dir and EXIT, but should allow basic operations
// todo: "Insert" on table view page
// todo: edit table structure
error_reporting(-1);
ini_set('display_errors', true);
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'Europe/Warsaw');
}
// Fix IIS missing variables in $_SERVER:
if (!isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}
}
if (!isset($_SERVER['SERVER_ADDR'])) {
if (isset($_SERVER['LOCAL_ADDR'])) {
$_SERVER['SERVER_ADDR'] = $_SERVER['LOCAL_ADDR'];
} else {
$_SERVER['SERVER_ADDR'] = 'unknown';
}
}
set_error_handler('errorHandler');
register_shutdown_function('errorHandler_last');
ini_set('display_errors', 1);
global $Global_LastError;
function errorHandler_last()
{
if (function_exists("error_get_last")) {
$error = error_get_last();
if ($error) {
errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
}
}
}
function errorHandler($errno, $errstr, $errfile, $errline)
{
global $Global_LastError;
$Global_LastError = $errstr;
// Check with error_reporting, if statement is preceded with @ we have to ignore it.
if (!($errno & error_reporting())) {
return;
}
// Headers.
if (!headers_sent()) {
header('HTTP/1.0 503 Service Unavailable');
while (ob_get_level()) { ob_end_clean(); } // This will cancel ob_gzhandler, so later we set Content-encoding to none.
header('Content-Encoding: none'); // Fix gzip encoding header.
header("Content-Type: text/html; charset=utf-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
// Error short message.
$errfile = basename($errfile);
$msg = sprintf('%s
In %s on line %d.', nl2br($errstr), $errfile, $errline);
// Display error.
printf("
%s', $html); printf('