Server IP : 127.0.0.2 / Your IP : 3.145.177.28 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/phpmyadmin/libraries/plugins/import/ |
Upload File : |
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * SQL import plugin for phpMyAdmin * * @package PhpMyAdmin-Import * @subpackage SQL */ if (! defined('PHPMYADMIN')) { exit; } /* Get the import interface */ require_once 'libraries/plugins/ImportPlugin.class.php'; /** * Handles the import for the SQL format * * @package PhpMyAdmin-Import * @subpackage SQL */ class ImportSql extends ImportPlugin { /** * Constructor */ public function __construct() { $this->setProperties(); } /** * Sets the import plugin properties. * Called in the constructor. * * @return void */ protected function setProperties() { $props = 'libraries/properties/'; include_once "$props/plugins/ImportPluginProperties.class.php"; include_once "$props/options/groups/OptionsPropertyRootGroup.class.php"; include_once "$props/options/groups/OptionsPropertyMainGroup.class.php"; include_once "$props/options/items/SelectPropertyItem.class.php"; include_once "$props/options/items/BoolPropertyItem.class.php"; $importPluginProperties = new ImportPluginProperties(); $importPluginProperties->setText('SQL'); $importPluginProperties->setExtension('sql'); $importPluginProperties->setOptionsText(__('Options')); $compats = $GLOBALS['dbi']->getCompatibilities(); if (count($compats) > 0) { $values = array(); foreach ($compats as $val) { $values[$val] = $val; } // create the root group that will be the options field for // $importPluginProperties // this will be shown as "Format specific options" $importSpecificOptions = new OptionsPropertyRootGroup(); $importSpecificOptions->setName("Format Specific Options"); // general options main group $generalOptions = new OptionsPropertyMainGroup(); $generalOptions->setName("general_opts"); // create primary items and add them to the group $leaf = new SelectPropertyItem(); $leaf->setName("compatibility"); $leaf->setText(__('SQL compatibility mode:')); $leaf->setValues($values); $leaf->setDoc( array( 'manual_MySQL_Database_Administration', 'Server_SQL_mode', ) ); $generalOptions->addProperty($leaf); $leaf = new BoolPropertyItem(); $leaf->setName("no_auto_value_on_zero"); $leaf->setText( __('Do not use <code>AUTO_INCREMENT</code> for zero values') ); $leaf->setDoc( array( 'manual_MySQL_Database_Administration', 'Server_SQL_mode', 'sqlmode_no_auto_value_on_zero' ) ); $generalOptions->addProperty($leaf); // add the main group to the root group $importSpecificOptions->addProperty($generalOptions); // set the options for the import plugin property item $importPluginProperties->setOptions($importSpecificOptions); } $this->properties = $importPluginProperties; } /** * Handles the whole import logic * * @param array &$sql_data 2-element array with sql data * * @return void */ public function doImport(&$sql_data = array()) { global $error, $timeout_passed; // Handle compatibility options. $this->_setSQLMode($GLOBALS['dbi'], $_REQUEST); $bq = new SqlParser\Utils\BufferedQuery(); if (isset($_POST['sql_delimiter'])) { $bq->setDelimiter($_POST['sql_delimiter']); } /** * Will be set in PMA_importGetNextChunk(). * @global bool $GLOBALS['finished'] */ $GLOBALS['finished'] = false; while ((!$error) && (!$timeout_passed)) { // Getting the first statement, the remaining data and the last // delimiter. $statement = $bq->extract(); // If there is no full statement, we are looking for more data. if (empty($statement)) { // Importing new data. $newData = PMA_importGetNextChunk(); // Subtract data we didn't handle yet and stop processing. if ($newData === false) { $GLOBALS['offset'] -= mb_strlen($bq->query); break; } // Checking if the input buffer has finished. if ($newData === true) { $GLOBALS['finished'] = true; break; } // Convert CR (but not CRLF) to LF otherwise all queries may // not get executed on some platforms. $bq->query .= preg_replace("/\r($|[^\n])/", "\n$1", $newData); continue; } // Executing the query. PMA_importRunQuery($statement, $statement, false, $sql_data); } // Extracting remaining statements. while ((!$error) && (!$timeout_passed) && (!empty($bq->query))) { $statement = $bq->extract(true); if (!empty($statement)) { PMA_importRunQuery($statement, $statement, false, $sql_data); } } // Finishing. PMA_importRunQuery('', '', false, $sql_data); } /** * Handle compatibility options * * @param PMA_DatabaseInterface $dbi Database interface * @param array $request Request array * * @return void */ private function _setSQLMode($dbi, $request) { $sql_modes = array(); if (isset($request['sql_compatibility']) && 'NONE' != $request['sql_compatibility'] ) { $sql_modes[] = $request['sql_compatibility']; } if (isset($request['sql_no_auto_value_on_zero'])) { $sql_modes[] = 'NO_AUTO_VALUE_ON_ZERO'; } if (count($sql_modes) > 0) { $dbi->tryQuery( 'SET SQL_MODE="' . implode(',', $sql_modes) . '"' ); } } }