href = '';
if (isset($_REQUEST['database'])) {
$this->href .= 'database=' . urlencode($_REQUEST['database']);
if (isset($_REQUEST['schema']))
$this->href .= '&schema=' . urlencode($_REQUEST['schema']);
}
}
/**
* Sets the form tracking variable
*/
function setForm() {
$this->form = '';
if (isset($_REQUEST['database'])) {
$this->form .= "\n";
if (isset($_REQUEST['schema']))
$this->form .= "\n";
}
}
/**
* Replace all spaces with in a string
* @param $str The string to change
* @param $shownull True to show NULLs, false otherwise
* @param $type Field type if available, other NULL
* @return The string with replacements
*/
function printVal($str, $shownull = false, $type = null) {
global $lang;
// If the string contains at least one instance of >1 space in a row, a tab character, a
// space at the start of a line, or a space at the start of the whole string then
// substitute all spaces for s
if ($str === null && $shownull) return 'NULL';
else {
switch ($type) {
case 'int2':
case 'int4':
case 'int8':
case 'float4':
case 'float8':
case 'money':
case 'numeric':
case 'oid':
case 'xid':
case 'cid':
case 'tid':
return "
" . nl2br(htmlspecialchars($str)) . "
";
break;
case 'bool':
case 'boolean':
if ($str == 't') return $lang['strtrue'];
elseif ($str == 'f') return $lang['strfalse'];
else return nl2br(htmlspecialchars($str));
break;
case 'bytea':
// addCSlashes converts all weird ASCII characters to octal representation,
// EXCEPT the 'special' ones like \r \n \t, etc.
return htmlspecialchars(addCSlashes($str, "\0..\37\177..\377"));
break;
default:
if (strstr($str, ' ') || strstr($str, "\t") || strstr($str, "\n ") || ereg('^[ ]', $str)) {
$str = str_replace(' ', ' ', htmlspecialchars($str));
// Replace tabs with 8 spaces
$str = str_replace("\t", ' ', $str);
return nl2br($str);
}
else
return nl2br(htmlspecialchars($str));
}
}
}
/**
* A function to recursively strip slashes. Used to
* enforce magic_quotes_gpc being off.
* @param &var The variable to strip
*/
function stripVar(&$var) {
if (is_array($var)) {
foreach($var as $k => $v) {
$this->stripVar($var[$k]);
}
}
else
$var = stripslashes($var);
}
/**
* Print out a message
* @param $msg The message to print
*/
function printMsg($msg) {
if ($msg != '') echo "
{$msg}
\n";
}
/**
* Creates a database accessor
*/
function &getDatabaseAccessor($database) {
global $conf;
// Create the connection object and make the connection
$_connection = new Connection(
$conf['servers'][$_SESSION['webdbServerID']]['host'],
$conf['servers'][$_SESSION['webdbServerID']]['port'],
$_SESSION['webdbUsername'],
$_SESSION['webdbPassword'],
$database
);
// Get the name of the database driver we need to use. The description
// of the server is returned and placed into the conf array.
$_type = $_connection->getDriver($desc);
// XXX: NEED TO CHECK RETURN STATUS HERE
// Create a database wrapper class for easy manipulation of the
// connection.
include_once('./classes/database/' . $_type . '.php');
$data = &new $_type($_connection->conn);
return $data;
}
/**
* Prints the page header. If global variable $_no_output is
* set then no header is drawn.
* @param $title The title of the page
* @param $script script tag
*/
function printHeader($title = '', $script = null) {
global $appName, $lang, $_no_output, $conf;
if (!isset($_no_output)) {
// Send XHTML headers, or regular HTML headers
if (isset($conf['use_xhtml']) && $conf['use_xhtml']) {
echo "\n";
echo "\n";
echo "\n";
} else {
echo "\n";
echo "\n";
}
echo "\n";
echo "", htmlspecialchars($appName);
if ($title != '') echo " - {$title}";
echo "\n";
echo "\n";
// Theme
echo "\n";
if ($script) echo "{$script}\n";
echo "\n";
}
}
/**
* Prints the page footer
* @param $doBody True to output body tag, false otherwise
*/
function printFooter($doBody = true) {
global $_reload_browser, $_reload_drop_database;
if ($doBody) {
if (isset($_reload_browser)) $this->printReload(false);
elseif (isset($_reload_drop_database)) $this->printReload(true);
echo "\n";
}
echo "\n";
}
/**
* Prints the page body.
* @param $doBody True to output body tag, false otherwise
* @param $bodyClass - name of body class
*/
function printBody($bodyClass = '', $doBody = true ) {
global $_no_output;
if (!isset($_no_output)) {
if ($doBody) {
$bodyClass = htmlspecialchars($bodyClass);
echo "\n";
}
}
}
/**
* Outputs JavaScript code that will reload the browser
* @param $database True if dropping a database, false otherwise
*/
function printReload($database) {
echo "\n";
}
/**
* Display the navigation header for tables
*/
function printTableNav() {
global $lang;
$vars = $this->href . '&table=' . urlencode($_REQUEST['table']);
echo "
\n";
}
/**
* Do multi-page navigation. Displays the prev, next and page options.
* @param $page the page currently viewed
* @param $pages the maximum number of pages
* @param $url the url to refer to with the page number inserted
* @param $max_width the number of pages to make available at any one time (default = 20)
*/
function printPages($page, $pages, $url, $max_width = 20) {
global $lang;
$window = 10;
if ($page < 0 || $page > $pages) return;
if ($pages < 0) return;
if ($max_width <= 0) return;
if ($pages > 1) {
echo "
\n";
}
}
/**
* Displays link to the context help.if $conf['docsdir'] is set
* @param $url - last part of a document's url (relative to $conf['docsdir'])
*/
function printHelp($url) {
global $lang, $conf;
if (isset($conf['docdir'])) {
echo "