updates the // display mode if ($the_disp_mode != 'nnnn00000') { // 2.1 Statement is a "SELECT COUNT", // "CHECK/ANALYZE/REPAIR/OPTIMIZE" or an "EXPLAIN" if ($GLOBALS['is_count'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) { $do_display['edit_lnk'] = 'nn'; // no edit link $do_display['del_lnk'] = 'nn'; // no delete link $do_display['sort_lnk'] = (string) '0'; $do_display['nav_bar'] = (string) '0'; $do_display['ins_row'] = (string) '0'; $do_display['bkm_form'] = (string) '1'; $do_display['text_btn'] = (string) '0'; } // 2.2 Statement is a "SHOW..." else if ($GLOBALS['is_show']) { // 2.2.1 TODO : defines edit/delete links depending on show statement $tmp = eregi('^SHOW[[:space:]]+(VARIABLES|PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS)', $GLOBALS['sql_query'], $which); if (strtoupper($which[1]) == 'PROCESSLIST') { $do_display['edit_lnk'] = 'nn'; // no edit link $do_display['del_lnk'] = 'kp'; // "kill process" type edit link } else { // Default case -> no links $do_display['edit_lnk'] = 'nn'; // no edit link $do_display['del_lnk'] = 'nn'; // no delete link } // 2.2.2 Other settings $do_display['sort_lnk'] = (string) '0'; $do_display['nav_bar'] = (string) '0'; $do_display['ins_row'] = (string) '0'; $do_display['bkm_form'] = (string) '1'; $do_display['text_btn'] = (string) '0'; } // 2.3 Other statements (ie "SELECT" ones) -> updates // $do_display['edit_lnk'], $do_display['del_lnk'] and // $do_display['text_btn'] (keeps other default values) else { $prev_table = $fields_meta[0]->table; for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) { $is_link = ($do_display['edit_lnk'] != 'nn' || $do_display['del_lnk'] != 'nn' || $do_display['sort_lnk'] != '0' || $do_display['ins_row'] != '0'); // 2.3.1 Displays text cut/expand button? if ($do_display['text_btn'] == '0' && eregi('BLOB', $fields_meta[$i]->type)) { $do_display['text_btn'] = (string) '1'; if (!$is_link) { break; } } // end if (2.3.1) // 2.3.2 Displays edit/delete/sort/insert links? if ($is_link && ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) { $do_display['edit_lnk'] = 'nn'; // don't display links $do_display['del_lnk'] = 'nn'; // TODO: May be problematic with same fields names in // two joined table. // $do_display['sort_lnk'] = (string) '0'; $do_display['ins_row'] = (string) '0'; if ($do_display['text_btn'] == '1') { break; } } // end if (2.3.2) $prev_table = $fields_meta[$i]->table; } // end for } // end if..elseif...else (2.1 -> 2.3) } // end if (2) // 3. Gets the total number of rows if it is unknown if (isset($unlim_num_rows) && $unlim_num_rows != '') { $the_total = $unlim_num_rows; } else if (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') && (!empty($db) && !empty($table))) { $local_query = 'SELECT COUNT(*) AS total FROM ' . backquote($db) . '.' . backquote($table); $result = mysql_query($local_query) or mysql_die('', $local_query, '', $err_url); $the_total = mysql_result($result, 0, 'total'); mysql_free_result($result); } // 4. If navigation bar or sorting fields names urls should be // displayed but there is only one row, change these settings to // false if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') { if (isset($unlim_num_rows) && $unlim_num_rows < 2) { $do_display['nav_bar'] = (string) '0'; $do_display['sort_lnk'] = (string) '0'; } } // end if (3) // 5. Updates the synthetic var $the_disp_mode = join('', $do_display); return $do_display; } // end of the 'set_display_mode()' function /** * Displays a navigation bar to browse among the results of a sql query * * @param integer the offset for the "next" page * @param integer the offset for the "previous" page * @param string the url-encoded query * * @global string the current language * @global integer the server to use (refers to the number in the * configuration file) * @global string the database name * @global string the table name * @global string the url to go back in case of errors * @global integer the total number of rows returned by the sql query * @global integer the total number of rows returned by the sql query * without any programmatically appended "LIMIT" clause * @global integer the current position in results * @global mixed the maximum number of rows per page ('all' = no limit) * @global boolean whether to limit the number of displayed characters of * text type fields or not * * @access private * * @see display_table() */ function display_table_navigation($pos_next, $pos_prev, $encoded_query) { global $lang, $server, $db, $table; global $goto; global $num_rows, $unlim_num_rows, $pos, $sessionMaxRows; global $dontlimitchars; ?> 0 && $sessionMaxRows != 'all') { ?> = $sessionMaxRows && $sessionMaxRows != 'all') { echo "\n"; ?>
   
   
   
