diff --git a/ChangeLog b/ChangeLog index 7c075c299..bc2ec78ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -91,6 +91,10 @@ $Id$ + [core] Dropped AllowAnywhereRecoding configuration variable. - rfe #3016457 [interface] Define tab order in SQL form to allow easier tab navigation. ++ [code] Centralized format string expansion, @VARIABLES@ are recommended way + now. ++ [validator] SQL validator works also with SOAP PHP extension. +- [interface] Better formatting for SQL validator results. 3.3.6.0 (not yet released) - bug #3031705 [core] Do not use CONCAT for DECIMAL fields. diff --git a/Documentation.html b/Documentation.html index 4c23ec6d4..3e5edeea3 100644 --- a/Documentation.html +++ b/Documentation.html @@ -69,7 +69,7 @@ vim: expandtab ts=4 sw=4 sts=4 tw=78
  • To support uploading of ZIP files, you need the PHP zip extension.
  • For proper support of multibyte strings (eg. UTF-8, which is - currently default), you should install mbstring and ctype + currently the default), you should install the mbstring and ctype extensions.
  • You need GD2 support in PHP to display inline @@ -84,6 +84,9 @@ vim: expandtab ts=4 sw=4 sts=4 tw=78
  • To support upload progress bars, see FAQ 2.9.
  • +
  • To support BLOB streaming, see PHP and MySQL requirements + in + FAQ 6.25.
  • MySQL 5.0 or newer (details);
  • @@ -340,7 +343,8 @@ rm -rf config # remove not needed directory FAQ 1.23).

    If you already had this infrastructure and upgraded to MySQL 4.1.2 - or newer, please use ./scripts/upgrade_tables_mysql_4_1_2+.sql.

    + or newer, please use ./scripts/upgrade_tables_mysql_4_1_2+.sql + and then create new tables by importing ./scripts/create_tables.sql.

    You can use your phpMyAdmin to create the tables for you. Please be aware that you may need special (administrator) privileges to create the database @@ -2149,24 +2153,8 @@ setfacl -d -m "g:www-data:rwx" tmp

    $cfg['TitleDatabase'] string
    $cfg['TitleServer'] string
    $cfg['TitleDefault'] string
    -
    Allows you to specify window's title bar. Following magic string can - be used to get special values: -
    -
    @HTTP_HOST@
    -
    HTTP host that runs phpMyAdmin
    -
    @SERVER@
    -
    MySQL server name
    -
    @VERBOSE@
    -
    Verbose MySQL server name as defined in server configuration
    -
    @VSERVER@
    -
    Verbose MySQL server name if set, otherwise normal
    -
    @DATABASE@
    -
    Currently opened database
    -
    @TABLE@
    -
    Currently opened table
    -
    @PHPMYADMIN@
    -
    phpMyAdmin with version
    -
    +
    Allows you to specify window's title bar. You can use + format string expansion.
    $cfg['ErrorIconic'] boolean
    @@ -4123,25 +4111,34 @@ INSERT INTO REL_towns VALUES ('M', 'Montréal'); 6.14 How do I set up the SQL Validator? -

    To use it, you need a very recent version of PHP, 4.3.0 recommended, with +

    + To use SQL Validator, you need PHP with XML, PCRE and PEAR support. - On your system command line, run "pear install Net_Socket Net_URL - HTTP_Request Mail_Mime Net_DIME SOAP" to get the necessary - PEAR modules - for usage.
    - On a more recent pear version, I had problems with the state of Net_DIME - being beta, so this single command - "pear -d preferred_state=beta install -a SOAP" installed all the - needed modules.
    + In addition you need a SOAP support, either as a PHP extension or as a PEAR SOAP + module. +

    + +

    + To install PEAR SOAP module, run "pear install Net_Socket Net_URL + HTTP_Request Mail_Mime Net_DIME SOAP" to get the necessary PEAR modules for + usage. +

    + +

    If you use the Validator, you should be aware that any SQL statement you submit will be stored anonymously (database/table/column names, strings, numbers replaced with generic values). The Mimer SQL Validator itself, is © 2001 Upright Database Technology. - We utilize it as free SOAP service.

    + We utilize it as free SOAP service. +

    6.15 I want to add a BLOB column and put an index on @@ -4312,13 +4309,20 @@ chmod o+rwx tmp

    6.25 How does BLOB streaming work in phpMyAdmin?

    -

    First, for general information about BLOB streaming on MySQL, visit blobstreaming.org. We currently support streaming if you are running MySQL 5.1 with the PBXT and PBMS storage engines. Moreover, only PBMS 0.5.04 is supported.

    +

    For general information about BLOB streaming on MySQL, visit blobstreaming.org. You need the following components:

    + + +

    Here are details about configuration and operation:

      -
    1. In config.inc.php your host should be defined with a FQDN (fully qualified domain name) instead of something like "localhost".
    2. -
    3. A current limitation is that your first login via phpMyAdmin to a freshly-started server must be done with an account that has the SUPER privilege.
    4. -
    5. On your target database, go to Operations and in the "BLOB Repository" section, click "Enable". This creates the PBMS system tables inside your database.
    6. -
    7. Ensure that your target table is under the PBXT storage engine and has a LONGBLOB column.
    8. +
    9. In config.inc.php your host should be defined with a FQDN (fully qualified domain name) instead of "localhost".
    10. +
    11. Ensure that your target table is under the PBXT storage engine and has a LONGBLOB column and a primary key.
    12. When you insert or update a row in this table, put a checkmark on the "Upload to BLOB repository" optional choice; otherwise, the upload will be done directly in your column instead of the repository.
    13. Finally when you browse your table, you'll see in your column a link to stream your data, for example "View image". A header containing the correct MIME-type will be sent to your browser; this MIME-type was stored at upload time but in case it's incorrect, it's possible to edit it by clicking on the displayed MIME-type.
    @@ -4329,6 +4333,33 @@ chmod o+rwx tmp

    Click the first row of the range, hold the shift key and click the last row of the range. This works everywhere you see rows, for example in Browse mode or on the Structure page.

    +

    + 6.27 What format strings can I use?

    + +

    + In all places where phpMyAdmin accepts format strings, you can use + @VARIABLE@ expansion and + strftime format strings. The + expanded variables depend on a context (eg. if you don't have chosen + table, you can not get table name), but following variables can be used: +

    +
    +
    @HTTP_HOST@
    +
    HTTP host that runs phpMyAdmin
    +
    @SERVER@
    +
    MySQL server name
    +
    @VERBOSE@
    +
    Verbose MySQL server name as defined in server configuration
    +
    @VSERVER@
    +
    Verbose MySQL server name if set, otherwise normal
    +
    @DATABASE@
    +
    Currently opened database
    +
    @TABLE@
    +
    Currently opened table
    +
    @PHPMYADMIN@
    +
    phpMyAdmin with version
    +
    +

    phpMyAdmin project

    @@ -4824,6 +4855,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  • Replication support
  • +
  • Barrie Leslie +
  • +

    diff --git a/bs_change_mime_type.php b/bs_change_mime_type.php index 8ad8d1abc..edefae144 100644 --- a/bs_change_mime_type.php +++ b/bs_change_mime_type.php @@ -30,70 +30,19 @@ $bsNewMIMEType = isset($_REQUEST['bs_new_mime_type']) ? urldecode($_REQUEST['bs_new_mime_type']) : NULL; // necessary variables exist - if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType) + if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType) { - // load PMA configuration - $PMA_Config = $GLOBALS['PMA_Config']; + if (PMA_BS_SetContentType($bsDB, $bsTable, $bsReference, $bsNewMIMEType)) { + // determine redirector page + $newLoc = $cfg['PmaAbsoluteUri'] . 'sql.php?' . PMA_generate_common_url ('','', '&') . (isset($bsDB) ? '&db=' . urlencode($bsDB) : '') . (isset($bsTable) ? '&table=' . urlencode($bsTable) : '') . (isset($token) ? '&token=' . urlencode($token) : '') . (isset($goto) ? '&goto=' . urlencode($goto) : '') . '&reload=1&purge=1'; - // if PMA configuration exists - if (!empty($PMA_Config)) - { - // if BS plugins exist - if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST')) - { - $pbms_ref_tbl = $PMA_Config->get('PBMS_NAME') . '_reference'; - $pbms_cust_content_type_tbl = $PMA_Config->get('PBMS_NAME') . '_custom_content_type'; - - // if specified DB is selected - if (PMA_DBI_select_db($bsDB)) - { - $query = "SELECT * FROM " . PMA_backquote($pbms_ref_tbl); - $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'"; - - $result = PMA_DBI_query($query); - - // if record exists - if ($data = PMA_DBI_fetch_assoc($result)) - { - $query = "SELECT count(*) FROM " . PMA_backquote($pbms_cust_content_type_tbl); - $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'"; - - $result = PMA_DBI_query($query); - - // if record exists - if ($data = PMA_DBI_fetch_assoc($result)) - { - if (1 == $data['count(*)']) - { - $query = "UPDATE " . PMA_backquote($pbms_cust_content_type_tbl) . " SET Content_type='"; - $query .= PMA_sqlAddslashes($bsNewMIMEType) . "' WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'"; - } - else - { - $query = "INSERT INTO " . PMA_backquote($pbms_cust_content_type_tbl) . " (Blob_url, Content_type)"; - $query .= " VALUES('" . PMA_sqlAddslashes($bsReference) . "', '" . PMA_sqlAddslashes($bsNewMIMEType) . "')"; - } - - $result = PMA_DBI_query($query); - - // if query execution succeeded - if ($result) - { - // determine redirector page - $newLoc = $cfg['PmaAbsoluteUri'] . 'sql.php?' . PMA_generate_common_url ('','', '&') . (isset($bsDB) ? '&db=' . urlencode($bsDB) : '') . (isset($bsTable) ? '&table=' . urlencode($bsTable) : '') . (isset($token) ? '&token=' . urlencode($token) : '') . (isset($goto) ? '&goto=' . urlencode($goto) : '') . '&reload=1&purge=1'; - - // redirect to specified page - ?> - - get('BLOBSTREAMING_PLUGINS_EXIST')) - } // end if (!empty($PMA_Config)) + // redirect to specified page + ?> + + diff --git a/bs_disp_as_mime_type.php b/bs_disp_as_mime_type.php index 9b26a59ac..085d88823 100644 --- a/bs_disp_as_mime_type.php +++ b/bs_disp_as_mime_type.php @@ -9,13 +9,6 @@ */ require_once './libraries/common.inc.php'; -// load PMA configuration -$PMA_Config = $GLOBALS['PMA_Config']; - -// retrieve BS server variables from PMA configuration -$bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER'); -if (empty($bs_server)) die('No blob streaming server configured!'); - // Check URL parameters PMA_checkParameters(array('reference', 'c_type')); @@ -30,15 +23,23 @@ $reference = $_REQUEST['reference']; */ $c_type = preg_replace('/[^A-Za-z0-9/_-]/', '_', $_REQUEST['c_type']); -$filename = 'http://' . $bs_server . '/' . $reference; +// Get the blob streaming URL +$filename = PMA_BS_getURL($reference); +if (empty($filename)) { + die(__('No blob streaming server configured!')); +} $hdrs = get_headers($filename, 1); -if ($hdrs === FALSE) die('Failed to fetch headers'); +if ($hdrs === FALSE) { + die(__('Failed to fetch headers')); +} $fHnd = fopen($filename, "rb"); -if ($fHnd === FALSE) die('Failed to open remote URL'); +if ($fHnd === FALSE) { + die(__('Failed to open remote URL')); +} $f_size = $hdrs['Content-Length']; @@ -58,8 +59,9 @@ while (!feof($fHnd)) { $content .= fread($fHnd, $f_size); $pos = strlen($content); - if ($pos >= $f_size) + if ($pos >= $f_size) { break; + } } echo $content; diff --git a/bs_play_media.php b/bs_play_media.php index ad3c9af51..fe6f57425 100644 --- a/bs_play_media.php +++ b/bs_play_media.php @@ -15,7 +15,7 @@ $mediaType = isset($_REQUEST['media_type']) ? $_REQUEST['media_type'] : NULL; /* - * @var string indicates whether media type is of custom type + * @var string indicates whether media type is of custom type */ $customType = isset($_REQUEST['custom_type']) ? $_REQUEST['custom_type'] : false; @@ -25,24 +25,16 @@ $bsReference = isset($_REQUEST['bs_reference']) ? $_REQUEST['bs_reference'] : NULL; // if media type and BS reference are specified - if (isset($mediaType) && isset($bsReference)) - { - // load PMA configuration - $PMA_Config = $GLOBALS['PMA_Config']; - - // if PMA configuration exists - if (!empty($PMA_Config)) - { - // retrieve BS server variables from PMA configuration - $bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER'); - if (empty($bs_server)) die('No blob streaming server configured!'); - - $bs_file_path = "http://" . $bs_server . '/' . $bsReference; - - if (isset($customType) && $customType) - - $bs_file_path = 'bs_disp_as_mime_type.php' . PMA_generate_common_url(array('reference' => $bsReference, 'c_type' => $mediaType)); - + if (isset($mediaType) && isset($bsReference)) { + if (isset($customType) && $customType) { + $bs_file_path = 'bs_disp_as_mime_type.php' . PMA_generate_common_url(array('reference' => $bsReference, 'c_type' => $mediaType)); + } else { + // Get the BLOB streaming URL + $bs_file_path = PMA_BS_getURL($bsReference); + if (empty($bs_file_path)) { + die(__('No blob streaming server configured!')); + } + } ?> @@ -69,7 +61,6 @@ diff --git a/config.sample.inc.php b/config.sample.inc.php index 575e96562..679555bca 100644 --- a/config.sample.inc.php +++ b/config.sample.inc.php @@ -35,12 +35,6 @@ $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['extension'] = 'mysql'; $cfg['Servers'][$i]['AllowNoPassword'] = false; -/* for blobstreaming */ -$cfg['Servers'][$i]['bs_garbage_threshold'] = 50; -$cfg['Servers'][$i]['bs_repository_threshold'] = '32M'; -$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600; -$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M'; - /* User for advanced features */ // $cfg['Servers'][$i]['controluser'] = 'pma'; // $cfg['Servers'][$i]['controlpass'] = 'pmapass'; diff --git a/db_operations.php b/db_operations.php index e4e6992e7..773213173 100644 --- a/db_operations.php +++ b/db_operations.php @@ -19,9 +19,6 @@ require_once './libraries/common.inc.php'; require_once './libraries/Table.class.php'; require_once './libraries/mysql_charsets.lib.php'; -// add blobstreaming library functions -require_once "./libraries/blobstreaming.lib.php"; - /** * Rename/move or copy database */ @@ -260,65 +257,6 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { } } -/* - * Enable/Disable/Repair BLOB Repository Monitoring for current database -*/ -if (strlen($db) > 0 && !empty($db_blob_streaming_op)) -{ - // load PMA_Config - $PMA_Config = $GLOBALS['PMA_Config']; - - if (!empty($PMA_Config)) - { - if ($PMA_Config->get('PBXT_NAME') !== strtolower($db)) - { - // if Blobstreaming plugins exist, begin checking for Blobstreaming tables - if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST')) - { - $bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES'); - $bs_tables = $bs_tables[$db]; - - $oneBSTableExists = FALSE; - - // check if at least one blobstreaming table exists - foreach ($bs_tables as $table_key=>$tbl) - if ($bs_tables[$table_key]['Exists']) - { - $oneBSTableExists = TRUE; - break; - } - - switch ($db_blob_streaming_op) - { - // enable BLOB repository monitoring - case "enable": - // if blobstreaming tables do not exist, create them - if (!$oneBSTableExists) - PMA_BS_CreateTables($db); - break; - // disable BLOB repository monitoring - case "disable": - // if at least one blobstreaming table exists, execute drop - if ($oneBSTableExists) - PMA_BS_DropTables($db); - break; - // repair BLOB repository - case "repair": - // check if a blobstreaming table is missing - foreach ($bs_tables as $table_key=>$tbl) - if (!$bs_tables[$table_key]['Exists']) - { - PMA_DBI_select_db($db); - PMA_DBI_query(PMA_BS_GetTableStruct($table_key)); - } - } - - // refresh side menu - PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'db_operations.php?' . PMA_generate_common_url ('','', '&') . (isset($db) ? '&db=' . urlencode($db) : '') . (isset($token) ? '&token=' . urlencode($token) : '') . (isset($goto) ? '&goto=' . urlencode($goto) : '') . 'reload=1&purge=1'); - } // end if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST')) - } // end if ($PMA_Config->get('PBXT_NAME') !== strtolower($db)) - } -} /** * Settings for relations stuff @@ -500,92 +438,6 @@ if (!$is_information_schema) { get('PBXT_NAME') !== strtolower($db)) - { - if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST')) - { - $bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES'); - $bs_tables = $bs_tables[$db]; - - $oneBSTableExists = FALSE; - $allBSTablesExist = TRUE; - - // first check that all blobstreaming tables do not exist - foreach ($bs_tables as $table_key=>$tbl) - if ($bs_tables[$table_key]['Exists']) - $oneBSTableExists = TRUE; - else - $allBSTablesExist = FALSE; - - ?> - -

    - -
    - - - - - : - - - -
    -
    - - -
    - - - -
    - - -
    - - - -
    - - -
    - -
    - get('BLOBSTREAMING_PLUGINS_EXIST')) - } // end if ($PMA_Config->get('PBXT_NAME') !== strtolower($db)) - } /** * Change database charset diff --git a/db_structure.php b/db_structure.php index 9a6ee24ec..077dcab45 100644 --- a/db_structure.php +++ b/db_structure.php @@ -150,27 +150,14 @@ $hidden_fields = array(); $odd_row = true; $sum_row_count_pre = ''; -// for blobstreaming -$PMA_Config = $GLOBALS['PMA_Config']; - -if (!empty($PMA_Config)) - $session_bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES'); // list of blobstreaming tables - $tableReductionCount = 0; // the amount to reduce the table count by foreach ($tables as $keyname => $each_table) { - if (isset($session_bs_tables)) - { - // compare table name against blobstreaming tables - foreach ($session_bs_tables as $table_key=>$table_val) - // if the table is a blobstreaming table, reduce table count and skip outer foreach loop - if ($table_key == $keyname) - { - $tableReductionCount++; - continue 2; - } + if (PMA_BS_IsHiddenTable($keyname)) { + $tableReductionCount++; + continue; } - + // Get valid statistics whatever is the table type $table_is_view = false; diff --git a/export.php b/export.php index ccc3da28d..72c3d5bdc 100644 --- a/export.php +++ b/export.php @@ -259,18 +259,16 @@ if ($asfile) { if (isset($remember_template)) { $GLOBALS['PMA_Config']->setCookie('pma_server_filename_template', $filename_template); } - $filename = str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)); } elseif ($export_type == 'database') { if (isset($remember_template)) { $GLOBALS['PMA_Config']->setCookie('pma_db_filename_template', $filename_template); } - $filename = str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template))); } else { if (isset($remember_template)) { $GLOBALS['PMA_Config']->setCookie('pma_table_filename_template', $filename_template); } - $filename = str_replace('__TABLE__', $table, str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)))); } + $filename = PMA_expandUserString($filename_template); // convert filename to iso-8859-1, it is safer $filename = PMA_convert_string($charset, 'iso-8859-1', $filename); diff --git a/js/functions.js b/js/functions.js index 0395e6e63..3b4180bbf 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1726,6 +1726,13 @@ $(document).ready(function(){ return false; }); $('#sqlquery').focus(); + if ($('#input_username')) { + if ($('#input_username').val() == '') { + $('#input_username').focus(); + } else { + $('#input_password').focus(); + } + } }); /** diff --git a/libraries/File.class.php b/libraries/File.class.php index a6a515f44..83f5d14de 100644 --- a/libraries/File.class.php +++ b/libraries/File.class.php @@ -279,118 +279,27 @@ class PMA_File $is_bs_upload = FALSE; // check if this field requires a repository upload - if (isset($_REQUEST['upload_blob_repo_' . $key])) + if (isset($_REQUEST['upload_blob_repo_' . $key])) { $is_bs_upload = ($_REQUEST['upload_blob_repo_' . $key]['multi_edit'][0] == "on") ? TRUE : FALSE; - + } // if request is an upload to the BLOB repository - if ($is_bs_upload) - { - // load PMA configuration - $PMA_Config = $GLOBALS['PMA_Config']; + if ($is_bs_upload) { + $bs_db = $_REQUEST['db']; + $bs_table = $_REQUEST['table']; + $tmp_filename = $file['tmp_name']; + $tmp_file_type = $file['type']; - // if PMA configuration is loaded - if (!empty($PMA_Config)) - { - // load BS variables from PMA configuration - $pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'); - $curlExists = $PMA_Config->get('CURL_EXISTS'); - $bs_database = $PMA_Config->get('BLOBSTREAMABLE_DATABASES'); - $bs_database = $bs_database[$_REQUEST['db']]; + if (! $tmp_file_type) { + $tmp_file_type = NULL; + } - $allBSTablesExist = TRUE; - - // determine if plugins and curl exist - if ($pluginsExist && $curlExists) - { - foreach ($bs_database as $table_key=>$table) - { - if (!$bs_database[$table_key]['Exists']) - { - $allBSTablesExist = FALSE; - break; - } - } - } - else - $allBSTablesExist = FALSE; - - // if necessary BS tables exist - if ($allBSTablesExist) - { - // setup bs variables for uploading - $bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER'); - $bs_db = $_REQUEST['db']; - $bs_table = $_REQUEST['table']; - - // setup file handle and related variables - $tmp_file = fopen($file['tmp_name'], 'r'); - $tmp_file_type = $file['type']; - $tmp_file_size = $file['size']; - - if (!$tmp_file_type) - $tmp_file_type = NULL; - - // if none of the required variables contain data, return with an unknown error message - if (!$bs_server || !$bs_db || !$bs_table || !$tmp_file || !$tmp_file_size) - { - $this->_error_message = __('Unknown error in file upload.'); - return FALSE; - } - else - $bs_server_path = 'http://' . $bs_server . '/' . $bs_db . '/' . $bs_table; - - // init curl handle - $curlHnd = curl_init ($bs_server_path); - - // if curl handle init successful - if ($curlHnd) - { - // specify custom header - $customHeader = array( - "Accept-Language: en-us;en;q=0;5", - "Accept-Charset: ISO-8859-1;utf-8;q=0.7,*;q=0.7", - "Content-type: $tmp_file_type" - ); - - // specify CURL options in array - $curlOptArr = array( - CURLOPT_PUT => TRUE, - CURLOPT_HEADER => TRUE, - CURLOPT_HTTPHEADER => $customHeader, - CURLOPT_INFILESIZE => $tmp_file_size, - CURLOPT_INFILE => $tmp_file, - CURLOPT_RETURNTRANSFER => TRUE - ); - - // pass array of options to curl handle setup function - curl_setopt_array($curlHnd, $curlOptArr); - - // execute curl request and retrieve error message(s) (if any) - $ret = curl_exec($curlHnd); - $errRet = curl_error($curlHnd); - - // close curl handle - curl_close($curlHnd); - - // split entire string into array of lines - $retArr = explode("\r\n", $ret); - - // check each line as a valid string of a BLOB reference - foreach ($retArr as $value) - if (strlen($value) > strlen("~*$bs_db/~") && "~*$bs_db/~" == substr($value, 0, strlen($bs_db) + 4)) - { - // is a valid reference, so set as current and break - PMA_File::setRecentBLOBReference($value); - break; - } - - // close file handle - if ($tmp_file) - fclose($tmp_file); - } // end if ($curlHnd) - } // end if ($allBSTablesExist) - } // end if ($PMA_Config) - } // end if ($is_bs_upload) + if (! $bs_db || ! $bs_table) { + $this->_error_message = $GLOBALS['strUploadErrorUnknown']; + return FALSE; + } + $blob_url = PMA_BS_UpLoadFile($bs_db, $bs_table, $tmp_file_type, $tmp_filename); + PMA_File::setRecentBLOBReference($blob_url); + } // end if ($is_bs_upload) // check for file upload errors switch ($file['error']) { @@ -487,135 +396,43 @@ class PMA_File $is_bs_upload = FALSE; // check if this field requires a repository upload - if (isset($_REQUEST['upload_blob_repo_' . $key])) + if (isset($_REQUEST['upload_blob_repo_' . $key])) { $is_bs_upload = ($_REQUEST['upload_blob_repo_' . $key]['multi_edit'][0] == "on") ? TRUE : FALSE; + } // is a request to upload file to BLOB repository using uploadDir mechanism - if ($is_bs_upload) - { - // load PMA configuration - $PMA_Config = $GLOBALS['PMA_Config']; + if ($is_bs_upload) { + $bs_db = $_REQUEST['db']; + $bs_table = $_REQUEST['table']; + $tmp_filename = $GLOBALS['cfg']['UploadDir'] . '/' . $_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$primary]; - // if the PMA configuration was loaded - if (!empty($PMA_Config)) - { - // load BS variables from PMA configuration - $pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'); - $curlExists = $PMA_Config->get('CURL_EXISTS'); - $bs_database = $PMA_Config->get('BLOBSTREAMABLE_DATABASES'); - $bs_database = $bs_database[$_REQUEST['db']]; + // check if fileinfo library exists + if ($PMA_Config->get('FILEINFO_EXISTS')) { + // attempt to init fileinfo + $finfo = finfo_open(FILEINFO_MIME); - $allBSTablesExist = TRUE; - - // if plugins and curl exist - if ($pluginsExist && $curlExists) - { - foreach ($bs_database as $table_key=>$table) - { - if (!$bs_database[$table_key]['Exists']) - { - $allBSTablesExist = FALSE; - break; - } - } + // fileinfo exists + if ($finfo) { + // pass in filename to fileinfo and close fileinfo handle after + $tmp_file_type = finfo_file($finfo, $tmp_filename); + finfo_close($finfo); } - else - $allBSTablesExist = FALSE; + } else { + // no fileinfo library exists, use file command + $tmp_file_type = exec("file -bi " . escapeshellarg($tmp_filename)); + } - // if necessary BS tables exist - if ($allBSTablesExist) - { - // load BS variables - $bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER'); - $bs_db = $_REQUEST['db']; - $bs_table = $_REQUEST['table']; + if (! $tmp_file_type) { + $tmp_file_type = NULL; + } - // setup uploadDir mechanism and file variables - $tmp_filename = $GLOBALS['cfg']['UploadDir'] . '/' . $_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$primary]; - $tmp_file = fopen($tmp_filename, 'r'); - $tmp_file_size = filesize($tmp_filename); - - // check if fileinfo library exists - if ($PMA_Config->get('FILEINFO_EXISTS')) - { - // attempt to init fileinfo - $finfo = finfo_open(FILEINFO_MIME); - - // fileinfo exists - if ($finfo) - { - // pass in filename to fileinfo and close fileinfo handle after - $tmp_file_type = finfo_file($finfo, $tmp_filename); - finfo_close($finfo); - } - } - else // no fileinfo library exists, use file command - $tmp_file_type = exec("file -bi " . escapeshellarg($tmp_filename)); - - if (!$tmp_file_type) - $tmp_file_type = NULL; - - // necessary variables aren't loaded, return error message (unknown error) - if (!$bs_server || !$bs_db || !$bs_table || !$tmp_file || !$tmp_file_size) - { - $this->_error_message = __('Unknown error in file upload.'); - return FALSE; - } - else - $bs_server_path = 'http://' . $bs_server . '/' . $bs_db . '/' . $bs_table; - - // init curl handle - $curlHnd = curl_init ($bs_server_path); - - // curl handle exists - if ($curlHnd) - { - // specify custom header - $customHeader = array( - "Accept-Language: en-us;en;q=0;5", - "Accept-Charset: ISO-8859-1;utf-8;q=0.7,*;q=0.7", - "Content-type: $tmp_file_type" - ); - - // specify custom curl options - $curlOptArr = array( - CURLOPT_PUT => TRUE, - CURLOPT_HEADER => TRUE, - CURLOPT_HTTPHEADER => $customHeader, - CURLOPT_INFILESIZE => $tmp_file_size, - CURLOPT_INFILE => $tmp_file, - CURLOPT_RETURNTRANSFER => TRUE - ); - - // setup custom curl options (as specified in above array) - curl_setopt_array($curlHnd, $curlOptArr); - - // execute curl request and retrieve error message(s) (if any) - $ret = curl_exec($curlHnd); - $errRet = curl_error($curlHnd); - - // close curl handle - curl_close($curlHnd); - - // split return string into lines - $retArr = explode("\r\n", $ret); - - // check subsequent lines for valid BLOB reference string - foreach ($retArr as $value) - if (strlen($value) > strlen("~*$bs_db/~") && "~*$bs_db/~" == substr($value, 0, strlen($bs_db) + 4)) - { - // is a valid reference, so set as current and break - PMA_File::setRecentBLOBReference($value); - break; - } - - // close file handle - if ($tmp_file) - fclose($tmp_file); - } // end if ($curlHnd) - } // end if ($allBSTablesExist) - } // end if ($PMA_Config) - } // end if ($is_bs_upload) + if (! $bs_db || !$bs_table) { + $this->_error_message = $GLOBALS['strUploadErrorUnknown']; + return FALSE; + } + $blob_url = PMA_BS_UpLoadFile($bs_db, $bs_table, $tmp_file_type, $tmp_filename); + PMA_File::setRecentBLOBReference($blob_url); + } // end if ($is_bs_upload) return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$primary]); } else { @@ -633,127 +450,36 @@ class PMA_File // is a request to upload file to BLOB repository using uploadDir mechanism if ($is_bs_upload) { - // load PMA configuration - $PMA_Config = $GLOBALS['PMA_Config']; + // check if fileinfo library exists + if ($PMA_Config->get('FILEINFO_EXISTS')) + { + // attempt to init fileinfo + $finfo = finfo_open(FILEINFO_MIME); - // if the PMA configuration was loaded - if (!empty($PMA_Config)) - { - // load BS variables from PMA configuration - $pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'); - $curlExists = $PMA_Config->get('CURL_EXISTS'); - $bs_database = $PMA_Config->get('BLOBSTREAMABLE_DATABASES'); - $bs_database = $bs_database[$_REQUEST['db']]; + // if fileinfo exists + if ($finfo) + { + // pass in filename to fileinfo and close fileinfo handle after + $tmp_file_type = finfo_file($finfo, $tmp_filename); + finfo_close($finfo); + } + } + else // no fileinfo library exists, use file command + $tmp_file_type = exec("file -bi " . escapeshellarg($tmp_filename)); - $allBSTablesExist = TRUE; + if (!$tmp_file_type) + $tmp_file_type = NULL; - // if plugins and curl exist - if ($pluginsExist && $curlExists) - { - foreach ($bs_database as $table_key=>$table) - { - if (!$bs_database[$table_key]['Exists']) - { - $allBSTablesExist = FALSE; - break; - } - } - } - else - $allBSTablesExist = FALSE; + $bs_db = $_REQUEST['db']; + $bs_table = $_REQUEST['table']; + if (!$bs_db || !$bs_table) + { + $this->_error_message = $GLOBALS['strUploadErrorUnknown']; + return FALSE; + } + $blob_url = PMA_BS_UpLoadFile($bs_db, $bs_table, $tmp_file_type, $tmp_filename); + PMA_File::setRecentBLOBReference($blob_url); - if ($allBSTablesExist) - { - // load BS variables - $bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER'); - $bs_db = $_REQUEST['db']; - $bs_table = $_REQUEST['table']; - - // setup uploadDir mechanism and file variables - $tmp_filename = $GLOBALS['cfg']['UploadDir'] . '/' . $_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$primary]; - $tmp_file = fopen($tmp_filename, 'r'); - $tmp_file_size = filesize($tmp_filename); - - // check if fileinfo library exists - if ($PMA_Config->get('FILEINFO_EXISTS')) - { - // attempt to init fileinfo - $finfo = finfo_open(FILEINFO_MIME); - - // if fileinfo exists - if ($finfo) - { - // pass in filename to fileinfo and close fileinfo handle after - $tmp_file_type = finfo_file($finfo, $tmp_filename); - finfo_close($finfo); - } - } - else // no fileinfo library exists, use file command - $tmp_file_type = exec("file -bi " . escapeshellarg($tmp_filename)); - - if (!$tmp_file_type) - $tmp_file_type = NULL; - - // necessary variables aren't loaded, return error message (unknown error) - if (!$bs_server || !$bs_db || !$bs_table || !$tmp_file || !$tmp_file_size) - { - $this->_error_message = __('Unknown error in file upload.'); - return FALSE; - } - else - $bs_server_path = 'http://' . $bs_server . '/' . $bs_db . '/' . $bs_table; - - // init curl handle - $curlHnd = curl_init ($bs_server_path); - - // if curl handle exists - if ($curlHnd) - { - // specify custom header - $customHeader = array( - "Accept-Language: en-us;en;q=0;5", - "Accept-Charset: ISO-8859-1;utf-8;q=0.7,*;q=0.7", - "Content-type: $tmp_file_type" - ); - - // specify custom curl options - $curlOptArr = array( - CURLOPT_PUT => TRUE, - CURLOPT_HEADER => TRUE, - CURLOPT_HTTPHEADER => $customHeader, - CURLOPT_INFILESIZE => $tmp_file_size, - CURLOPT_INFILE => $tmp_file, - CURLOPT_RETURNTRANSFER => TRUE - ); - - // setup custom curl options (as specified in above array) - curl_setopt_array($curlHnd, $curlOptArr); - - // execute curl request and retrieve error message(s) (if any) - $ret = curl_exec($curlHnd); - $errRet = curl_error($curlHnd); - - // close curl handle - curl_close($curlHnd); - - // split return string into lines - $retArr = explode("\r\n", $ret); - - // check subsequent lines for valid BLOB reference string - foreach ($retArr as $value) - if (strlen($value) > strlen("~*$bs_db/~") && "~*$bs_db/~" == substr($value, 0, strlen($bs_db) + 4)) - { - // is a valid reference, so set as current and break - PMA_File::setRecentBLOBReference($value); - break; - } - - // close file handle - if ($tmp_file) - fclose($tmp_file); - } // end if ($curlHnd) - } // end if ($allBSTablesExist) - } // end if ($PMA_Config) } // end if ($is_bs_upload) return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal_' . $key]); diff --git a/libraries/StorageEngine.class.php b/libraries/StorageEngine.class.php index 2ae125a3e..71b363625 100644 --- a/libraries/StorageEngine.class.php +++ b/libraries/StorageEngine.class.php @@ -91,12 +91,7 @@ class PMA_StorageEngine && ($details['Support'] == 'NO' || $details['Support'] == 'DISABLED')) { continue; } - // currently (MySQL 5.1.26) there is no way we can be informed - // that PBMS does not support normal table creation so - // we use an exception here - if ('PBMS' == $details['Engine']) { - continue; - } + $output .= '