Update blob streaming to match the current API and use the PBMS PHP extension.

This commit is contained in:
Barry Leslie
2010-07-12 15:39:06 -07:00
committed by Marc Delisle
parent e65625ce1e
commit f8653e5803
16 changed files with 428 additions and 1216 deletions

View File

@@ -30,70 +30,21 @@
$bsNewMIMEType = isset($_REQUEST['bs_new_mime_type']) ? urldecode($_REQUEST['bs_new_mime_type']) : NULL; $bsNewMIMEType = isset($_REQUEST['bs_new_mime_type']) ? urldecode($_REQUEST['bs_new_mime_type']) : NULL;
// necessary variables exist // necessary variables exist
if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType) if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType)
{ {
// load PMA configuration if (PMA_BS_SetContentType($bsDB, $bsTable, $bsReference, $bsNewMIMEType))
$PMA_Config = $GLOBALS['PMA_Config']; {
// 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 // redirect to specified page
if (!empty($PMA_Config)) ?>
{ <script>
// if BS plugins exist window.location = "<?php echo $newLoc ?>";
if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST')) </script>
{ <?php
$pbms_ref_tbl = $PMA_Config->get('PBMS_NAME') . '_reference'; } // end if ($result)
$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
?>
<script>
window.location = "<?php echo $newLoc ?>";
</script>
<?php
} // end if ($result)
} // end if ($data = PMA_DBI_fetch_assoc($result))
} // end if ($data = PMA_DBI_fetch_assoc($result))
} // end if (PMA_DBI_select_db($bsDB))
} // end if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'))
} // end if (!empty($PMA_Config))
} // end if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType) } // end if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType)
?> ?>

View File

@@ -9,13 +9,6 @@
*/ */
require_once './libraries/common.inc.php'; 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 // Check URL parameters
PMA_checkParameters(array('reference', 'c_type')); PMA_checkParameters(array('reference', 'c_type'));
@@ -30,7 +23,9 @@ $reference = $_REQUEST['reference'];
*/ */
$c_type = preg_replace('/[^A-Za-z0-9/_-]/', '_', $_REQUEST['c_type']); $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); $hdrs = get_headers($filename, 1);

View File

@@ -27,21 +27,13 @@
// if media type and BS reference are specified // if media type and BS reference are specified
if (isset($mediaType) && isset($bsReference)) 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) if (isset($customType) && $customType)
$bs_file_path = 'bs_disp_as_mime_type.php' . PMA_generate_common_url(array('reference' => $bsReference, 'c_type' => $mediaType)); $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!');
}
?> ?>
<html> <html>
@@ -69,7 +61,6 @@
</body> </body>
</html> </html>
<?php <?php
} // end if (!empty($PMA_Config))
} // end if (isset($mediaType) && isset($bsReference)) } // end if (isset($mediaType) && isset($bsReference))
?> ?>

View File

