<?php
/* +----------------------------------------------------------------------+
| Netautor Professional Application Server |
+----------------------------------------------------------------------+
| Copyright (C) 1998-2005 digiconcept GmbH. <www.digiconcept.net> |
+----------------------------------------------------------------------+
| This file is subject to license, that is bundled with this package |
| in the file LICENSE.TXT, and is available at through the |
| world-wide-web at http://www.netautor.com/license/ |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| hide@address.com so we can mail you a copy. |
+----------------------------------------------------------------------+
| Authors: Stefan Rottensteiner <hide@address.com> |
| Marek Kadziela <hide@address.com> |
| Gregor Wollner |
| Christian Unger |
| Helli Kleinhans |
+----------------------------------------------------------------------+
| @version $Revision: 1.17 $ |
+----------------------------------------------------------------------+*/
/**
* Show tables and informations of the current database connection.
* @author Marek Kadziela
* @author Stefan Rottensteiner
*/
require_once('../../include/init.inc');
if(!$GLOBALS['USER']->check_feature('Admin') && !$GLOBALS['USER']->check_feature('ac_database'))
{
$GLOBALS['USER']->login_call();
}
includeNaPro('array,form');
$GLOBALS['LOCALE']->textdomain('database');
$td_class1 = 'dbresult1';
$td_class2 = 'dbresult2';
$td_class = $td_class1;
$text = '';
$error = '';
$result = '';
$message = '';
$width = 975;
if(!empty($result_window)) $width = 750;
if (empty($counter)) $counter=0;
if(isset($request) && trim($request) == '')
{
$error .= 'No query given!';
$request = '';
}
if(!empty($request))
{
$message.= htmlspecialchars($request);
if ( strpos(strtolower($request), 'select ') >=0)
{
$start = microtime();
$result = $sql_world->select($request,0,$counter,2);
$ende = microtime();
list($m_start,$start) = explode(' ',trim($start));
list($m_ende,$ende) = explode(' ',trim($ende));
$start = doubleval($start) + doubleval($m_start);
$ende = doubleval($ende) + doubleval($m_ende);
$duration = $ende-$start;
$message .= '<br>'.$duration.' '.$GLOBALS['LOCALE']->gettext('sec');
if($result)
{
$text .= '<table border="0" cellspacing="2" cellpadding="3">
';
$text .= '<tr>
';
$text .= '<td align="left" valign="top" class="dbresulthead">#<br></td>
';
foreach($result[0] as $key => $values)
{
$text .= '<td align="left" valign="top" class="dbresulthead">'.$key.'<br>';
if(substr($key,0,3) == 'na_')
{
$field_id = substr($key,3);
$select_string = "SELECT me_name FROM melements WHERE me_id = ".$field_id;
$temp = $sql_world->select($select_string,0,1,0);
$text .= ''.$temp[0][0].'<br>';
}
$text .= '</td>
';
}
$text .= '</tr>
';
foreach($result as $key => $values)
{
$td_class = ( $td_class == $td_class2 ? $td_class1 :$td_class2);
$text .= '<tr>
';
$text .= '<td class="'.$td_class.'">'.$key.'<br></td>
';
foreach($values as $sub_key => $sub_value)
{
$text.= '<td class="'.$td_class.'">'.htmlentities($sub_value).'<br></td>
';
}
$text.= '</tr>
';
}
$text.= '</table>
';
}
else
{
DumpVar($result);
}
}
else
{
$result = $sql_world->exec($request,$leer);
DumpVar($result,$request);
}
}
if (!empty($sql_world->errnr))
{
$error.='ERROR: '.$sql_world->errstr.'';
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>digiconcept/netautor/sql query result</title>
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta name ="robots" content="noindex">
<link href="../../include/netautor.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
function new_window()
{
window.open('<?php echo $_SERVER['PHP_SELF']; ?>','SQL_RESULT','width=800,height=600,scrollbars=yes,resizable=yes');
document.forms[0].target = 'SQL_RESULT';
document.forms[0].elements['result_window'].value = 'yes';
setTimeout('reset_frame()',200);
}
function reset_frame()
{
document.forms[0].submit()
document.forms[0].target = '_self';
document.forms[0].elements['result_window'].value = '';
document.forms[0].elements['request'].value = '';
setTimeout('document.forms[0].submit()',200);
}
// -->
</script>
</head>
<body class="brown">
<table width="<?php echo($width); ?>" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="<?php echo(ceil($width/3)); ?>" align="left" valign="center" class="text">
<img src="../../grafik/pixel.gif" width="1" height="1"><br>
</td>
<td width="<?php echo(ceil($width/3)); ?>" align="center" valign="top" nowrap>
<img src="../../grafik/pixel.gif" width="1" height="1"><br>
<span class="head">
<?php echo( $GLOBALS['LOCALE']->gettext('result') ); ?><br>
</span>
</td>
<td width="<?php echo(ceil($width/3)); ?>" align="right" valign="center" class="text">
<img src="../../grafik/pixel.gif" width="1" height="1"><br>
<?php
if(empty($result_window))
{
?>
<a href="#" onClick="new_window();" class="link"><?php echo( $GLOBALS['LOCALE']->gettext('new_window') ); ?></a><br>
<?php
}
?>
</td>
</tr>
</table>
<table width="<?php echo($width); ?>" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="<?php echo($width); ?>" align="center" valign="top" class="text">
<center>
<br>
<?php
if(!empty($message)) echo($message.'<br>');
if(!empty($error)) echo('<span class="textred">'.$error.'</span><br>');
?>
</center>
<br>
<?php
if(!empty($text)) echo($text.'<br>');
?>
<br><br>
<img src="../../grafik/pixel.gif" width="592" height="1"><br>
</td>
</tr>
<tr>
<td width="<?php echo($width); ?>"><img src="../../grafik/pixel.gif" width="<?php echo($width); ?>" height="1"><br></td>
</tr>
</table>
<br>
<form name="result" action="<?php echo $_SERVER['PHP_SELF']; ?>" target="_self">
<input type="hidden" name="result_window" value="">
<input type="hidden" name="request" value="<?php if(!empty($request)) echo($request); ?>">
<input type="hidden" name="counter" value="<?php if(!empty($counter)) echo($counter); ?>">
</form>
</body>
</html>