Rev Author Line No. Line
250 kaklik 1 <?php
2 /* $Id: db_details_links.inc.php,v 1.2 2006/01/17 17:02:30 cybot_tm Exp $ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4  
5 require_once('./libraries/common.lib.php');
6  
7 /**
8 * If coming from a Show MySQL link on the home page,
9 * put something in $sub_part
10 */
11 if (empty($sub_part)) {
12 $sub_part = '_structure';
13 }
14  
15 /**
16 * Checks for superuser privileges
17 */
18 // We were checking privileges with 'USE mysql' but users with the global
19 // priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
20 // (even if they cannot see the tables)
21  
22 $is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', null, PMA_DBI_QUERY_STORE);
23  
24 /**
25 * Prepares links
26 */
27 // Drop link if allowed
28 // rabus: Don't even try to drop information_schema. You won't be able to. Believe me. You won't.
29 // nijel: Don't allow to easilly drop mysql database, RFE #1327514.
30 if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) && ! $db_is_information_schema && ($db != 'mysql')) {
31 $tab_drop['link'] = 'sql.php';
32 $tab_drop['args']['sql_query'] = 'DROP DATABASE ' . PMA_backquote($db);
33 $tab_drop['args']['zero_rows'] = sprintf($GLOBALS['strDatabaseHasBeenDropped'], htmlspecialchars(PMA_backquote($db)));
34 $tab_drop['args']['goto'] = 'main.php';
35 $tab_drop['args']['back'] = 'db_details' . $sub_part . '.php';
36 $tab_drop['args']['reload'] = 1;
37 $tab_drop['args']['purge'] = 1;
38 $tab_drop['attr'] = 'onclick="return confirmLinkDropDB(this, \'DROP DATABASE ' . PMA_jsFormat($db) . '\')"';
39 }
40  
41 /**
42 * export, search and qbe links if there is at least one table
43 */
44 if ( $num_tables > 0 ) {
45 $tab_export['link'] = 'db_details_export.php';
46 $tab_search['link'] = 'db_search.php';
47 $tab_qbe['link'] = 'db_details_qbe.php';
48 }
49  
50 $tab_structure['link'] = 'db_details_structure.php';
51 $tab_structure['text'] = $GLOBALS['strStructure'];
52 $tab_structure['icon'] = 'b_props.png';
53  
54 $tab_sql['link'] = 'db_details.php';
55 $tab_sql['args']['db_query_force'] = 1;
56 $tab_sql['text'] = $GLOBALS['strSQL'];
57 $tab_sql['icon'] = 'b_sql.png';
58  
59 $tab_export['text'] = $GLOBALS['strExport'];
60 $tab_export['icon'] = 'b_export.png';
61 $tab_search['text'] = $GLOBALS['strSearch'];
62 $tab_search['icon'] = 'b_search.png';
63  
64 $tab_qbe['text'] = $GLOBALS['strQBE'];
65 $tab_qbe['icon'] = 's_db.png';
66  
67  
68 if ( ! $db_is_information_schema ) {
69 $tab_import['link'] = 'db_import.php';
70 $tab_import['text'] = $GLOBALS['strImport'];
71 $tab_import['icon'] = 'b_import.png';
72 $tab_drop['text'] = $GLOBALS['strDrop'];
73 $tab_drop['icon'] = 'b_deltbl.png';
74 $tab_drop['class'] = 'caution';
75 $tab_operation['link'] = 'db_operations.php';
76 $tab_operation['text'] = $GLOBALS['strOperations'];
77 $tab_operation['icon'] = 'b_tblops.png';
78 if ( $is_superuser ) {
79 $tab_privileges['link'] = 'server_privileges.php';
80 $tab_privileges['args']['checkprivs'] = $db;
81 // stay on database view
82 $tab_privileges['args']['viewing_mode'] = 'db';
83 $tab_privileges['text'] = $GLOBALS['strPrivileges'];
84 $tab_privileges['icon'] = 's_rights.png';
85 }
86 }
87  
88 /**
89 * Displays tab links
90 */
91 $tabs = array();
92 $tabs[] =& $tab_structure;
93 $tabs[] =& $tab_sql;
94 $tabs[] =& $tab_search;
95 $tabs[] =& $tab_qbe;
96 $tabs[] =& $tab_export;
97 if ( ! $db_is_information_schema ) {
98 $tabs[] =& $tab_import;
99 $tabs[] =& $tab_operation;
100 if ( $is_superuser ) {
101 $tabs[] =& $tab_privileges;
102 }
103 if ( $is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase'] ) {
104 $tabs[] =& $tab_drop;
105 }
106 }
107  
108 echo PMA_getTabs( $tabs );
109 unset( $tabs );
110  
111 /**
112 * Displays a message
113 */
114 if (!empty($message)) {
115 PMA_showMessage($message);
116 unset($message);
117 }
118 ?>
119 <br />