The branch, master has been updated
via f30125fcd3c0cf2f4d80997c8dc2332311cfc12c (commit)
from aa38371c48976ef6e14581f3e189bf1632ba6cff (commit)
- Log -----------------------------------------------------------------
commit f30125fcd3c0cf2f4d80997c8dc2332311cfc12c
Author: Marc Delisle <marc(a)infomarc.info>
Date: Mon Dec 6 12:49:08 2010 -0500
Continue insertion did not work if the form had special controls like file upload from
client, file upload from server or BLOB streaming upload
-----------------------------------------------------------------------
Summary of changes:
libraries/File.class.php | 177 +++++++++++++++-------------------------------
tbl_change.php | 6 +-
2 files changed, 59 insertions(+), 124 deletions(-)
diff --git a/libraries/File.class.php b/libraries/File.class.php
index 2c59179..c093a7b 100644
--- a/libraries/File.class.php
+++ b/libraries/File.class.php
@@ -263,24 +263,19 @@ class PMA_File
* @param string $rownumber
* @return boolean success
*/
- function setUploadedFromTblChangeRequest($key, $rownumber = null)
+ function setUploadedFromTblChangeRequest($key, $rownumber)
{
- if (! isset($_FILES['fields_upload_' . $key])) {
+ if (! isset($_FILES['fields_upload']) && !
isset($_FILES['fields_upload']['name']['multi_edit'][$rownumber][$key]))
{
return false;
}
-
- $file = $_FILES['fields_upload_' . $key];
-
- if (null !== $rownumber) {
- $file = PMA_File::fetchUploadedFromTblChangeRequestMultiple($file,
$rownumber);
- }
+ $file =
PMA_File::fetchUploadedFromTblChangeRequestMultiple($_FILES['fields_upload'],
$rownumber, $key);
// for blobstreaming
$is_bs_upload = FALSE;
// check if this field requires a repository upload
- if (isset($_REQUEST['upload_blob_repo_' . $key])) {
- $is_bs_upload = ($_REQUEST['upload_blob_repo_' .
$key]['multi_edit'][0] == "on") ? TRUE : FALSE;
+ if
(isset($_REQUEST['upload_blob_repo']['multi_edit'][$rownumber][$key])) {
+ $is_bs_upload =
($_REQUEST['upload_blob_repo']['multi_edit'][$rownumber][$key] ==
"on") ? TRUE : FALSE;
}
// if request is an upload to the BLOB repository
if ($is_bs_upload) {
@@ -340,11 +335,11 @@ class PMA_File
* strips some dimension from the multi-dimensional array from $_FILES
*
* <code>
- * $file['name']['multi_edit'][$rownumber] = [value]
- * $file['type']['multi_edit'][$rownumber] = [value]
- * $file['size']['multi_edit'][$rownumber] = [value]
- * $file['tmp_name']['multi_edit'][$rownumber] = [value]
- * $file['error']['multi_edit'][$rownumber] = [value]
+ * $file['name']['multi_edit'][$rownumber][$key] = [value]
+ * $file['type']['multi_edit'][$rownumber][$key] = [value]
+ * $file['size']['multi_edit'][$rownumber][$key] = [value]
+ * $file['tmp_name']['multi_edit'][$rownumber][$key] = [value]
+ * $file['error']['multi_edit'][$rownumber][$key] = [value]
*
* // becomes:
*
@@ -360,16 +355,17 @@ class PMA_File
* @static
* @param array $file the array
* @param string $rownumber
+ * @param string $key
* @return array
*/
- function fetchUploadedFromTblChangeRequestMultiple($file, $rownumber)
+ function fetchUploadedFromTblChangeRequestMultiple($file, $rownumber, $key)
{
$new_file = array(
- 'name' =>
$file['name']['multi_edit'][$rownumber],
- 'type' =>
$file['type']['multi_edit'][$rownumber],
- 'size' =>
$file['size']['multi_edit'][$rownumber],
- 'tmp_name' =>
$file['tmp_name']['multi_edit'][$rownumber],
- 'error' =>
$file['error']['multi_edit'][$rownumber],
+ 'name' =>
$file['name']['multi_edit'][$rownumber][$key],
+ 'type' =>
$file['type']['multi_edit'][$rownumber][$key],
+ 'size' =>
$file['size']['multi_edit'][$rownumber][$key],
+ 'tmp_name' =>
$file['tmp_name']['multi_edit'][$rownumber][$key],
+ 'error' =>
$file['error']['multi_edit'][$rownumber][$key],
);
return $new_file;
@@ -388,104 +384,55 @@ class PMA_File
*/
function setSelectedFromTblChangeRequest($key, $rownumber = null)
{
- if (null !== $rownumber) {
- if (! empty($_REQUEST['fields_uploadlocal_' .
$key]['multi_edit'][$rownumber])
- && is_string($_REQUEST['fields_uploadlocal_' .
$key]['multi_edit'][$rownumber])) {
- // ... whether with multiple rows ...
- // for blobstreaming
- $is_bs_upload = FALSE;
-
- // check if this field requires a repository upload
- 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) {
- $bs_db = $_REQUEST['db'];
- $bs_table = $_REQUEST['table'];
- $tmp_filename = $GLOBALS['cfg']['UploadDir'] .
'/' . $_REQUEST['fields_uploadlocal_' .
$key]['multi_edit'][$rownumber];
-
- // 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;
- }
-
- 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'][$rownumber]);
- } else {
- return false;
- }
- } elseif (! empty($_REQUEST['fields_uploadlocal_' . $key])
- && is_string($_REQUEST['fields_uploadlocal_' . $key])) {
+ if (!
empty($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key])
+ &&
is_string($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key]))
{
+ // ... whether with multiple rows ...
// for blobstreaming
$is_bs_upload = FALSE;
// check if this field requires a repository upload
- if (isset($_REQUEST['upload_blob_repo_' . $key]))
- $is_bs_upload = ($_REQUEST['upload_blob_repo_' .
$key]['multi_edit'][0] == "on") ? TRUE : FALSE;
+ if
(isset($_REQUEST['upload_blob_repo']['multi_edit'][$rownumber][$key])) {
+ $is_bs_upload =
($_REQUEST['upload_blob_repo']['multi_edit'][$rownumber][$key] ==
"on") ? TRUE : FALSE;
+ }
// is a request to upload file to BLOB repository using uploadDir mechanism
- if ($is_bs_upload)
- {
- // 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;
-
- $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 ($is_bs_upload) {
+ $bs_db = $_REQUEST['db'];
+ $bs_table = $_REQUEST['table'];
+ $tmp_filename = $GLOBALS['cfg']['UploadDir'] .
'/' . $_REQUEST['fields_uploadlocal_' .
$key]['multi_edit'][$rownumber];
+
+ // 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;
+ }
+ 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]);
+ return
$this->setLocalSelectedFile($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key]);
+ } else {
+ return false;
}
-
- return false;
}
/**
@@ -525,22 +472,10 @@ class PMA_File
// well done ...
$this->_error_message = '';
return true;
-/*
- } elseif ($this->setUploadedFromTblChangeRequest($key)) {
- // well done ...
- $this->_error_message = '';
- return true;
-*/
} elseif ($this->setSelectedFromTblChangeRequest($key, $rownumber)) {
// well done ...
$this->_error_message = '';
return true;
-/*
- } elseif ($this->setSelectedFromTblChangeRequest($key)) {
- // well done ...
- $this->_error_message = '';
- return true;
-*/
}
// all failed, whether just no file uploaded/selected or an error
diff --git a/tbl_change.php b/tbl_change.php
index bee7017..edbddb0 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -889,11 +889,11 @@ foreach ($rows as $row_id => $vrow) {
// check if field type is of longblob and if the table is PBMS enabled.
if (($field['pma_type'] == "longblob") &&
PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type)) {
echo '<br />';
- echo '<input type="checkbox"
name="upload_blob_repo_' . $field['Field_md5'] . $vkey . '"
/> ' . __('Upload to BLOB repository');
+ echo '<input type="checkbox"
name="upload_blob_repo' . $vkey . '[' . $field['Field_md5'] .
']" /> ' . __('Upload to BLOB repository');
}
echo '<br />';
- echo '<input type="file" name="fields_upload_'
. $field['Field_md5'] . $vkey . '" class="textfield"
id="field_' . $idindex . '_3" size="10" ' .
$unnullify_trigger . '/> ';
+ echo '<input type="file" name="fields_upload' .
$vkey . '[' . $field['Field_md5'] . ']"
class="textfield" id="field_' . $idindex . '_3"
size="10" ' . $unnullify_trigger . '/> ';
// find maximum upload size, based on field type
/**
@@ -926,7 +926,7 @@ foreach ($rows as $row_id => $vrow) {
} elseif (!empty($files)) {
echo "<br />\n";
echo ' <i>' . __('Or') .
'</i>' . ' ' . __('web server upload directory') .
':<br />' . "\n";
- echo ' <select size="1"
name="fields_uploadlocal_' . $field['Field_md5'] . $vkey .
'">' . "\n";
+ echo ' <select size="1"
name="fields_uploadlocal' . $vkey . '[' . $field['Field_md5'] .
']">' . "\n";
echo ' <option value=""
selected="selected"></option>' . "\n";
echo $files;
echo ' </select>' . "\n";
hooks/post-receive
--
phpMyAdmin