@@ -19,9 +19,6 @@ require_once './libraries/common.inc.php';
require_once './libraries/Table.class.php'; require_once './libraries/Table.class.php';
require_once './libraries/mysql_charsets.lib.php'; require_once './libraries/mysql_charsets.lib.php';
// add blobstreaming library functions
require_once "./libraries/blobstreaming.lib.php";
/** /**
* Rename/move or copy database * 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 * Settings for relations stuff

View File

@@ -150,26 +150,17 @@ $hidden_fields = array();
$odd_row = true; $odd_row = true;
$sum_row_count_pre = ''; $sum_row_count_pre = '';
// for blobstreaming // added by rajk - for blobstreaming
$PMA_Config = $GLOBALS['PMA_Config']; $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 $tableReductionCount = 0; // the amount to reduce the table count by
foreach ($tables as $keyname => $each_table) { foreach ($tables as $keyname => $each_table) {
if (isset($session_bs_tables))
{ if (PMA_BS_IsHiddenTable($keyname)) {
// compare table name against blobstreaming tables $tableReductionCount++;
foreach ($session_bs_tables as $table_key=>$table_val) continue;
// if the table is a blobstreaming table, reduce table count and skip outer foreach loop }
if ($table_key == $keyname)
{
$tableReductionCount++;
continue 2;
}
}
// Get valid statistics whatever is the table type // Get valid statistics whatever is the table type

View File

@@ -285,112 +285,24 @@ class PMA_File
// if request is an upload to the BLOB repository // if request is an upload to the BLOB repository
if ($is_bs_upload) if ($is_bs_upload)
{ {
// load PMA configuration $bs_db = $_REQUEST['db'];
$PMA_Config = $GLOBALS['PMA_Config']; $bs_table = $_REQUEST['table'];
$tmp_filename = $file['tmp_name'];
$tmp_file_type = $file['type'];
// if PMA configuration is loaded if (!$tmp_file_type)
if (!empty($PMA_Config)) $tmp_file_type = NULL;
{
// 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']];
$allBSTablesExist = TRUE;
// determine if plugins and curl exist if (!$bs_db || !$bs_table)
if ($pluginsExist && $curlExists) {
{ $this->_error_message = $GLOBALS['strUploadErrorUnknown'];
foreach ($bs_database as $table_key=>$table) return FALSE;
{ }
if (!$bs_database[$table_key]['Exists']) $blob_url = PMA_BS_UpLoadFile($bs_db, $bs_table, $tmp_file_type, $tmp_filename);
{ PMA_File::setRecentBLOBReference($blob_url);
$allBSTablesExist = FALSE;
break;
}
}
}
else
$allBSTablesExist = FALSE;
// if necessary BS tables exist } // end if ($is_bs_upload)
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)
// check for file upload errors // check for file upload errors
switch ($file['error']) { switch ($file['error']) {
@@ -493,129 +405,40 @@ class PMA_File
// is a request to upload file to BLOB repository using uploadDir mechanism // is a request to upload file to BLOB repository using uploadDir mechanism
if ($is_bs_upload) if ($is_bs_upload)
{ {
// load PMA configuration $bs_db = $_REQUEST['db'];
$PMA_Config = $GLOBALS['PMA_Config']; $bs_table = $_REQUEST['table'];
$tmp_filename = $GLOBALS['cfg']['UploadDir'] . '/' . $_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$primary];
// if the PMA configuration was loaded // check if fileinfo library exists
if (!empty($PMA_Config)) if ($PMA_Config->get('FILEINFO_EXISTS'))
{ {
// load BS variables from PMA configuration // attempt to init fileinfo
$pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'); $finfo = finfo_open(FILEINFO_MIME);
$curlExists = $PMA_Config->get('CURL_EXISTS');
$bs_database = $PMA_Config->get('BLOBSTREAMABLE_DATABASES');
$bs_database = $bs_database[$_REQUEST['db']];
$allBSTablesExist = TRUE; // 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 plugins and curl exist if (!$tmp_file_type)
if ($pluginsExist && $curlExists) $tmp_file_type = NULL;
{
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)
{
// load BS variables
$bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER');
$bs_db = $_REQUEST['db'];
$bs_table = $_REQUEST['table'];
// setup uploadDir mechanism and file variables if (!$bs_db || !$bs_table)
$tmp_filename = $GLOBALS['cfg']['UploadDir'] . '/' . $_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$primary]; {
$tmp_file = fopen($tmp_filename, 'r'); $this->_error_message = $GLOBALS['strUploadErrorUnknown'];
$tmp_file_size = filesize($tmp_filename); return FALSE;
}
$blob_url = PMA_BS_UpLoadFile($bs_db, $bs_table, $tmp_file_type, $tmp_filename);
PMA_File::setRecentBLOBReference($blob_url);
// check if fileinfo library exists } // end if ($is_bs_upload)
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)
return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$primary]); return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$primary]);
} else { } else {
@@ -633,127 +456,36 @@ class PMA_File
// is a request to upload file to BLOB repository using uploadDir mechanism // is a request to upload file to BLOB repository using uploadDir mechanism
if ($is_bs_upload) if ($is_bs_upload)
{ {
// load PMA configuration // check if fileinfo library exists
$PMA_Config = $GLOBALS['PMA_Config']; if ($PMA_Config->get('FILEINFO_EXISTS'))
{
// attempt to init fileinfo
$finfo = finfo_open(FILEINFO_MIME);
// if the PMA configuration was loaded // if fileinfo exists
if (!empty($PMA_Config)) if ($finfo)
{ {
// load BS variables from PMA configuration // pass in filename to fileinfo and close fileinfo handle after
$pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'); $tmp_file_type = finfo_file($finfo, $tmp_filename);
$curlExists = $PMA_Config->get('CURL_EXISTS'); finfo_close($finfo);
$bs_database = $PMA_Config->get('BLOBSTREAMABLE_DATABASES'); }
$bs_database = $bs_database[$_REQUEST['db']]; }
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 $bs_db = $_REQUEST['db'];
if ($pluginsExist && $curlExists) $bs_table = $_REQUEST['table'];
{ if (!$bs_db || !$bs_table)
foreach ($bs_database as $table_key=>$table) {
{ $this->_error_message = $GLOBALS['strUploadErrorUnknown'];
if (!$bs_database[$table_key]['Exists']) return FALSE;
{ }
$allBSTablesExist = FALSE; $blob_url = PMA_BS_UpLoadFile($bs_db, $bs_table, $tmp_file_type, $tmp_filename);
break; PMA_File::setRecentBLOBReference($blob_url);
}
}
}
else
$allBSTablesExist = FALSE;
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) } // end if ($is_bs_upload)
return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal_' . $key]); return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal_' . $key]);

View File

@@ -91,12 +91,7 @@ class PMA_StorageEngine
&& ($details['Support'] == 'NO' || $details['Support'] == 'DISABLED')) { && ($details['Support'] == 'NO' || $details['Support'] == 'DISABLED')) {
continue; 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 .= ' <option value="' . htmlspecialchars($key). '"' $output .= ' <option value="' . htmlspecialchars($key). '"'
. (empty($details['Comment']) . (empty($details['Comment'])
? '' : ' title="' . htmlspecialchars($details['Comment']) . '"') ? '' : ' title="' . htmlspecialchars($details['Comment']) . '"')
@@ -144,6 +139,8 @@ class PMA_StorageEngine
*/ */
static public function isValid($engine) static public function isValid($engine)
{ {
if ($engine == "PBMS")
return TRUE;
$storage_engines = PMA_StorageEngine::getStorageEngines(); $storage_engines = PMA_StorageEngine::getStorageEngines();
return isset($storage_engines[$engine]); return isset($storage_engines[$engine]);
} }
@@ -265,6 +262,8 @@ class PMA_StorageEngine
return $mysql_vars; return $mysql_vars;
} }
function engine_init() {}
/** /**
* Constructor * Constructor
* *
@@ -303,7 +302,9 @@ class PMA_StorageEngine
default: default:
$this->support = PMA_ENGINE_SUPPORT_NO; $this->support = PMA_ENGINE_SUPPORT_NO;
} }
} } else {
$this->engine_init();
}
} }
/** /**

View File

@@ -13,7 +13,6 @@
* @uses PMA_Config::set() * @uses PMA_Config::set()
* @uses PMA_BS_SetVariables() * @uses PMA_BS_SetVariables()
* @uses PMA_BS_GetVariables() * @uses PMA_BS_GetVariables()
* @uses PMA_BS_SetFieldReferences()
* @uses PMA_cacheSet() * @uses PMA_cacheSet()
* @uses PMA_cacheGet() * @uses PMA_cacheGet()
* @return boolean * @return boolean
@@ -63,69 +62,38 @@ function checkBLOBStreamingPlugins()
$serverCfg['socket'] = ""; $serverCfg['socket'] = "";
} }
$allPluginsExist = false; $has_blobstreaming = false;
if (PMA_MYSQL_INT_VERSION >= 50109) { if (PMA_MYSQL_INT_VERSION >= 50109) {
$PMA_Config->set('PBXT_NAME', 'pbxt');
$PMA_Config->set('PBMS_NAME', 'pbms');
$required_plugins[$PMA_Config->get('PBXT_NAME')]['Library'] = 'libpbxt.so';
$required_plugins[$PMA_Config->get('PBMS_NAME')]['Library'] = 'libpbms.so';
$number_of_required_plugins_found = 0;
// Retrieve MySQL plugins // Retrieve MySQL plugins
$existing_plugins = PMA_DBI_fetch_result('SHOW PLUGINS'); $existing_plugins = PMA_DBI_fetch_result('SHOW PLUGINS');
foreach ($existing_plugins as $one_existing_plugin) { foreach ($existing_plugins as $one_existing_plugin) {
// check if required plugins exist // check if required plugins exist
foreach ($required_plugins as $one_required_plugin) { if ( strtolower($one_existing_plugin['Library']) == 'libpbms.so'
if ( strtolower($one_existing_plugin['Library']) == strtolower($one_required_plugin['Library']) && $one_existing_plugin['Status'] == "ACTIVE") {
&& $one_existing_plugin['Status'] == "ACTIVE") { $has_blobstreaming = true;
$number_of_required_plugins_found++; break;
} }
}
if (2 == $number_of_required_plugins_found) {
$allPluginsExist = true;
break;
}
} }
unset($required_plugins, $existing_plugins, $one_required_plugin, $one_existing_plugin, $number_of_required_plugins_found); unset($existing_plugins, $one_existing_plugin);
} }
// set variable indicating BS plugin existence // set variable indicating BS plugin existence
$PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', $allPluginsExist); $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', $has_blobstreaming);
if ($allPluginsExist) { if ($has_blobstreaming) {
// retrieve BS variables from PMA configuration $bs_variables = PMA_BS_GetVariables();
$bs_set_variables = array();
$bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_garbage_threshold'] = (isset($serverCfg['bs_garbage_threshold'])) ? $serverCfg['bs_garbage_threshold'] : NULL; // if no BS variables exist, set plugin existence to false and return
$bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_repository_threshold'] = (isset($serverCfg['bs_repository_threshold'])) ? $serverCfg['bs_repository_threshold'] : NULL;
$bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_temp_blob_timeout'] = (isset($serverCfg['bs_temp_blob_timeout'])) ? $serverCfg['bs_temp_blob_timeout'] : NULL;
$bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_temp_log_threshold'] = (isset($serverCfg['bs_temp_log_threshold'])) ? $serverCfg['bs_temp_log_threshold'] : NULL;
// set BS variables to PMA configuration defaults
PMA_BS_SetVariables($bs_set_variables);
// retrieve updated BS variables (configurable and unconfigurable)
$bs_variables = PMA_BS_GetVariables();
// if no BS variables exist, set plugin existence to false and return
if (count($bs_variables) <= 0) { if (count($bs_variables) <= 0) {
$PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE); $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
PMA_cacheSet('skip_blobstreaming', true, true); PMA_cacheSet('skip_blobstreaming', true, true);
return FALSE; return FALSE;
} // end if (count($bs_variables) <= 0) } // end if (count($bs_variables) <= 0)
// switch on BS field references // get BS server port
if (strtolower($bs_variables[$PMA_Config->get('PBMS_NAME') . '_field_references']) == "off") { $BS_PORT = $bs_variables['pbms_port'];
if (! PMA_BS_SetFieldReferences('ON')) {
PMA_cacheSet('skip_blobstreaming', true, true);
return FALSE;
}
}
// get BS server port
$BS_PORT = $bs_variables[$PMA_Config->get('PBMS_NAME') . '_port'];
// if no BS server port exists, set plugin existance to false and return // if no BS server port exists, set plugin existance to false and return
if (! $BS_PORT) { if (! $BS_PORT) {
@@ -138,22 +106,15 @@ function checkBLOBStreamingPlugins()
$PMA_Config->set('BLOBSTREAMING_PORT', $BS_PORT); $PMA_Config->set('BLOBSTREAMING_PORT', $BS_PORT);
$PMA_Config->set('BLOBSTREAMING_HOST', $serverCfg['host']); $PMA_Config->set('BLOBSTREAMING_HOST', $serverCfg['host']);
$PMA_Config->set('BLOBSTREAMING_SERVER', $serverCfg['host'] . ':' . $BS_PORT); $PMA_Config->set('BLOBSTREAMING_SERVER', $serverCfg['host'] . ':' . $BS_PORT);
$PMA_Config->set('CURL_EXISTS', FALSE); $PMA_Config->set('PHP_PBMS_EXISTS', FALSE);
$PMA_Config->set('FILEINFO_EXISTS', FALSE); $PMA_Config->set('FILEINFO_EXISTS', FALSE);
// check if CURL exists // Check to see if the BLOB Streaming PHP extension is loaded
if (function_exists("curl_init")) { if (extension_loaded("PBMS")) {
// initialize curl handler $PMA_Config->set('PHP_PBMS_EXISTS', TRUE);
$curlHnd = curl_init(); }
// CURL exists, set necessary variable and close resource // check if PECL's fileinfo library exist
if (! empty($curlHnd)) {
$PMA_Config->set('CURL_EXISTS', TRUE);
curl_close($curlHnd);
} // end if (!empty($curlHnd))
} // end if (function_exists("curl_init"))
// check if PECL's fileinfo library exist
$finfo = NULL; $finfo = NULL;
if (function_exists("finfo_open")) { if (function_exists("finfo_open")) {
@@ -165,180 +126,15 @@ function checkBLOBStreamingPlugins()
$PMA_Config->set('FILEINFO_EXISTS', TRUE); $PMA_Config->set('FILEINFO_EXISTS', TRUE);
finfo_close($finfo); finfo_close($finfo);
} // end if (!empty($finfo)) } // end if (!empty($finfo))
} else { } else {
PMA_cacheSet('skip_blobstreaming', true, true); PMA_cacheSet('skip_blobstreaming', true, true);
return FALSE; return FALSE;
} // end if ($allPluginsExist) } // end if ($has_blobstreaming)
$bs_tables = array();
// specify table structure for BS reference table
$bs_tables[$PMA_Config->get('PBMS_NAME') . '_reference'] = array();
$bs_tables[$PMA_Config->get('PBMS_NAME') . '_reference']['struct'] = <<<EOD
CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_reference
(
Table_name CHAR(64) COMMENT 'The name of the referencing table',
Blob_id BIGINT COMMENT 'The BLOB reference number - part of the BLOB URL',
Column_name CHAR(64) COMMENT 'The column name of the referencing field',
Row_condition VARCHAR(255) COMMENT 'This condition identifies the row in the table',
Blob_url VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
Repository_id INT COMMENT 'The repository file number of the BLOB',
Repo_blob_offset BIGINT COMMENT 'The offset in the repository file',
Blob_size BIGINT COMMENT 'The size of the BLOB in bytes',
Deletion_time TIMESTAMP COMMENT 'The time the BLOB was deleted',
Remove_in INT COMMENT 'The number of seconds before the reference/BLOB is removed perminently',
Temp_log_id INT COMMENT 'Temporary log number of the referencing deletion entry',
Temp_log_offset BIGINT COMMENT 'Temporary log offset of the referencing deletion entry'
) ENGINE=PBMS;
EOD;
// specify table structure for BS repository table
$bs_tables[$PMA_Config->get('PBMS_NAME') . '_repository'] = array();
$bs_tables[$PMA_Config->get('PBMS_NAME') . '_repository']['struct'] = <<<EOD
CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_repository
(
Repository_id INT COMMENT 'The repository file number',
Repo_blob_offset BIGINT COMMENT 'The offset of the BLOB in the repository file',
Blob_size BIGINT COMMENT 'The size of the BLOB in bytes',
Head_size SMALLINT UNSIGNED COMMENT 'The size of the BLOB header - proceeds the BLOB data',
Access_code INT COMMENT 'The 4-byte authorisation code required to access the BLOB - part of the BLOB URL',
Creation_time TIMESTAMP COMMENT 'The time the BLOB was created',
Last_ref_time TIMESTAMP COMMENT 'The last time the BLOB was referenced',
Last_access_time TIMESTAMP COMMENT 'The last time the BLOB was accessed (read)',
Content_type CHAR(128) COMMENT 'The content type of the BLOB - returned by HTTP GET calls',
Blob_data LONGBLOB COMMENT 'The data of this BLOB'
) ENGINE=PBMS;
EOD;
// specify table structure for BS custom content type table
$bs_tables[$PMA_Config->get('PBMS_NAME') . '_custom_content_type'] = array();
$bs_tables[$PMA_Config->get('PBMS_NAME') . '_custom_content_type']['struct'] = <<<EOD
CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_custom_content_type
(
Blob_url VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
Content_type VARCHAR(255) COMMENT 'The custom MIME type for a given BLOB reference as specified by the user',
PRIMARY KEY(Blob_url)
);
EOD;
// add BS tables to PMA configuration
$PMA_Config->set('BLOBSTREAMING_TABLES', $bs_tables);
return TRUE; return TRUE;
} }
/**
* checks for databases that support BLOBStreaming
*
* @access public
* @uses PMA_GetDatabases()
* @uses PMA_TablesExist()
* @uses PMA_Config::set()
*/
function checkBLOBStreamableDatabases()
{
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
$serverCfg = $GLOBALS['cfg']['Server'];
// retrieve BS tables from PMA configuration
$session_bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
$bs_databases = array();
$bs_tables = array();
// return if BS tables do not exist
if (!$session_bs_tables)
return;
foreach ($session_bs_tables as $table_key=>$table)
{
$bs_tables[$table_key] = array();
$bs_tables[$table_key]['Exists'] = FALSE;
}
// retrieve MySQL databases
$databases = PMA_GetDatabases();
// check if BS tables exist for each database
foreach ($databases as $db_key=>$db_name)
{
$bs_databases[$db_name] = $bs_tables;
PMA_TablesExist($bs_databases[$db_name], $db_name);
}
// set BS databases in PMA configuration
$PMA_Config->set('BLOBSTREAMABLE_DATABASES', $bs_databases);
}
/**
* checks whether a given set of tables exist in a given database
*
* @access public
* @param array - list of tables to look for
* @param string - name of database
* @uses PMA_DBI_select_db()
* @uses PMA_DBI_query()
* @uses PMA_DBI_fetch_assoc()
*/
function PMA_TablesExist(&$tables, $db_name)
{
// select specified database
PMA_DBI_select_db($db_name);
// run query to retrieve tables in specified database
$query = "SHOW TABLES";
$result = PMA_DBI_query($query);
// while there are records to parse
while ($data = @PMA_DBI_fetch_assoc($result))
{
$state = TRUE;
// check if necessary tables exist
foreach ($tables as $table_key=>$table)
if (!$table['Exists'])
if ($data['Tables_in_' . $db_name] == $table_key)
$tables[$table_key]['Exists'] = TRUE;
else
if ($state)
$state = FALSE;
// break if necessary tables are found before all records are parsed
if ($state)
break;
} // end while ($data = @PMA_DBI_fetch_assoc($result))
}
/**
* returns a list of databases
*
* @access public
* @uses PMA_DBI_query()
* @uses PMA_DBI_fetch_assoc()
* @return array - list of databases acquired via MySQL
*/
function PMA_GetDatabases()
{
// run query to retrieve databases
$query = "SHOW DATABASES";
$result = PMA_DBI_query($query);
$databases = array();
// while there are records to parse
while ($data = @PMA_DBI_fetch_assoc($result))
$databases[] = $data['Database'];
// return list of databases
return $databases;
}
/** /**
* sets BLOBStreaming variables to a list of specified arguments * sets BLOBStreaming variables to a list of specified arguments
* @access public * @access public
@@ -388,7 +184,7 @@ function PMA_BS_GetVariables()
return NULL; return NULL;
// run query to retrieve BS variables // run query to retrieve BS variables
$query = "SHOW VARIABLES LIKE '%" . $PMA_Config->get('PBMS_NAME') . "%'"; $query = "SHOW VARIABLES LIKE '%pbms%'";
$result = PMA_DBI_query($query); $result = PMA_DBI_query($query);
$BS_Variables = array(); $BS_Variables = array();
@@ -401,313 +197,245 @@ function PMA_BS_GetVariables()
return $BS_Variables; return $BS_Variables;
} }
/** //========================
* sets the BLOBStreaming global field references to ON/OFF //========================
* function PMA_BS_ReportPBMSError($msg)
* @access public {
* @param string - ON or OFF $tmp_err = pbms_error();
* @uses PMA_Config::get() PMA_showMessage("PBMS error, $msg $tmp_err");
* @uses PMA_sqlAddslashes() }
* @uses PMA_DBI_query()
* @return boolean - success/failure of query execution //------------
*/ function PMA_do_connect($db_name, $quiet)
function PMA_BS_SetFieldReferences($val)
{ {
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config']; $PMA_Config = $GLOBALS['PMA_Config'];
// return if unable to load PMA configuration // return if unable to load PMA configuration
if (empty($PMA_Config)) if (empty($PMA_Config))
return FALSE; return FALSE;
// set field references to value specified
$query = "SET GLOBAL " . $PMA_Config->get('PBMS_NAME') . "_field_references=" . PMA_sqlAddslashes($val);
$result = PMA_DBI_try_query($query, null, 0);
// get last known error (if applicable)
PMA_DBI_getError();
// return success of query execution
if ($result && 0 == $GLOBALS['errno'])
return TRUE;
else
return FALSE;
}
/**
* gets the SQL table definition for a given BLOBStreaming table
*
* @access public
* @param string - table name
* @uses PMA_Config::get()
* @return string - SQL table definition
*/
function PMA_BS_GetTableStruct($tbl_name)
{
// retrieve table structures for BS tables
$bs_tables = $GLOBALS['PMA_Config']->get('BLOBSTREAMING_TABLES');
// return if tables don't exist
if (!$bs_tables)
return;
// return if specified table doesn't exist in collection of BS tables
if (!isset($bs_tables[$tbl_name]))
return;
// return specified table's structure
return $bs_tables[$tbl_name]['struct'];
}
/**
* creates the BLOBStreaming tables for a given database
*
* @access public
* @param string - database name
* @uses PMA_Config::get()
* @uses PMA_DBI_select_db()
* @uses PMA_DBI_query()
* @uses PMA_BS_GetTableStruct()
* @return boolean - success/failure of transactional query execution
*/
function PMA_BS_CreateTables($db_name)
{
// retrieve BS tables
$bs_tables = $GLOBALS['PMA_Config']->get('BLOBSTREAMING_TABLES');
// select specified database
PMA_DBI_select_db($db_name);
// create necessary BS tables for specified database
foreach ($bs_tables as $table_key=>$table)
{
$result = PMA_DBI_query(PMA_BS_GetTableStruct($table_key));
// return false if query execution fails
if (!$result)
return FALSE;
}
// return true on success
return TRUE;
}
/**
* drops BLOBStreaming tables for a given database
*
* @access public
* @param string - database name
* @uses PMA_Config::get()
* @uses PMA_DBI_select_db()
* @uses PMA_backquote()
* @uses PMA_DBI_query()
* @return boolean - success/failure of transactional query execution
*/
function PMA_BS_DropTables($db_name)
{
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
// return if unable to load PMA configuration
if (empty($PMA_Config))
return FALSE;
// retrieve BS tables
$bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
// select specified database
PMA_DBI_select_db($db_name);
// drop BS tables
foreach ($bs_tables as $table_key=>$table)
{
$query = "DROP TABLE IF EXISTS " . PMA_backquote($table_key);
$result = PMA_DBI_query($query);
// return false if query execution fails
if (!$result)
return FALSE;
}
// return true on success
return TRUE;
}
/**
* returns the field name for a primary key of a given table in a given database
*
* @access public
* @param string - database name
* @param string - table name
* @uses PMA_DBI_select_db()
* @uses PMA_backquote()
* @uses PMA_DBI_query()
* @uses PMA_DBI_fetch_assoc()
* @return string - field name for primary key
*/
function PMA_BS_GetPrimaryField($db_name, $tbl_name)
{
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
// return if unable to load PMA configuration
if (empty($PMA_Config))
return FALSE;
// select specified database
PMA_DBI_select_db($db_name);
// retrieve table fields
$query = "SHOW FULL FIELDS FROM " . PMA_backquote($tbl_name);
$result = PMA_DBI_query($query);
// while there are records to parse
while ($data = PMA_DBI_fetch_assoc($result))
if ("PRI" == $data['Key'])
return $data['Field'];
// return NULL on no primary key
return NULL;
}
/**
* checks whether a BLOB reference exists in the BLOB repository
*
* @access public
* @param string - BLOB reference
* @param string - database name
* @uses PMA_DBI_select_db()
* @uses PMA_backquote()
* @uses PMA_Config::get()
* @uses PMA_sqlAddslashes()
* @uses PMA_DBI_query()
* @return boolean - existence of BLOB reference
*/
function PMA_BS_ReferenceExists($bs_reference, $db_name)
{
$referenceExists = FALSE;
// return false on invalid BS reference
if (strlen ($bs_reference) < strlen ("~*$db_name/~") || "~*$db_name/~" != substr ($bs_reference, 0, strlen ($db_name) + 4))
return $referenceExists;
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
// return if unable to load PMA configuration
if (empty($PMA_Config))
return $referenceExists;
// select specified database
PMA_DBI_select_db($db_name);
// run query on BS reference retrieval
$query = "SELECT * FROM " . PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference") . " WHERE Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
$result = PMA_DBI_query($query);
// if record exists
if ($data = @PMA_DBI_fetch_assoc($result))
$referenceExists = TRUE;
// return reference existance
return $referenceExists;
}
/**
* creates a HTTP link to a given blob reference for a given database
*
* @access public
* @param string - BLOB reference
* @param string - database name
* @uses PMA_Config::get()
* @uses PMA_DBI_select_db()
* @uses PMA_backquote()
* @uses PMA_sqlAddslashes()
* @uses PMA_DBI_query()
* @uses PMA_DBI_fetch_assoc()
* @return string - HTTP link or Error
*/
function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
{
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
// return if unable to load PMA configuration
if (empty($PMA_Config))
return '';
// generate bs reference link // generate bs reference link
$bs_ref_link = 'http://' . $PMA_Config->get('BLOBSTREAMING_SERVER') . '/' . $bs_reference; $pbms_host = $PMA_Config->get('BLOBSTREAMING_HOST');
$pbms_port = $PMA_Config->get('BLOBSTREAMING_PORT');
// select specified database if (pbms_connect($pbms_host, $pbms_port, $db_name) == FALSE) {
PMA_DBI_select_db($db_name); if ($quiet == FALSE)
PMA_BS_ReportPBMSError("PBMS Connectiuon failed: pbms_connect($pbms_host, $pbms_port, $db_name)");
$pbms_repo_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_repository"); return FALSE;
$pbms_ref_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference");
$pbms_cust_content_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_custom_content_type");
// run query on determining specified BS reference
$query = "SELECT $pbms_repo_bq.Content_type, $pbms_cust_content_bq.Content_type AS Custom_type";
$query .= " FROM $pbms_repo_bq LEFT JOIN $pbms_ref_bq ON";
$query .= "$pbms_repo_bq.Repository_id=$pbms_ref_bq.Repository_id";
$query .= " AND $pbms_repo_bq.Blob_size=$pbms_ref_bq.Blob_size";
$query .= " AND $pbms_repo_bq.Repo_blob_offset=$pbms_ref_bq.Repo_blob_offset";
$query .= " LEFT JOIN $pbms_cust_content_bq ON $pbms_cust_content_bq.Blob_url=$pbms_ref_bq.Blob_url";
$query .= " WHERE $pbms_ref_bq.Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
$result = PMA_DBI_query($query);
// if record exists
if ($data = @PMA_DBI_fetch_assoc($result))
{
// determine content-type for BS repository file (original or custom)
$is_custom_type = false;
if (isset($data['Custom_type']))
{
$content_type = $data['Custom_type'];
$is_custom_type = true;
} }
else return TRUE;
$content_type = $data['Content_type']; }
if (!$content_type) //------------
$content_type = NULL; function PMA_do_disconnect()
{
pbms_close();
}
$output = "<a href=\"#\" onclick=\"requestMIMETypeChange('" . urlencode($db_name) . "', '" . urlencode($GLOBALS['table']) . "', '" . urlencode($bs_reference) . "', '" . urlencode($content_type) . "')\">$content_type</a>"; //------------
/**
* checks whether the BLOB reference looks valid
*
*/
function PMA_BS_IsPBMSReference($bs_reference, $db_name)
{
if (PMA_do_connect($db_name, TRUE) == FALSE) {
return FALSE;
}
$ok = pbms_is_blob_reference($bs_reference);
PMA_do_disconnect();
return $ok ;
}
// specify custom HTML for various content types //------------
switch ($content_type) function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
{ {
// no content specified if (PMA_do_connect($db_name, FALSE) == FALSE) {
case NULL: return 'Error';
$output = "NULL"; }
break;
// image content
case 'image/jpeg':
case 'image/png':
$output .= ' (<a href="' . $bs_ref_link . '" target="new">' . __('View image') . '</a>)';
break;
// audio content
case 'audio/mpeg':
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 120)">' . __('Play audio'). '</a>)';
break;
// video content
case 'application/x-flash-video':
case 'video/mpeg':
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 480)">' . __('View video') . '</a>)';
break;
// unsupported content. specify download
default:
$output .= ' (<a href="' . $bs_ref_link . '" target="new">' . __('Download file'). '</a>)';
}
// return HTML if (pbms_get_info($bs_reference) == FALSE) {
return $output; PMA_BS_ReportPBMSError("PBMS get BLOB info failed: pbms_get_info($bs_reference)");
} // end if ($data = @PMA_DBI_fetch_assoc($result)) PMA_do_disconnect();
return 'Error';
}
$content_type = pbms_get_metadata_value("Content-type");
if ($content_type == FALSE) {
PMA_BS_ReportPBMSError("PMA_BS_CreateReferenceLink($bs_reference, $db_name): get BLOB Content-type failed: ");
}
PMA_do_disconnect();
if (!$content_type)
$content_type = "image/jpeg";
$bs_url = PMA_BS_getURL($bs_reference);
if (empty($bs_url)) {
PMA_BS_ReportPBMSError("No blob streaming server configured!");
return 'Error';
}
$output = "<a href=\"#\" onclick=\"requestMIMETypeChange('" . urlencode($db_name) . "', '" . urlencode($GLOBALS['table']) . "', '" . urlencode($bs_reference) . "', '" . urlencode($content_type) . "')\">$content_type</a>";
// specify custom HTML for various content types
switch ($content_type)
{
// no content specified
case NULL:
$output = "NULL";
break;
// image content
case 'image/jpeg':
case 'image/png':
$output .= ' (<a href="' . $bs_url . '" target="new">' . __('View image') . '</a>)';
break;
// audio content
case 'audio/mpeg':
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 120)">' . __('Play audio'). '</a>)';
break;
// video content
case 'application/x-flash-video':
case 'video/mpeg':
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 480)">' . __('View video') . '</a>)';
break;
// unsupported content. specify download
default:
$output .= ' (<a href="' . $bs_url . '" target="new">' . __('Download file'). '</a>)';
}
//PMA_showMessage("PMA_BS_CreateReferenceLink($bs_reference, $db_name): $output");
return $output;
}
//------------
// In the future there may be server variables to turn on/off PBMS
// BLOB streaming on a per table or database basis. So in anticipation of this
// PMA_BS_IsTablePBMSEnabled() passes in the table and database name even though
// they are not currently needed.
function PMA_BS_IsTablePBMSEnabled($db_name, $tbl_name, $tbl_type)
{
if ((isset($tbl_type) == FALSE) || (strlen($tbl_type) == 0))
return FALSE;
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
// return if unable to load PMA configuration
if (empty($PMA_Config))
return FALSE;
// This information should be cached rather than selecting it each time.
//$query = "SELECT count(*) FROM information_schema.TABLES T, pbms.pbms_enabled E where T.table_schema = ". PMA_backquote($db_name) . " and T.table_name = ". PMA_backquote($tbl_name) . " and T.engine = E.name";
$query = "SELECT count(*) FROM pbms.pbms_enabled E where E.name = '". PMA_sqlAddslashes($tbl_type) . "'" ;
$result = PMA_DBI_query($query);
$data = PMA_DBI_fetch_row($result);
if ($data[0] == 1)
return TRUE;
return FALSE;
}
//------------
function PMA_BS_UpLoadFile($db_name, $tbl_name, $file_type, $file_name)
{
if (PMA_do_connect($db_name, FALSE) == FALSE) {
return FALSE;
}
$fh = fopen($file_name, 'r');
if (!$fh) {
PMA_do_disconnect();
PMA_showMessage("Could not open file: $file_name");
return FALSE;
}
pbms_add_metadata("Content-type", $file_type);
$pbms_blob_url = pbms_read_stream($fh, filesize($file_name), $tbl_name);
if (!$pbms_blob_url) {
PMA_BS_ReportPBMSError("pbms_read_stream() Failed");
}
//PMA_showMessage(" PMA_BS_UpLoadFile($db_name, $tbl_name, $file_type, $file_name): $pbms_blob_url");
fclose($fh);
PMA_do_disconnect();
return $pbms_blob_url;
}
//------------
function PMA_BS_SetContentType($db_name, $bsTable, $blobReference, $contentType)
{
// This is a really ugly way to do this but currently there is nothing better.
// In a future version of PBMS the system tables will be redesigned to make this
// more eficient.
$query = "SELECT Repository_id, Repo_blob_offset FROM pbms_reference WHERE Blob_url='" . PMA_sqlAddslashes($blobReference) . "'";
//error_log(" PMA_BS_SetContentType: $query\n", 3, "/tmp/mylog");
$result = PMA_DBI_query($query);
//error_log(" $query\n", 3, "/tmp/mylog");
// if record exists
if ($data = PMA_DBI_fetch_assoc($result))
{
$where = "WHERE Repository_id=" . $data['Repository_id'] . " AND Repo_blob_offset=" . $data['Repo_blob_offset'] ;
$query = "SELECT name from pbms_metadata $where";
$result = PMA_DBI_query($query);
if (PMA_DBI_num_rows($result) == 0)
$query = "INSERT into pbms_metadata Values( ". $data['Repository_id'] . ", " . $data['Repo_blob_offset'] . ", 'Content_type', '" . PMA_sqlAddslashes($contentType) . "')";
else
$query = "UPDATE pbms_metadata SET name = 'Content_type', Value = '" . PMA_sqlAddslashes($contentType) . "' $where";
//error_log("$query\n", 3, "/tmp/mylog");
PMA_DBI_query($query);
} else {
// if ($result == FALSE) {
// $err = PMA_DBI_getError();
// error_log("MySQL ERROR: $err\n", 3, "/tmp/mylog");
// } else
// error_log("No results: $query\n", 3, "/tmp/mylog");
return FALSE;
}
return TRUE;
}
//------------
function PMA_BS_IsHiddenTable($table)
{
switch ($table) {
case 'pbms_repository' :
case 'pbms_reference' :
case 'pbms_metadata' :
case 'pbms_metadata_header' :
case 'pbms_dump' :
return TRUE;
}
return FALSE;
}
//------------
function PMA_BS_getURL($reference)
{
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
if (empty($PMA_Config))
return FALSE;
// retrieve BS server variables from PMA configuration
$bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER');
if (empty($bs_server))
return FALSE;
$bs_url = 'http://' . $bs_server . '/' . rtrim($reference);
//PMA_showMessage(" PMA_BS_getURL($reference): $bs_url");
return $bs_url;
// return on error
return 'Error';
} }
?> ?>

