3 // vim: expandtab sw=4 ts=4 sts=4:
5 // Displays form for creating a table (if user has privileges for that)
7 require_once('./libraries/check_user_privileges.lib.php');
9 $is_create_table_priv = FALSE;
11 foreach( $dbs_where_create_table_allowed as $allowed_db ) {
13 // if we find the exact db name, we stop here
14 if ($allowed_db == $db) {
15 $is_create_table_priv = TRUE;
19 // '*' indicates a global CREATE priv
20 if ($allowed_db == '*') {
21 $is_create_table_priv = TRUE;
25 if (ereg('%|_', $allowed_db)) {
26 // take care of wildcards and escaped wildcards,
27 // transforming them into regexp patterns
28 $max_position = strlen($allowed_db) - 1;
31 while ($i <= $max_position) {
32 if ($allowed_db[$i] == '\\'){
33 if ($i < $max_position - 1 && $allowed_db[$i+
1] == '_'){
36 } elseif ($i < $max_position - 1 && $allowed_db[$i+
1] == '%'){
40 $chunk = $allowed_db[$i];
42 } elseif ($allowed_db[$i] == '_'){
44 } elseif ($allowed_db[$i] == '%'){
47 $chunk = $allowed_db[$i];
52 unset($i, $max_position, $chunk);
55 if (preg_match('@' .$pattern . '@i', $db, $matches)) {
56 if ($matches[0] == $db) {
57 $is_create_table_priv = TRUE;
59 //TODO: maybe receive in $allowed_db also the db names
60 // on which we cannot CREATE, and check them
61 // in this foreach, because if a user is allowed to CREATE
62 // on db foo% but forbidden on db foobar, he should not
63 // see the Create table dialog
68 unset($i, $max_position, $chunk, $pattern);
71 <form method
="post" action
="tbl_create.php"
72 onsubmit
="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldCount']); ?>', 1))">
76 if ( $GLOBALS['cfg']['PropertiesIconic'] ) {
77 echo '<img class="icon" src="' . $pmaThemeImage . 'b_newtbl.png" width="16" height="16" alt="" />';
79 echo sprintf( $strCreateNewTable, PMA_getDbLink() );
82 <?php
if ( $is_create_table_priv ) { ?
>
83 <?php
echo PMA_generate_common_hidden_inputs( $db ); ?
>
84 <div
class="formelement">
85 <?php
echo $strName; ?
>:
86 <input type
="text" name
="table" maxlength
="64" size
="30" />
88 <div
class="formelement">
89 <?php
echo $strNumberOfFields; ?
>:
90 <input type
="text" name
="num_fields" size
="2" />
93 <fieldset
class="tblFooters">
94 <input type
="submit" value
="<?php echo $strGo; ?>" />
96 <div
class="error"><?php
echo $strNoPrivileges; ?
></div
>
97 <?php
} // end if else ?>