⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tbl_change.php

📁 一个用PHP编写的
💻 PHP
📖 第 1 页 / 共 3 页
字号:
        <tr>            <th colspan="5" align="right" class="tblFooters">                <input type="submit" value="<?php echo $strGo; ?>" />&nbsp;            </th>        </tr>            <?php        } // end if        echo "\n";        $row_table_def   = $trow_table_def[$i];        $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);        $field           = $row_table_def['Field'];        // removed previous PHP3-workaround that caused a problem with        // field names like '000'        $rowfield = $field;        // d a t e t i m e        //        // loic1: current date should not be set as default if the field is NULL        //        for the current row        // lem9:  but do not put here the current datetime if there is a default        //        value (the real default value will be set in the        //        Default value logic below)        // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,        // $row_table_def['Default'] is not set if it contains NULL:        // Array ( [Field] => 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 ($row_table_def['Type'] == 'datetime'            && !isset($row_table_def['Default'])            && isset($row_table_def['Null'])            && $row_table_def['Null'] == 'YES') {            $row_table_def['Default'] = null;        }        if ($row_table_def['Type'] == 'datetime'            && (!isset($row_table_def['Default']))            && (!is_null($row_table_def['Default']))) {            // INSERT case            if ($insert_mode) {                if (isset($vrow)) {                    $vrow[$rowfield] = date('Y-m-d H:i:s', time());                } else {                    $vrow = array($rowfield => date('Y-m-d H:i:s', time()));                }            }            // UPDATE case with an empty and not NULL value under PHP4            elseif (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {                $vrow[$rowfield] = date('Y-m-d H:i:s', time());            } // end if... elseif...        }        $len             = (preg_match('@float|double@', $row_table_def['Type']))                         ? 100                         : PMA_DBI_field_len($vresult, $i);        $first_timestamp = 0;        $field_name = htmlspecialchars($field);        if (isset($comments_map[$field])) {            $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$field]) . '">' . $field_name . '</span>';        }        $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];        ?>        <tr>            <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo $field_name; ?></td>        <?php        echo "\n";        // The type column        $is_binary                  = stristr($row_table_def['Type'], ' binary');        $is_blob                    = stristr($row_table_def['Type'], 'blob');        $is_char                    = stristr($row_table_def['Type'], 'char');        switch ($row_table_def['True_Type']) {            case 'set':                $type         = 'set';                $type_nowrap  = '';                break;            case 'enum':                $type         = 'enum';                $type_nowrap  = '';                break;            case 'timestamp':                if (!$timestamp_seen) {   // can only occur once per table                    $timestamp_seen  = 1;                    $first_timestamp = 1;                }                $type         = $row_table_def['Type'];                $type_nowrap  = ' nowrap="nowrap"';                break;            default:                $type         = $row_table_def['Type'];                $type_nowrap  = ' nowrap="nowrap"';                break;        }        ?>            <td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>>                <?php echo $type; ?>            </td>        <?php        echo "\n";        // Prepares the field value        $real_null_value = FALSE;        if (isset($vrow)) {            if (!isset($vrow[$rowfield])              || (function_exists('is_null') && is_null($vrow[$rowfield]))) {                $real_null_value = TRUE;                $vrow[$rowfield]   = '';                $special_chars = '';                $data          = $vrow[$rowfield];            } else {                // loic1: special binary "characters"                if ($is_binary || $is_blob) {                    $vrow[$rowfield] = str_replace("\x00", '\0', $vrow[$rowfield]);                    $vrow[$rowfield] = str_replace("\x08", '\b', $vrow[$rowfield]);                    $vrow[$rowfield] = str_replace("\x0a", '\n', $vrow[$rowfield]);                    $vrow[$rowfield] = str_replace("\x0d", '\r', $vrow[$rowfield]);                    $vrow[$rowfield] = str_replace("\x1a", '\Z', $vrow[$rowfield]);                } // end if                $special_chars   = htmlspecialchars($vrow[$rowfield]);                $data            = $vrow[$rowfield];            } // end if... else...            // loic1: if a timestamp field value is not included in an update            //        statement MySQL auto-update it to the current timestamp            $backup_field  = ($row_table_def['True_Type'] == 'timestamp')                           ? ''                           : '<input type="hidden" name="fields_prev' . $vkey . '[' . urlencode($field) . ']" value="' . urlencode($vrow[$rowfield]) . '" />';        } else {            // loic1: display default values            if (!isset($row_table_def['Default'])) {                $row_table_def['Default'] = '';                $real_null_value          = TRUE;                $data                     = '';            } else {                $data                     = $row_table_def['Default'];            }            $special_chars = htmlspecialchars($row_table_def['Default']);            $backup_field  = '';        }        $idindex  = ($o_rows * $fields_cnt) + $i + 1;        $tabindex = (($idindex - 1) * 3) + 1;        // The function column        // -------------------        // Change by Bernard M. Piller <bernard@bmpsystems.com>        // 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'] && $is_blob && !$is_upload)                || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {                echo '        <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";            } elseif (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {                echo '        <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";            } else {                ?>            <td bgcolor="<?php echo $bgcolor; ?>">                <select name="funcs<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_function); ?>" id="field_<?php echo $idindex; ?>_1">                    <option></option>                <?php                echo "\n";                $selected     = '';                // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'                // or something similar. Then directly look up the entry in the RestrictFunctions array,                // which will then reveal the available dropdown options                if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]) && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {                    $current_func_type  = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];                    $dropdown           = $cfg['RestrictFunctions'][$current_func_type];                    $default_function   = $cfg['DefaultFunctions'][$current_func_type];                } else {                    $dropdown = array();                    $default_function   = '';                }                $dropdown_built = array();                $op_spacing_needed = FALSE;                // garvin: loop on the dropdown array and print all available options for that field.                $cnt_dropdown = count($dropdown);                for ($j = 0; $j < $cnt_dropdown; $j++) {                    // Is current function defined as default?                    // For MySQL < 4.1.2, for the first timestamp we set as                    // default function the one defined in config (which                    // should be NOW() ).                    // For MySQL >= 4.1.2, we don't set the default function                    // if there is a default value for the timestamp                     // (not including CURRENT_TIMESTAMP)                    // and the column does not have the                     // ON UPDATE DEFAULT TIMESTAMP attribute.                                        if (PMA_MYSQL_INT_VERSION < 40102                     || (PMA_MYSQL_INT_VERSION >= 40102                        && !($row_table_def['True_Type'] == 'timestamp' && !empty($row_table_def['Default']) &&  !isset($analyzed_sql[0]['create_table_fields'][$field]['on_update_current_timestamp'])))) {                    $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])                                || (!$first_timestamp && $dropdown[$j] == $default_function)                              ? ' selected="selected"'                              : '';                }                    echo '                ';                    echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";                    $dropdown_built[$dropdown[$j]] = 'TRUE';                    $op_spacing_needed = TRUE;                }                // garvin: For compatibility's sake, do not let out all other functions. Instead                // print a separator (blank) and then show ALL functions which weren't shown                // yet.                $cnt_functions = count($cfg['Functions']);                for ($j = 0; $j < $cnt_functions; $j++) {                    if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {                        // Is current function defined as default?                        $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])                                    || (!$first_timestamp && $cfg['Functions'][$j] == $default_function)                                  ? ' selected="selected"'                                  : '';                        if ($op_spacing_needed == TRUE) {                            echo '                ';                            echo '<option value="">--------</option>' . "\n";                            $op_spacing_needed = FALSE;                        }                        echo '                ';                        echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";                    }                } // end for                unset($selected);                ?>                </select>            </td>                <?php            }        } // end if ($cfg['ShowFunctionFields'])        echo "\n";        // The null column        // ---------------        echo '        <td bgcolor="' . $bgcolor . '">' . "\n";        if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary))            && $row_table_def['Null'] == 'YES') {            echo '            <input type="hidden" name="fields_null_prev' . $vkey . '[' . urlencode($field) . ']"';            if ($real_null_value && !$first_timestamp) {                echo ' checked="checked"';            }            echo ' />' . "\n";            echo '            <input type="checkbox" tabindex="' . ($tabindex + $tabindex_for_null) . '"'                 . ' name="fields_null' . $vkey . '[' . urlencode($field) . ']"';            if ($real_null_value && !$first_timestamp) {                echo ' checked="checked"';            }            echo ' id="field_' . ($idindex) . '_2"';            $onclick         = ' onclick="if (this.checked) {nullify(';            if (strstr($row_table_def['True_Type'], 'enum')) {                if (strlen($row_table_def['Type']) > 20) {                    $onclick .= '1, ';                } else {                    $onclick .= '2, ';                }            } elseif (strstr($row_table_def['True_Type'], 'set')) {                $onclick     .= '3, ';            } elseif ($foreigners && isset($foreigners[$field])) {                $onclick     .= '4, ';            } else {                $onclick     .= '5, ';            }            $onclick         .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\', \'' . $vkey . '\'); this.checked = true}; return true" />' . "\n";            echo $onclick;        } else {            echo '            &nbsp;' . "\n";        }        echo '        </td>' . "\n";        // The value column (depends on type)        // ----------------        require('./libraries/get_foreign.lib.php');        if (isset($foreign_link) && $foreign_link == true) {            ?>            <td bgcolor="<?php echo $bgcolor; ?>">            <?php echo $backup_field . "\n"; ?>            <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" />            <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo ($idindex); ?>_1" />            <input type="text"   name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3" value="<?php echo htmlspecialchars($data); ?>" />            <script type="text/javascript" language="javascript">            //<![CDATA[                document.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes,resizable=yes\'); return false" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&amp;field=<?php echo urlencode($field) . $browse_foreigners_uri; ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>');            //]]>            </script>            </td>            <?php        } elseif (isset($disp_row) && is_array($disp_row)) {            ?>            <td bgcolor="<?php echo $bgcolor; ?>">            <?php echo $backup_field . "\n"; ?>            <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" />            <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $idindex; ?>_1" />            <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3">                <?php echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']); ?>            </select>            </td>            <?php            unset($disp_row);        } elseif ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {            ?>            <td bgcolor="<?php echo $bgcolor; ?>">&nbsp;</td>        </tr>        <tr>            <td colspan="4" align="right" bgcolor="<?php echo $bgcolor; ?>">                <?php echo $backup_field . "\n"; ?>                <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo ($cfg['TextareaRows']*2); ?>" cols="<?php echo ($cfg['TextareaCols']*2); ?>" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($idindex); ?>_3"                    <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"><?php echo $special_chars; ?></textarea>            </td>          <?php        } elseif (strstr($type, 'text')) {            ?>            <td bgcolor="<?php echo $bgcolor; ?>">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -