Improve create-release script to handle QA branches higher than QA_4_8.
[phpmyadmin.git] / db_search.php
blobd64d21ed6adfa07c4959e32a7afaedba6127258e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * searches the entire database
6 * @todo make use of UNION when searching multiple tables
7 * @todo display executed query, optional?
8 * @package PhpMyAdmin
9 */
10 declare(strict_types=1);
12 use PhpMyAdmin\Database\Search;
13 use PhpMyAdmin\DatabaseInterface;
14 use PhpMyAdmin\Di\Container;
15 use PhpMyAdmin\Response;
16 use PhpMyAdmin\Template;
17 use PhpMyAdmin\Util;
19 if (! defined('ROOT_PATH')) {
20 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
23 global $db, $url_query;
25 require_once ROOT_PATH . 'libraries/common.inc.php';
27 $container = Container::getDefaultContainer();
28 $container->set(Response::class, Response::getInstance());
30 /** @var Response $response */
31 $response = $container->get(Response::class);
33 /** @var DatabaseInterface $dbi */
34 $dbi = $container->get(DatabaseInterface::class);
36 /** @var Template $template */
37 $template = $containerBuilder->get('template');
39 $header = $response->getHeader();
40 $scripts = $header->getScripts();
41 $scripts->addFile('db_search.js');
42 $scripts->addFile('sql.js');
43 $scripts->addFile('makegrid.js');
45 require ROOT_PATH . 'libraries/db_common.inc.php';
47 // If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
48 if (! $GLOBALS['cfg']['UseDbSearch']) {
49 Util::mysqlDie(
50 __('Access denied!'),
51 '',
52 false,
53 $err_url
55 } // end if
56 $url_query .= '&amp;goto=db_search.php';
57 $url_params['goto'] = 'db_search.php';
59 // Create a database search instance
60 $db_search = new Search($dbi, $db, $template);
62 // Display top links if we are not in an Ajax request
63 if (! $response->isAjax()) {
64 list(
65 $tables,
66 $num_tables,
67 $total_num_tables,
68 $sub_part,
69 $is_show_stats,
70 $db_is_system_schema,
71 $tooltip_truename,
72 $tooltip_aliasname,
73 $pos
74 ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
77 // Main search form has been submitted, get results
78 if (isset($_POST['submit_search'])) {
79 $response->addHTML($db_search->getSearchResults());
82 // If we are in an Ajax request, we need to exit after displaying all the HTML
83 if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) {
84 exit;
87 // Display the search form
88 $response->addHTML($db_search->getMainHtml());