} elseif (isset($after_insert) && $after_insert == 'same_insert') { $goto = 'tbl_change.php?' . PMA_generate_common_url($db, $table, '&') . '&goto=' . urlencode($goto) . '&pos=' . $pos . '&session_max_rows=' . $session_max_rows . '&disp_direction=' . $disp_direction . '&repeat_cells=' . $repeat_cells . '&dontlimitchars=' . $dontlimitchars . '&after_insert=' . $after_insert . (empty($sql_query) ? '' : '&sql_query=' . urlencode($sql_query)); if (isset($primary_key)) { foreach ($primary_key as $pk) { $goto .= '&primary_key[]=' . $pk; } } } elseif (isset($after_insert) && $after_insert == 'edit_next') { $goto = 'tbl_change.php?' . PMA_generate_common_url($db, $table, '&') . '&goto=' . urlencode($goto) . '&pos=' . $pos . '&session_max_rows=' . $session_max_rows . '&disp_direction=' . $disp_direction . '&repeat_cells=' . $repeat_cells . '&dontlimitchars=' . $dontlimitchars . '&after_insert=' . $after_insert . (empty($sql_query) ? '' : '&sql_query=' . urlencode($sql_query)); if (isset($primary_key)) { foreach ($primary_key as $pk) { $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . str_replace('` =', '` >', urldecode($pk)) . ' LIMIT 1;'; $res = PMA_DBI_query($local_query); $row = PMA_DBI_fetch_row($res); $meta = PMA_DBI_get_fields_meta($res); $goto .= '&primary_key[]=' . urlencode(PMA_getUvaCondition($res, count($row), $meta, $row)); } } } elseif ($goto == 'sql.php') { $goto = 'sql.php?' . PMA_generate_common_url($db, $table, '&') . '&pos=' . $pos . '&session_max_rows=' . $session_max_rows . '&disp_direction=' . $disp_direction . '&repeat_cells=' . $repeat_cells . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode($sql_query); } elseif (!empty($goto)) { // Security checkings $is_gotofile = preg_replace('@^([^?]+).*$@', '\\1', $goto); if (!@file_exists('./' . $is_gotofile)) { $goto = !isset($table) || !strlen($table) ? 'db_details.php' : 'tbl_properties.php'; $is_gotofile = TRUE; } else { $is_gotofile = $is_gotofile == $goto; } } // Defines the url to return in case of failure of the query
/** * Dispatches between the versions of 'getTableContent' to use depending * on the php version * * @param string the database name * @param string the table name * @param string the end of line sequence * @param string the url to go back in case of error * @param string SQL query for obtaining data * * @return bool Whether it suceeded * * @global boolean whether to use backquotes to allow the use of special * characters in database, table and fields names or not * @global integer the number of records * @global integer the current record position * * @access public * * @see PMA_getTableContentFast(), PMA_getTableContentOld() * * @author staybyte */ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { global $use_backquotes; global $rows_cnt; global $current_row; $formatted_table_name = isset($GLOBALS['use_backquotes']) ? PMA_backquote($table) : '\'' . $table . '\''; $head = $crlf . $GLOBALS['comment_marker'] . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strDumpingData'] . ' ' . $formatted_table_name . $crlf . $GLOBALS['comment_marker'] . $crlf . $crlf; if (!PMA_exportOutputHandler($head)) { return FALSE; } $buffer = ''; // analyze the query to get the true column names, not the aliases // (this fixes an undefined index, also if Complete inserts // are used, we did not get the true column name in case of aliases) $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query)); $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); if ($result != FALSE) { $fields_cnt = PMA_DBI_num_fields($result); // Get field information $fields_meta = PMA_DBI_get_fields_meta($result); $field_flags = array(); for ($j = 0; $j < $fields_cnt; $j++) { $field_flags[$j] = PMA_DBI_field_flags($result, $j); } for ($j = 0; $j < $fields_cnt; $j++) { if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) { $field_set[$j] = PMA_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $use_backquotes); } else { $field_set[$j] = PMA_backquote($fields_meta[$j]->name, $use_backquotes); } } if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'update') { // update $schema_insert = 'UPDATE '; if (isset($GLOBALS['sql_ignore'])) { $schema_insert .= 'IGNORE '; } $schema_insert .= PMA_backquote($table, $use_backquotes) . ' SET '; } else { // insert or replace if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'replace') { $sql_command = 'REPLACE'; } else { $sql_command = 'INSERT'; } // delayed inserts? if (isset($GLOBALS['delayed'])) { $insert_delayed = ' DELAYED'; } else { $insert_delayed = ''; } // insert ignore? if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'insert' && isset($GLOBALS['sql_ignore'])) { $insert_delayed .= ' IGNORE'; } // scheme for inserting fields if (isset($GLOBALS['showcolumns'])) { $fields = implode(', ', $field_set); $schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_backquote($table, $use_backquotes) . ' (' . $fields . ') VALUES ('; } else { $schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_backquote($table, $use_backquotes) . ' VALUES ('; } } $search = array("", "\n", "\r", ""); //\x08\\x09, not required $replace = array('\\0', '\\n', '\\r', '\\Z'); $current_row = 0; $separator = isset($GLOBALS['extended_ins']) ? ',' : ';'; while ($row = PMA_DBI_fetch_row($result)) { $current_row++; for ($j = 0; $j < $fields_cnt; $j++) { // NULL if (!isset($row[$j]) || is_null($row[$j])) { $values[] = 'NULL'; // a number // timestamp is numeric on some MySQL 4.1 } elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp') { $values[] = $row[$j]; // a binary field // Note: with mysqli, under MySQL 4.1.3, we get the flag // "binary" for those field types (I don't know why) } else { if (stristr($field_flags[$j], 'BINARY') && isset($GLOBALS['hexforbinary']) && $fields_meta[$j]->type != 'datetime' && $fields_meta[$j]->type != 'date' && $fields_meta[$j]->type != 'time' && $fields_meta[$j]->type != 'timestamp') { // empty blobs need to be different, but '0' is also empty :-( if (empty($row[$j]) && $row[$j] != '0') { $values[] = '\'\''; } else { $values[] = '0x' . bin2hex($row[$j]); } // something else -> treat as a string } else { $values[] = '\'' . str_replace($search, $replace, PMA_sqlAddslashes($row[$j])) . '\''; } } // end if } // end for // should we make update? if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'update') { $insert_line = $schema_insert; for ($i = 0; $i < $fields_cnt; $i++) { if ($i > 0) { $insert_line .= ', '; } $insert_line .= $field_set[$i] . ' = ' . $values[$i]; } $insert_line .= ' WHERE ' . PMA_getUvaCondition($result, $fields_cnt, $fields_meta, $row); } else { // Extended inserts case if (isset($GLOBALS['extended_ins'])) { if ($current_row == 1) { $insert_line = $schema_insert . implode(', ', $values) . ')'; } else { $insert_line = '(' . implode(', ', $values) . ')'; } } else { $insert_line = $schema_insert . implode(', ', $values) . ')'; } } unset($values); if (!PMA_exportOutputHandler(($current_row == 1 ? '' : $separator . $crlf) . $insert_line)) { return FALSE; } } // end while if ($current_row > 0) { if (!PMA_exportOutputHandler(';' . $crlf)) { return FALSE; } } } // end if ($result != FALSE) PMA_DBI_free_result($result); return TRUE; }
/** * Displays the body of the results table * * @param integer the link id associated to the query which results have * to be displayed * @param array which elements to display * @param array the list of relations * @param array the analyzed query * * @return boolean always true * * @global string $db the database name * @global string $table the table name * @global string $goto the url to go back in case of errors * @global boolean $dontlimitchars whether to limit the number of displayed * characters of text type fields or not * @global string $sql_query the sql query * @global integer $pos the current position in results * @global integer $session_max_rows the maximum number of rows per page * @global array $fields_meta the list of fields properties * @global integer $fields_cnt the total number of fields returned by * the sql query * @global array $vertical_display informations used with vertical display * mode * @global string $disp_direction the display mode * (horizontal/vertical/horizontalflipped) * @global integer $repeat_cells the number of row to display between two * table headers * @global array $highlight_columns collumn names to highlight * @gloabl array $row current row data * * @access private * * @see PMA_displayTable() */ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { global $db, $table, $goto, $dontlimitchars; global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt; global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns; global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin $url_sql_query = $sql_query; // query without conditions to shorten urls when needed, 200 is just // guess, it should depend on remaining url length if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' && strlen($sql_query) > 200) { $url_sql_query = 'SELECT '; if (isset($analyzed_sql[0]['queryflags']['distinct'])) { $url_sql_query .= ' DISTINCT '; } $url_sql_query .= $analyzed_sql[0]['select_expr_clause']; if (!empty($analyzed_sql[0]['from_clause'])) { $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause']; } } if (!is_array($map)) { $map = array(); } $row_no = 0; $vertical_display['edit'] = array(); $vertical_display['delete'] = array(); $vertical_display['data'] = array(); $vertical_display['row_delete'] = array(); // Correction uva 19991216 in the while below // Previous code assumed that all tables have keys, specifically that // the phpMyAdmin GUI should support row delete/edit only for such // tables. // Although always using keys is arguably the prescribed way of // defining a relational table, it is not required. This will in // particular be violated by the novice. // We want to encourage phpMyAdmin usage by such novices. So the code // below has been changed to conditionally work as before when the // table being displayed has one or more keys; but to display // delete/edit options correctly for tables without keys. // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row' // to get the NULL values // rabus: This function needs a little rework. // Using MYSQL_BOTH just pollutes the memory! // ne0x: Use function PMA_DBI_fetch_array() due to mysqli // compatibility. Now this function is wrapped. $odd_row = true; while ($row = PMA_DBI_fetch_row($dt_result)) { // lem9: "vertical display" mode stuff if ($row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { echo '<tr>' . "\n"; if ($vertical_display['emptypre'] > 0) { echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n" . ' </th>' . "\n"; } foreach ($vertical_display['desc'] as $val) { echo $val; } if ($vertical_display['emptyafter'] > 0) { echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n" . ' </th>' . "\n"; } echo '</tr>' . "\n"; } // end if $class = $odd_row ? 'odd' : 'even'; $odd_row = !$odd_row; if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { // loic1: pointer code part echo ' <tr class="' . $class . '">' . "\n"; $class = ''; } // 1. Prepares the row (gets primary keys to use) // 1.1 Results from a "SELECT" statement -> builds the // "primary" key to use in links $uva_condition = urlencode(PMA_getUvaCondition($dt_result, $fields_cnt, $fields_meta, $row)); // 1.2 Defines the urls for the modify/delete link(s) $url_query = PMA_generate_common_url($db, $table) . '&pos=' . $pos . '&session_max_rows=' . $session_max_rows . '&disp_direction=' . $disp_direction . '&repeat_cells=' . $repeat_cells . '&dontlimitchars=' . $dontlimitchars; if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') { // We need to copy the value or else the == 'both' check will always return true if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $iconic_spacer = '<div class="nowrap">'; } else { $iconic_spacer = ''; } // 1.2.1 Modify link(s) if ($is_display['edit_lnk'] == 'ur') { // update row case $lnk_goto = 'sql.php'; $edit_url = 'tbl_change.php' . '?' . $url_query . '&primary_key=' . $uva_condition . '&sql_query=' . urlencode($url_sql_query) . '&goto=' . urlencode($lnk_goto); if ($GLOBALS['cfg']['PropertiesIconic'] === false) { $edit_str = $GLOBALS['strEdit']; } else { $edit_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" />'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $edit_str .= ' ' . $GLOBALS['strEdit'] . '</div>'; } } } // end if (1.2.1) if ($table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db'] && isset($row[1]) && isset($row[0])) { $bookmark_go = '<a href="import.php?' . PMA_generate_common_url($row[1], '') . '&id_bookmark=' . $row[0] . '&action_bookmark=0' . '&action_bookmark_all=1' . '&SQL=' . $GLOBALS['strExecuteBookmarked'] . ' " title="' . $GLOBALS['strExecuteBookmarked'] . '">'; if ($GLOBALS['cfg']['PropertiesIconic'] === false) { $bookmark_go .= $GLOBALS['strExecuteBookmarked']; } else { $bookmark_go .= $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" />'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $bookmark_go .= ' ' . $GLOBALS['strExecuteBookmarked'] . '</div>'; } } $bookmark_go .= '</a>'; } else { $bookmark_go = ''; } // 1.2.2 Delete/Kill link(s) if ($is_display['del_lnk'] == 'dr') { // delete row case $lnk_goto = 'sql.php' . '?' . str_replace('&', '&', $url_query) . '&sql_query=' . urlencode($url_sql_query) . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . (empty($goto) ? 'tbl_properties.php' : $goto); $del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . '+LIMIT+1'; $del_url = 'sql.php' . '?' . $url_query . '&sql_query=' . $del_query . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . urlencode($lnk_goto); $js_conf = 'DELETE FROM ' . PMA_jsFormat($table) . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), false)) . ' LIMIT 1'; if ($GLOBALS['cfg']['PropertiesIconic'] === false) { $del_str = $GLOBALS['strDelete']; } else { $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" />'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $del_str .= ' ' . $GLOBALS['strDelete'] . '</div>'; } } } elseif ($is_display['del_lnk'] == 'kp') { // kill process case $lnk_goto = 'sql.php' . '?' . str_replace('&', '&', $url_query) . '&sql_query=' . urlencode($url_sql_query) . '&goto=main.php'; $del_url = 'sql.php?' . PMA_generate_common_url('mysql') . '&sql_query=' . urlencode('KILL ' . $row[0]) . '&goto=' . urlencode($lnk_goto); $del_query = urlencode('KILL ' . $row[0]); $js_conf = 'KILL ' . $row[0]; if ($GLOBALS['cfg']['PropertiesIconic'] === false) { $del_str = $GLOBALS['strKill']; } else { $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" />'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $del_str .= ' ' . $GLOBALS['strKill'] . '</div>'; } } } // end if (1.2.2) // 1.3 Displays the links at left if required if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { $doWriteModifyAt = 'left'; require './libraries/display_tbl_links.lib.php'; } // end if (1.3) } // end if (1) // 2. Displays the rows' values for ($i = 0; $i < $fields_cnt; ++$i) { $meta = $fields_meta[$i]; // loic1: To fix bug #474943 under php4, the row pointer will // depend on whether the "is_null" php4 function is // available or not $pointer = function_exists('is_null') ? $i : $meta->name; // garvin: See if this column should get highlight because it's used in the // where-query. if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) { $condition_field = true; } else { $condition_field = false; } $mouse_events = ''; if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1')) { if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) { $mouse_events .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"' . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');" '; } if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) { $mouse_events .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" '; } else { $mouse_events .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" '; } } // end if // garvin: Wrap MIME-transformations. [MIME] $default_function = 'default_function'; // default_function $transform_function = $default_function; $transform_options = array(); if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) { $include_file = PMA_sanitizeTransformationFile($GLOBALS['mime_map'][$meta->name]['transformation']); if (file_exists('./libraries/transformations/' . $include_file)) { $transformfunction_name = preg_replace('@(\\.inc\\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']); require_once './libraries/transformations/' . $include_file; if (function_exists('PMA_transformation_' . $transformfunction_name)) { $transform_function = 'PMA_transformation_' . $transformfunction_name; $transform_options = PMA_transformation_getOptions(isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''); $meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']); } } // end if file_exists } // end if transformation is set } // end if mime/transformation works. $transform_options['wrapper_link'] = '?' . (isset($url_query) ? $url_query : '') . '&primary_key=' . (isset($uva_condition) ? $uva_condition : '') . '&sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '') . '&goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '') . '&transform_key=' . urlencode($meta->name); // n u m e r i c if ($meta->numeric == 1) { // lem9: if two fields have the same name (this is possible // with self-join queries, for example), using $meta->name // will show both fields NULL even if only one is NULL, // so use the $pointer // (works only if function_exists('is_null') // PS: why not always work with the number ($i), since // the default second parameter of // mysql_fetch_array() is MYSQL_BOTH, so we always get // associative and numeric indices? //if (!isset($row[$meta->name]) if (!isset($row[$i]) || is_null($row[$i])) { $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n"; } elseif ($row[$i] != '') { $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . ' nowrap">'; if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; } // end if } // end if } // end while } if (isset($map[$meta->name])) { // Field to display from the foreign table? if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]; $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE); if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { list($dispval) = PMA_DBI_fetch_row($dispresult, 0); } else { $dispval = $GLOBALS['strLinkNotFound']; } @PMA_DBI_free_result($dispresult); } else { $dispval = ''; } // end if... else... if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . ' <code>[->' . $dispval . ']</code>'; } else { $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : ''; $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>' . ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>'; } } else { $vertical_display['data'][$row_no][$i] .= $transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta); } $vertical_display['data'][$row_no][$i] .= '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ' nowrap' . ($condition_field ? ' condition' : '') . '"> </td>' . "\n"; } // b l o b } elseif ($GLOBALS['cfg']['ShowBlob'] == false && stristr($meta->type, 'BLOB')) { // loic1 : PMA_mysql_fetch_fields returns BLOB in place of // TEXT fields type, however TEXT fields must be displayed // even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type // of the fields. $field_flags = PMA_DBI_field_flags($dt_result, $i); if (stristr($field_flags, 'BINARY')) { $blobtext = '[BLOB'; if (!isset($row[$i]) || is_null($row[$i])) { $blobtext .= ' - NULL'; $blob_size = 0; } elseif (isset($row[$i])) { $blob_size = strlen($row[$i]); $display_blob_size = PMA_formatByteDown($blob_size, 3, 1); $blobtext .= ' - ' . $display_blob_size[0] . ' ' . $display_blob_size[1]; unset($display_blob_size); } $blobtext .= ']'; if (strpos($transform_function, 'octetstream')) { $blobtext = $row[$i]; } if ($blob_size > 0) { $blobtext = $default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta); } unset($blob_size); $vertical_display['data'][$row_no][$i] = ' <td align="left"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $blobtext . '</td>'; } else { if (!isset($row[$i]) || is_null($row[$i])) { $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n"; } elseif ($row[$i] != '') { // garvin: if a transform function for blob is set, none of these replacements will be made if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1) { $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } // loic1: displays all space characters, 4 space // characters for tabulations and <cr>/<lf> $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta); $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $row[$i] . '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"> </td>' . "\n"; } } } else { if (!isset($row[$i]) || is_null($row[$i])) { $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n"; } elseif ($row[$i] != '') { // loic1: support blanks in the key $relation_id = $row[$i]; // nijel: Cut all fields to $GLOBALS['cfg']['LimitChars'] // lem9: (unless it's a link-type transformation) if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1 && !strpos($transform_function, 'link') === true) { $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } // loic1: displays special characters from binaries $field_flags = PMA_DBI_field_flags($dt_result, $i); if (stristr($field_flags, 'BINARY')) { $row[$i] = str_replace("", '\\0', $row[$i]); $row[$i] = str_replace("", '\\b', $row[$i]); $row[$i] = str_replace("\n", '\\n', $row[$i]); $row[$i] = str_replace("\r", '\\r', $row[$i]); $row[$i] = str_replace("", '\\Z', $row[$i]); $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta); } else { $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta); } // garvin: transform functions may enable nowrapping: $function_nowrap = $transform_function . '_nowrap'; $bool_nowrap = $default_function != $transform_function && function_exists($function_nowrap) ? $function_nowrap($transform_options) : false; // loic1: do not wrap if date field type $nowrap = preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap ? ' nowrap' : ''; $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . $nowrap . ($condition_field ? ' condition' : '') . '">'; if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; } // end if } // end if } // end while } if (isset($map[$meta->name])) { // Field to display from the foreign table? if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($row[$i]) . '\''; $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE); if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { list($dispval) = PMA_DBI_fetch_row($dispresult); @PMA_DBI_free_result($dispresult); } else { $dispval = $GLOBALS['strLinkNotFound']; } } else { $dispval = ''; } $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : ''; $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>' . $row[$i] . '</a>'; } else { $vertical_display['data'][$row_no][$i] .= $row[$i]; } $vertical_display['data'][$row_no][$i] .= '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"> </td>' . "\n"; } } // lem9: output stored cell if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { echo $vertical_display['data'][$row_no][$i]; } if (isset($vertical_display['rowdata'][$i][$row_no])) { $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i]; } else { $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i]; } } // end for (2) // 3. Displays the modify/delete links on the right if required if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { $doWriteModifyAt = 'right'; require './libraries/display_tbl_links.lib.php'; } // end if (3) if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { ?> </tr> <?php } // end if // 4. Gather links of del_urls and edit_urls in an array for later // output if (!isset($vertical_display['edit'][$row_no])) { $vertical_display['edit'][$row_no] = ''; $vertical_display['delete'][$row_no] = ''; $vertical_display['row_delete'][$row_no] = ''; } $column_style_vertical = ''; if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) { $column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"' . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');"'; } $column_marker_vertical = ''; if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) { $column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\');'; } if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { $vertical_display['row_delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n" . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $uva_condition . ']"' . ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"' . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . ' </td>' . "\n"; } else { unset($vertical_display['row_delete'][$row_no]); } if (isset($edit_url)) { $vertical_display['edit'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n" . PMA_linkOrButton($edit_url, $edit_str, array(), false) . $bookmark_go . ' </td>' . "\n"; } else { unset($vertical_display['edit'][$row_no]); } if (isset($del_url)) { $vertical_display['delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '', false) . ' </td>' . "\n"; } else { unset($vertical_display['delete'][$row_no]); } echo $disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped' ? "\n" : ''; $row_no++; } // end while if (isset($url_query)) { $GLOBALS['url_query'] = $url_query; } return true; }
if (isset($_REQUEST['after_insert']) && in_array($_REQUEST['after_insert'], array('new_insert', 'same_insert', 'edit_next'))) { $url_params['after_insert'] = $_REQUEST['after_insert']; //$GLOBALS['goto'] = 'tbl_change.php'; $goto_include = 'tbl_change.php'; if (isset($_REQUEST['primary_key'])) { if ($_REQUEST['after_insert'] == 'same_insert') { foreach ($_REQUEST['primary_key'] as $pk) { $url_params['primary_key'][] = $pk; } } elseif ($_REQUEST['after_insert'] == 'edit_next') { foreach ($_REQUEST['primary_key'] as $pk) { $local_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table']) . ' WHERE ' . str_replace('` =', '` >', $pk) . ' LIMIT 1;'; $res = PMA_DBI_query($local_query); $row = PMA_DBI_fetch_row($res); $meta = PMA_DBI_get_fields_meta($res); $url_params['primary_key'][] = PMA_getUvaCondition($res, count($row), $meta, $row); } } } } elseif (!empty($GLOBALS['goto'])) { if (!preg_match('@^[a-z_]+\\.php$@', $GLOBALS['goto'])) { // this should NOT happen //$GLOBALS['goto'] = false; $goto_include = false; } else { $goto_include = $GLOBALS['goto']; } if ($GLOBALS['goto'] == 'db_sql.php' && isset($GLOBALS['table'])) { unset($GLOBALS['table']); } }