Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
62ec9715f9
@ -11,7 +11,8 @@
|
||||
require_once './libraries/common.inc.php';
|
||||
|
||||
if (! isset($selected_tbl)) {
|
||||
require_once './libraries/header.inc.php';
|
||||
require './libraries/db_common.inc.php';
|
||||
require './libraries/db_info.inc.php';
|
||||
}
|
||||
|
||||
|
||||
@ -55,16 +56,15 @@ if ($cfgRelation['commwork']) {
|
||||
* Selects the database and gets tables names
|
||||
*/
|
||||
PMA_DBI_select_db($db);
|
||||
$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
|
||||
$tables = PMA_DBI_get_tables($db);
|
||||
|
||||
$count = 0;
|
||||
while ($row = PMA_DBI_fetch_row($rowset)) {
|
||||
$table = $row[0];
|
||||
foreach($tables as $table) {
|
||||
$comments = PMA_getComments($db, $table);
|
||||
|
||||
echo '<div>' . "\n";
|
||||
|
||||
echo '<h2>' . $table . '</h2>' . "\n";
|
||||
echo '<h2>' . htmlspecialchars($table) . '</h2>' . "\n";
|
||||
|
||||
/**
|
||||
* Gets table informations
|
||||
@ -204,7 +204,7 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
|
||||
} else {
|
||||
$row['Default'] = htmlspecialchars($row['Default']);
|
||||
}
|
||||
$field_name = htmlspecialchars($row['Field']);
|
||||
$field_name = $row['Field'];
|
||||
|
||||
if (PMA_MYSQL_INT_VERSION < 50025
|
||||
&& ! empty($analyzed_sql[0]['create_table_fields'][$field_name]['type'])
|
||||
@ -226,9 +226,9 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
|
||||
<td nowrap="nowrap">
|
||||
<?php
|
||||
if (isset($pk_array[$row['Field']])) {
|
||||
echo '<u>' . $field_name . '</u>';
|
||||
echo '<u>' . htmlspecialchars($field_name) . '</u>';
|
||||
} else {
|
||||
echo $field_name;
|
||||
echo htmlspecialchars($field_name);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
@ -362,24 +362,26 @@ class PMA_Table
|
||||
}
|
||||
|
||||
switch ($default_type) {
|
||||
case 'USER_DEFINED' :
|
||||
if ($is_timestamp && $default_value === '0') {
|
||||
// a TIMESTAMP does not accept DEFAULT '0'
|
||||
// but DEFAULT 0 works
|
||||
$query .= ' DEFAULT 0';
|
||||
} elseif ($type == 'BIT') {
|
||||
$query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default_value) . '\'';
|
||||
} else {
|
||||
$query .= ' DEFAULT \'' . PMA_sqlAddSlashes($default_value) . '\'';
|
||||
}
|
||||
break;
|
||||
case 'NULL' :
|
||||
case 'CURRENT_TIMESTAMP' :
|
||||
$query .= ' DEFAULT ' . $default_type;
|
||||
break;
|
||||
case 'NONE' :
|
||||
default :
|
||||
break;
|
||||
case 'USER_DEFINED' :
|
||||
if ($is_timestamp && $default_value === '0') {
|
||||
// a TIMESTAMP does not accept DEFAULT '0'
|
||||
// but DEFAULT 0 works
|
||||
$query .= ' DEFAULT 0';
|
||||
} elseif ($type == 'BIT') {
|
||||
$query .= ' DEFAULT b\''
|
||||
. preg_replace('/[^01]/', '0', $default_value)
|
||||
. '\'';
|
||||
} else {
|
||||
$query .= ' DEFAULT \'' . PMA_sqlAddSlashes($default_value) . '\'';
|
||||
}
|
||||
break;
|
||||
case 'NULL' :
|
||||
case 'CURRENT_TIMESTAMP' :
|
||||
$query .= ' DEFAULT ' . $default_type;
|
||||
break;
|
||||
case 'NONE' :
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($extra)) {
|
||||
@ -389,8 +391,10 @@ class PMA_Table
|
||||
if ($extra == 'AUTO_INCREMENT') {
|
||||
$primary_cnt = count($field_primary);
|
||||
if (1 == $primary_cnt) {
|
||||
for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) {
|
||||
//void
|
||||
for ($j = 0; $j < $primary_cnt; $j++) {
|
||||
if ($field_primary[$j] == $index) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($field_primary[$j]) && $field_primary[$j] == $index) {
|
||||
$query .= ' PRIMARY KEY';
|
||||
|
||||
@ -708,13 +708,27 @@ function PMA_includeJS($url)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds JS code snippets to be displayed by header.inc.php. Adds a newline to each snippet.
|
||||
* Adds JS code snippets to be displayed by header.inc.php. Adds a
|
||||
* newline to each snippet.
|
||||
*
|
||||
* @param string $str Js code to be added (e.g. "token=1234;")
|
||||
*
|
||||
*/
|
||||
function PMA_AddJSCode($str) {
|
||||
function PMA_AddJSCode($str)
|
||||
{
|
||||
$GLOBALS['js_script'][] = $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds JS code snippet for variable assignment to be displayed by header.inc.php.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
*
|
||||
*/
|
||||
function PMA_AddJSVar($key, $value)
|
||||
{
|
||||
PMA_AddJsCode(PMA_getJsValue($key, $value));
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -56,25 +56,64 @@ function PMA_escapeJsString($string)
|
||||
"\r" => '\r')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a value for javascript code.
|
||||
*
|
||||
* @param string $value String to be formatted.
|
||||
*
|
||||
* @retrun string formatted value.
|
||||
*/
|
||||
function PMA_formatJsVal($value)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
if ($value) {
|
||||
return 'true';
|
||||
} else {
|
||||
return 'false';
|
||||
}
|
||||
} elseif (is_int($value)) {
|
||||
return (int)$value;
|
||||
} else {
|
||||
return '"' . PMA_escapeJsString($value) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an javascript assignment with proper escaping of a value
|
||||
* and support for assigning array of strings.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
*
|
||||
* @return string Javascript code.
|
||||
*/
|
||||
function PMA_getJsValue($key, $value)
|
||||
{
|
||||
$result = $key . ' = ';
|
||||
if (is_array($value)) {
|
||||
$result .= '[';
|
||||
foreach ($value as $id => $val) {
|
||||
$result .= PMA_formatJsVal($value) . ",";
|
||||
}
|
||||
$result .= "];\n";
|
||||
} else {
|
||||
$result .= PMA_formatJsVal($value) . ";\n";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an javascript assignment with proper escaping of a value
|
||||
* and support for assigning array of strings.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function PMA_printJsValue($key, $value)
|
||||
{
|
||||
echo $key . ' = ';
|
||||
if (is_array($value)) {
|
||||
echo '[';
|
||||
foreach ($value as $id => $val) {
|
||||
echo "'" . PMA_escapeJsString($val) . "',";
|
||||
}
|
||||
echo "];\n";
|
||||
} else {
|
||||
echo "'" . PMA_escapeJsString($value) . "';\n";
|
||||
}
|
||||
echo PMA_getJsValue($key, $value);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -11,71 +11,64 @@
|
||||
|
||||
require_once 'url_generating.lib.php';
|
||||
|
||||
/**
|
||||
* PMA_tbl_setTitle() sets the title for foreign keys display link
|
||||
/**
|
||||
* Sets the title for foreign keys display link.
|
||||
*
|
||||
* @param $propertiesIconic Type of icon property
|
||||
* @param $themeImage Icon Image
|
||||
* @return string $str Value of the Title
|
||||
* @param mixed $propertiesIconic Type of icon property
|
||||
* @param string $pmaThemeImage Icon Image
|
||||
*
|
||||
* @return string $str Value of the Title
|
||||
*/
|
||||
|
||||
function PMA_tbl_setTitle($propertiesIconic,$pmaThemeImage){
|
||||
function PMA_tbl_setTitle($propertiesIconic, $pmaThemeImage)
|
||||
{
|
||||
if ($propertiesIconic == true) {
|
||||
$str = '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
|
||||
.'b_browse.png" alt="' . __('Browse foreign values') . '" title="'
|
||||
. __('Browse foreign values') . '" />';
|
||||
.'b_browse.png" alt="' . __('Browse foreign values') . '" title="'
|
||||
. __('Browse foreign values') . '" />';
|
||||
|
||||
if ($propertiesIconic === 'both') {
|
||||
$str .= __('Browse foreign values');
|
||||
return $str;
|
||||
}
|
||||
} else {
|
||||
return __('Browse foreign values');
|
||||
}
|
||||
if ($propertiesIconic === 'both') {
|
||||
$str .= __('Browse foreign values');
|
||||
}
|
||||
|
||||
return $str;
|
||||
} else {
|
||||
return __('Browse foreign values');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PMA_tbl_getFields() gets all the fields of a table along with their types,collations and whether null or not.
|
||||
/**
|
||||
* Gets all the fields of a table along with their types, collations
|
||||
* and whether null or not.
|
||||
*
|
||||
* @uses PMA_DBI_query()
|
||||
* @uses PMA_backquote()
|
||||
* @uses PMA_DBI_num_rows()
|
||||
* @uses PMA_DBI_fetch_assoc()
|
||||
* @uses PMA_DBI_free_result()
|
||||
* @uses preg_replace()
|
||||
* @uses str_replace()
|
||||
* @uses strncasecmp()
|
||||
* @uses empty()
|
||||
*
|
||||
* @param $db Selected database
|
||||
* @param $table Selected table
|
||||
*
|
||||
* @return array($fields_list,$fields_type,$fields_collation,$fields_null) Array containing the field list, field types, collations and null constatint
|
||||
* @param string $table Selected table
|
||||
* @param string $db Selected database
|
||||
*
|
||||
* @return array Array containing the field list, field types, collations
|
||||
* and null constraint
|
||||
*/
|
||||
|
||||
function PMA_tbl_getFields($table,$db) {
|
||||
|
||||
function PMA_tbl_getFields($table,$db)
|
||||
{
|
||||
// Gets the list and number of fields
|
||||
|
||||
$fields = PMA_DBI_get_columns($db, $table, true);
|
||||
$fields = PMA_DBI_get_columns($db, $table, true);
|
||||
$fields_list = $fields_null = $fields_type = $fields_collation = array();
|
||||
$geom_column_present = false;
|
||||
$geom_types = PMA_getGISDatatypes();
|
||||
|
||||
foreach ($fields as $row) {
|
||||
$fields_list[] = $row['Field'];
|
||||
$type = $row['Type'];
|
||||
|
||||
// check whether table contains geometric columns
|
||||
if (in_array($type, $geom_types)) {
|
||||
$geom_column_present = true;
|
||||
}
|
||||
|
||||
// reformat mysql query output
|
||||
if (strncasecmp($type, 'set', 3) == 0
|
||||
|| strncasecmp($type, 'enum', 4) == 0) {
|
||||
|| strncasecmp($type, 'enum', 4) == 0
|
||||
) {
|
||||
$type = str_replace(',', ', ', $type);
|
||||
} else {
|
||||
|
||||
// strip the "BINARY" attribute, except if we find "BINARY(" because
|
||||
// this would be a BINARY or VARBINARY field type
|
||||
if (!preg_match('@BINARY[\(]@i', $type)) {
|
||||
@ -91,51 +84,49 @@ function PMA_tbl_getFields($table,$db) {
|
||||
}
|
||||
$fields_null[] = $row['Null'];
|
||||
$fields_type[] = $type;
|
||||
$fields_collation[] = !empty($row['Collation']) && $row['Collation'] != 'NULL'
|
||||
? $row['Collation']
|
||||
: '';
|
||||
$fields_collation[] = ! empty($row['Collation']) && $row['Collation'] != 'NULL'
|
||||
? $row['Collation']
|
||||
: '';
|
||||
} // end while
|
||||
|
||||
return array($fields_list,$fields_type,$fields_collation,$fields_null, $geom_column_present);
|
||||
|
||||
return array($fields_list, $fields_type, $fields_collation, $fields_null, $geom_column_present);
|
||||
}
|
||||
|
||||
/* PMA_tbl_setTableHeader() sets the table header for displaying a table in query-by-example format
|
||||
/**
|
||||
* Sets the table header for displaying a table in query-by-example format.
|
||||
*
|
||||
* @return HTML content, the tags and content for table header
|
||||
* @param bool $geom_column_present whether a geometry column is present
|
||||
*
|
||||
* @return HTML content, the tags and content for table header
|
||||
*/
|
||||
|
||||
function PMA_tbl_setTableHeader($geom_column_present = false){
|
||||
|
||||
function PMA_tbl_setTableHeader($geom_column_present = false)
|
||||
{
|
||||
// Display the Function column only if there is alteast one geomety colum
|
||||
$func = '';
|
||||
if ($geom_column_present) {
|
||||
$func = '<th>' . __('Function') . '</th>';
|
||||
}
|
||||
|
||||
return '<thead>
|
||||
return '<thead>
|
||||
<tr>' . $func . '<th>' . __('Column') . '</th>
|
||||
<th>' . __('Type') . '</th>
|
||||
<th>' . __('Collation') . '</th>
|
||||
<th>' . __('Operator') . '</th>
|
||||
<th>' . __('Value') . '</th>
|
||||
</tr>
|
||||
</tr>
|
||||
</thead>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* PMA_tbl_getSubTabs() returns an array with necessary configrations to create sub-tabs(Table Search and Zoom Search) in the table_select page
|
||||
*
|
||||
* @return array $subtabs Array containing configuration (icon,text,link,id,args) of sub-tabs for Table Search and Zoom search
|
||||
/**
|
||||
* Returns an array with necessary configrations to create
|
||||
* sub-tabs(Table Search and Zoom Search) in the table_select page.
|
||||
*
|
||||
* @return array Array containing configuration (icon, text, link, id, args)
|
||||
* of sub-tabs for Table Search and Zoom search
|
||||
*/
|
||||
|
||||
function PMA_tbl_getSubTabs(){
|
||||
|
||||
function PMA_tbl_getSubTabs()
|
||||
{
|
||||
$subtabs = array();
|
||||
|
||||
$subtabs['search']['icon'] = 'b_search.png';
|
||||
$subtabs['search']['text'] = __('Table Search');
|
||||
$subtabs['search']['link'] = 'tbl_select.php';
|
||||
@ -148,74 +139,65 @@ function PMA_tbl_getSubTabs(){
|
||||
$subtabs['zoom']['id'] = 'zoom_search_id';
|
||||
|
||||
return $subtabs;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* PMA_tbl_getForeignFields_Values() creates the HTML content for: 1) Browsing foreign data for a field. 2) Creating elements for search criteria input on fields.
|
||||
/**
|
||||
* Creates the HTML content for:
|
||||
* 1) Browsing foreign data for a field.
|
||||
* 2) Creating elements for search criteria input on fields.
|
||||
*
|
||||
* @uses PMA_foreignDropdown
|
||||
* @uses PMA_generate_common_url
|
||||
* @uses isset()
|
||||
* @uses is_array()
|
||||
* @uses in_array()
|
||||
* @uses urlencode()
|
||||
* @uses str_replace()
|
||||
* @uses stbstr()
|
||||
*
|
||||
* @param $foreigners Array of foreign keys
|
||||
* @param $foreignData Foreign keys data
|
||||
* @param $field Column name
|
||||
* @param $tbl_fields_type Column type
|
||||
* @param $i Column index
|
||||
* @param $db Selected database
|
||||
* @param $table Selected table
|
||||
* @param $titles Selected title
|
||||
* @param $foreignMaxLimit Max limit of displaying foreign elements
|
||||
* @param $fields Array of search criteria inputs
|
||||
* @param $in_fbs In function based search
|
||||
*
|
||||
* @return string $str HTML content for viewing foreing data and elements for search criteria input.
|
||||
* @param array $foreigners Array of foreign keys
|
||||
* @param array $foreignData Foreign keys data
|
||||
* @param string $field Column name
|
||||
* @param string $tbl_fields_type Column type
|
||||
* @param int $i Column index
|
||||
* @param string $db Selected database
|
||||
* @param string $table Selected table
|
||||
* @param array $titles Selected title
|
||||
* @param int $foreignMaxLimit Max limit of displaying foreign elements
|
||||
* @param array $fields Array of search criteria inputs
|
||||
* @param bool $in_fbs Whether we are in 'function based search'
|
||||
*
|
||||
* @return string HTML content for viewing foreing data and elements
|
||||
* for search criteria input.
|
||||
*/
|
||||
|
||||
function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false){
|
||||
|
||||
function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false)
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) {
|
||||
// f o r e i g n k e y s
|
||||
$str .= ' <select name="fields[' . $i . ']" id="fieldID_' . $i .'">' . "\n";
|
||||
$str .= '<select name="fields[' . $i . ']" id="fieldID_' . $i .'">' . "\n";
|
||||
// go back to first row
|
||||
// here, the 4th parameter is empty because there is no current
|
||||
// value of data for the dropdown (the search page initial values
|
||||
// are displayed empty)
|
||||
$str .= PMA_foreignDropdown($foreignData['disp_row'],
|
||||
$foreignData['foreign_field'],
|
||||
$foreignData['foreign_display'],
|
||||
'', $foreignMaxLimit);
|
||||
$str .= ' </select>' . "\n";
|
||||
}
|
||||
elseif ($foreignData['foreign_link'] == true) {
|
||||
$str .= PMA_foreignDropdown(
|
||||
$foreignData['disp_row'], $foreignData['foreign_field'],
|
||||
$foreignData['foreign_display'], '', $foreignMaxLimit
|
||||
);
|
||||
$str .= '</select>' . "\n";
|
||||
|
||||
} elseif ($foreignData['foreign_link'] == true) {
|
||||
if(isset($fields[$i]) && is_string($fields[$i])){
|
||||
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] " value="' . $fields[$i] . '"';
|
||||
'id="field_' . md5($field) . '[' . $i .']"
|
||||
class="textfield"/>' ;
|
||||
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] " value="' . $fields[$i] . '"';
|
||||
'id="field_' . md5($field) . '[' . $i .']"
|
||||
class="textfield"/>' ;
|
||||
}
|
||||
else{
|
||||
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] "';
|
||||
'id="field_' . md5($field) . '[' . $i .']"
|
||||
class="textfield" />' ;
|
||||
$str .= '<input type="text" id="fieldID_' . $i .'"name="fields[' . $i . '] "';
|
||||
'id="field_' . md5($field) . '[' . $i .']"
|
||||
class="textfield" />' ;
|
||||
}
|
||||
?>
|
||||
<?php $str .= '<script type="text/javascript">';
|
||||
<?php $str .= '<script type="text/javascript">';
|
||||
// <![CDATA[
|
||||
$str .= <<<EOT
|
||||
$str .= <<<EOT
|
||||
<a target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes'); return false" href="browse_foreigners.php?
|
||||
EOT;
|
||||
$str .= '' . PMA_generate_common_url($db, $table) . '&field=' . urlencode($field) . '&fieldkey=' . $i . '">' . str_replace("'", "\'", $titles['Browse']) . '</a>';
|
||||
// ]]
|
||||
$str .= '</script>';
|
||||
|
||||
} elseif (in_array($tbl_fields_type[$i], PMA_getGISDatatypes())) {
|
||||
// g e o m e t r y
|
||||
$str .= '<input type="text" name="fields[' . $i . ']"'
|
||||
@ -228,72 +210,68 @@ EOT;
|
||||
$str .= PMA_linkOrButton($edit_url, $edit_str, array(), false, false, '_blank');
|
||||
$str .= '</span>';
|
||||
}
|
||||
|
||||
} elseif (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0) {
|
||||
// e n u m s
|
||||
$enum_value=explode(', ', str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)));
|
||||
$cnt_enum_value = count($enum_value);
|
||||
$str .= '<select name="fields[' . ($i) . '][]" id="fieldID_' . $i .'"'
|
||||
.' multiple="multiple" size="' . min(3, $cnt_enum_value) . '">' . "\n";
|
||||
for ($j = 0; $j < $cnt_enum_value; $j++) {
|
||||
if(isset($fields[$i]) && is_array($fields[$i]) && in_array($enum_value[$j],$fields[$i])){
|
||||
$str .= ' <option value="' . $enum_value[$j] . '" Selected>'
|
||||
. $enum_value[$j] . '</option>';
|
||||
}
|
||||
else{
|
||||
$str .= ' <option value="' . $enum_value[$j] . '">'
|
||||
. $enum_value[$j] . '</option>';
|
||||
}
|
||||
} // end for
|
||||
$str .= ' </select>' . "\n";
|
||||
}
|
||||
else {
|
||||
.' multiple="multiple" size="' . min(3, $cnt_enum_value) . '">' . "\n";
|
||||
|
||||
for ($j = 0; $j < $cnt_enum_value; $j++) {
|
||||
if (isset($fields[$i])
|
||||
&& is_array($fields[$i])
|
||||
&& in_array($enum_value[$j], $fields[$i])
|
||||
) {
|
||||
$str .= '<option value="' . $enum_value[$j] . '" Selected>'
|
||||
. $enum_value[$j] . '</option>';
|
||||
} else {
|
||||
$str .= '<option value="' . $enum_value[$j] . '">'
|
||||
. $enum_value[$j] . '</option>';
|
||||
}
|
||||
} // end for
|
||||
$str .= '</select>' . "\n";
|
||||
|
||||
} else {
|
||||
// o t h e r c a s e s
|
||||
$the_class = 'textfield';
|
||||
$type = $tbl_fields_type[$i];
|
||||
|
||||
if ($type == 'date') {
|
||||
$the_class .= ' datefield';
|
||||
} elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
|
||||
$the_class .= ' datetimefield';
|
||||
}
|
||||
if(isset($fields[$i]) && is_string($fields[$i])){
|
||||
$str .= ' <input type="text" name="fields[' . $i . ']" '
|
||||
.' size="40" class="' . $the_class . '" id="fieldID_' . $i .'" value = "' . $fields[$i] . '"/>' . "\n";
|
||||
}
|
||||
else{
|
||||
$str .= ' <input type="text" name="fields[' . $i . ']"'
|
||||
.' size="40" class="' . $the_class . '" id="fieldID_' . $i .'" />' . "\n";
|
||||
}
|
||||
};
|
||||
return $str;
|
||||
|
||||
if (isset($fields[$i]) && is_string($fields[$i])) {
|
||||
$str .= '<input type="text" name="fields[' . $i . ']"'
|
||||
.' size="40" class="' . $the_class . '" id="fieldID_'
|
||||
. $i .'" value = "' . $fields[$i] . '"/>' . "\n";
|
||||
} else {
|
||||
$str .= '<input type="text" name="fields[' . $i . ']"'
|
||||
.' size="40" class="' . $the_class . '" id="fieldID_'
|
||||
. $i .'" />' . "\n";
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
/* PMA_tbl_search_getWhereClause() Return the where clause for query generation based on the inputs provided.
|
||||
/**
|
||||
* Return the where clause for query generation based on the inputs provided.
|
||||
*
|
||||
* @uses PMA_backquote
|
||||
* @uses PMA_sqlAddslashes
|
||||
* @uses preg_match
|
||||
* @uses isset()
|
||||
* @uses in_array()
|
||||
* @uses str_replace()
|
||||
* @uses strpos()
|
||||
* @uses explode()
|
||||
* @uses trim()
|
||||
*
|
||||
* @param $fields Search criteria input
|
||||
* @param $names Name of the field(column) on which search criteria is submitted
|
||||
* @param $types Type of the field
|
||||
* @param $collations Field collation
|
||||
* @param $func_type Search fucntion/operator
|
||||
* @param $unaryFlag Whether operator unary or not
|
||||
*
|
||||
* @return string $str HTML content for viewing foreing data and elements for search criteria input.
|
||||
* @param mixed $fields Search criteria input
|
||||
* @param string $names Name of the column on which search is submitted
|
||||
* @param string $types Type of the field
|
||||
* @param string $collations Field collation
|
||||
* @param string $func_type Search fucntion/operator
|
||||
* @param bool $unaryFlag Whether operator unary or not
|
||||
* @param bool $geom_func Whether geometry functions should be applied
|
||||
*
|
||||
* @return string HTML content for viewing foreing data and elements
|
||||
* for search criteria input.
|
||||
*/
|
||||
|
||||
function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type, $unaryFlag, $geom_func = null){
|
||||
|
||||
function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type, $unaryFlag, $geom_func = null)
|
||||
{
|
||||
/**
|
||||
* @todo move this to a more apropriate place
|
||||
*/
|
||||
@ -305,7 +283,6 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
);
|
||||
|
||||
$w = '';
|
||||
|
||||
// If geometry function is set apply it to the field name
|
||||
if ($geom_func != null && trim($geom_func) != '') {
|
||||
// Get details about the geometry fucntions
|
||||
@ -314,8 +291,8 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
// If the function takes a single parameter
|
||||
if ($geom_funcs[$geom_func]['params'] == 1) {
|
||||
$backquoted_name = $geom_func . '(' . PMA_backquote($names) . ')';
|
||||
// If the function takes two parameters
|
||||
} else {
|
||||
// If the function takes two parameters
|
||||
// create gis data from the string
|
||||
$gis_data = PMA_createGISData($fields);
|
||||
|
||||
@ -326,7 +303,7 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
// New output type is the output type of the function being applied
|
||||
$types = $geom_funcs[$geom_func]['type'];
|
||||
|
||||
// If the intended where clause is something like 'IsEmpty(`spatial_col_name`)'
|
||||
// If the where clause is something like 'IsEmpty(`spatial_col_name`)'
|
||||
if (isset($geom_unary_functions[$geom_func]) && trim($fields) == '') {
|
||||
$w = $backquoted_name;
|
||||
return $w;
|
||||
@ -335,11 +312,11 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
$backquoted_name = PMA_backquote($names);
|
||||
}
|
||||
|
||||
if($unaryFlag){
|
||||
if ($unaryFlag) {
|
||||
$fields = '';
|
||||
$w = $backquoted_name . ' ' . $func_type;
|
||||
$w = $backquoted_name . ' ' . $func_type;
|
||||
|
||||
} elseif (in_array($types, PMA_getGISDatatypes())) {
|
||||
} elseif (in_array($types, PMA_getGISDatatypes()) && ! empty($fields)) {
|
||||
// create gis data from the string
|
||||
$gis_data = PMA_createGISData($fields);
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . $gis_data;
|
||||
@ -360,23 +337,25 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
$parens_open = '(';
|
||||
$parens_close = ')';
|
||||
|
||||
} else {
|
||||
$parens_open = '';
|
||||
$parens_close = '';
|
||||
}
|
||||
$enum_where = '\'' . PMA_sqlAddslashes($fields[0]) . '\'';
|
||||
for ($e = 1; $e < $enum_selected_count; $e++) {
|
||||
$enum_where .= ', \'' . PMA_sqlAddslashes($fields[$e]) . '\'';
|
||||
}
|
||||
} else {
|
||||
$parens_open = '';
|
||||
$parens_close = '';
|
||||
}
|
||||
$enum_where = '\'' . PMA_sqlAddslashes($fields[0]) . '\'';
|
||||
for ($e = 1; $e < $enum_selected_count; $e++) {
|
||||
$enum_where .= ', \'' . PMA_sqlAddslashes($fields[$e]) . '\'';
|
||||
}
|
||||
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close;
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close;
|
||||
}
|
||||
|
||||
} elseif ($fields != '') {
|
||||
// For these types we quote the value. Even if it's another type (like INT),
|
||||
// for a LIKE we always quote the value. MySQL converts strings to numbers
|
||||
// and numbers to strings as necessary during the comparison
|
||||
if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types) || strpos(' ' . $func_type, 'LIKE')) {
|
||||
if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types)
|
||||
|| strpos(' ' . $func_type, 'LIKE')
|
||||
) {
|
||||
$quot = '\'';
|
||||
} else {
|
||||
$quot = '';
|
||||
@ -392,23 +371,28 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
$fields = '^' . $fields . '$';
|
||||
}
|
||||
|
||||
if ($func_type == 'IN (...)' || $func_type == 'NOT IN (...)' || $func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN') {
|
||||
if ($func_type == 'IN (...)'
|
||||
|| $func_type == 'NOT IN (...)'
|
||||
|| $func_type == 'BETWEEN'
|
||||
|| $func_type == 'NOT BETWEEN'
|
||||
) {
|
||||
$func_type = str_replace(' (...)', '', $func_type);
|
||||
|
||||
// quote values one by one
|
||||
$values = explode(',', $fields);
|
||||
foreach ($values as &$value)
|
||||
$value = $quot . PMA_sqlAddslashes(trim($value)) . $quot;
|
||||
// quote values one by one
|
||||
$values = explode(',', $fields);
|
||||
foreach ($values as &$value) {
|
||||
$value = $quot . PMA_sqlAddslashes(trim($value)) . $quot;
|
||||
}
|
||||
|
||||
if ($func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN')
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . (isset($values[0]) ? $values[0] : '') . ' AND ' . (isset($values[1]) ? $values[1] : '');
|
||||
else
|
||||
if ($func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN') {
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . (isset($values[0]) ? $values[0] : '')
|
||||
. ' AND ' . (isset($values[1]) ? $values[1] : '');
|
||||
} else {
|
||||
$w = $backquoted_name . ' ' . $func_type . ' (' . implode(',', $values) . ')';
|
||||
}
|
||||
else {
|
||||
}
|
||||
} else {
|
||||
$w = $backquoted_name . ' ' . $func_type . ' ' . $quot . PMA_sqlAddslashes($fields) . $quot;;
|
||||
}
|
||||
|
||||
} // end if
|
||||
|
||||
return $w;
|
||||
@ -417,14 +401,14 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu
|
||||
/**
|
||||
* Formats a SVG plot for the query results.
|
||||
*
|
||||
* @param array $data Data for the status chart
|
||||
* @param array &$settings Settings used to generate the chart
|
||||
* @param array $data Data for the status chart
|
||||
* @param array &$settings Settings used to generate the chart
|
||||
*
|
||||
* @return string HTML and JS code for the SVG plot
|
||||
*/
|
||||
function PMA_SVG_scatter_plot($data, &$settings)
|
||||
{
|
||||
require_once './libraries/svg_plot/pma_scatter_plot.php';
|
||||
include_once './libraries/svg_plot/pma_scatter_plot.php';
|
||||
|
||||
if (empty($data)) {
|
||||
// empty data
|
||||
@ -441,15 +425,5 @@ function PMA_SVG_scatter_plot($data, &$settings)
|
||||
}
|
||||
return $scatter_plot->asSVG();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
|
||||
|
||||
$table = $T;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
require_once "./pmd_common.php";
|
||||
require_once './libraries/pmd_common.php';
|
||||
|
||||
$tab_column = get_tab_info();
|
||||
$script_tabs = get_script_tabs();
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
require_once 'pmd_common.php';
|
||||
require_once './libraries/pmd_common.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* @package phpMyAdmin-Designer
|
||||
*/
|
||||
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
|
||||
/**
|
||||
* If called directly from the designer, first save the positions
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
$die_save_pos = 0;
|
||||
include_once 'pmd_save_pos.php';
|
||||
extract($_POST, EXTR_SKIP);
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
extract($_POST, EXTR_SKIP);
|
||||
extract($_GET, EXTR_SKIP);
|
||||
$die_save_pos = 0;
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
include_once 'pmd_common.php';
|
||||
include_once './libraries/pmd_common.php';
|
||||
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
|
||||
|
||||
@ -1416,7 +1416,7 @@ if (isset($_REQUEST['flush_privileges'])) {
|
||||
/**
|
||||
* defines some standard links
|
||||
*/
|
||||
$link_edit = '<a class="edit_user_anchor ' . $conditional_class . '" href="server_privileges.php?' . $GLOBALS['url_query']
|
||||
$link_edit = '<a class="edit_user_anchor ' . $conditional_class . '" href="server_privileges.php?' . str_replace($GLOBALS['url_query'], '%', '%%')
|
||||
. '&username=%s'
|
||||
. '&hostname=%s'
|
||||
. '&dbname=%s'
|
||||
@ -1424,7 +1424,7 @@ $link_edit = '<a class="edit_user_anchor ' . $conditional_class . '" href="serve
|
||||
. PMA_getIcon('b_usredit.png', __('Edit Privileges'))
|
||||
. '</a>';
|
||||
|
||||
$link_revoke = '<a href="server_privileges.php?' . $GLOBALS['url_query']
|
||||
$link_revoke = '<a href="server_privileges.php?' . str_replace($GLOBALS['url_query'], '%', '%%')
|
||||
. '&username=%s'
|
||||
. '&hostname=%s'
|
||||
. '&dbname=%s'
|
||||
@ -1433,7 +1433,7 @@ $link_revoke = '<a href="server_privileges.php?' . $GLOBALS['url_query']
|
||||
. PMA_getIcon('b_usrdrop.png', __('Revoke'))
|
||||
. '</a>';
|
||||
|
||||
$link_export = '<a class="export_user_anchor ' . $conditional_class . '" href="server_privileges.php?' . $GLOBALS['url_query']
|
||||
$link_export = '<a class="export_user_anchor ' . $conditional_class . '" href="server_privileges.php?' . str_replace($GLOBALS['url_query'], '%', '%%')
|
||||
. '&username=%s'
|
||||
. '&hostname=%s'
|
||||
. '&initial=%s'
|
||||
@ -2353,7 +2353,9 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
|
||||
. ' ' . ($current['Grant_priv'] == 'Y' ? __('Yes') : __('No')) . "\n"
|
||||
. ' </td>' . "\n"
|
||||
. ' <td>' . "\n";
|
||||
$user_form .= sprintf($link_edit, urlencode($current_user),
|
||||
$user_form .= sprintf(
|
||||
$link_edit,
|
||||
urlencode($current_user),
|
||||
urlencode($current_host),
|
||||
urlencode(! isset($current['Db']) || $current['Db'] == '*' ? '' : $current['Db']),
|
||||
'');
|
||||
|
||||
@ -620,7 +620,8 @@ $links['innodb']['doc'] = 'innodb';
|
||||
// Variable to contain all com_ variables
|
||||
$used_queries = array();
|
||||
|
||||
// Variable to map variable names to their respective section name (used for js category filtering)
|
||||
// Variable to map variable names to their respective section name
|
||||
// (used for js category filtering)
|
||||
$allocationMap = array();
|
||||
|
||||
// sort vars into arrays
|
||||
@ -637,10 +638,15 @@ foreach ($server_status as $name => $value) {
|
||||
}
|
||||
|
||||
if(PMA_DRIZZLE) {
|
||||
$used_queries = PMA_DBI_fetch_result('SELECT * FROM data_dictionary.global_statements', 0, 1);
|
||||
$used_queries = PMA_DBI_fetch_result(
|
||||
'SELECT * FROM data_dictionary.global_statements',
|
||||
0,
|
||||
1
|
||||
);
|
||||
unset($used_queries['admin_commands']);
|
||||
} else {
|
||||
// admin commands are not queries (e.g. they include COM_PING, which is excluded from $server_status['Questions'])
|
||||
// admin commands are not queries (e.g. they include COM_PING,
|
||||
// which is excluded from $server_status['Questions'])
|
||||
unset($used_queries['Com_admin_commands']);
|
||||
}
|
||||
|
||||
@ -667,14 +673,38 @@ $server_db_isLocal = strtolower($cfg['Server']['host']) == 'localhost'
|
||||
|| $cfg['Server']['host'] == '127.0.0.1'
|
||||
|| $cfg['Server']['host'] == '::1';
|
||||
|
||||
PMA_AddJSCode('pma_token = \'' . $_SESSION[' PMA_token '] . "';\n" .
|
||||
'url_query = \'' . str_replace('&', '&', PMA_generate_common_url($db)) . "';\n" .
|
||||
'server_time_diff = new Date().getTime() - ' . (microtime(true) * 1000) . ";\n" .
|
||||
'server_os = \'' . PHP_OS . "';\n" .
|
||||
'is_superuser = ' . (PMA_isSuperuser() ? 'true' : 'false') . ";\n" .
|
||||
'server_db_isLocal = ' . ($server_db_isLocal ? 'true' : 'false') . ";\n" .
|
||||
'profiling_docu = \'' . PMA_showMySQLDocu('general-thread-states', 'general-thread-states') . "';\n" .
|
||||
'explain_docu = \'' . PMA_showMySQLDocu('explain-output', 'explain-output') . ";'\n");
|
||||
PMA_AddJSVar(
|
||||
'pma_token',
|
||||
$_SESSION[' PMA_token ']
|
||||
);
|
||||
PMA_AddJSVar(
|
||||
'url_query',
|
||||
str_replace('&', '&', PMA_generate_common_url($db))
|
||||
);
|
||||
PMA_AddJSVar(
|
||||
'server_time_diff',
|
||||
'new Date().getTime() - ' . (microtime(true) * 1000)
|
||||
);
|
||||
PMA_AddJSVar(
|
||||
'server_os',
|
||||
PHP_OS
|
||||
);
|
||||
PMA_AddJSVar(
|
||||
'is_superuser',
|
||||
PMA_isSuperuser()
|
||||
);
|
||||
PMA_AddJSVar(
|
||||
'server_db_isLocal',
|
||||
$server_db_isLocal
|
||||
);
|
||||
PMA_AddJSVar(
|
||||
'profiling_docu',
|
||||
PMA_showMySQLDocu('general-thread-states', 'general-thread-states')
|
||||
);
|
||||
PMA_AddJSVar(
|
||||
'explain_docu',
|
||||
PMA_showMySQLDocu('explain-output', 'explain-output')
|
||||
);
|
||||
|
||||
/**
|
||||
* start output
|
||||
|
||||
@ -16,9 +16,9 @@ require_once './libraries/common.inc.php';
|
||||
|
||||
$GLOBALS['js_include'][] = 'server_variables.js';
|
||||
|
||||
PMA_AddJSCode('pma_token = \'' . $_SESSION[' PMA_token '] . "';\n" .
|
||||
'is_superuser = ' . (PMA_isSuperuser() ? 'true' : 'false') . ";\n" .
|
||||
'url_query = \'' . str_replace('&', '&', PMA_generate_common_url($db)) . "';\n");
|
||||
PMA_AddJSVar('pma_token', $_SESSION[' PMA_token ']);
|
||||
PMA_AddJSVar('url_query', str_replace('&', '&', PMA_generate_common_url($db)));
|
||||
PMA_AddJSVar('is_superuser', PMA_isSuperuser() ? true : false);
|
||||
|
||||
|
||||
/**
|
||||
@ -179,4 +179,4 @@ function formatVariable($name,$value)
|
||||
*/
|
||||
require './libraries/footer.inc.php';
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
36
test/libraries/js_escape_test.php
Normal file
36
test/libraries/js_escape_test.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for JS variable formatting
|
||||
*
|
||||
* @package phpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/js_escape.lib.php';
|
||||
|
||||
class PMA_JS_Escape_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider variables
|
||||
*/
|
||||
public function testFormat($key, $value, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, PMA_getJsValue($key, $value));
|
||||
}
|
||||
|
||||
public function variables() {
|
||||
return array(
|
||||
array('foo', true, "foo = true;\n"),
|
||||
array('foo', false, "foo = false;\n"),
|
||||
array('foo', 100, "foo = 100;\n"),
|
||||
array('foo', 0, "foo = 0;\n"),
|
||||
array('foo', 'text', "foo = \"text\";\n"),
|
||||
array('foo', 'quote"', "foo = \"quote\\\"\";\n"),
|
||||
array('foo', 'apostroph\'', "foo = \"apostroph\\'\";\n"),
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user