View File

@@ -788,7 +788,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$_SESSION['PMA_Theme_Manager']->setThemeCookie(); $_SESSION['PMA_Theme_Manager']->setThemeCookie();
if (! empty($cfg['Server'])) { if (! empty($cfg['Server'])) {
/** /**
* Loads the proper database interface for this server * Loads the proper database interface for this server
@@ -797,7 +797,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
require_once './libraries/logging.lib.php'; require_once './libraries/logging.lib.php';
// Gets the authentication library that fits the $cfg['Server'] settings // Gets the authentication library that fits the $cfg['Server'] settings
// and run authentication // and run authentication
// to allow HTTP or http // to allow HTTP or http
@@ -809,14 +809,13 @@ if (! defined('PMA_MINIMUM_COMMON')) {
* the required auth type plugin * the required auth type plugin
*/ */
require_once './libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php'; require_once './libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php';
if (!PMA_auth_check()) { if (!PMA_auth_check()) {
PMA_auth(); PMA_auth();
} else { } else {
PMA_auth_set_user(); PMA_auth_set_user();
} }
// Check IP-based Allow/Deny rules as soon as possible to reject the // Check IP-based Allow/Deny rules as soon as possible to reject the
// user // user
// Based on mod_access in Apache: // Based on mod_access in Apache:
// http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/aaa/mod_access.c?rev=1.37&content-type=text/vnd.viewcvs-markup // http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/aaa/mod_access.c?rev=1.37&content-type=text/vnd.viewcvs-markup
@@ -953,9 +952,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
// checks for blobstreaming plugins and databases that support // checks for blobstreaming plugins and databases that support
// blobstreaming (by having the necessary tables for blobstreaming) // blobstreaming (by having the necessary tables for blobstreaming)
if (checkBLOBStreamingPlugins()) { checkBLOBStreamingPlugins();
checkBLOBStreamableDatabases();
}
} // end if !defined('PMA_MINIMUM_COMMON') } // end if !defined('PMA_MINIMUM_COMMON')
// remove sensitive values from session // remove sensitive values from session

View File

@@ -791,18 +791,12 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
// load PMA configuration // load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config']; $PMA_Config = $GLOBALS['PMA_Config'];
// if PMA configuration exists
if (!empty($PMA_Config))
$session_bs_tables = $GLOBALS['PMA_Config']->get('BLOBSTREAMING_TABLES');
foreach ($tables as $table_name => $table) { foreach ($tables as $table_name => $table) {
// if BS tables exist // if BS tables exist
if (isset($session_bs_tables)) if (PMA_BS_IsHiddenTable($table_name)) {
// compare table name to tables in list of blobstreaming tables continue;
foreach ($session_bs_tables as $table_key=>$table_val) }
// if table is in list, skip outer foreach loop
if ($table_name == $table_key)
continue 2;
// check for correct row count // check for correct row count
if (null === $table['Rows']) { if (null === $table['Rows']) {

View File

@@ -310,31 +310,11 @@ function PMA_getTableCount($db)
if ($tables) { if ($tables) {
$num_tables = PMA_DBI_num_rows($tables); $num_tables = PMA_DBI_num_rows($tables);
// for blobstreaming - get blobstreaming tables // do not count hidden blobstreaming tables
// for use in determining if a table here is a blobstreaming table while ((($num_tables > 0)) && $data = PMA_DBI_fetch_assoc($tables)) {
if (PMA_BS_IsHiddenTable($data['Tables_in_' . $db]))
// load PMA configuration $num_tables--;
$PMA_Config = $GLOBALS['PMA_Config']; }
// if PMA configuration exists
if (!empty($PMA_Config))
{
// load BS tables
$session_bs_tables = $GLOBALS['PMA_Config']->get('BLOBSTREAMING_TABLES');
// if BS tables exist
if (isset ($session_bs_tables))
while ($data = PMA_DBI_fetch_assoc($tables))
foreach ($session_bs_tables as $table_key=>$table_val)
// if the table is a blobstreaming table, reduce the table count
if ($data['Tables_in_' . $db] == $table_key)
{
if ($num_tables > 0)
$num_tables--;
break;
}
} // end if PMA configuration exists
PMA_DBI_free_result($tables); PMA_DBI_free_result($tables);
} else { } else {

View File

@@ -1286,47 +1286,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
} else { } else {
// for blobstreaming // for blobstreaming
$bs_reference_exists = $allBSTablesExist = FALSE; // if valid BS reference exists
if (PMA_BS_IsPBMSReference($row[$i], $db)) {
// load PMA configuration $blobtext = PMA_BS_CreateReferenceLink($row[$i], $db);
$PMA_Config = $GLOBALS['PMA_Config'];
// if PMA configuration exists
if ($PMA_Config) {
// load BS variables
$pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST');
// if BS plugins exist
if ($pluginsExist) {
// load BS databases
$bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES');
// if BS db array and specified db string not empty and valid
if (!empty($bs_tables) && strlen($db) > 0) {
$bs_tables = $bs_tables[$db];
if (isset($bs_tables)) {
$allBSTablesExist = TRUE;
// check if BS tables exist for given database
foreach ($bs_tables as $table_key=>$bs_tbl)
if (!$bs_tables[$table_key]['Exists']) {
$allBSTablesExist = FALSE;
break;
}
}
}
}
}
// if necessary BS tables exist
if ($allBSTablesExist) {
$bs_reference_exists = PMA_BS_ReferenceExists($row[$i], $db);
}
// if valid BS reference exists
if ($bs_reference_exists) {
$blobtext = PMA_BS_CreateReferenceLink($row[$i], $db);
} else { } else {
$blobtext = PMA_handle_non_printable_contents('BLOB', (isset($row[$i]) ? $row[$i] : ''), $transform_function, $transform_options, $default_function, $meta, $_url_params); $blobtext = PMA_handle_non_printable_contents('BLOB', (isset($row[$i]) ? $row[$i] : ''), $transform_function, $transform_options, $default_function, $meta, $_url_params);
} }

View File

@@ -98,6 +98,46 @@ class PMA_StorageEngine_pbxt extends PMA_StorageEngine
} }
return PMA_formatByteDown($value); return PMA_formatByteDown($value);
} }
//--------------------
function getInfoPages()
{
$pages = array();
$pages['Documentation'] = __('Documentation');
return $pages;
}
//--------------------
function getPage($id)
{
if (! array_key_exists($id, $this->getInfoPages())) {
return false;
}
$id = 'getPage' . $id;
return $this->$id();
}
function getPageDocumentation()
{
$output = '<p> Documentation and furtther information about PBXT can be found on the ' . "\n"
. '<a href="http://www.primebase.com/xt/" target="_blank">PrimeBase XT Home Page</a>.<br><br>' . "\n"
. '<table id="PBMS_Related_Links" >' . "\n"
. '<tr>' . "\n"
. '<td>' . "\n"
. '<p>' . "\n"
. '<strong><font size="2"><b>Related Links</b></font></strong>' . "\n"
. '<br>' . "\n"
. '<a href="http://pbxt.blogspot.com/" target="_blank">The PrimeBase XT Blog by Paul McCullagh</a><br><br>' . "\n"
. '<a href="http://www.blobstreaming.org/" target="_blank">The PrimeBase Media Streaming (PBMS) home page</a>.<br><br>' . "\n"
. '</font>' . "\n"
. '</td>' . "\n"
. '</tr>' . "\n"
. '</table>' . "\n";
return $output;
}
} }
?> ?>

