本文整理汇总了PHP中PMA_Util::mysqlDie方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util::mysqlDie方法的具体用法?PHP PMA_Util::mysqlDie怎么用?PHP PMA_Util::mysqlDie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Util
的用法示例。
在下文中一共展示了PMA_Util::mysqlDie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_getSQLToCreateForeignKey
}
}
$tmp_error_create = false;
if ($create) {
$create_query = PMA_getSQLToCreateForeignKey($table, $master_field, $foreign_db, $foreign_table, $foreign_field, $_REQUEST['constraint_name'][$master_field_md5], $options_array[$_REQUEST['on_delete'][$master_field_md5]], $options_array[$_REQUEST['on_update'][$master_field_md5]]);
$display_query .= $create_query . "\n";
PMA_DBI_try_query($create_query);
$tmp_error_create = PMA_DBI_getError();
if (!empty($tmp_error_create)) {
$seen_error = true;
if (substr($tmp_error_create, 1, 4) == '1005') {
$message = PMA_Message::error(__('Error creating foreign key on %1$s (check data types)'));
$message->addParam($master_field);
$message->display();
} else {
$html_output .= PMA_Util::mysqlDie($tmp_error_create, $create_query, false, '', false);
}
$html_output .= PMA_Util::showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
}
// this is an alteration and the old constraint has been dropped
// without creation of a new one
if ($drop && $create && empty($tmp_error_drop) && !empty($tmp_error_create)) {
// a rollback may be better here
$sql_query_recreate = '# Restoring the dropped constraint...' . "\n";
$sql_query_recreate .= PMA_getSQLToCreateForeignKey($table, $master_field, PMA_Util::backquote($existrel_foreign[$master_field]['foreign_db']), PMA_Util::backquote($existrel_foreign[$master_field]['foreign_table']), PMA_Util::backquote($existrel_foreign[$master_field]['foreign_field']), $existrel_foreign[$master_field]['constraint'], $options_array[$existrel_foreign[$master_field]['on_delete']], $options_array[$existrel_foreign[$master_field]['on_update']]);
$display_query .= $sql_query_recreate . "\n";
PMA_DBI_try_query($sql_query_recreate);
}
}
}
// end foreach
示例2:
// Now we can check the parameters
PMA_Util::checkParameters(array('sql_query'));
}
/**
* Parse and analyze the query
*/
require_once 'libraries/parse_analyze.inc.php';
/**
* Check rights in case of DROP DATABASE
*
* This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
* but since a malicious user may pass this variable by url/form, we don't take
* into account this case.
*/
if (PMA_hasNoRightsToDropDatabase($analyzed_sql_results, $cfg['AllowUserDropDatabase'], $is_superuser)) {
PMA_Util::mysqlDie(__('"DROP DATABASE" statements are disabled.'), '', '', $err_url);
}
// end if
/**
* Need to find the real end of rows?
*/
if (isset($find_real_end) && $find_real_end) {
$unlim_num_rows = PMA_findRealEndOfRows($db, $table);
}
/**
* Bookmark add
*/
if (isset($_POST['store_bkm'])) {
PMA_addBookmark($cfg['PmaAbsoluteUri'], $goto);
// script has exited at this point
}
示例3: PMA_handleUpdateForForeignKey
/**
* Function to handle update for a foreign key
*
* @param array $multi_edit_columns_name multu edit columns name
* @param string $master_field_md5 master field md5
* @param string $destination_foreign_table destination foreign table
* @param string $destination_foreign_column destination foreign column
* @param array $options_array options array
* @param array $existrel_foreign db, table, column
* @param string $table current table
* @param bool &$seen_error whether seen error
* @param string &$display_query display query
* @param string $foreign_db foreign database
*
* @return string
*/
function PMA_handleUpdateForForeignKey($multi_edit_columns_name, $master_field_md5, $destination_foreign_table, $destination_foreign_column, $options_array, $existrel_foreign, $table, &$seen_error, &$display_query, $foreign_db)
{
$html_output = '';
$create = false;
$drop = false;
// Map the fieldname's md5 back to its real name
$master_field = $multi_edit_columns_name[$master_field_md5];
$foreign_table = $destination_foreign_table[$master_field_md5];
$foreign_field = $destination_foreign_column[$master_field_md5];
if (!empty($foreign_db) && !empty($foreign_table) && !empty($foreign_field)) {
if (isset($existrel_foreign[$master_field])) {
$constraint_name = $existrel_foreign[$master_field]['constraint'];
$on_delete = !empty($existrel_foreign[$master_field]['on_delete']) ? $existrel_foreign[$master_field]['on_delete'] : 'RESTRICT';
$on_update = !empty($existrel_foreign[$master_field]['on_update']) ? $existrel_foreign[$master_field]['on_update'] : 'RESTRICT';
}
if (!isset($existrel_foreign[$master_field])) {
// no key defined for this field
$create = true;
} elseif ($existrel_foreign[$master_field]['foreign_db'] != $foreign_db || $existrel_foreign[$master_field]['foreign_table'] != $foreign_table || $existrel_foreign[$master_field]['foreign_field'] != $foreign_field || $_REQUEST['constraint_name'][$master_field_md5] != $constraint_name || $_REQUEST['on_delete'][$master_field_md5] != $on_delete || $_REQUEST['on_update'][$master_field_md5] != $on_update) {
// another foreign key is already defined for this field
// or an option has been changed for ON DELETE or ON UPDATE
$drop = true;
$create = true;
}
// end if... else....
} elseif (isset($existrel_foreign[$master_field])) {
$drop = true;
}
// end if... else....
$tmp_error_drop = false;
if ($drop) {
$drop_query = PMA_getSQLToDropForeignKey($table, $existrel_foreign[$master_field]['constraint']);
$display_query .= $drop_query . "\n";
$GLOBALS['dbi']->tryQuery($drop_query);
$tmp_error_drop = $GLOBALS['dbi']->getError();
if (!empty($tmp_error_drop)) {
$seen_error = true;
$html_output .= PMA_Util::mysqlDie($tmp_error_drop, $drop_query, false, '', false);
return $html_output;
}
}
$tmp_error_create = false;
if ($create) {
$create_query = PMA_getSQLToCreateForeignKey($table, $master_field, $foreign_db, $foreign_table, $foreign_field, $_REQUEST['constraint_name'][$master_field_md5], $options_array[$_REQUEST['on_delete'][$master_field_md5]], $options_array[$_REQUEST['on_update'][$master_field_md5]]);
$display_query .= $create_query . "\n";
$GLOBALS['dbi']->tryQuery($create_query);
$tmp_error_create = $GLOBALS['dbi']->getError();
if (!empty($tmp_error_create)) {
$seen_error = true;
if (substr($tmp_error_create, 1, 4) == '1005') {
$message = PMA_Message::error(__('Error creating foreign key on %1$s (check data types)'));
$message->addParam($master_field);
$html_output .= $message->getDisplay();
} else {
$html_output .= PMA_Util::mysqlDie($tmp_error_create, $create_query, false, '', false);
}
$html_output .= PMA_Util::showMySQLDocu('InnoDB_foreign_key_constraints') . "\n";
}
// this is an alteration and the old constraint has been dropped
// without creation of a new one
if ($drop && $create && empty($tmp_error_drop) && !empty($tmp_error_create)) {
// a rollback may be better here
$sql_query_recreate = '# Restoring the dropped constraint...' . "\n";
$sql_query_recreate .= PMA_getSQLToCreateForeignKey($table, $master_field, $existrel_foreign[$master_field]['foreign_db'], $existrel_foreign[$master_field]['foreign_table'], $existrel_foreign[$master_field]['foreign_field'], $existrel_foreign[$master_field]['constraint'], $options_array[$existrel_foreign[$master_field]['on_delete']], $options_array[$existrel_foreign[$master_field]['on_update']]);
$display_query .= $sql_query_recreate . "\n";
$GLOBALS['dbi']->tryQuery($sql_query_recreate);
}
}
return $html_output;
}
示例4: PMA_getMessageForUpdatePassword
/**
* Update password and get message for password updating
*
* @param string $err_url error url
* @param string $username username
* @param string $hostname hostname
*
* @return string $message success or error message after updating password
*/
function PMA_getMessageForUpdatePassword($err_url, $username, $hostname)
{
// similar logic in user_password.php
$message = '';
if (empty($_REQUEST['nopass']) && isset($_POST['pma_pw']) && isset($_POST['pma_pw2'])) {
if ($_POST['pma_pw'] != $_POST['pma_pw2']) {
$message = PMA_Message::error(__('The passwords aren\'t the same!'));
} elseif (empty($_POST['pma_pw']) || empty($_POST['pma_pw2'])) {
$message = PMA_Message::error(__('The password is empty!'));
}
}
// here $nopass could be == 1
if (empty($message)) {
$hashing_function = (!empty($_REQUEST['pw_hash']) && $_REQUEST['pw_hash'] == 'old' ? 'OLD_' : '') . 'PASSWORD';
// in $sql_query which will be displayed, hide the password
$sql_query = 'SET PASSWORD FOR \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\' = ' . ($_POST['pma_pw'] == '' ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $_POST['pma_pw']) . '\')');
$local_query = 'SET PASSWORD FOR \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\' = ' . ($_POST['pma_pw'] == '' ? '\'\'' : $hashing_function . '(\'' . PMA_Util::sqlAddSlashes($_POST['pma_pw']) . '\')');
PMA_DBI_try_query($local_query) or PMA_Util::mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
$message = PMA_Message::success(__('The password for %s was changed successfully.'));
$message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
}
return $message;
}
示例5: PMA_handleQueryExecuteError
/**
* Responds an error when an error happens when executing the query
*
* @param boolean $is_gotofile whether goto file or not
* @param String $error error after executing the query
* @param String $full_sql_query full sql query
*
* @return void
*/
function PMA_handleQueryExecuteError($is_gotofile, $error, $full_sql_query)
{
if ($is_gotofile) {
$message = PMA_Message::rawError($error);
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $message);
} else {
PMA_Util::mysqlDie($error, $full_sql_query, '', '');
}
exit;
}
示例6:
}
}
}
// Go back to the structure sub-page
$message = PMA_Message::success(__('Table %1$s has been altered successfully'));
$message->addParam($table);
if ($GLOBALS['is_ajax_request'] == true) {
$response->addJSON('message', $message);
$response->addJSON('sql_query', PMA_Util::getMessage(null, $sql_query));
exit;
}
$active_page = 'tbl_structure.php';
$abort = true;
include 'tbl_structure.php';
} else {
$error_message_html = PMA_Util::mysqlDie('', '', '', $err_url, false);
$response->addHTML($error_message_html);
if ($GLOBALS['is_ajax_request'] == true) {
exit;
}
// An error happened while inserting/updating a table definition.
// to prevent total loss of that data, we embed the form once again.
// The variable $regenerate will be used to restore data in libraries/tbl_columns_definition_form.inc.php
$num_fields = $_REQUEST['orig_num_fields'];
if (isset($_REQUEST['orig_after_field'])) {
$_REQUEST['after_field'] = $_REQUEST['orig_after_field'];
}
if (isset($_REQUEST['orig_field_where'])) {
$_REQUEST['field_where'] = $_REQUEST['orig_field_where'];
}
$regenerate = true;
示例7: PMA_updateColumns
/**
* Update the table's structure based on $_REQUEST
*
* @param string $db database name
* @param string $table table name
*
* @return boolean $regenerate true if error occurred
*
*/
function PMA_updateColumns($db, $table)
{
$err_url = 'tbl_structure.php?' . PMA_URL_getCommon($db, $table);
$regenerate = false;
$field_cnt = count($_REQUEST['field_name']);
$key_fields = array();
$changes = array();
for ($i = 0; $i < $field_cnt; $i++) {
if (PMA_columnNeedsAlterTable($i)) {
$changes[] = 'CHANGE ' . PMA_Table::generateAlter(isset($_REQUEST['field_orig'][$i]) ? $_REQUEST['field_orig'][$i] : '', $_REQUEST['field_name'][$i], $_REQUEST['field_type'][$i], $_REQUEST['field_length'][$i], $_REQUEST['field_attribute'][$i], isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '', isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : 'NOT NULL', $_REQUEST['field_default_type'][$i], $_REQUEST['field_default_value'][$i], isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false, isset($_REQUEST['field_comments'][$i]) ? $_REQUEST['field_comments'][$i] : '', $key_fields, $i, isset($_REQUEST['field_move_to'][$i]) ? $_REQUEST['field_move_to'][$i] : '');
}
}
// end for
$response = PMA_Response::getInstance();
if (count($changes) > 0) {
// Builds the primary keys statements and updates the table
$key_query = '';
/**
* this is a little bit more complex
*
* @todo if someone selects A_I when altering a column we need to check:
* - no other column with A_I
* - the column has an index, if not create one
*
*/
// To allow replication, we first select the db to use
// and then run queries on this db.
if (!$GLOBALS['dbi']->selectDb($db)) {
PMA_Util::mysqlDie($GLOBALS['dbi']->getError(), 'USE ' . PMA_Util::backquote($db) . ';', '', $err_url);
}
$sql_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' ';
$sql_query .= implode(', ', $changes) . $key_query;
$sql_query .= ';';
$result = $GLOBALS['dbi']->tryQuery($sql_query);
if ($result !== false) {
$message = PMA_Message::success(__('Table %1$s has been altered successfully.'));
$message->addParam($table);
$response->addHTML(PMA_Util::getMessage($message, $sql_query, 'success'));
} else {
// An error happened while inserting/updating a table definition
$response->isSuccess(false);
$response->addJSON('message', PMA_Message::rawError(__('Query error') . ':<br />' . $GLOBALS['dbi']->getError()));
$regenerate = true;
}
}
include_once 'libraries/transformations.lib.php';
// update field names in relation
if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) {
foreach ($_REQUEST['field_orig'] as $fieldindex => $fieldcontent) {
if ($_REQUEST['field_name'][$fieldindex] != $fieldcontent) {
PMA_REL_renameField($db, $table, $fieldcontent, $_REQUEST['field_name'][$fieldindex]);
}
}
}
// update mime types
if (isset($_REQUEST['field_mimetype']) && is_array($_REQUEST['field_mimetype']) && $GLOBALS['cfg']['BrowseMIME']) {
foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
if (isset($_REQUEST['field_name'][$fieldindex]) && strlen($_REQUEST['field_name'][$fieldindex])) {
PMA_setMIME($db, $table, $_REQUEST['field_name'][$fieldindex], $mimetype, $_REQUEST['field_transformation'][$fieldindex], $_REQUEST['field_transformation_options'][$fieldindex]);
}
}
}
return $regenerate;
}
示例8: PMA_securePath
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $message);
exit;
}
/**
* Go to target path.
*/
include '' . PMA_securePath($goto);
} else {
$full_err_url = $err_url;
if (preg_match('@^(db|tbl)_@', $err_url)) {
$full_err_url .= '&show_query=1&sql_query=' . urlencode($sql_query);
}
PMA_Util::mysqlDie($error, $full_sql_query, '', $full_err_url);
}
exit;
}
unset($error);
// If there are no errors and bookmarklabel was given,
// store the query as a bookmark
if (!empty($bkm_label) && !empty($import_text)) {
include_once 'libraries/bookmark.lib.php';
$bfields = array('dbase' => $db, 'user' => $cfg['Bookmark']['user'], 'query' => urlencode($import_text), 'label' => $bkm_label);
// Should we replace bookmark?
if (isset($bkm_replace)) {
$bookmarks = PMA_Bookmark_getList($db);
foreach ($bookmarks as $key => $val) {
if ($val == $bkm_label) {
PMA_Bookmark_delete($db, $key);
示例9: htmlspecialchars
PMA_Util::checkParameters(array('db'));
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
/* Check if database name is empty */
if (mb_strlen($db) == 0) {
PMA_Util::mysqlDie(__('The database name is empty!'), '', false, 'index.php');
}
/**
* Selects the database to work with
*/
if (!$GLOBALS['dbi']->selectDb($db)) {
PMA_Util::mysqlDie(sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)), '', false, 'index.php');
}
if ($GLOBALS['dbi']->getColumns($db, $table)) {
// table exists already
PMA_Util::mysqlDie(sprintf(__('Table %s already exists!'), htmlspecialchars($table)), '', false, 'db_structure.php' . PMA_URL_getCommon(array('db' => $db)));
}
// for libraries/tbl_columns_definition_form.inc.php
// check number of fields to be created
$num_fields = PMA_getNumberOfFieldsFromRequest();
$action = 'tbl_create.php';
/**
* The form used to define the structure of the table has been submitted
*/
if (isset($_REQUEST['do_save_data'])) {
$sql_query = PMA_getTableCreationQuery($db, $table);
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_previewSQL($sql_query);
}
// Executes the query
示例10: PMA_changePassUrlParamsAndSubmitQuery
/**
* Generate the error url and submit the query
*
* @param string $username Username
* @param string $hostname Hostname
* @param string $password Password
* @param string $sql_query SQL query
* @param string $hashing_function Hashing function
* @param string $auth_plugin Authentication Plugin
*
* @return void
*/
function PMA_changePassUrlParamsAndSubmitQuery($username, $hostname, $password, $sql_query, $hashing_function, $auth_plugin)
{
$err_url = 'user_password.php' . PMA_URL_getCommon();
if (PMA_Util::getServerType() === 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706) {
$local_query = 'ALTER USER \'' . $username . '\'@\'' . $hostname . '\'' . ' IDENTIFIED with ' . $auth_plugin . ' BY ' . ($password == '' ? '\'\'' : '\'' . PMA_Util::sqlAddSlashes($password) . '\'');
} else {
$local_query = 'SET password = ' . ($password == '' ? '\'\'' : $hashing_function . '(\'' . PMA_Util::sqlAddSlashes($password) . '\')');
}
if (!@$GLOBALS['dbi']->tryQuery($local_query)) {
PMA_Util::mysqlDie($GLOBALS['dbi']->getError(), $sql_query, false, $err_url);
}
}
示例11: PMA_changePassUrlParamsAndSubmitQuery
/**
* Generate the error url and submit the query
*
* @param string $username Username
* @param string $hostname Hostname
* @param string $password Password
* @param string $sql_query SQL query
* @param string $hashing_function Hashing function
* @param string $orig_auth_plugin Original Authentication Plugin
*
* @return void
*/
function PMA_changePassUrlParamsAndSubmitQuery($username, $hostname, $password, $sql_query, $hashing_function, $orig_auth_plugin)
{
$err_url = 'user_password.php' . PMA_URL_getCommon();
$serverType = PMA_Util::getServerType();
if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706) {
$local_query = 'ALTER USER \'' . $username . '\'@\'' . $hostname . '\'' . ' IDENTIFIED with ' . $orig_auth_plugin . ' BY ' . ($password == '' ? '\'\'' : '\'' . PMA_Util::sqlAddSlashes($password) . '\'');
} else {
if ($serverType == 'MariaDB' && PMA_MYSQL_INT_VERSION >= 50200) {
if ($orig_auth_plugin == 'mysql_native_password') {
// Set the hashing method used by PASSWORD()
// to be 'mysql_native_password' type
$GLOBALS['dbi']->tryQuery('SET old_passwords = 0;');
} else {
if ($orig_auth_plugin == 'sha256_password') {
// Set the hashing method used by PASSWORD()
// to be 'sha256_password' type
$GLOBALS['dbi']->tryQuery('SET `old_passwords` = 2;');
}
}
$hashedPassword = PMA_getHashedPassword($_POST['pma_pw']);
$local_query = "UPDATE `mysql`.`user` SET" . " `authentication_string` = '" . $hashedPassword . "', `Password` = '', " . " `plugin` = '" . $orig_auth_plugin . "'" . " WHERE `User` = '" . $username . "' AND Host = '" . $hostname . "';";
$GLOBALS['dbi']->tryQuery("FLUSH PRIVILEGES;");
} else {
$local_query = 'SET password = ' . ($password == '' ? '\'\'' : $hashing_function . '(\'' . PMA_Util::sqlAddSlashes($password) . '\')');
}
}
if (!@$GLOBALS['dbi']->tryQuery($local_query)) {
PMA_Util::mysqlDie($GLOBALS['dbi']->getError(), $sql_query, false, $err_url);
}
}
示例12: PMA_ChangePassUrlParamsAndSubmitQuery
/**
* Generate the error url and submit the query
*
* @param string $password
* @param array $_url_params
* @param string $sql_query
* @param string $hashing_function
*
* @return void
*/
function PMA_ChangePassUrlParamsAndSubmitQuery(
$password, $_url_params, $sql_query, $hashing_function
) {
$err_url = 'user_password.php' . PMA_generate_common_url($_url_params);
$local_query = 'SET password = ' . (($password == '')
? '\'\''
: $hashing_function . '(\'' . PMA_Util::sqlAddSlashes($password) . '\')');
$result = @PMA_DBI_try_query($local_query)
or PMA_Util::mysqlDie(
PMA_DBI_getError(), $sql_query, false, $err_url
);
}
示例13: PMA_updatePassword
/**
* Update password and get message for password updating
*
* @param string $err_url error url
* @param string $username username
* @param string $hostname hostname
*
* @return string $message success or error message after updating password
*/
function PMA_updatePassword($err_url, $username, $hostname)
{
// similar logic in user_password.php
$message = '';
if (empty($_REQUEST['nopass']) && isset($_POST['pma_pw']) && isset($_POST['pma_pw2'])) {
if ($_POST['pma_pw'] != $_POST['pma_pw2']) {
$message = PMA_Message::error(__('The passwords aren\'t the same!'));
} elseif (empty($_POST['pma_pw']) || empty($_POST['pma_pw2'])) {
$message = PMA_Message::error(__('The password is empty!'));
}
}
// here $nopass could be == 1
if (empty($message)) {
if (PMA_Util::getServerType() == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706) {
if (!empty($_REQUEST['pw_hash']) && $_REQUEST['pw_hash'] != 'old') {
$query_prefix = "ALTER USER '" . PMA_Util::sqlAddSlashes($username) . "'@'" . PMA_Util::sqlAddSlashes($hostname) . "'" . " IDENTIFIED WITH " . $_REQUEST['pw_hash'] . " BY '";
} else {
$query_prefix = "ALTER USER '" . PMA_Util::sqlAddSlashes($username) . "'@'" . PMA_Util::sqlAddSlashes($hostname) . "'" . " IDENTIFIED BY '";
}
// in $sql_query which will be displayed, hide the password
$sql_query = $query_prefix . "*'";
$local_query = $query_prefix . PMA_Util::sqlAddSlashes($_POST['pma_pw']) . "'";
} else {
if (!empty($_REQUEST['pw_hash']) && $_REQUEST['pw_hash'] == 'old') {
$hashing_function = 'OLD_PASSWORD';
} elseif (!empty($_REQUEST['pw_hash']) && $_REQUEST['pw_hash'] == 'sha256_password') {
$hashing_function = 'PASSWORD';
// Backup the old value, to be reset later
$row = $GLOBALS['dbi']->fetchSingleRow('SHOW VARIABLES like \'old_passwords\';');
$orig_value = $row['Value'];
// Set the hashing method used by PASSWORD()
// to be 'sha256_password' type
$GLOBALS['dbi']->tryQuery('SET old_passwords = 2;');
} else {
$hashing_function = 'PASSWORD';
}
$sql_query = 'SET PASSWORD FOR \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\' = ' . ($_POST['pma_pw'] == '' ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $_POST['pma_pw']) . '\')');
$local_query = 'SET PASSWORD FOR \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\' = ' . ($_POST['pma_pw'] == '' ? '\'\'' : $hashing_function . '(\'' . PMA_Util::sqlAddSlashes($_POST['pma_pw']) . '\')');
}
$GLOBALS['dbi']->tryQuery($local_query) or PMA_Util::mysqlDie($GLOBALS['dbi']->getError(), $sql_query, false, $err_url);
$message = PMA_Message::success(__('The password for %s was changed successfully.'));
$message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
if (isset($orig_value)) {
$GLOBALS['dbi']->tryQuery('SET `old_passwords` = ' . $orig_value . ';');
}
}
return $message;
}
示例14: getDatabasesFull
/**
* returns array with databases containing extended infos about them
*
* @param string $database database
* @param boolean $force_stats retrieve stats also for MySQL < 5
* @param object $link mysql link
* @param string $sort_by column to order by
* @param string $sort_order ASC or DESC
* @param integer $limit_offset starting offset for LIMIT
* @param bool|int $limit_count row count for LIMIT or true
* for $GLOBALS['cfg']['MaxDbList']
*
* @todo move into PMA_List_Database?
*
* @return array $databases
*/
public function getDatabasesFull($database = null, $force_stats = false, $link = null, $sort_by = 'SCHEMA_NAME', $sort_order = 'ASC', $limit_offset = 0, $limit_count = false)
{
$sort_order = strtoupper($sort_order);
if (true === $limit_count) {
$limit_count = $GLOBALS['cfg']['MaxDbList'];
}
$apply_limit_and_order_manual = true;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
/**
* if $GLOBALS['cfg']['NaturalOrder'] is enabled, we cannot use LIMIT
* cause MySQL does not support natural ordering,
* we have to do it afterward
*/
$limit = '';
if (!$GLOBALS['cfg']['NaturalOrder']) {
if ($limit_count) {
$limit = ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset;
}
$apply_limit_and_order_manual = false;
}
// get table information from information_schema
if (!empty($database)) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \'' . PMA_Util::sqlAddSlashes($database) . '\'';
} else {
$sql_where_schema = '';
}
$sql = 'SELECT *,
CAST(BIN_NAME AS CHAR CHARACTER SET utf8) AS SCHEMA_NAME
FROM (';
$sql .= 'SELECT
BINARY s.SCHEMA_NAME AS BIN_NAME,
s.DEFAULT_COLLATION_NAME';
if ($force_stats) {
$sql .= ',
COUNT(t.TABLE_SCHEMA) AS SCHEMA_TABLES,
SUM(t.TABLE_ROWS) AS SCHEMA_TABLE_ROWS,
SUM(t.DATA_LENGTH) AS SCHEMA_DATA_LENGTH,
SUM(t.MAX_DATA_LENGTH) AS SCHEMA_MAX_DATA_LENGTH,
SUM(t.INDEX_LENGTH) AS SCHEMA_INDEX_LENGTH,
SUM(t.DATA_LENGTH + t.INDEX_LENGTH)
AS SCHEMA_LENGTH,
SUM(t.DATA_FREE) AS SCHEMA_DATA_FREE';
}
$sql .= '
FROM `information_schema`.SCHEMATA s';
if ($force_stats) {
$sql .= '
LEFT JOIN `information_schema`.TABLES t
ON BINARY t.TABLE_SCHEMA = BINARY s.SCHEMA_NAME';
}
$sql .= $sql_where_schema . '
GROUP BY BINARY s.SCHEMA_NAME, s.DEFAULT_COLLATION_NAME
ORDER BY ';
if ($sort_by == 'SCHEMA_NAME' || $sort_by == 'DEFAULT_COLLATION_NAME') {
$sql .= 'BINARY ';
}
$sql .= PMA_Util::backquote($sort_by) . ' ' . $sort_order . $limit;
$sql .= ') a';
$databases = $this->fetchResult($sql, 'SCHEMA_NAME', null, $link);
$mysql_error = $this->getError($link);
if (!count($databases) && $GLOBALS['errno']) {
PMA_Util::mysqlDie($mysql_error, $sql);
}
// display only databases also in official database list
// f.e. to apply hide_db and only_db
$drops = array_diff(array_keys($databases), (array) $GLOBALS['pma']->databases);
foreach ($drops as $drop) {
unset($databases[$drop]);
}
} else {
$databases = array();
foreach ($GLOBALS['pma']->databases as $database_name) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
// todo : remove and check the rest of the code for usage,
// MySQL 5.0 or higher is required for current PMA version
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
include_once './libraries/mysql_charsets.inc.php';
$databases[$database_name]['DEFAULT_COLLATION_NAME'] = PMA_getDbCollation($database_name);
if (!$force_stats) {
continue;
}
// get additional info about tables
$databases[$database_name]['SCHEMA_TABLES'] = 0;
//.........这里部分代码省略.........
示例15: PMA_tryColumnCreationQuery
/**
* Function to execute the column creation statement
*
* @param string $db current database
* @param string $table current table
* @param string $err_url error page url
*
* @return array
*/
function PMA_tryColumnCreationQuery($db, $table, $err_url)
{
// get column addition statements
$sql_statement = PMA_getColumnCreationStatements(false);
// To allow replication, we first select the db to use and then run queries
// on this db.
$GLOBALS['dbi']->selectDb($db) or PMA_Util::mysqlDie($GLOBALS['dbi']->getError(), 'USE ' . PMA_Util::backquote($db), false, $err_url);
$sql_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' ' . $sql_statement . ';';
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_previewSQL($sql_query);
}
return array($GLOBALS['dbi']->tryQuery($sql_query), $sql_query);
}