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

📄 tbl_change.php

📁 WEBGAME源码,有架设说明,只是非常简单
💻 PHP
📖 第 1 页 / 共 3 页
字号:
        // 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[$field] = date('Y-m-d H:i:s', time());                } else {                    $vrow = array($field => date('Y-m-d H:i:s', time()));                }            }            // UPDATE case with an empty and not NULL value under PHP4            elseif (empty($vrow[$field]) && is_null($vrow[$field])) {                $vrow[$field] = 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 = $field_html;        if (isset($comments_map[$field])) {            $field_name = '<span style="border-bottom: 1px dashed black;" title="'                . htmlspecialchars($comments_map[$field]) . '">' . $field_name . '</span>';        }        ?>        <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">            <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center"><?php echo $field_name; ?></td>        <?php        // 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"<?php echo $type_nowrap; ?>>                <?php echo $type; ?>            </td>        <?php        // Prepares the field value        $real_null_value = FALSE;        if (isset($vrow)) {            if (!isset($vrow[$field])              || (function_exists('is_null') && is_null($vrow[$field]))) {                $real_null_value = TRUE;                $vrow[$field]   = '';                $special_chars = '';                $data          = $vrow[$field];            } else {                // loic1: special binary "characters"                if ($is_binary || $is_blob) {                    $vrow[$field] = str_replace("\x00", '\0', $vrow[$field]);                    $vrow[$field] = str_replace("\x08", '\b', $vrow[$field]);                    $vrow[$field] = str_replace("\x0a", '\n', $vrow[$field]);                    $vrow[$field] = str_replace("\x0d", '\r', $vrow[$field]);                    $vrow[$field] = str_replace("\x1a", '\Z', $vrow[$field]);                } // end if                $special_chars   = htmlspecialchars($vrow[$field]);                $data            = $vrow[$field];            } // end if... else...            // loic1: if a timestamp field value is not included in an update            //        statement MySQL auto-update it to the current timestamp            // lem9:  however, things have changed since MySQL 4.1, so            //        it's better to set a fields_prev in this situation            $backup_field  = (PMA_MYSQL_INT_VERSION < 40100 && $row_table_def['True_Type'] == 'timestamp')                           ? ''                           : '<input type="hidden" name="fields_prev' . $field_name_appendix . '" value="' . htmlspecialchars($vrow[$field]) . '" />';        } 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">' . $strBinary . '</td>' . "\n";            } elseif (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {                echo '        <td align="center">--</td>' . "\n";            } else {                ?>            <td>                <select name="funcs<?php echo $field_name_appendix; ?>" <?php echo $unnillify_trigger; ?> tabindex="<?php echo ($tabindex + $tabindex_for_function); ?>" id="field_<?php echo $idindex; ?>_1">                    <option></option>                <?php                $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'])        // The null column        // ---------------        echo '        <td>' . "\n";        if ($row_table_def['Null'] == 'YES') {            echo '            <input type="hidden" name="fields_null_prev' . $field_name_appendix . '"';            if ($real_null_value && !$first_timestamp) {                echo ' value="on"';            }            echo ' />' . "\n";            if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary)) ) {                echo '            <input type="checkbox" tabindex="' . ($tabindex + $tabindex_for_null) . '"'                     . ' name="fields_null' . $field_name_appendix . '"';                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         .= '\'' . PMA_escapeJsString($field_html) . '\', \'' . $field_md5 . '\', \'' . PMA_escapeJsString($vkey) . '\'); this.checked = true}; return true" />' . "\n";                echo $onclick;            } else {                echo '            <input type="hidden" name="fields_null' . $field_name_appendix . '"';                if ($real_null_value && !$first_timestamp) {                    echo ' value="on"';                }                echo ' />' . "\n";            }        }        echo '        </td>' . "\n";        // The value column (depends on type)        // ----------------        require './libraries/get_foreign.lib.php';        if (isset($foreign_link) && $foreign_link == true) {            ?>            <td>            <?php echo $backup_field . "\n"; ?>            <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>"                value="foreign" />            <input type="hidden" name="fields<?php echo $field_name_appendix; ?>"                value="" id="field_<?php echo ($idindex); ?>_1" />            <input type="text"   name="field_<?php echo $field_name_appendix_md5; ?>"                class="textfield" <?php echo $unnillify_trigger; ?>                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"');                document.writeln(' href="browse_foreigners.php?');                document.writeln('<?php echo PMA_generate_common_url($db, $table); ?>');                document.writeln('&amp;field=<?php echo PMA_escapeJsString(urlencode($field) . $browse_foreigners_uri); ?>">');                document.writeln('<?php echo str_replace("'", "\'", $titles['Browse']); ?></a>');            //]]>            </script>            </td>            <?php        } elseif (isset($disp_row) && is_array($disp_row)) {            ?>            <td>            <?php echo $backup_field . "\n"; ?>            <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>"                value="foreign" />            <input type="hidden" name="fields<?php echo $field_name_appendix; ?>"                value="" id="field_<?php echo $idindex; ?>_1" />            <select name="field_<?php echo $field_name_appendix_md5; ?>"                <?php echo $unnillify_trigger; ?>                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>&nbsp;</td>        </tr>        <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">            <td colspan="5" align="right">                <?php echo $backup_field . "\n"; ?>                <textarea name="fields<?php echo $field_name_appendix; ?>"                    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 $unnillify_trigger; ?>                    tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"                    ><?php echo $special_chars; ?></textarea>            </td>          <?php        } elseif (strstr($type, 'text')) {            ?>            <td>                <?php echo $backup_field . "\n"; ?>                <textarea name="fields<?php echo $field_name_appendix; ?>"                    rows="<?php echo $cfg['TextareaRows']; ?>"                    cols="<?php echo $cfg['TextareaCols']; ?>"                    dir="<?php echo $text_dir; ?>"                    id="field_<?php echo ($idindex); ?>_3"                    <?php echo $unnillify_trigger; ?>                    tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"                    ><?php echo $special_chars; ?></textarea>            </td>            <?php            echo "\n";            if (strlen($special_chars) > 32000) {                echo '        <td>' . $strTextAreaLength . '</td>' . "\n";            }        } elseif ($type == 'enum') {            $enum        = PMA_getEnumSetOptions($row_table_def['Type']);            $enum_cnt    = count($enum);            ?>            <td>

⌨️ 快捷键说明

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