View File

@@ -80,7 +80,18 @@ if (empty($_REQUEST['engine'])
. '</tr>' . "\n"; . '</tr>' . "\n";
$odd_row = !$odd_row; $odd_row = !$odd_row;
} }
unset($odd_row, $engine, $details); // Special case for PBMS daemon which is not listed as an engine
echo '<tr class="'
. ($odd_row ? 'odd' : 'even')
. '">' . "\n"
. ' <td><a href="./server_engines.php'
. PMA_generate_common_url(array('engine' => "PBMS")) . '">' . "\n"
. ' ' . "PBMS\n"
. ' </a></td>' . "\n"
. ' <td>' . htmlspecialchars("PrimeBase BLOB streaming daemon") . '</td>' . "\n"
. '</tr>' . "\n";
unset($odd_row, $engine, $details);
echo '</tbody>' . "\n" echo '</tbody>' . "\n"
. '</table>' . "\n"; . '</table>' . "\n";

View File

@@ -834,51 +834,7 @@ foreach ($rows as $row_id => $vrow) {
|| ($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) { || ($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) {
echo "\n"; echo "\n";
// for blobstreaming // for blobstreaming
$bs_reference_exists = FALSE; if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type) && PMA_BS_IsPBMSReference($data, $db))
if (isset ($tbl_type) && strlen ($tbl_type) > 0)
{
// load PMA_Config
$PMA_Config = $GLOBALS['PMA_Config'];
if (!empty($PMA_Config))
{
$requiredTblType = $PMA_Config->get('PBXT_NAME');
if ($requiredTblType == strtolower ($tbl_type))
{
$pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST');
// check if blobstreaming plugins exist
if ($pluginsExist)
{
$bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES');
if (!empty($bs_tables) && strlen($db) > 0)
{
$bs_tables = $bs_tables[$db];
if (isset($bs_tables))
{
$allBSTablesExist = TRUE;
foreach ($bs_tables as $table_key=>$bs_tbl)
if (!$bs_tables[$table_key]['Exists'])
{
$allBSTablesExist = FALSE;
break;
}
if ($allBSTablesExist)
$bs_reference_exists = PMA_BS_ReferenceExists($data, $db);
} // end if (isset($bs_tables))
} // end if (!empty($bs_tables) && strlen($db) > 0)
} // end if ($pluginsExist)
} // end if ($requiredTblType == strtolower ($tbl_type))
} // end if (!empty($PMA_Config))
} // end if (isset ($tbl_type) && strlen ($tbl_type) > 0)
if ($bs_reference_exists)
{ {
echo '<input type="hidden" name="remove_blob_ref_' . $field['Field_md5'] . $vkey . '" value="' . $data . '" />'; echo '<input type="hidden" name="remove_blob_ref_' . $field['Field_md5'] . $vkey . '" value="' . $data . '" />';
echo '<input type="checkbox" name="remove_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Remove BLOB Repository Reference') . "<br />"; echo '<input type="checkbox" name="remove_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Remove BLOB Repository Reference') . "<br />";
@@ -894,7 +850,7 @@ foreach ($rows as $row_id => $vrow) {
unset($data_size); unset($data_size);
} }
echo "\n"; echo "\n";
} // end if ($bs_reference_exists) } // end if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type) && PMA_BS_IsPBMSReference($data, $db))
?> ?>
<input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="protected" /> <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="protected" />
<input type="hidden" name="fields<?php echo $field_name_appendix; ?>" value="" /> <input type="hidden" name="fields<?php echo $field_name_appendix; ?>" value="" />
@@ -932,63 +888,11 @@ foreach ($rows as $row_id => $vrow) {
// (displayed whatever value the ProtectBinary has) // (displayed whatever value the ProtectBinary has)
if ($is_upload && $field['is_blob']) { if ($is_upload && $field['is_blob']) {
// check if field type is of longblob // check if field type is of longblob and if the table is PBMS enabled.
if ($field['pma_type'] == "longblob") if (($field['pma_type'] == "longblob") && PMA_BS_IsTablePBMSEnabled($db_name, $tbl_name, $tbl_type))
{ {
if (isset ($tbl_type) && strlen ($tbl_type) > 0) echo '<br />';
{ echo '<input type="checkbox" name="upload_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Upload to BLOB repository');
// load PMA Config
$PMA_Config = $GLOBALS['PMA_Config'];
// is PMA_Config's data loaded? continue only if it is
if (!empty($PMA_Config))
{
$requiredTblType = $PMA_Config->get('PBXT_NAME');
if ($requiredTblType == strtolower ($tbl_type))
{
$pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST');
// check if blobstreaming plugins exist
if ($pluginsExist)
{
$curlExists = $PMA_Config->get('CURL_EXISTS');
// check if CURL exists
if ($curlExists)
{
$bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES');
// check for BLOBStreamable databases and if current database name is provided
if (!empty($bs_tables) && strlen($db) > 0)
{
$bs_tables = $bs_tables[$db];
// check if reference to BLOBStreaming tables exists
if (isset($bs_tables))
{
$allBSTablesExist = TRUE;
foreach ($bs_tables as $table_key=>$bs_tbl)
if (!$bs_tables[$table_key]['Exists'])
{
$allBSTablesExist = FALSE;
break;
}
// check if necessary BLOBStreaming tables exist
if ($allBSTablesExist)
{
echo '<br />';
echo '<input type="checkbox" name="upload_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Upload to BLOB repository');
} // end if ($allBSTablesExist)
} // end if (isset($bs_tables)
} // end if (!empty($bs_tables) && strlen ($db) > 0)
} // end if ($curlExists)
} // end if ($pluginsExist)
} // end if ($requiredTblType == strtolower ($tbl_type))
} // end if (!empty($PMA_Config))
} // end if (isset ($tbl_type) && strlen ($tbl_type) > 0)
} }
echo '<br />'; echo '<br />';

View File

@@ -210,10 +210,6 @@ foreach ($loop_array as $rowcount => $where_clause) {
? $_REQUEST['auto_increment']['multi_edit'][$rowcount] ? $_REQUEST['auto_increment']['multi_edit'][$rowcount]
: null; : null;
if ($blob_streaming_active) {
$primary_field = PMA_BS_GetPrimaryField($GLOBALS['db'], $GLOBALS['table']);
}
// Fetch the current values of a row to use in case we have a protected field // Fetch the current values of a row to use in case we have a protected field
// @todo possibly move to ./libraries/tbl_replace_fields.inc.php // @todo possibly move to ./libraries/tbl_replace_fields.inc.php
if ($is_insert && $using_key && isset($me_fields_type) && is_array($me_fields_type) && isset($where_clause)) { if ($is_insert && $using_key && isset($me_fields_type) && is_array($me_fields_type) && isset($where_clause)) {