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

@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Displays form for password change
* Displays form for password change
*
* @version $Id$
*/
@@ -24,52 +24,45 @@ $calling_script = PMA_getenv('PHP_SELF');
}?>
<fieldset id="fieldset_change_password">
<legend><?php echo $GLOBALS['strChangePassword']; ?></legend>
<table class="data">
<tr class="odd noclick">
<td colspan="2">
<input type="radio" name="nopass" value="1" onclick="pma_pw.value = ''; pma_pw2.value = ''; this.checked = true" />
<?php echo $GLOBALS['strNoPassword'] . "\n"; ?>
</td>
</tr>
<tr class="even noclick">
<td>
<input type="radio" name="nopass" value="0" onclick="document.getElementById('pw_pma_pw').focus();" checked="checked " />
<?php echo $GLOBALS['strPassword']; ?>:&nbsp;
</td>
<td>
<input type="password" name="pma_pw" id="pw_pma_pw" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
&nbsp;&nbsp;
<?php echo $GLOBALS['strReType']; ?>:&nbsp;
<input type="password" name="pma_pw2" id="pw_pma_pw2" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
</td>
</tr>
<?php
if (PMA_MYSQL_INT_VERSION >= 40102) {
?>
<tr>
<table class="data">
<tr class="odd noclick">
<td colspan="2">
<input type="radio" name="nopass" value="1" onclick="pma_pw.value = ''; pma_pw2.value = ''; this.checked = true" />
<?php echo $GLOBALS['strNoPassword'] . "\n"; ?>
</td>
</tr>
<tr class="even noclick">
<td>
<input type="radio" name="nopass" value="0" onclick="document.getElementById('pw_pma_pw').focus();" checked="checked " />
<?php echo $GLOBALS['strPassword']; ?>:&nbsp;
</td>
<td>
<input type="password" name="pma_pw" id="pw_pma_pw" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
&nbsp;&nbsp;
<?php echo $GLOBALS['strReType']; ?>:&nbsp;
<input type="password" name="pma_pw2" id="pw_pma_pw2" size="10" class="textfield" <?php echo $chg_evt_handler; ?>="nopass[1].checked = true" />
</td>
</tr>
<tr>
<td>
<?php echo $strPasswordHashing; ?>:
</td>
<td>
<?php echo $strPasswordHashing; ?>:
</td>
<td>
<input type="radio" name="pw_hash" id="radio_pw_hash_new" value="new" checked="checked" />
<label for="radio_pw_hash_new">
MySQL&nbsp;4.1+
</label>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="radio" name="pw_hash" id="radio_pw_hash_old" value="old" />
<label for="radio_pw_hash_old">
<?php echo $strCompatibleHashing; ?>
</label>
</td>
</tr>
<?php
}
?>
<input type="radio" name="pw_hash" id="radio_pw_hash_new" value="new" checked="checked" />
<label for="radio_pw_hash_new">
MySQL&nbsp;4.1+
</label>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="radio" name="pw_hash" id="radio_pw_hash_old" value="old" />
<label for="radio_pw_hash_old">
<?php echo $strCompatibleHashing; ?>
</label>
</td>
</tr>
</table>
</fieldset>
<fieldset id="fieldset_change_password_footer" class="tblFooters">

View File

@@ -19,12 +19,10 @@ if ($is_create_db_priv) {
<?php echo PMA_generate_common_hidden_inputs('', '', 5); ?>
<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"/>
<?php
if (PMA_MYSQL_INT_VERSION >= 40101) {
require_once './libraries/mysql_charsets.lib.php';
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, TRUE, 5);
}
?>
<?php
require_once './libraries/mysql_charsets.lib.php';
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, TRUE, 5);
?>
<input type="submit" value="<?php echo $strCreate; ?>" id="buttonGo" />
</form>
<?php

View File

@@ -3,6 +3,25 @@
/**
* 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$
*/
@@ -11,93 +30,8 @@
*/
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;
/*
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"
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());
?>
</legend>
<?php if ($is_create_table_priv) { ?>
<?php echo PMA_generate_common_hidden_inputs($db); ?>
<div class="formelement">
<?php echo $strName; ?>:
@@ -124,8 +57,5 @@ echo sprintf($strCreateNewTable, PMA_getDbLink());
</fieldset>
<fieldset class="tblFooters">
<input type="submit" value="<?php echo $strGo; ?>" />
<?php } else { ?>
<div class="error"><?php echo $strNoPrivileges; ?></div>
<?php } // end if else ?>
</fieldset>
</form>

View File

@@ -106,7 +106,7 @@ if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
echo '>' . htmlentities($temp_charset) . '</option>' . "\n";
}
echo ' </select><br />' . "\n" . ' ';
} elseif (PMA_MYSQL_INT_VERSION >= 40100) {
} else {
echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
} // 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']).
// Do not show comments, if using horizontalflipped mode, because of space usage
if ($GLOBALS['cfg']['ShowBrowseComments']
&& ($GLOBALS['cfgRelation']['commwork']
|| PMA_MYSQL_INT_VERSION >= 40100)
&& $_SESSION['userconf']['disp_direction'] != 'horizontalflipped') {
$comments_map = array();
if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
@@ -2120,16 +2118,14 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
* (but see 2006-01-19 note in display_create_table.lib.php,
* I think we cannot detect db-specific privileges reliably)
*/
if (PMA_MYSQL_INT_VERSION >= 50000) {
if (!$header_shown) {
echo $header;
$header_shown = TRUE;
}
echo PMA_linkOrButton(
'view_create.php' . $url_query,
PMA_getIcon('b_views.png', 'CREATE VIEW', false, true),
'', true, true, '') . "\n";
if (!$header_shown) {
echo $header;
$header_shown = TRUE;
}
echo PMA_linkOrButton(
'view_create.php' . $url_query,
PMA_getIcon('b_views.png', 'CREATE VIEW', false, true),
'', true, true, '') . "\n";
if ($header_shown) {
echo '</fieldset><br />';