$db, 'sql_query' => $sql_query ); if (preg_match('@^tbl_@', $GLOBALS['goto'])) { $_url_params['table'] = $table; } $err_url = $GLOBALS['goto'] . PMA_generate_common_url($_url_params); unset($_url_params); /** * Sets parameters for links * where is this variable used? * replace by PMA_generate_common_url($url_params); */ $url_query = PMA_generate_common_url($url_params, 'html', ''); /** * get table information * @todo should be done by a Table object */ require_once './libraries/tbl_info.inc.php'; /** * Get comments for table fileds/columns */ $comments_map = array(); if ($GLOBALS['cfg']['ShowPropertyComments']) { $comments_map = PMA_getComments($db, $table); } /** * START REGULAR OUTPUT */ /** * used in ./libraries/header.inc.php to load JavaScript library file */ $GLOBALS['js_include'][] = 'tbl_change.js'; /** * HTTP and HTML headers */ require_once './libraries/header.inc.php'; /** * Displays the query submitted and its result * * @todo where does $disp_message and $disp_query come from??? */ if (! empty($disp_message)) { if (! isset($disp_query)) { $disp_query = null; } PMA_showMessage($disp_message, $disp_query); } /** * Displays top menu links */ require_once './libraries/tbl_links.inc.php'; /** * Get the analysis of SHOW CREATE TABLE for this table * @todo should be handled by class Table */ $show_create_table = PMA_DBI_fetch_value( 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0, 1); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); unset($show_create_table); /** * Get the list of the fields of the current table */ PMA_DBI_select_db($db); $table_fields = PMA_DBI_fetch_result('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, null, null, PMA_DBI_QUERY_STORE); $rows = array(); if (isset($primary_key)) { // when in edit mode load all selected rows from table $insert_mode = false; if (is_array($primary_key)) { $primary_key_array = $primary_key; } else { $primary_key_array = array(0 => $primary_key); } $result = array(); $found_unique_key = false; foreach ($primary_key_array as $key_id => $primary_key) { $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . str_replace(']', ']', $primary_key) . ';'; $result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE); $rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]); $primary_keys[$key_id] = str_replace('\\', '\\\\', $primary_key); // No row returned if (! $rows[$key_id]) { unset($rows[$key_id], $primary_key_array[$key_id]); PMA_showMessage($strEmptyResultSet, $local_query); echo "\n"; require_once './libraries/footer.inc.php'; } else { // end if (no record returned) $meta = PMA_DBI_get_fields_meta($result[$key_id]); if ($tmp = PMA_getUniqueCondition($result[$key_id], count($meta), $meta, $rows[$key_id], true)) { $found_unique_key = true; } unset($tmp); } } } else { // no primary key given, just load first row - but what happens if tbale is empty? $insert_mode = true; $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE); $rows = array_fill(0, $cfg['InsertRows'], false); } // // retrieve keys into foreign fields, if any $foreigners = PMA_getForeigners($db, $table); /** * Displays the form */ // loic1: autocomplete feature of IE kills the "onchange" event handler and it // must be replaced by the "onpropertychange" one in this case $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5 && PMA_USR_BROWSER_VER < 7) ? 'onpropertychange' : 'onchange'; // Had to put the URI because when hosted on an https server, // some browsers send wrongly this form to the http server. if ($cfg['CtrlArrowsMoving']) { ?> $db, 'table' => $table, 'goto' => $GLOBALS['goto'], 'err_url' => $err_url, 'sql_query' => $sql_query, ); if (isset($primary_keys)) { foreach ($primary_key_array as $key_id => $primary_key) { $_form_params['primary_key[' . $key_id . ']'] = trim($primary_key); } } ?>
> 1)); echo $strShow . ' : ' . $strFunction . '' . "\n"; } foreach ($rows as $row_id => $vrow) { if ($vrow === false) { unset($vrow); } $jsvkey = $row_id; $browse_foreigners_uri = '&pk=' . $row_id; $vkey = '[multi_edit][' . $jsvkey . ']'; $vresult = (isset($result) && is_array($result) && isset($result[$row_id]) ? $result[$row_id] : $result); if ($insert_mode && $row_id > 0) { echo ''; echo '
' . "\n"; } ?> 0)); echo ' ' . "\n"; } ?> d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime) // but, look what we get if we switch to iso: (Default is NULL) // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime) // so I force a NULL into it (I don't think it's possible // to have an empty default value for DATETIME) // then, the "if" after this one will work if ($table_fields[$i]['Type'] == 'datetime' && ! isset($table_fields[$i]['Default']) && isset($table_fields[$i]['Null']) && $table_fields[$i]['Null'] == 'YES') { $table_fields[$i]['Default'] = null; } $table_fields[$i]['len'] = preg_match('@float|double@', $table_fields[$i]['Type']) ? 100 : -1; if (isset($comments_map[$table_fields[$i]['Field']])) { $table_fields[$i]['Field_title'] = '' . $table_fields[$i]['Field_html'] . ''; } else { $table_fields[$i]['Field_title'] = $table_fields[$i]['Field_html']; } // The type column $table_fields[$i]['is_binary'] = stristr($table_fields[$i]['Type'], 'binary'); $table_fields[$i]['is_blob'] = stristr($table_fields[$i]['Type'], 'blob'); $table_fields[$i]['is_char'] = stristr($table_fields[$i]['Type'], 'char'); $table_fields[$i]['first_timestamp'] = false; switch ($table_fields[$i]['True_Type']) { case 'set': $table_fields[$i]['pma_type'] = 'set'; $table_fields[$i]['wrap'] = ''; break; case 'enum': $table_fields[$i]['pma_type'] = 'enum'; $table_fields[$i]['wrap'] = ''; break; case 'timestamp': if (!$timestamp_seen) { // can only occur once per table $timestamp_seen = 1; $table_fields[$i]['first_timestamp'] = true; } $table_fields[$i]['pma_type'] = $table_fields[$i]['Type']; $table_fields[$i]['wrap'] = ' nowrap="nowrap"'; break; default: $table_fields[$i]['pma_type'] = $table_fields[$i]['Type']; $table_fields[$i]['wrap'] = ' nowrap="nowrap"'; break; } } $field = $table_fields[$i]; $extracted_fieldspec = PMA_extractFieldSpec($field['Type']); if (-1 === $field['len']) { $field['len'] = PMA_DBI_field_len($vresult, $i); } $unnullify_trigger = $chg_evt_handler . "=\"return unNullify('" . PMA_escapeJsString($field['Field_html']) . "', '" . PMA_escapeJsString($jsvkey) . "')\""; $field_name_appendix = $vkey . '[' . $field['Field_html'] . ']'; $field_name_appendix_md5 = $field['Field_md5'] . $vkey . '[]'; if ($field['Type'] == 'datetime' && ! isset($field['Default']) && ! is_null($field['Default']) && ($insert_mode || ! isset($vrow[$field['Field']]))) { // INSERT case or // UPDATE case with an NULL value $vrow[$field['Field']] = date('Y-m-d H:i:s', time()); } ?> '; } else { // loic1: display default values if (!isset($field['Default'])) { $field['Default'] = ''; $real_null_value = TRUE; $data = ''; } else { $data = $field['Default']; } if ($field['True_Type'] == 'bit') { $special_chars = PMA_printable_bit_value($field['Default'], $extracted_fieldspec['spec_in_brackets']); } else { $special_chars = htmlspecialchars($field['Default']); } $backup_field = ''; $special_chars_encoded = PMA_duplicateFirstNewline($special_chars); } $idindex = ($o_rows * $fields_cnt) + $i + 1; $tabindex = (($idindex - 1) * 3) + 1; // The function column // ------------------- // Change by Bernard M. Piller // We don't want binary data to be destroyed // Note: from the MySQL manual: "BINARY doesn't affect how the column is // stored or retrieved" so it does not mean that the contents is // binary if ($cfg['ShowFunctionFields']) { if (($cfg['ProtectBinary'] && $field['is_blob'] && !$is_upload) || ($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) { echo ' ' . "\n"; } elseif (strstr($field['True_Type'], 'enum') || strstr($field['True_Type'], 'set')) { echo ' ' . "\n"; } else { ?> ' . "\n"; if ($field['Null'] == 'YES') { echo ' ' . "\n"; if (!(($cfg['ProtectBinary'] && $field['is_blob']) || ($cfg['ProtectBinary'] == 'all' && $field['is_binary']))) { echo ' 20) { $onclick .= '1, '; } else { $onclick .= '2, '; } } elseif (strstr($field['True_Type'], 'set')) { $onclick .= '3, '; } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == false) { // foreign key in a drop-down $onclick .= '4, '; } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == true) { // foreign key with a browsing icon $onclick .= '6, '; } else { $onclick .= '5, '; } $onclick .= '\'' . PMA_escapeJsString($field['Field_html']) . '\', \'' . $field['Field_md5'] . '\', \'' . PMA_escapeJsString($vkey) . '\'); this.checked = true}; return true" />' . "\n"; echo $onclick; } else { echo ' ' . "\n"; } } echo ' ' . "\n"; // The value column (depends on type) // ---------------- // See bug #1667887 for the reason why we don't use the maxlength // HTML attribute echo ' \n"; echo '
' . $strFunction . '
align="center"> > ' . $strBinary . '-- ' . "\n"; if ($foreignData['foreign_link'] == true) { echo $backup_field . "\n"; ?> tabindex="" id="field__3" value="" />  
32000) { echo " ' . $strTextAreaLength; } } elseif ($field['pma_type'] == 'enum') { if (! isset($table_fields[$i]['values'])) { $table_fields[$i]['values'] = array(); foreach ($extracted_fieldspec['enum_set_values'] as $val) { // Removes automatic MySQL escape format $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val)); $table_fields[$i]['values'][] = array( 'plain' => $val, 'html' => htmlspecialchars($val), ); } } $field_enum_values = $table_fields[$i]['values']; ?> 20) { ?> '; echo '' . "\n"; $j++; } // end for } // end else } elseif ($field['pma_type'] == 'set') { if (! isset($table_fields[$i]['values'])) { $table_fields[$i]['values'] = array(); foreach ($extracted_fieldspec['enum_set_values'] as $val) { $table_fields[$i]['values'][] = array( 'plain' => $val, 'html' => htmlspecialchars($val), ); } $table_fields[$i]['select_size'] = min(4, count($table_fields[$i]['values'])); } $field_set_values = $table_fields[$i]['values']; $select_size = $table_fields[$i]['select_size']; $vset = array_flip(explode(',', $data)); echo $backup_field . "\n"; ?> // We don't want binary data destroyed elseif ($field['is_binary'] || $field['is_blob']) { if (($cfg['ProtectBinary'] && $field['is_blob']) || ($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) { echo "\n"; // rajk - for blobstreaming $bs_reference_exists = FALSE; if (isset ($tbl_type) && strlen ($tbl_type) > 0) { // load PMA_Config $PMA_Config = $_SESSION['PMA_Config']; if (!empty($PMA_Config)) { $requiredTblType = $PMA_Config->get('PBXT_NAME'); if ($requiredTblType == strtolower ($tbl_type)) { $pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'); // check if blobstreaming plugins exist if ($pluginsExist) { $bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES'); if (!empty($bs_tables) && strlen($db) > 0) { $bs_tables = $bs_tables[$db]; if (isset($bs_tables)) { $allBSTablesExist = TRUE; foreach ($bs_tables as $table_key=>$bs_tbl) if (!$bs_tables[$table_key]['Exists']) { $allBSTablesExist = FALSE; break; } if ($allBSTablesExist) $bs_reference_exists = PMA_BS_ReferenceExists($data, $db); } // end if (isset($bs_tables)) } // end if (!empty($bs_tables) && strlen($db) > 0) } // end if ($pluginsExist) } // end if ($requiredTblType == strtolower ($tbl_type)) } // end if (!empty($PMA_Config)) } // end if (isset ($tbl_type) && strlen ($tbl_type) > 0) if ($bs_reference_exists) { echo ''; echo ' ' . $strBLOBRepositoryRemove . "
"; echo PMA_BS_CreateReferenceLink($data, $db); echo "
"; } else { echo $strBinaryDoNotEdit; if (isset($data)) { $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1); echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')'; unset($data_size); } echo "\n"; } // end if ($bs_reference_exists) ?> tabindex="" id="field__3" /> 0) { // load PMA Config $PMA_Config = $_SESSION['PMA_Config']; // is PMA_Config's data loaded? continue only if it is if (!empty($PMA_Config)) { $requiredTblType = $PMA_Config->get('PBXT_NAME'); if ($requiredTblType == strtolower ($tbl_type)) { $pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'); // check if blobstreaming plugins exist if ($pluginsExist) { $curlExists = $PMA_Config->get('CURL_EXISTS'); // check if CURL exists if ($curlExists) { $bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES'); // check for BLOBStreamable databases and if current database name is provided if (!empty($bs_tables) && strlen($db) > 0) { $bs_tables = $bs_tables[$db]; // check if reference to BLOBStreaming tables exists if (isset($bs_tables)) { $allBSTablesExist = TRUE; foreach ($bs_tables as $table_key=>$bs_tbl) if (!$bs_tables[$table_key]['Exists']) { $allBSTablesExist = FALSE; break; } // check if necessary BLOBStreaming tables exist if ($allBSTablesExist) { echo '
'; echo ' ' . $strBLOBRepositoryUpload; } // end if ($allBSTablesExist) } // end if (isset($bs_tables) } // end if (!empty($bs_tables) && strlen ($db) > 0) } // end if ($curlExists) } // end if ($pluginsExist) } // end if ($requiredTblType == strtolower ($tbl_type)) } // end if (!empty($PMA_Config)) } // end if (isset ($tbl_type) && strlen ($tbl_type) > 0) } echo '
'; echo ' '; // find maximum upload size, based on field type /** * @todo with functions this is not so easy, as you can basically * process any data with function like MD5 */ $max_field_sizes = array( 'tinyblob' => '256', 'blob' => '65536', 'mediumblob' => '16777216', 'longblob' => '4294967296'); // yeah, really $this_field_max_size = $max_upload_size; // from PHP max if ($this_field_max_size > $max_field_sizes[$field['pma_type']]) { $this_field_max_size = $max_field_sizes[$field['pma_type']]; } echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n"; // do not generate here the MAX_FILE_SIZE, because we should // put only one in the form to accommodate the biggest field if ($this_field_max_size > $biggest_max_file_size) { $biggest_max_file_size = $this_field_max_size; } } if (!empty($cfg['UploadDir'])) { $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir'])); if ($files === FALSE) { echo ' ' . $strError . '
' . "\n"; echo ' ' . $strWebServerUploadDirectoryError . "\n"; } elseif (!empty($files)) { echo "
\n"; echo ' ' . $strOr . '' . ' ' . $strWebServerUploadDirectory . ':
' . "\n"; echo ' ' . "\n"; } } // end if (web-server upload directory) } // end elseif (binary or blob) else { // field size should be at least 4 and max 40 $fieldsize = min(max($field['len'], 4), 40); echo $backup_field . "\n"; if ($field['is_char'] && ($cfg['CharEditing'] == 'textarea' || strpos($data, "\n") !== FALSE)) { echo "\n"; ?> tabindex="" id="field__3" />

'; } // end foreach on multi-edit ?>
      
0) { echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n"; } ?>
$primary_key) { echo ''. "\n"; } } $tmp = '' . "\n"; echo "\n" . sprintf($strRestartInsertion, $tmp); unset($tmp); echo '' . "\n"; echo '
' . "\n"; } /** * Displays the footer */ require_once './libraries/footer.inc.php'; ?>