Skip to content

Commit

Permalink
Retrieve parameters from $_POST in insert/edit pages
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Nov 10, 2018
1 parent ca06ecc commit 3d9ed65
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 118 deletions.
94 changes: 47 additions & 47 deletions libraries/classes/InsertEdit.php
Expand Up @@ -79,8 +79,8 @@ public function getFormParametersForInsertForm(
$_form_params['where_clause[' . $key_id . ']'] = trim($where_clause); $_form_params['where_clause[' . $key_id . ']'] = trim($where_clause);
} }
} }
if (isset($_REQUEST['clause_is_unique'])) { if (isset($_POST['clause_is_unique'])) {
$_form_params['clause_is_unique'] = $_REQUEST['clause_is_unique']; $_form_params['clause_is_unique'] = $_POST['clause_is_unique'];
} }
return $_form_params; return $_form_params;
} }
Expand Down Expand Up @@ -280,13 +280,13 @@ public function showTypeOrFunction($which, array $url_params, $is_show)
$this_url_params = array_merge($url_params, $params); $this_url_params = array_merge($url_params, $params);


if (! $is_show) { if (! $is_show) {
return ' : <a href="tbl_change.php' return ' : <a href="tbl_change.php" data-post="'
. Url::getCommon($this_url_params) . '">' . Url::getCommon($this_url_params, '') . '">'
. $this->showTypeOrFunctionLabel($which) . $this->showTypeOrFunctionLabel($which)
. '</a>'; . '</a>';
} }
return '<th><a href="tbl_change.php' return '<th><a href="tbl_change.php" data-post="'
. Url::getCommon($this_url_params) . Url::getCommon($this_url_params, '')
. '" title="' . __('Hide') . '">' . '" title="' . __('Hide') . '">'
. $this->showTypeOrFunctionLabel($which) . $this->showTypeOrFunctionLabel($which)
. '</a></th>'; . '</a></th>';
Expand Down Expand Up @@ -1120,7 +1120,7 @@ private function getDropDownDependingOnLength(
$html_output .= '<option value="' . $enum_value['html'] . '"'; $html_output .= '<option value="' . $enum_value['html'] . '"';
if ($data == $enum_value['plain'] if ($data == $enum_value['plain']
|| ($data == '' || ($data == ''
&& (! isset($_REQUEST['where_clause']) || $column['Null'] != 'YES') && (! isset($_POST['where_clause']) || $column['Null'] != 'YES')
&& isset($column['Default']) && isset($column['Default'])
&& $enum_value['plain'] == $column['Default']) && $enum_value['plain'] == $column['Default'])
) { ) {
Expand Down Expand Up @@ -1176,7 +1176,7 @@ private function getRadioButtonDependingOnLength(
. ' ' . $onChangeClause; . ' ' . $onChangeClause;
if ($data == $enum_value['plain'] if ($data == $enum_value['plain']
|| ($data == '' || ($data == ''
&& (! isset($_REQUEST['where_clause']) || $column['Null'] != 'YES') && (! isset($_POST['where_clause']) || $column['Null'] != 'YES')
&& isset($column['Default']) && isset($column['Default'])
&& $enum_value['plain'] == $column['Default']) && $enum_value['plain'] == $column['Default'])
) { ) {
Expand Down Expand Up @@ -1737,7 +1737,7 @@ public function getContinueInsertionForm(
'err_url' => $err_url, 'err_url' => $err_url,
'goto' => $GLOBALS['goto'], 'goto' => $GLOBALS['goto'],
'sql_query' => isset($_POST['sql_query']) ? $_POST['sql_query'] : null, 'sql_query' => isset($_POST['sql_query']) ? $_POST['sql_query'] : null,
'has_where_clause' => isset($_REQUEST['where_clause']), 'has_where_clause' => isset($_POST['where_clause']),
'insert_rows_default' => $GLOBALS['cfg']['InsertRows'], 'insert_rows_default' => $GLOBALS['cfg']['InsertRows'],
]); ]);
} }
Expand Down Expand Up @@ -2019,8 +2019,8 @@ private function getSpecialCharsAndBackupFieldForExistingRow(


//when copying row, it is useful to empty auto-increment column //when copying row, it is useful to empty auto-increment column
// to prevent duplicate key error // to prevent duplicate key error
if (isset($_REQUEST['default_action']) if (isset($_POST['default_action'])
&& $_REQUEST['default_action'] === 'insert' && $_POST['default_action'] === 'insert'
) { ) {
if ($column['Key'] === 'PRI' if ($column['Key'] === 'PRI'
&& mb_strpos($column['Extra'], 'auto_increment') !== false && mb_strpos($column['Extra'], 'auto_increment') !== false
Expand Down Expand Up @@ -2099,29 +2099,29 @@ private function getSpecialCharsAndBackupFieldForInsertingMode(
*/ */
public function getParamsForUpdateOrInsert() public function getParamsForUpdateOrInsert()
{ {
if (isset($_REQUEST['where_clause'])) { if (isset($_POST['where_clause'])) {
// we were editing something => use the WHERE clause // we were editing something => use the WHERE clause
$loop_array = is_array($_REQUEST['where_clause']) $loop_array = is_array($_POST['where_clause'])
? $_REQUEST['where_clause'] ? $_POST['where_clause']
: array($_REQUEST['where_clause']); : array($_POST['where_clause']);
$using_key = true; $using_key = true;
$is_insert = isset($_REQUEST['submit_type']) $is_insert = isset($_POST['submit_type'])
&& ($_REQUEST['submit_type'] == 'insert' && ($_POST['submit_type'] == 'insert'
|| $_REQUEST['submit_type'] == 'showinsert' || $_POST['submit_type'] == 'showinsert'
|| $_REQUEST['submit_type'] == 'insertignore'); || $_POST['submit_type'] == 'insertignore');
} else { } else {
// new row => use indexes // new row => use indexes
$loop_array = array(); $loop_array = array();
if (! empty($_REQUEST['fields'])) { if (! empty($_POST['fields'])) {
foreach ($_REQUEST['fields']['multi_edit'] as $key => $dummy) { foreach ($_POST['fields']['multi_edit'] as $key => $dummy) {
$loop_array[] = $key; $loop_array[] = $key;
} }
} }
$using_key = false; $using_key = false;
$is_insert = true; $is_insert = true;
} }
$is_insertignore = isset($_REQUEST['submit_type']) $is_insertignore = isset($_POST['submit_type'])
&& $_REQUEST['submit_type'] == 'insertignore'; && $_POST['submit_type'] == 'insertignore';
return array($loop_array, $using_key, $is_insert, $is_insertignore); return array($loop_array, $using_key, $is_insert, $is_insertignore);
} }


Expand All @@ -2133,11 +2133,11 @@ public function getParamsForUpdateOrInsert()
*/ */
public function isInsertRow() public function isInsertRow()
{ {
if (isset($_REQUEST['insert_rows']) if (isset($_POST['insert_rows'])
&& is_numeric($_REQUEST['insert_rows']) && is_numeric($_POST['insert_rows'])
&& $_REQUEST['insert_rows'] != $GLOBALS['cfg']['InsertRows'] && $_POST['insert_rows'] != $GLOBALS['cfg']['InsertRows']
) { ) {
$GLOBALS['cfg']['InsertRows'] = $_REQUEST['insert_rows']; $GLOBALS['cfg']['InsertRows'] = $_POST['insert_rows'];
$response = Response::getInstance(); $response = Response::getInstance();
$header = $response->getHeader(); $header = $response->getHeader();
$scripts = $header->getScripts(); $scripts = $header->getScripts();
Expand Down Expand Up @@ -2197,8 +2197,8 @@ public function setSessionForEditNext($one_where_clause)
public function getGotoInclude($goto_include) public function getGotoInclude($goto_include)
{ {
$valid_options = array('new_insert', 'same_insert', 'edit_next'); $valid_options = array('new_insert', 'same_insert', 'edit_next');
if (isset($_REQUEST['after_insert']) if (isset($_POST['after_insert'])
&& in_array($_REQUEST['after_insert'], $valid_options) && in_array($_POST['after_insert'], $valid_options)
) { ) {
$goto_include = 'tbl_change.php'; $goto_include = 'tbl_change.php';
} elseif (! empty($GLOBALS['goto'])) { } elseif (! empty($GLOBALS['goto'])) {
Expand Down Expand Up @@ -2232,8 +2232,8 @@ public function getGotoInclude($goto_include)
*/ */
public function getErrorUrl(array $url_params) public function getErrorUrl(array $url_params)
{ {
if (isset($_REQUEST['err_url'])) { if (isset($_POST['err_url'])) {
return $_REQUEST['err_url']; return $_POST['err_url'];
} }


return 'tbl_change.php' . Url::getCommon($url_params); return 'tbl_change.php' . Url::getCommon($url_params);
Expand All @@ -2242,7 +2242,7 @@ public function getErrorUrl(array $url_params)
/** /**
* Builds the sql query * Builds the sql query
* *
* @param boolean $is_insertignore $_REQUEST['submit_type'] == 'insertignore' * @param boolean $is_insertignore $_POST['submit_type'] == 'insertignore'
* @param array $query_fields column names array * @param array $query_fields column names array
* @param array $value_sets array of query values * @param array $value_sets array of query values
* *
Expand Down Expand Up @@ -2292,7 +2292,7 @@ public function executeSqlQuery(array $url_params, array $query)
$error_messages = array(); $error_messages = array();


foreach ($query as $single_query) { foreach ($query as $single_query) {
if ($_REQUEST['submit_type'] == 'showinsert') { if ($_POST['submit_type'] == 'showinsert') {
$last_messages[] = Message::notice(__('Showing SQL query')); $last_messages[] = Message::notice(__('Showing SQL query'));
continue; continue;
} }
Expand Down Expand Up @@ -2482,7 +2482,7 @@ public function transformEditedValues(
$_url_params = array( $_url_params = array(
'db' => $db, 'db' => $db,
'table' => $table, 'table' => $table,
'where_clause' => $_REQUEST['where_clause'], 'where_clause' => $_POST['where_clause'],
'transform_key' => $column_name 'transform_key' => $column_name
); );
$transform_options = Transformations::getOptions( $transform_options = Transformations::getOptions(
Expand Down Expand Up @@ -2719,10 +2719,10 @@ public function getCurrentValueForDifferentTypes(
$current_value = "''"; $current_value = "''";
} }
} elseif ($type == 'set') { } elseif ($type == 'set') {
if (! empty($_REQUEST['fields']['multi_edit'][$rownumber][$key])) { if (! empty($_POST['fields']['multi_edit'][$rownumber][$key])) {
$current_value = implode( $current_value = implode(
',', ',',
$_REQUEST['fields']['multi_edit'][$rownumber][$key] $_POST['fields']['multi_edit'][$rownumber][$key]
); );
$current_value = "'" $current_value = "'"
. $this->dbi->escapeString($current_value) . "'"; . $this->dbi->escapeString($current_value) . "'";
Expand Down Expand Up @@ -2803,7 +2803,7 @@ public function verifyWhetherValueCanBeTruncatedAndAppendExtraData(
. Util::backquote($column_name) . Util::backquote($column_name)
. ' FROM ' . Util::backquote($db) . '.' . ' FROM ' . Util::backquote($db) . '.'
. Util::backquote($table) . Util::backquote($table)
. ' WHERE ' . $_REQUEST['where_clause'][0]; . ' WHERE ' . $_POST['where_clause'][0];


$result = $this->dbi->tryQuery($sql_for_real_value); $result = $this->dbi->tryQuery($sql_for_real_value);
$fields_meta = $this->dbi->getFieldsMeta($result); $fields_meta = $this->dbi->getFieldsMeta($result);
Expand Down Expand Up @@ -2849,23 +2849,23 @@ public function getTableColumns($db, $table)
*/ */
public function determineInsertOrEdit($where_clause, $db, $table) public function determineInsertOrEdit($where_clause, $db, $table)
{ {
if (isset($_REQUEST['where_clause'])) { if (isset($_POST['where_clause'])) {
$where_clause = $_REQUEST['where_clause']; $where_clause = $_POST['where_clause'];
} }
if (isset($_SESSION['edit_next'])) { if (isset($_SESSION['edit_next'])) {
$where_clause = $_SESSION['edit_next']; $where_clause = $_SESSION['edit_next'];
unset($_SESSION['edit_next']); unset($_SESSION['edit_next']);
$after_insert = 'edit_next'; $after_insert = 'edit_next';
} }
if (isset($_REQUEST['ShowFunctionFields'])) { if (isset($_POST['ShowFunctionFields'])) {
$GLOBALS['cfg']['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields']; $GLOBALS['cfg']['ShowFunctionFields'] = $_POST['ShowFunctionFields'];
} }
if (isset($_REQUEST['ShowFieldTypesInDataEditView'])) { if (isset($_POST['ShowFieldTypesInDataEditView'])) {
$GLOBALS['cfg']['ShowFieldTypesInDataEditView'] $GLOBALS['cfg']['ShowFieldTypesInDataEditView']
= $_REQUEST['ShowFieldTypesInDataEditView']; = $_POST['ShowFieldTypesInDataEditView'];
} }
if (isset($_REQUEST['after_insert'])) { if (isset($_POST['after_insert'])) {
$after_insert = $_REQUEST['after_insert']; $after_insert = $_POST['after_insert'];
} }


if (isset($where_clause)) { if (isset($where_clause)) {
Expand All @@ -2890,8 +2890,8 @@ public function determineInsertOrEdit($where_clause, $db, $table)


// Copying a row - fetched data will be inserted as a new row, // Copying a row - fetched data will be inserted as a new row,
// therefore the where clause is needless. // therefore the where clause is needless.
if (isset($_REQUEST['default_action']) if (isset($_POST['default_action'])
&& $_REQUEST['default_action'] === 'insert' && $_POST['default_action'] === 'insert'
) { ) {
$where_clause = $where_clauses = null; $where_clause = $where_clauses = null;
} }
Expand Down

0 comments on commit 3d9ed65

Please sign in to comment.