removed MySQL < 5 code

This commit is contained in:
Sebastian Mendel
2007-10-02 09:23:37 +00:00
parent 1f6d6d419b
commit a3923d6bdd
5 changed files with 70 additions and 153 deletions

View File

@@ -43,10 +43,6 @@ $calling_script = PMA_getenv('PHP_SELF');
<input type="password" name="pma_pw2" id="pw_pma_pw2" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" /> <input type="password" name="pma_pw2" id="pw_pma_pw2" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
</td> </td>
</tr> </tr>
<?php
if (PMA_MYSQL_INT_VERSION >= 40102) {
?>
<tr> <tr>
<td> <td>
<?php echo $strPasswordHashing; ?>: <?php echo $strPasswordHashing; ?>:
@@ -67,9 +63,6 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
</label> </label>
</td> </td>
</tr> </tr>
<?php
}
?>
</table> </table>
</fieldset> </fieldset>
<fieldset id="fieldset_change_password_footer" class="tblFooters"> <fieldset id="fieldset_change_password_footer" class="tblFooters">

View File

@@ -20,10 +20,8 @@ if ($is_create_db_priv) {
<input type="hidden" name="reload" value="1" /> <input type="hidden" name="reload" value="1" />
<input type="text" name="db" value="<?php echo $db_to_create; ?>" maxlength="64" class="textfield" id="text_create_db"/> <input type="text" name="db" value="<?php echo $db_to_create; ?>" maxlength="64" class="textfield" id="text_create_db"/>
<?php <?php
if (PMA_MYSQL_INT_VERSION >= 40101) {
require_once './libraries/mysql_charsets.lib.php'; require_once './libraries/mysql_charsets.lib.php';
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, TRUE, 5); echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, TRUE, 5);
}
?> ?>
<input type="submit" value="<?php echo $strCreate; ?>" id="buttonGo" /> <input type="submit" value="<?php echo $strCreate; ?>" id="buttonGo" />
</form> </form>

View File