<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?> " align="center"> <?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?> > name) . '(`?)[ ,$]', $sql_order); } // 2.1.3 Checks if the table name is required (it's the case // for a query with a "JOIN" statement and if the column // isn't aliased) if ($is_join && !eregi('([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name, $select_stt[1], $parts)) { $sort_tbl = backquote($fields_meta[$i]->table) . '.'; } else { $sort_tbl = ''; } // 2.1.4 Do define the sorting url if (!$is_in_sort) { // loic1: patch #455484 ("Smart" order) $cfgOrder = strtoupper($GLOBALS['cfgOrder']); if ($cfgOrder == 'SMART') { $cfgOrder = (eregi('time|date', $fields_meta[$i]->type)) ? 'DESC' : 'ASC'; } $sort_order = ' ORDER BY ' . $sort_tbl . backquote($fields_meta[$i]->name) . ' ' . $cfgOrder; $order_img = ''; } else if (substr($sql_order, -3) == 'ASC' && $is_in_sort) { $sort_order = ' ORDER BY ' . $sort_tbl . backquote($fields_meta[$i]->name) . ' DESC'; $order_img = ' ASC'; } else if (substr($sql_order, -4) == 'DESC' && $is_in_sort) { $sort_order = ' ORDER BY ' . $sort_tbl . backquote($fields_meta[$i]->name) . ' ASC'; $order_img = ' DESC'; } if (eregi('(.*)( LIMIT (.*)| PROCEDURE (.*)| FOR UPDATE| LOCK IN SHARE MODE)', $unsorted_sql_query, $regs3)) { $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2]; } else { $sorted_sql_query = $unsorted_sql_query . $sort_order; } $url_query = 'lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . '&table=' . urlencode($table) . '&pos=' . $pos . '&sessionMaxRows=' . $sessionMaxRows . '&dontlimitchars' . $dontlimitchars . '&sql_query=' . urlencode($sorted_sql_query); // 2.1.5 Displays the sorting url ?> name); ?> name) . "\n"; ?> " align="center"> <?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?> '; } echo "\n"; ?> builds the // the "primary" key to use in links if ($is_display['edit_lnk'] == 'ur' /* || $is_display['edit_lnk'] == 'dr' */) { for ($i = 0; $i < $fields_cnt; ++$i) { $primary = $fields_meta[$i]; $condition = ' ' . backquote($primary->name) . ' '; if (!isset($row[$primary->name])) { $condition .= 'IS NULL AND'; } else { $condition .= '= \'' . sql_addslashes($row[$primary->name]) . '\' AND'; } if ($primary->primary_key > 0) { $primary_key .= $condition; } $uva_nonprimary_condition .= $condition; } // end for // Correction uva 19991216: prefer primary keys for // condition, but use conjunction of all values if no // primary key if ($primary_key) { $uva_condition = $primary_key; } else { $uva_condition = $uva_nonprimary_condition; } $uva_condition = urlencode(ereg_replace(' ?AND$', '', $uva_condition)); } // end if (1.1) // 1.2 Defines the urls for the modify/delete link(s) $url_query = 'lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . '&table=' . urlencode($table) . '&pos=' . $pos . '&sessionMaxRow=' . $sessionMaxRow . '&dontlimitchars=' . $dontlimitchars; // 1.2.1 Modify link(s) if ($is_display['edit_lnk'] == 'ur') { // update row case if (!empty($goto) && empty($GLOBALS['QUERY_STRING']) && (empty($GLOBALS['HTTP_SERVER_VARS']) || empty($GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']))) { // void } else { $goto = 'sql.php3'; } $edit_url = 'tbl_change.php3' . '?' . $url_query . '&primary_key=' . $uva_condition . '&sql_query=' . urlencode($sql_query) . '&goto=' . urlencode($goto); $edit_str = $GLOBALS['strEdit']; } // end if (1.2.1) // 1.2.2 Delete/Kill link(s) if ($is_display['del_lnk'] == 'dr') { // delete row case $goto = 'sql.php3' . '?' . $url_query . '&sql_query=' . urlencode($sql_query) . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=tbl_properties.php3'; $del_url = 'sql.php3' . '?' . $url_query . '&sql_query=' . urlencode('DELETE FROM ' . backquote($table) . ' WHERE') . $uva_condition . urlencode(' LIMIT 1') . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . urlencode($goto); $js_conf = 'DELETE FROM ' . js_format($table) . ' WHERE ' . trim(js_format(urldecode($uva_condition), FALSE)) . ' LIMIT 1'; $del_str = $GLOBALS['strDelete']; } else if ($is_display['del_lnk'] == 'kp') { // kill process case $del_url = 'sql.php3' . '?lang=' . $lang . '&server=' . $server . '&db=mysql' . '&sql_query=' . urlencode('KILL ' . $row['Id']) . '&goto=main.php3'; $js_conf = 'KILL ' . $row['Id']; $del_str = $GLOBALS['strKill']; } // end if (1.2.2) // 1.3 Displays the links at left if required if ($GLOBALS['cfgModifyDeleteAtLeft']) { if (!empty($edit_url)) { ?> > numeric == 1) { if (!isset($row[$primary->name])) { echo ' NULL' . "\n"; } else if ($row[$i] != '') { echo ' ' . $row[$primary->name] . '' . "\n"; } else { echo '  ' . "\n"; } } else if ($GLOBALS['cfgShowBlob'] == FALSE && eregi('BLOB', $primary->type)) { // loic1 : mysql_fetch_fields returns BLOB in place of TEXT // fields type, however TEXT fields must be displayed even // if $cfgShowBlob is false -> get the true type of the // fields. $field_flags = mysql_field_flags($dt_result, $i); if (eregi('BINARY', $field_flags)) { echo ' [BLOB]' . "\n"; } else { if (!isset($row[$primary->name])) { echo ' NULL' . "\n"; } else if ($row[$primary->name] != '') { if (strlen($row[$primary->name]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) { $row[$primary->name] = substr($row[$primary->name], 0, $GLOBALS['cfgLimitChars']) . '...'; } // loic1 : displays / $row[$primary->name] = ereg_replace("((\015\012)|(\015)|(\012))+", '
', htmlspecialchars($row[$primary->name])); echo ' ' . $row[$primary->name] . '' . "\n"; } else { echo '  ' . "\n"; } } } else { if (!isset($row[$primary->name])) { echo ' NULL' . "\n"; } else if ($row[$primary->name] != '') { // loic1: Cut text/blob fields even if $cfgShowBlob is true if (eregi('BLOB', $primary->type)) { if (strlen($row[$primary->name]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) { $row[$primary->name] = substr($row[$primary->name], 0, $GLOBALS['cfgLimitChars']) . '...'; } } // loic1 : displays / $row[$primary->name] = ereg_replace("((\015\012)|(\015)|(\012))+", '
', htmlspecialchars($row[$primary->name])); echo ' ' . $row[$primary->name] . '' . "\n"; } else { echo '  ' . "\n"; } } } // end for (2) // 3. Displays the modify/delete links on the right if required if ($GLOBALS['cfgModifyDeleteAtRight']) { if (!empty($edit_url)) { ?> > $total) ? $total : $pos_next; show_message($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec ($total " . $GLOBALS['strTotal'] . $selectstring . ')'); } else { show_message($GLOBALS['strSQLQuery']); } // 2.3 Displays the navigation bars if (!isset($table) || strlen(trim($table)) == 0) { $table = $fields_meta[0]->table; } if ($is_display['nav_bar'] == '1') { display_table_navigation($pos_next, $pos_prev, $encoded_sql_query); echo "\n"; } else { echo "\n" . '

' . "\n"; } // 3. ----- Displays the results table ----- ?>

' . "\n"; } } // end of the 'display_table()' function } // $__LIB_DISPLAY_TBL__ ?>