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;
+}
+
+/**
+ * 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 = $_SESSION['PMA_Config'];
+
+ // return if unable to load PMA configuration
+ if (empty($PMA_Config))
+ return;
+
+ // 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 set of plugins exist
+ *
+ * @access public
+ * @param array - a list of plugin names and accompanying library filenames to check for
+ * @uses PMA_DBI_query()
+ * @uses PMA_DBI_fetch_assoc()
+*/
+function PMA_PluginsExist(&$plugins)
+{
+ if (PMA_MYSQL_INT_VERSION < 50109) {
+ return;
+ }
+ // run query to retrieve MySQL plugins
+ $query = "SHOW PLUGINS";
+ $result = PMA_DBI_query($query);
+
+ // while there are records to parse
+ while ($data = @PMA_DBI_fetch_assoc($result))
+ {
+ // reset plugin state
+ $state = TRUE;
+
+ // check if required plugins exist
+ foreach ($plugins as $plugin_key=>$plugin)
+ if (!$plugin['Exists'])
+ if (
+ strtolower($data['Library']) == strtolower($plugin['Library']) &&
+ $data['Status'] == "ACTIVE"
+ )
+ $plugins[$plugin_key]['Exists'] = TRUE;
+ else
+ if ($state)
+ $state = FALSE;
+
+ // break if all necessary plugins are found before all records are parsed
+ if ($state)
+ break;
+ } // end while ($data = @PMA_DBI_fetch_assoc($result))
+}
+
+/**
+ * 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
+ * @access public
+ * @uses PMA_DBI_query()
+ * @returns boolean - success of variables setup
+*/
+
+function PMA_BS_SetVariables($bs_variables)
+{
+ // if no variables exist in array, return false
+ if (empty($bs_variables) || count($bs_variables) == 0)
+ return FALSE;
+
+ // set BS variables to those specified in array
+ foreach ($bs_variables as $key=>$val)
+ if (!is_null($val) && strlen($val) > 0)
+ {
+ // set BS variable to specified value
+ $query = "SET GLOBAL $key=" . PMA_sqlAddSlashes($val);
+ $result = PMA_DBI_query($query);
+
+ // if query fails execution, return false
+ if (!$result)
+ return FALSE;
+ } // end if (!is_null($val) && strlen($val) > 0)
+
+ // return true on success
+ return TRUE;
+}
+
+/**
+ * returns a list of BLOBStreaming variables used by MySQL
+ *
+ * @access public
+ * @uses PMA_Config::get()
+ * @uses PMA_DBI_query()
+ * @uses PMA_DBI_fetch_assoc()
+ * @return array - list of BLOBStreaming variables
+*/
+function PMA_BS_GetVariables()
+{
+ // load PMA configuration
+ $PMA_Config = $_SESSION['PMA_Config'];
+
+ // return if unable to load PMA configuration
+ if (empty($PMA_Config))
+ return NULL;
+
+ // run query to retrieve BS variables
+ $query = "SHOW VARIABLES LIKE '%" . $PMA_Config->get('PBMS_NAME') . "%'";
+ $result = PMA_DBI_query($query);
+
+ $BS_Variables = array();
+
+ // while there are records to retrieve
+ while ($data = @PMA_DBI_fetch_assoc($result))
+ $BS_Variables[$data['Variable_name']] = $data['Value'];
+
+ // return BS variables
+ return $BS_Variables;
+}
+
+/**
+ * sets the BLOBStreaming global field references to ON/OFF
+ *
+ * @access public
+ * @param string - ON or OFF
+ * @uses PMA_Config::get()
+ * @uses PMA_sqlAddslashes()
+ * @uses PMA_DBI_query()
+ * @return boolean - success/failure of query execution
+*/
+function PMA_BS_SetFieldReferences($val)
+{
+ // load PMA configuration
+ $PMA_Config = $_SESSION['PMA_Config'];
+
+ // return if unable to load PMA configuration
+ if (empty($PMA_Config))
+ return FALSE;
+
+ // set field references to value specified
+ $query = "SET GLOBAL " . $PMA_Config->get('PBMS_NAME') . "_field_references=" . PMA_sqlAddslashes($val);
+ $result = PMA_DBI_query($query);
+
+ // return success of query execution
+ if ($result)
+ 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 = $_SESSION['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 = $_SESSION['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 = $_SESSION['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 = $_SESSION['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 = $_SESSION['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 = $_SESSION['PMA_Config'];
+
+ // return if unable to load PMA configuration
+ if (empty($PMA_Config))
+ return '';
+
+ // generate bs reference link
+ $bs_ref_link = 'http://' . $PMA_Config->get('BLOBSTREAMING_SERVER') . '/' . $bs_reference;
+
+ // select specified database
+ PMA_DBI_select_db($db_name);
+
+ $pbms_repo_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_repository");
+ $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)
+ $content_type = isset($data['Custom_type']) ? $data['Custom_type'] : $data['Content_type'];
+
+ if (!$content_type)
+ $content_type = NULL;
+
+ $output = "$content_type";
+
+ // 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 .= ' (View Image)';
+ break;
+ // audio content
+ case 'audio/mpeg':
+ $output .= ' (Play Audio)';
+ break;
+ // video content
+ case 'application/x-flash-video':
+ case 'video/mpeg':
+ $output .= ' (View Video)';
+ break;
+ // unsupported content. specify download
+ default:
+ $output .= ' (Download File)';
+ }
+
+ // return HTML
+ return $output;
+ } // end if ($data = @PMA_DBI_fetch_assoc($result))
+
+ // return on error
+ return 'Error';
+}
+
+?>
diff --git a/libraries/common.inc.php b/libraries/common.inc.php
index 30ebbf3fc..227340e83 100644
--- a/libraries/common.inc.php
+++ b/libraries/common.inc.php
@@ -8,7 +8,7 @@
*
* Order of sections for common.inc.php:
*
- * the authentication libraries must be loaded before db connections
+ * the authentication libraries must be before the connection to db
*
* ... so the required order is:
*
@@ -40,6 +40,7 @@ require_once './libraries/Error_Handler.class.php';
* initialize the error handler
*/
$GLOBALS['error_handler'] = new PMA_Error_Handler();
+$cfg['Error_Handler']['display'] = TRUE;
// at this point PMA_PHP_INT_VERSION is not yet defined
if (version_compare(phpversion(), '6', 'lt')) {
@@ -409,6 +410,10 @@ if (! PMA_isValid($_REQUEST['token']) || $_SESSION[' PMA_token '] != $_REQUEST['
'pma_lang', 'pma_charset', 'pma_collation_connection',
/* Possible login form */
'pma_servername', 'pma_username', 'pma_password',
+ /* rajk - for playing blobstreamable media */
+ 'media_type', 'bs_reference',
+ /* rajk - for changing BLOB repository file MIME type */
+ 'bs_db', 'bs_table', 'bs_ref', 'bs_new_mime_type'
);
/**
* Require cleanup functions
@@ -703,7 +708,7 @@ $GLOBALS['pmaThemeImage'] = $_SESSION['PMA_Theme']->getImgPath();
if (@file_exists($_SESSION['PMA_Theme']->getLayoutFile())) {
include $_SESSION['PMA_Theme']->getLayoutFile();
/**
- * @todo remove if all themes are updated to use Navi instead of Left as frame name
+ * @todo remove if all themes are update use Navi instead of Left as frame name
*/
if (! isset($GLOBALS['cfg']['NaviWidth'])
&& isset($GLOBALS['cfg']['LeftWidth'])) {
@@ -931,6 +936,13 @@ if (! defined('PMA_MINIMUM_COMMON')) {
unset($_SESSION['profiling']);
}
+ // rajk - library file for blobstreaming
+ require_once './libraries/blobstreaming.lib.php';
+
+ // rajk - checks for blobstreaming plugins and databases that support
+ // blobstreaming (by having the necessary tables for blobstreaming)
+ if (checkBLOBStreamingPlugins())
+ checkBLOBStreamableDatabases();
} // end if !defined('PMA_MINIMUM_COMMON')
// remove sensitive values from session
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index 47588d73c..1f3ef0910 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -748,7 +748,23 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
$table_groups = array();
+ // for blobstreaming - list of blobstreaming tables - rajk
+
+ // load PMA configuration
+ $PMA_Config = $_SESSION['PMA_Config'];
+
+ // if PMA configuration exists
+ if (!empty($PMA_Config))
+ $session_bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
+
foreach ($tables as $table_name => $table) {
+ // if BS tables exist
+ if (isset($session_bs_tables))
+ // compare table name to tables in list of blobstreaming tables
+ 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
if (null === $table['Rows']) {
@@ -764,7 +780,7 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
if ($tbl_is_view) {
$table['Rows'] = PMA_Table::countRecords($db, $table['Name'],
- $return = true);
+ $return = true);
}
}
@@ -1091,7 +1107,7 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice')
if (! empty($cfg['SQLQuery']['Explain']) && ! $query_too_big) {
$explain_params = $url_params;
// Detect if we are validating as well
- // To preserve the validate URL data
+ // To preserve the validate uRL data
if (! empty($GLOBALS['validatequery'])) {
$explain_params['validatequery'] = 1;
}
@@ -1490,7 +1506,7 @@ function PMA_getTab($tab)
$tab = array_merge($defaults, $tab);
- // determine additional style-class
+ // determine additionnal style-class
if (empty($tab['class'])) {
if ($tab['text'] == $GLOBALS['strEmpty']
|| $tab['text'] == $GLOBALS['strDrop']) {
diff --git a/libraries/config.default.php b/libraries/config.default.php
index 18b90e573..fe4b6899e 100644
--- a/libraries/config.default.php
+++ b/libraries/config.default.php
@@ -129,6 +129,12 @@ $cfg['Servers'][$i]['connect_type'] = 'tcp';
*/
$cfg['Servers'][$i]['extension'] = 'mysql';
+/* rajk - added for blobstreaming */
+$cfg['Servers'][$i]['bs_garbage_threshold'] = '';
+$cfg['Servers'][$i]['bs_repository_threshold'] = '';
+$cfg['Servers'][$i]['bs_temp_blob_timeout'] = '';
+$cfg['Servers'][$i]['bs_temp_log_threshold'] = '';
+
/**
* Use compressed protocol for the MySQL connection (requires PHP >= 4.3.0)
*
diff --git a/libraries/core.lib.php b/libraries/core.lib.php
index daa2ae4da..a01d08a1d 100644
--- a/libraries/core.lib.php
+++ b/libraries/core.lib.php
@@ -297,6 +297,33 @@ function PMA_getTableCount($db)
null, PMA_DBI_QUERY_STORE);
if ($tables) {
$num_tables = PMA_DBI_num_rows($tables);
+
+ // for blobstreaming - get blobstreaming tables
+ // for use in determining if a table here is a blobstreaming table - rajk
+
+ // load PMA configuration
+ $PMA_Config = $_SESSION['PMA_Config'];
+
+ // if PMA configuration exists
+ if (!empty($PMA_Config))
+ {
+ // load BS tables
+ $session_bs_tables = $_SESSION['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);
} else {
$num_tables = 0;
@@ -472,9 +499,9 @@ function PMA_checkPageValidity(&$page, $whitelist)
}
/**
- * tries to find the value for the given environment variable name
+ * trys to find the value for the given environment vriable name
*
- * searches in $_SERVER, $_ENV then tries getenv() and apache_getenv()
+ * searchs in $_SERVER, $_ENV than trys getenv() and apache_getenv()
* in this order
*
* @uses $_SERVER
@@ -517,7 +544,7 @@ function PMA_removeCookie($cookie)
}
/**
- * sets cookie if value is different from current cookie value,
+ * sets cookie if value is different from current cokkie value,
* or removes if value is equal to default
*
* @uses PMA_Config::isHttps()
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index a1a6ce64c..8b1ef45c3 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -1223,7 +1223,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$nowrap = ' nowrap';
$where_comparison = ' = ' . $row[$i];
- $vertical_display['data'][$row_no][$i] = ' | ' . "\n";
}
@@ -1235,7 +1235,56 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// TEXT fields type so we have to ensure it's really a BLOB
$field_flags = PMA_DBI_field_flags($dt_result, $i);
if (stristr($field_flags, 'BINARY')) {
- $blobtext = PMA_handle_non_printable_contents('BLOB', (isset($row[$i]) ? $row[$i] : ''), $transform_function, $transform_options, $default_function, $meta);
+ // rajk - for blobstreaming
+
+ $bs_reference_exists = $allBSTablesExist = FALSE;
+
+ // load PMA configuration
+ $PMA_Config = $_SESSION['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
+ $blobtext = PMA_handle_non_printable_contents('BLOB', (isset($row[$i]) ? $row[$i] : ''), $transform_function, $transform_options, $default_function, $meta);
+
$vertical_display['data'][$row_no][$i] = ' ' . $blobtext . ' | ';
unset($blobtext);
} else {
@@ -1290,7 +1339,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// loic1: do not wrap if date field type
$nowrap = ((preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap) ? ' nowrap' : '');
$where_comparison = ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
- $vertical_display['data'][$row_no][$i] = ' | ' . "\n";
@@ -2159,13 +2208,12 @@ function PMA_handle_non_printable_contents($category, $content, $transform_funct
* @param string $map
* @param string $data
* @param string $transform_function
- * @param string $transform_options
* @param string $default_function
* @param string $nowrap
* @param string $where_comparison
* @return string formatted data
*/
-function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $transform_options, $default_function, $nowrap, $where_comparison) {
+function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison) {
// continue the tag started before calling this function:
$result = $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . $nowrap . '">';
diff --git a/libraries/header_scripts.inc.php b/libraries/header_scripts.inc.php
index 88e48d102..2fd4b03da 100644
--- a/libraries/header_scripts.inc.php
+++ b/libraries/header_scripts.inc.php
@@ -75,9 +75,17 @@ if (in_array('functions.js', $GLOBALS['js_include'])) {
if ($GLOBALS['cfg']['Confirm']) {
$GLOBALS['js_messages']['strDoYouReally'] = $GLOBALS['strDoYouReally'];
$GLOBALS['js_messages']['strDropDatabaseStrongWarning'] = $GLOBALS['strDropDatabaseStrongWarning'];
+
+ // rajk - for blobstreaming
+ $GLOBALS['js_messages']['strBLOBRepositoryDisableStrongWarning'] = $GLOBALS['strBLOBRepositoryDisableStrongWarning'];
+ $GLOBALS['js_messages']['strBLOBRepositoryDisableAreYouSure'] = sprintf($GLOBALS['strBLOBRepositoryDisableAreYouSure'], $GLOBALS['db']);
} else {
$GLOBALS['js_messages']['strDoYouReally'] = '';
$GLOBALS['js_messages']['strDropDatabaseStrongWarning'] = '';
+
+ // rajk - for blobstreaming
+ $GLOBALS['js_messages']['strBLOBRepositoryDisableStrongWarning'] = '';
+ $GLOBALS['js_messages']['strBLOBRepositoryDisableAreYouSure'] = '';
}
} elseif (in_array('indexes.js', $GLOBALS['js_include'])) {
$GLOBALS['js_messages']['strFormEmpty'] = $GLOBALS['strFormEmpty'];
diff --git a/scripts/setup.php b/scripts/setup.php
index 68412e515..075757c82 100644
--- a/scripts/setup.php
+++ b/scripts/setup.php
@@ -999,6 +999,12 @@ function show_server_form($defaults = array(), $number = FALSE) {
array('Server socket', 'socket', 'Socket on which MySQL server is listening, leave empty for default'),
array('Connection type', 'connect_type', 'How to connect to server, keep tcp if unsure', array('tcp', 'socket')),
array('PHP extension to use', 'extension', 'What PHP extension to use, use mysqli if supported', array('mysql', 'mysqli')),
+ /* added by rajk - for blobstreaming */
+ array('PBMS Garbage Threshold', 'bs_garbage_threshold', 'The size in percentage of the garbage level of a BLOB repository file that must be reached for compaction'),
+ array('PBMS Repository Threshold', 'bs_repository_threshold', 'The size in bytes of a repository file before it is unlocked'),
+ array('PBMS Temporary BLOB Timeout', 'bs_temp_blob_timeout', 'The time in seconds before a temporary BLOB reference is scheduled for deletion'),
+ array('PBMS Temporary Log Threshold', 'bs_temp_log_threshold', 'The maximum size in bytes of a PBMS temporary log file'),
+ /* end of blobstreaming additions */
array('Compress connection', 'compress', 'Whether to compress connection to MySQL server', FALSE),
array('Authentication type', 'auth_type', 'Authentication method to use', array('cookie', 'http', 'config', 'signon')),
array('User for config auth', 'user', 'Leave empty if not using config auth'),
diff --git a/tbl_change.php b/tbl_change.php
index bf3e363ea..e63ebb8df 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -790,13 +790,68 @@ foreach ($rows as $row_id => $vrow) {
if (($cfg['ProtectBinary'] && $field['is_blob'])
|| ($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) {
echo "\n";
- echo $strBinaryDoNotEdit;
- if (isset($data)) {
- $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
- echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
- unset($data_size);
+ // rajk - for blobstreaming
+ $bs_reference_exists = FALSE;
+
+ if (isset ($tbl_type) && strlen ($tbl_type) > 0)
+ {
+ // load PMA_Config
+ $PMA_Config = $_SESSION['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 '';
+ echo ' ' . $strBLOBRepositoryRemove . " ";
+ echo PMA_BS_CreateReferenceLink($data, $db);
+ echo " ";
}
- echo "\n";
+ else
+ {
+ echo $strBinaryDoNotEdit;
+ if (isset($data)) {
+ $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
+ echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
+ unset($data_size);
+ }
+ echo "\n";
+ } // end if ($bs_reference_exists)
?>
@@ -834,6 +889,66 @@ foreach ($rows as $row_id => $vrow) {
// (displayed whatever value the ProtectBinary has)
if ($is_upload && $field['is_blob']) {
+ // added by rajk
+ // check if field type is of longblob
+ if ($field['pma_type'] == "longblob")
+ {
+ if (isset ($tbl_type) && strlen ($tbl_type) > 0)
+ {
+ // load PMA Config
+ $PMA_Config = $_SESSION['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 ' ';
+ echo ' ' . $strBLOBRepositoryUpload;
+ } // 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 ' ';
echo ' ';
diff --git a/tbl_replace.php b/tbl_replace.php
index 82c273b33..c8a5edbe7 100644
--- a/tbl_replace.php
+++ b/tbl_replace.php
@@ -35,6 +35,7 @@
* @uses $GLOBALS['table']
* @uses $GLOBALS['goto']
* @uses $GLOBALS['sql_query']
+ * @uses PMA_File::getRecentBLOBReference()
*/
/**
@@ -199,10 +200,41 @@ foreach ($loop_array as $rowcount => $primary_key) {
? $_REQUEST['auto_increment']['multi_edit'][$rowcount]
: null;
+ $primary_field = PMA_BS_GetPrimaryField($GLOBALS['db'], $GLOBALS['table']);
+
foreach ($me_fields as $key => $val) {
require './libraries/tbl_replace_fields.inc.php';
+ // rajk - for blobstreaming
+ if (NULL != $primary_field || strlen($primary_field) > 0)
+ {
+ $remove_blob_repo = isset($_REQUEST['remove_blob_repo_' . $key]) ? $_REQUEST['remove_blob_repo_' . $key] : NULL;
+ $upload_blob_repo = isset($_REQUEST['upload_blob_repo_' . $key]) ? $_REQUEST['upload_blob_repo_' . $key] : NULL;
+
+ // checks if an existing blob repository reference should be removed
+ if (isset($remove_blob_repo) && !isset($upload_blob_repo))
+ {
+ $remove_blob_reference = $_REQUEST['remove_blob_ref_' . $key];
+
+ if (isset($remove_blob_reference))
+ $val = "''";
+ }
+
+ // checks if this field requires a bs reference attached to it
+ $requires_bs_reference = isset($upload_blob_repo);
+
+ if ($requires_bs_reference)
+ {
+ // get the most recent BLOB reference
+ $bs_reference = PMA_File::getRecentBLOBReference();
+
+ // if the most recent BLOB reference exists, set it as a field value
+ if (!is_null($bs_reference))
+ $val = "'" . PMA_sqlAddslashes($bs_reference) . "'";
+ }
+ }
+
if (empty($me_funcs[$key])) {
$cur_value = $val;
} elseif ('UNIX_TIMESTAMP' === $me_funcs[$key] && $val != "''") {
|