.html('<img src="<?php echo $GLOBALS['pmaThemeImage']; ?> ajax_clock_small.gif" width="16" height="16" alt="ajax clock" /> <?php echo PMA_jsFormat(__('The file is being processed, please be patient.'), false); ?> ') .show(); $('#import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?> '); // loads the message, either success or mysql error <?php // reload the left sidebar when the import is finished $GLOBALS['reload'] = true; echo PMA_Util::getReloadNavigationScript(true); ?> } // if finished else { setTimeout(perform_upload, 1000); } }); } setTimeout(perform_upload, 1000); <?php } else { // no plugin available ?> $('#upload_form_status_info').html('<img src="<?php
/** * Prepares queries for adding users and * also create database and return query and message * * @param boolean $_error whether user create or not * @param string $real_sql_query SQL query for add a user * @param string $sql_query SQL query to be displayed * @param string $username username * @param string $hostname host name * * @return array $sql_query, $message */ function PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query, $username, $hostname) { if ($_error || !PMA_DBI_try_query($real_sql_query)) { $_REQUEST['createdb-1'] = $_REQUEST['createdb-2'] = $_REQUEST['createdb-3'] = false; $message = PMA_Message::rawError(PMA_DBI_getError()); } else { $message = PMA_Message::success(__('You have added a new user.')); } if (isset($_REQUEST['createdb-1'])) { // Create database with same name and grant all privileges $q = 'CREATE DATABASE IF NOT EXISTS ' . PMA_Util::backquote(PMA_Util::sqlAddSlashes($username)) . ';'; $sql_query .= $q; if (!PMA_DBI_try_query($q)) { $message = PMA_Message::rawError(PMA_DBI_getError()); } /** * If we are not in an Ajax request, we can't reload navigation now */ if ($GLOBALS['is_ajax_request'] != true) { // this is needed in case tracking is on: $GLOBALS['db'] = $username; $GLOBALS['reload'] = true; echo PMA_Util::getReloadNavigationScript(); } $q = 'GRANT ALL PRIVILEGES ON ' . PMA_Util::backquote(PMA_Util::escapeMysqlWildcards(PMA_Util::sqlAddSlashes($username))) . '.* TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\';'; $sql_query .= $q; if (!PMA_DBI_try_query($q)) { $message = PMA_Message::rawError(PMA_DBI_getError()); } } if (isset($_REQUEST['createdb-2'])) { // Grant all privileges on wildcard name (username\_%) $q = 'GRANT ALL PRIVILEGES ON ' . PMA_Util::backquote(PMA_Util::sqlAddSlashes($username) . '\\_%') . '.* TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\';'; $sql_query .= $q; if (!PMA_DBI_try_query($q)) { $message = PMA_Message::rawError(PMA_DBI_getError()); } } if (isset($_REQUEST['createdb-3'])) { // Grant all privileges on the specified database to the new user $q = 'GRANT ALL PRIVILEGES ON ' . PMA_Util::backquote(PMA_Util::sqlAddSlashes($dbname)) . '.* TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\';'; $sql_query .= $q; if (!PMA_DBI_try_query($q)) { $message = PMA_Message::rawError(PMA_DBI_getError()); } } return array($sql_query, $message); }
/** * Loads common scripts * * @return void */ private function _addDefaultScripts() { $this->_scripts->addFile('jquery/jquery-1.6.2.js'); $this->_scripts->addFile('jquery/jquery-ui-1.8.16.custom.js'); $this->_scripts->addFile('jquery/jquery.sprintf.js'); $this->_scripts->addFile('update-location.js'); $this->_scripts->addFile('jquery/jquery.qtip-1.0.0-rc3.js'); if ($GLOBALS['cfg']['CodemirrorEnable']) { $this->_scripts->addFile('codemirror/lib/codemirror.js'); $this->_scripts->addFile('codemirror/mode/mysql/mysql.js'); } // Cross-framing protection if ($GLOBALS['cfg']['AllowThirdPartyFraming'] === false) { $this->_scripts->addFile('cross_framing_protection.js'); } // Localised strings $params = array('lang' => $GLOBALS['lang']); if (isset($GLOBALS['db'])) { $params['db'] = $GLOBALS['db']; } $this->_scripts->addFile('messages.php' . PMA_generate_common_url($params)); // Append the theme id to this url to invalidate // the cache on a theme change $this->_scripts->addFile('get_image.js.php?theme=' . urlencode($_SESSION['PMA_Theme']->getId())); $this->_scripts->addFile('functions.js'); $this->_scripts->addCode(PMA_Util::getReloadNavigationScript(true)); }
/** * other output tests */ public function testWriteReloadNavigation() { $GLOBALS['reload'] = true; $GLOBALS['db'] = 'test_db'; $url = './navigation.php?'.PMA_generate_common_url($GLOBALS['db'], '', '&'); $write = '<script type="text/javascript">' . PHP_EOL . '//<![CDATA[' . PHP_EOL . 'if (typeof(window.parent) != "undefined"' . PHP_EOL . ' && typeof(window.parent.frame_navigation) != "undefined"' . PHP_EOL . ' && window.parent.goTo) {' . PHP_EOL . ' window.parent.goTo("' . $url . '");' . PHP_EOL . '}' . PHP_EOL . '//]]>' . PHP_EOL . '</script>' . PHP_EOL; $this->expectOutputString($write); echo PMA_Util::getReloadNavigationScript(); $this->assertFalse(isset($GLOBALS['reload'])); unset($GLOBALS['db']); }
__('Deleting %s'), '\'' . $this_user . '\'@\'' . $this_host . '\'' ) . ' ...'; $queries[] = 'DROP USER \'' . PMA_Util::sqlAddSlashes($this_user) . '\'@\'' . PMA_Util::sqlAddSlashes($this_host) . '\';'; if (isset($_REQUEST['drop_users_db'])) { $queries[] = 'DROP DATABASE IF EXISTS ' . PMA_Util::backquote($this_user) . ';'; $GLOBALS['reload'] = true; if ($GLOBALS['is_ajax_request'] != true) { $response->addHTML( PMA_Util::getReloadNavigationScript() ); } } } if (empty($_REQUEST['change_copy'])) { list($sql_query, $message) = PMA_deleteUser($queries); } } /** * Changes / copies a user, part V */ if (isset($_REQUEST['change_copy'])) { $tmp_count = 0; foreach ($queries as $sql_query) {