~ubuntu-branches/ubuntu/dapper/phpmyadmin/dapper-updates

« back to all changes in this revision

Viewing changes to tbl_addfield.php

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Roszatycki
  • Date: 2004-12-13 19:23:57 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20041213192357-5jfwhvbnxaip4zbv
Tags: 2:2.6.1-rc1-1
* New upstream release.
* Security fix: Command execution and file disclosure was found.
  See http://www.phpmyadmin.net/home_page/security.php?issue=PMASA-2004-4
  Closes: #285488.
* Remove 003.non_standard_port_fix.diff applied to upstream.
* Add commented out options 'extension' and 'AllowRoot' to default config
  file.
* Support mysqli.so extension. Autodetect modules from 'extension' option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
/* $Id: tbl_addfield.php,v 2.3 2003/11/26 22:52:24 rabus Exp $ */
 
2
/* $Id: tbl_addfield.php,v 2.10 2004/10/21 15:33:39 nijel Exp $ */
3
3
// vim: expandtab sw=4 ts=4 sts=4:
4
4
 
5
 
 
6
5
/**
7
6
 * Get some core libraries
8
7
 */
19
18
 */
20
19
$err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table);
21
20
 
22
 
 
23
21
/**
24
22
 * The form used to define the field to add has been submitted
25
23
 */
26
24
$abort = false;
27
 
if (isset($submit)) {
 
25
if (isset($submit_num_fields)) {
 
26
    if (isset($orig_after_field)) {
 
27
        $after_field = $orig_after_field;
 
28
    }
 
29
    if (isset($orig_field_where)) {
 
30
        $field_where = $orig_field_where;
 
31
    }
 
32
    $num_fields = $orig_num_fields + $added_fields;
 
33
    $regenerate = TRUE;
 
34
} else if (isset($do_save_data)) {
28
35
    $query = '';
29
36
 
30
37
    // Transforms the radio button field_key into 3 arrays
83
90
            } // end if (auto_increment)
84
91
        }
85
92
 
86
 
        if ($after_field != '--end--') {
87
 
            // Only the first field can be added somewhere else than at the end
 
93
        if ($field_where != 'last') {
 
94
            // Only the first field can be added somewhere other than at the end
88
95
            if ($i == 0) {
89
 
                if ($after_field == '--first--') {
 
96
                if ($field_where == 'first') {
90
97
                    $query .= ' FIRST';
91
98
                } else {
92
99
                    $query .= ' AFTER ' . PMA_backquote(urldecode($after_field));
101
108
 
102
109
    // To allow replication, we first select the db to use and then run queries
103
110
    // on this db.
104
 
    $sql_query     = 'USE ' . PMA_backquote($db);
105
 
    $result        = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
 
111
    PMA_DBI_select_db($db) or PMA_mysqlDie(PMA_getError(), 'USE ' . PMA_backquotes($db), '', $err_url);
106
112
    $sql_query     = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD ' . $query;
107
 
    $error_create = false;
108
 
    $result        = PMA_mysql_query($sql_query)  or $error_create = true;
 
113
    $error_create = FALSE;
 
114
    PMA_DBI_try_query($sql_query) or $error_create = TRUE;
109
115
 
110
116
    if ($error_create == false) {
111
117
 
123
129
            } // end for
124
130
            $primary     = preg_replace('@, $@', '', $primary);
125
131
            if (!empty($primary)) {
126
 
                $sql_query      = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ')';
127
 
                $result         = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
 
132
                $sql_query      = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ');';
 
133
                $result         = PMA_DBI_query($sql_query);
128
134
                $sql_query_cpy  .= "\n" . $sql_query . ';';
129
135
            }
130
136
        } // end if
142
148
            $index     = preg_replace('@, $@', '', $index);
143
149
            if (!empty($index)) {
144
150
                $sql_query      = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')';
145
 
                $result         = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
 
151
                $result         = PMA_DBI_query($sql_query);
146
152
                $sql_query_cpy  .= "\n" . $sql_query . ';';
147
153
            }
148
154
        } // end if
160
166
            $unique = preg_replace('@, $@', '', $unique);
161
167
            if (!empty($unique)) {
162
168
                $sql_query      = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')';
163
 
                $result         = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
 
169
                $result         = PMA_DBI_query($sql_query);
164
170
                $sql_query_cpy  .= "\n" . $sql_query . ';';
165
171
            }
166
172
        } // end if
177
183
            $fulltext = preg_replace('@, $@', '', $fulltext);
178
184
            if (!empty($fulltext)) {
179
185
                $sql_query      = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')';
180
 
                $result         = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
 
186
                $result         = PMA_DBI_query($sql_query);
181
187
                $sql_query_cpy  .= "\n" . $sql_query . ';';
182
188
            }
183
189
        } // end if
190
196
 
191
197
        // garvin: Update comment table, if a comment was set.
192
198
        if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
193
 
            foreach($field_comments AS $fieldindex => $fieldcomment) {
 
199
            foreach ($field_comments AS $fieldindex => $fieldcomment) {
194
200
                PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment);
195
201
            }
196
202
        }
197
203
 
198
204
        // garvin: Update comment table for mime types [MIME]
199
205
        if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
200
 
            foreach($field_mimetype AS $fieldindex => $mimetype) {
 
206
            foreach ($field_mimetype AS $fieldindex => $mimetype) {
201
207
                PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
202
208
            }
203
209
        }
217
223
        if (isset($orig_after_field)) {
218
224
            $after_field = $orig_after_field;
219
225
        }
 
226
        if (isset($orig_field_where)) {
 
227
            $field_where = $orig_field_where;
 
228
        }
220
229
        $regenerate = true;
221
230
    }
222
231
} // end do alter table
225
234
 * Displays the form used to define the new field
226
235
 */
227
236
if ($abort == FALSE) {
 
237
    /**
 
238
     * Gets tables informations
 
239
     */
 
240
    require('./tbl_properties_common.php');
 
241
    require('./tbl_properties_table_info.php');
 
242
    /**
 
243
     * Displays top menu links
 
244
     */
 
245
    $active_page = 'tbl_properties_structure.php';
 
246
    require('./tbl_properties_links.php');
 
247
    /**
 
248
     * Display the form
 
249
     */
228
250
    $action = 'tbl_addfield.php';
229
251
    require('./tbl_properties.inc.php');
230
252