@@ -3,6 +3,25 @@
/** /**
* Displays form for creating a table (if user has privileges for that) * Displays form for creating a table (if user has privileges for that)
* *
* for MySQL >= 4.1.0, we should be able to detect if user has a CREATE
* privilege by looking at SHOW GRANTS output;
* for < 4.1.0, it could be more difficult because the logic tries to
* detect the current host and it might be expressed in many ways; also
* on a shared server, the user might be unable to define a controluser
* that has the proper rights to the "mysql" db;
* so we give up and assume that user has the right to create a table
*
* Note: in this case we could even skip the following "foreach" logic
*
* Addendum, 2006-01-19: ok, I give up. We got some reports about servers
* where the hostname field in mysql.user is not the same as the one
* in mysql.db for a user. In this case, SHOW GRANTS does not return
* the db-specific privileges. And probably, those users are on a shared
* server, so can't set up a control user with rights to the "mysql" db.
* We cannot reliably detect the db-specific privileges, so no more
* warnings about the lack of privileges for CREATE TABLE. Tested
* on MySQL 5.0.18.
*
* @version $Id$ * @version $Id$
*/ */
@@ -11,93 +30,8 @@
*/ */
require_once './libraries/check_user_privileges.lib.php'; require_once './libraries/check_user_privileges.lib.php';
// for MySQL >= 4.1.0, we should be able to detect if user has a CREATE
// privilege by looking at SHOW GRANTS output;
// for < 4.1.0, it could be more difficult because the logic tries to
// detect the current host and it might be expressed in many ways; also
// on a shared server, the user might be unable to define a controluser
// that has the proper rights to the "mysql" db;
// so we give up and assume that user has the right to create a table
//
// Note: in this case we could even skip the following "foreach" logic
// Addendum, 2006-01-19: ok, I give up. We got some reports about servers
// where the hostname field in mysql.user is not the same as the one
// in mysql.db for a user. In this case, SHOW GRANTS does not return
// the db-specific privileges. And probably, those users are on a shared
// server, so can't set up a control user with rights to the "mysql" db.
// We cannot reliably detect the db-specific privileges, so no more
// warnings about the lack of privileges for CREATE TABLE. Tested
// on MySQL 5.0.18.
$is_create_table_priv = true; $is_create_table_priv = true;
/*
if (PMA_MYSQL_INT_VERSION >= 40100) {
$is_create_table_priv = false;
} else {
$is_create_table_priv = true;
}
foreach ($dbs_where_create_table_allowed as $allowed_db) {
// if we find the exact db name, we stop here
if ($allowed_db == $db) {
$is_create_table_priv = TRUE;
break;
}
// '*' indicates a global CREATE priv
if ($allowed_db == '*') {
$is_create_table_priv = TRUE;
break;
}
if (ereg('%|_', $allowed_db)) {
// take care of wildcards and escaped wildcards,
// transforming them into regexp patterns
$max_position = strlen($allowed_db) - 1;
$i = 0;
$pattern = '';
while ($i <= $max_position) {
if ($allowed_db[$i] == '\\'){
if ($i < $max_position - 1 && $allowed_db[$i+1] == '_'){
$chunk = '_';
$i++;
} elseif ($i < $max_position - 1 && $allowed_db[$i+1] == '%'){
$chunk = '%';
$i++;
} else {
$chunk = $allowed_db[$i];
}
} elseif ($allowed_db[$i] == '_'){
$chunk = '.';
} elseif ($allowed_db[$i] == '%'){
$chunk = '(.)*';
} else {
$chunk = $allowed_db[$i];
}
$pattern .= $chunk;
$i++;
} // end while
unset($i, $max_position, $chunk);
$matches = '';
if (preg_match('@' .$pattern . '@i', $db, $matches)) {
if ($matches[0] == $db) {
$is_create_table_priv = TRUE;
break;
//TODO: maybe receive in $allowed_db also the db names
// on which we cannot CREATE, and check them
// in this foreach, because if a user is allowed to CREATE
// on db foo% but forbidden on db foobar, he should not
// see the Create table dialog
}
}
}
} // end foreach
unset($i, $max_position, $chunk, $pattern);
*/
?> ?>
<form method="post" action="tbl_create.php" <form method="post" action="tbl_create.php"
onsubmit="return (emptyFormElements(this, 'table') &amp;&amp; checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldCount']); ?>', 1))"> onsubmit="return (emptyFormElements(this, 'table') &amp;&amp; checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldCount']); ?>', 1))">
@@ -110,7 +44,6 @@ if ($GLOBALS['cfg']['PropertiesIconic']) {
echo sprintf($strCreateNewTable, PMA_getDbLink()); echo sprintf($strCreateNewTable, PMA_getDbLink());
?> ?>
</legend> </legend>
<?php if ($is_create_table_priv) { ?>
<?php echo PMA_generate_common_hidden_inputs($db); ?> <?php echo PMA_generate_common_hidden_inputs($db); ?>
<div class="formelement"> <div class="formelement">
<?php echo $strName; ?>: <?php echo $strName; ?>:
@@ -124,8 +57,5 @@ echo sprintf($strCreateNewTable, PMA_getDbLink());
</fieldset> </fieldset>
<fieldset class="tblFooters"> <fieldset class="tblFooters">
<input type="submit" value="<?php echo $strGo; ?>" /> <input type="submit" value="<?php echo $strGo; ?>" />
<?php } else { ?>
<div class="error"><?php echo $strNoPrivileges; ?></div>
<?php } // end if else ?>
</fieldset> </fieldset>
</form> </form>

View File

@@ -106,7 +106,7 @@ if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
echo '>' . htmlentities($temp_charset) . '</option>' . "\n"; echo '>' . htmlentities($temp_charset) . '</option>' . "\n";
} }
echo ' </select><br />' . "\n" . ' '; echo ' </select><br />' . "\n" . ' ';
} elseif (PMA_MYSQL_INT_VERSION >= 40100) { } else {
echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n"; echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', FALSE); echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
} // end if (recoding) } // end if (recoding)

View File

@@ -678,8 +678,6 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']). // 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
// Do not show comments, if using horizontalflipped mode, because of space usage // Do not show comments, if using horizontalflipped mode, because of space usage
if ($GLOBALS['cfg']['ShowBrowseComments'] if ($GLOBALS['cfg']['ShowBrowseComments']
&& ($GLOBALS['cfgRelation']['commwork']
|| PMA_MYSQL_INT_VERSION >= 40100)
&& $_SESSION['userconf']['disp_direction'] != 'horizontalflipped') { && $_SESSION['userconf']['disp_direction'] != 'horizontalflipped') {
$comments_map = array(); $comments_map = array();
if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) { if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
@@ -2120,7 +2118,6 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
* (but see 2006-01-19 note in display_create_table.lib.php, * (but see 2006-01-19 note in display_create_table.lib.php,
* I think we cannot detect db-specific privileges reliably) * I think we cannot detect db-specific privileges reliably)
*/ */
if (PMA_MYSQL_INT_VERSION >= 50000) {
if (!$header_shown) { if (!$header_shown) {
echo $header; echo $header;
$header_shown = TRUE; $header_shown = TRUE;
@@ -2129,7 +2126,6 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
'view_create.php' . $url_query, 'view_create.php' . $url_query,
PMA_getIcon('b_views.png', 'CREATE VIEW', false, true), PMA_getIcon('b_views.png', 'CREATE VIEW', false, true),
'', true, true, '') . "\n"; '', true, true, '') . "\n";
}
if ($header_shown) { if ($header_shown) {
echo '</fieldset><br />'; echo '</fieldset><br />';