~ubuntu-branches/ubuntu/hardy/phpmyadmin/hardy-updates

« back to all changes in this revision

Viewing changes to tbl_indexes.php

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2007-10-17 22:54:41 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20071017225441-xqwg7f10chaprdoe
Tags: 4:2.11.1.2-1

* New upstream release.
* Addresses two cross site scripting issues:
  PMASA-2007-5, PMASA-2007-6
  (CVE-2007-5386, closes: #446451)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
/* $Id: tbl_indexes.php 9602 2006-10-25 12:25:01Z nijel $ */
3
 
// vim: expandtab sw=4 ts=4 sts=4:
 
2
/* vim: expandtab sw=4 ts=4 sts=4: */
 
3
/**
 
4
 * display information about indexes in a table
 
5
 *
 
6
 * @version $Id: tbl_indexes.php 10240 2007-04-01 11:02:46Z cybot_tm $
 
7
 */
4
8
 
5
9
/**
6
10
 * Gets some core libraries
7
11
 */
8
 
require_once('./libraries/common.lib.php');
9
 
require_once('./libraries/tbl_indexes.lib.php');
10
 
 
11
 
/**
12
 
 * Defines the index types ("FULLTEXT" is available since MySQL 3.23.23)
13
 
 */
14
 
$index_types       = PMA_get_indextypes();
15
 
$index_types_cnt   = count($index_types);
 
12
require_once './libraries/common.inc.php';
 
13
require_once './libraries/tbl_indexes.lib.php';
16
14
 
17
15
/**
18
16
 * Ensures the db & table are valid, then loads headers and gets indexes
21
19
 */
22
20
if (!defined('PMA_IDX_INCLUDED')) {
23
21
    // Not a valid db name -> back to the welcome page
24
 
    if ( isset($db) && strlen($db) ) {
 
22
    if (strlen($db)) {
25
23
        $is_db = PMA_DBI_select_db($db);
26
24
    }
27
 
    if ( !isset($db) || !strlen($db) || !$is_db ) {
28
 
        $uri_params = array( 'reload' => '1' );
29
 
        if ( isset($message) ) {
 
25
    if (!strlen($db) || !$is_db) {
 
26
        $uri_params = array('reload' => '1');
 
27
        if (isset($message)) {
30
28
            $uri_params['message'] = $message;
31
29
        }
32
30
        PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php'
34
32
        exit;
35
33
    }
36
34
    // Not a valid table name -> back to the default db sub-page
37
 
    if ( isset($table) && strlen($table) ) {
 
35
    if (strlen($table)) {
38
36
        $is_table = PMA_DBI_query('SHOW TABLES LIKE \''
39
37
            . PMA_sqlAddslashes($table, TRUE) . '\'', null, PMA_DBI_QUERY_STORE);
40
38
    }
41
 
    if ( ! isset($table) || ! strlen($table)
42
 
      || !( $is_table && PMA_DBI_num_rows($is_table) ) ) {
43
 
        $uri_params = array( 'reload' => '1', 'db' => $db );
44
 
        if ( isset($message) ) {
 
39
    if (! strlen($table)
 
40
      || !($is_table && PMA_DBI_num_rows($is_table))) {
 
41
        $uri_params = array('reload' => '1', 'db' => $db);
 
42
        if (isset($message)) {
45
43
            $uri_params['message'] = $message;
46
44
        }
47
45
        PMA_sendHeaderLocation($cfg['PmaAbsoluteUri']
48
46
            . $cfg['DefaultTabDatabase']
49
47
            . PMA_generate_common_url($uri_params, '&'));
50
48
        exit;
51
 
    } elseif ( isset($is_table) ) {
 
49
    } elseif (isset($is_table)) {
52
50
        PMA_DBI_free_result($is_table);
53
51
    }
54
52
 
56
54
    $js_to_run = isset($index) && isset($do_save_data)
57
55
        ? 'functions.js'
58
56
        : 'indexes.js';
59
 
    require_once('./libraries/header.inc.php');
 
57
    require_once './libraries/header.inc.php';
60
58
} // end if
61
59
 
62
60
 
184
182
        . $strHasBeenAltered;
185
183
 
186
184
    $active_page = 'tbl_structure.php';
187
 
    require('./tbl_structure.php');
 
185
    require './tbl_structure.php';
188
186
} // end builds the new index
189
187
 
190
188
 
296
294
<label for="select_index_type"><?php echo $strIndexType; ?></label>
297
295
<select name="index_type" id="select_index_type" onchange="return checkIndexName()">
298
296
    <?php
299
 
    for ($i = 0; $i < $index_types_cnt; $i++) {
300
 
        if ($index_types[$i] == 'PRIMARY') {
301
 
            if ($index == 'PRIMARY' || !isset($indexes_info['PRIMARY'])) {
302
 
                echo '                '
303
 
                     . '<option value="PRIMARY"'
304
 
                     . (($index_type == 'PRIMARY') ? ' selected="selected"' : '')
305
 
                     . '>PRIMARY</option>' . "\n";
306
 
            }
307
 
        } else {
308
 
            echo '                '
309
 
                 . '<option value="' . $index_types[$i] . '"'
310
 
                 . (($index_type == $index_types[$i]) ? ' selected="selected"' : '')
311
 
                 . '>'. $index_types[$i] . '</option>' . "\n";
312
 
 
313
 
        } // end if... else...
314
 
    } // end for
 
297
    foreach (PMA_get_indextypes() as $each_index_type) {
 
298
        if ($each_index_type === 'PRIMARY'
 
299
         && $index !== 'PRIMARY'
 
300
         && isset($indexes_info['PRIMARY'])) {
 
301
            // skip PRIMARY if there is already one in the table
 
302
            continue;
 
303
        }
 
304
        echo '                '
 
305
             . '<option value="' . $each_index_type . '"'
 
306
             . (($index_type == $each_index_type) ? ' selected="selected"' : '')
 
307
             . '>'. $each_index_type . '</option>' . "\n";
 
308
    }
315
309
    ?>
316
310
</select>
317
311
<?php echo PMA_showMySQLDocu('SQL-Syntax', 'ALTER_TABLE'); ?>
353
347
                     . '<option value="' . htmlspecialchars($val) . '"'
354
348
                     . (($val == $selected) ? ' selected="selected"' : '') . '>'
355
349
                     . htmlspecialchars($val) . (($add_type) ? ' ['
356
 
                     . $fields_types[$key] . ']' : '' ) . '</option>' . "\n";
 
350
                     . $fields_types[$key] . ']' : '') . '</option>' . "\n";
357
351
            }
358
352
        } // end foreach $fields_names
359
353
        ?>
399
393
            '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
400
394
            1)">
401
395
    <?php
402
 
    echo PMA_generate_common_hidden_inputs( $db, $table );
 
396
    echo PMA_generate_common_hidden_inputs($db, $table);
403
397
    ?>
404
398
    <table id="table_indexes" class="data">
405
399
        <caption class="tblHeaders">
412
406
        </caption>
413
407
    <?php
414
408
 
415
 
    if ( count($ret_keys) > 0) {
 
409
    if (count($ret_keys) > 0) {
416
410
        $edit_link_text = '';
417
411
        $drop_link_text = '';
418
412
 
419
 
        // We need to copy the value or else the == 'both' check will always
420
 
        // return true
421
 
        $propicon = (string) $cfg['PropertiesIconic'];
422
 
 
423
 
        if ($cfg['PropertiesIconic'] === true || $propicon == 'both') {
 
413
        if ($cfg['PropertiesIconic'] === true || $cfg['PropertiesIconic'] === 'both') {
424
414
            $edit_link_text = '<img class="icon" src="' . $pmaThemeImage
425
415
                . 'b_edit.png" width="16" height="16" title="' . $strEdit
426
416
                . '" alt="' . $strEdit . '" />';
428
418
                . 'b_drop.png" width="16" height="16" title="' . $strDrop
429
419
                . '" alt="' . $strDrop . '" />';
430
420
        }
431
 
        if ($cfg['PropertiesIconic'] === false || $propicon == 'both') {
 
421
        if ($cfg['PropertiesIconic'] === false || $cfg['PropertiesIconic'] === 'both') {
432
422
            $edit_link_text .= $strEdit;
433
423
            $drop_link_text .= $strDrop;
434
424
        }
435
 
        if ($propicon == 'both') {
 
425
        if ($cfg['PropertiesIconic'] === 'both') {
436
426
            $edit_link_text = '<nobr>' . $edit_link_text . '</nobr>';
437
427
            $drop_link_text = '<nobr>' . $drop_link_text . '</nobr>';
438
428
        }
450
440
        <?php
451
441
        $idx_collection = PMA_show_indexes($table, $indexes, $indexes_info,
452
442
            $indexes_data, true);
453
 
        echo PMA_check_indexes($idx_collection);
 
443
        echo PMA_check_indexes($ret_keys);
454
444
    } // end display indexes
455
445
    else {
456
446
        // none indexes
482
472
echo "\n";
483
473
 
484
474
if (!defined('PMA_IDX_INCLUDED')){
485
 
    require_once('./libraries/footer.inc.php');
 
475
    require_once './libraries/footer.inc.php';
486
476
}
487
477
?>