action) { case 'find': $title = $this->lang['strfind']; $body_text = $this->doFind(); break; case 'sql': default: $title = $this->lang['strsql']; $body_text = $this->doDefault(); break; } $this->setWindowName('sqledit'); $this->scripts = ''; $this->printHeader($title, $this->scripts, true, 'header_sqledit.twig'); $this->printBody(true, 'sql_edit'); echo $body_text; $this->printFooter(true, 'footer_sqledit.twig'); } /** * Allow execution of arbitrary SQL statements on a database. */ public function doDefault() { $data = $this->misc->getDatabaseAccessor(); if (!isset($_SESSION['sqlquery'])) { $_SESSION['sqlquery'] = ''; } $this->coalesceArr($_REQUEST, 'search_path', implode(',', $data->getSearchPath())); $search_path = htmlspecialchars($_REQUEST['search_path']); $sqlquery = htmlspecialchars($_SESSION['sqlquery']); $default_html = $this->printTabs($this->misc->getNavTabs('popup'), 'sql', false); $default_html .= '
'; $default_html .= PHP_EOL; $default_html .= $this->printConnection('sql', false); $default_html .= PHP_EOL; $default_html .= '
'; $default_html .= ''.PHP_EOL; $default_html .= '
'.PHP_EOL; $default_html .= '
'; $default_html .= PHP_EOL; $default_html .= ''; $default_html .= PHP_EOL; $default_html .= '
'.PHP_EOL; $default_html .= '
'; if (ini_get('file_uploads')) { // Don't show upload option if max size of uploads is zero $max_size = $this->misc->inisizeToBytes(ini_get('upload_max_filesize')); if (is_double($max_size) && $max_size > 0) { $default_html .= '

'; $default_html .= ''; $default_html .= PHP_EOL; $default_html .= ''; $default_html .= '  

'; $default_html .= '

'.PHP_EOL; } } // Check that file uploads are enabled $checked = (isset($_REQUEST['paginate']) ? ' checked="checked"' : ''); $default_html .= '

'; $default_html .= PHP_EOL; $default_html .= '

'; $default_html .= PHP_EOL; $default_html .= '

'; $default_html .= ''.PHP_EOL; $default_html .= '

'.PHP_EOL; $default_html .= '
'.PHP_EOL; $default_html .= '
'; $default_html .= PHP_EOL; // Default focus //$this->setFocus('forms[0].query'); return $default_html; } private function _getFilters() { $filters = [ 'SCHEMA' => ['langkey' => 'strschemas', 'selected' => ''], 'TABLE' => ['langkey' => 'strtables', 'selected' => ''], 'VIEW' => ['langkey' => 'strviews', 'selected' => ''], 'SEQUENCE' => ['langkey' => 'strsequences', 'selected' => ''], 'COLUMN' => ['langkey' => 'strcolumns', 'selected' => ''], 'RULE' => ['langkey' => 'strrules', 'selected' => ''], 'INDEX' => ['langkey' => 'strindexes', 'selected' => ''], 'TRIGGER' => ['langkey' => 'strtriggers', 'selected' => ''], 'CONSTRAINT' => ['langkey' => 'strconstraints', 'selected' => ''], 'FUNCTION' => ['langkey' => 'strfunctions', 'selected' => ''], 'DOMAIN' => ['langkey' => 'strdomains', 'selected' => ''], ]; return $filters; } private function _getAdvancedFilters() { $advanced_filters = [ 'AGGREGATE' => ['langkey' => 'straggregates', 'selected' => ''], 'TYPE' => ['langkey' => 'strtypes', 'selected' => ''], 'OPERATOR' => ['langkey' => 'stroperators', 'selected' => ''], 'OPCLASS' => ['langkey' => 'stropclasses', 'selected' => ''], 'CONVERSION' => ['langkey' => 'strconversions', 'selected' => ''], 'LANGUAGE' => ['langkey' => 'strlanguages', 'selected' => ''], ]; return $advanced_filters; } /** * Searches for a named database object. */ public function doFind() { $data = $this->misc->getDatabaseAccessor(); $this->coalesceArr($_REQUEST, 'term', ''); $this->coalesceArr($_REQUEST, 'filter', ''); $default_html = $this->printTabs($this->misc->getNavTabs('popup'), 'find', false); $default_html .= '
'.PHP_EOL; $default_html .= $this->printConnection('find', false); $default_html .= '

_maxNameLen}\" />".PHP_EOL; $filters = $this->_getFilters(); $advanced_filters = $this->_getAdvancedFilters(); if (isset($filters[$_REQUEST['filter']])) { $filters[$_REQUEST['filter']]['selected'] = ' selected="selected" '; } if (isset($advanced_filters[$_REQUEST['filter']])) { $advanced_filters[$_REQUEST['filter']]['selected'] = ' selected="selected" '; } // Output list of filters. This is complex due to all the 'has' and 'conf' feature possibilities $default_html .= "'.PHP_EOL; $default_html .= "lang['strfind']}\" />".PHP_EOL; $default_html .= '

'.PHP_EOL; $default_html .= '
'.PHP_EOL; // Default focus $this->setFocus('forms[0].term'); return $default_html; } }