* * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. */ @define('HORDE_BASE', dirname(__FILE__) . '/..'); require_once HORDE_BASE . '/lib/base.php'; require_once 'Horde/Menu.php'; require_once 'Horde/Help.php'; require_once 'DB.php'; if (!Auth::isAdmin()) { Horde::fatal('Forbidden.', __FILE__, __LINE__); } $title = _("SQL Shell"); Horde::addScriptFile('stripe.js', 'horde', true); require HORDE_TEMPLATES . '/common-header.inc'; require HORDE_TEMPLATES . '/admin/common-header.inc'; ?>
setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS); if (Util::getFormData('list-tables')) { $description = 'LIST TABLES'; $result = $dbh->getListOf('tables'); } elseif (Util::getFormData('list-dbs')) { $description = 'LIST DATABASES'; $result = $dbh->getListOf('databases'); } elseif ($command = trim(Util::getFormData('sql'))) { // Keep a cache of prior queries for convenience. if (!isset($_SESSION['_sql_query_cache'])) { $_SESSION['_sql_query_cache'] = array(); } if (($key = array_search($command, $_SESSION['_sql_query_cache'])) !== false) { unset($_SESSION['_sql_query_cache'][$key]); } array_unshift($_SESSION['_sql_query_cache'], $command); while (count($_SESSION['_sql_query_cache']) > 20) { array_pop($_SESSION['_sql_query_cache']); } // Parse out the query results. $result = $dbh->query(String::convertCharset($command, NLS::getCharset(), $conf['sql']['charset'])); } if (isset($result)) { if (isset($command)) { echo '

' . _("Query") . '


' . htmlspecialchars($command) . '
'; } echo '

' . _("Results") . '


'; if (is_a($result, 'PEAR_Error')) { echo '
'; var_dump($result); echo '
'; } else { if (is_object($result)) { echo ''; $first = true; $i = 0; while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { if ($first) { echo ''; foreach ($row as $key => $val) { echo ''; } echo ''; $first = false; } echo ''; foreach ($row as $val) { echo ''; } echo ''; } echo '
' . (empty($key) ? ' ' : htmlspecialchars(String::convertCharset($key, $conf['sql']['charset']))) . '
' . (empty($val) ? ' ' : htmlspecialchars(String::convertCharset($val, $conf['sql']['charset']))) . '
'; } elseif (is_array($result)) { echo ''; $first = true; $i = 0; foreach ($result as $val) { if ($first) { echo ''; $first = false; } echo ''; } echo '
' . (isset($description) ? htmlspecialchars($description) : ' ') . '
' . (empty($val) ? ' ' : htmlspecialchars(String::convertCharset($val, $conf['sql']['charset']))) . '
'; } else { echo '' . _("Success") . ''; } } echo '
'; } ?> " class="button" onclick="document.sqlshell.sql.value = document.sqlshell.query_cache[document.sqlshell.query_cache.selectedIndex].value;" /> " class="button" onclick="document.sqlshell.sql.value = document.sqlshell.query_cache[document.sqlshell.query_cache.selectedIndex].value; document.sqlshell.submit();" />

" /> " onclick="document.sqlshell.sql.value=''" /> " /> getSpecialQuery('tables') !== null): ?>" /> getSpecialQuery('databases') !== null): ?>" />