diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index f87f3d18c..92aea60f8 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -310,6 +310,96 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $rs, $userl
return $dblist;
}
+/**
+ * Converts numbers like 10M into bytes
+ *
+ * @param string $size
+ * @return integer $size
+ */
+function get_real_size( $size = 0 ) {
+ if ( ! $size ) {
+ return 0;
+ }
+ $scan['MB'] = 1048576;
+ $scan['Mb'] = 1048576;
+ $scan['M'] = 1048576;
+ $scan['m'] = 1048576;
+ $scan['KB'] = 1024;
+ $scan['Kb'] = 1024;
+ $scan['K'] = 1024;
+ $scan['k'] = 1024;
+
+ while ( list( $key ) = each( $scan ) ) {
+ if ( ( strlen( $size ) > strlen( $key ) )
+ && ( substr( $size, strlen( $size ) - strlen( $key ) ) == $key ) ) {
+ $size = substr($size, 0, strlen($size) - strlen($key)) * $scan[$key];
+ break;
+ }
+ }
+ return $size;
+} // end function get_real_size()
+
+/**
+ * loads php module
+ *
+ * @uses PHP_OS
+ * @uses extension_loaded()
+ * @uses ini_get()
+ * @uses function_exists()
+ * @uses ob_start()
+ * @uses phpinfo()
+ * @uses strip_tags()
+ * @uses ob_get_contents()
+ * @uses ob_end_clean()
+ * @uses preg_match()
+ * @uses strtoupper()
+ * @uses substr()
+ * @uses dl()
+ * @param string $module name if module to load
+ * @return boolean success loading module
+ */
+function PMA_dl( $module ) {
+
+ static $dl_allowed = NULL;
+
+ if ( extension_loaded( $module ) ) {
+ return true;
+ }
+
+ if ( NULL === $dl_allowed ) {
+ if ( ! @ini_get('safe_mode')
+ && @ini_get('enable_dl')
+ && @function_exists('dl') ) {
+ ob_start();
+ phpinfo(INFO_GENERAL); /* Only general info */
+ $a = strip_tags(ob_get_contents());
+ ob_end_clean();
+ if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {
+ if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {
+ $dl_allowed = TRUE;
+ } else {
+ $dl_allowed = FALSE;
+ }
+ } else {
+ $dl_allowed = TRUE;
+ }
+ } else {
+ $dl_allowed = FALSE;
+ }
+ }
+
+ if ( ! $dl_allowed ) {
+ return false;
+ }
+
+ if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) {
+ $module_file = 'php_' . $module . '.dll';
+ } else {
+ $module_file = $module . '.so';
+ }
+
+ return @dl( $module_file );
+}
/**
* include here only libraries which contain only function definitions
@@ -319,36 +409,11 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $rs, $userl
require_once('./libraries/sanitizing.lib.php');
require_once('./libraries/Theme.class.php');
require_once('./libraries/Theme_Manager.class.php');
+require_once('./libraries/Config.class.php');
if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
- /**
- * @TODO add documentation
- */
- function get_real_size($size=0) {
- /// Converts numbers like 10M into bytes
- if (!$size) {
- return 0;
- }
- $scan['MB'] = 1048576;
- $scan['Mb'] = 1048576;
- $scan['M'] = 1048576;
- $scan['m'] = 1048576;
- $scan['KB'] = 1024;
- $scan['Kb'] = 1024;
- $scan['K'] = 1024;
- $scan['k'] = 1024;
-
- while (list($key) = each($scan)) {
- if ((strlen($size)>strlen($key))&&(substr($size, strlen($size) - strlen($key))==$key)) {
- $size = substr($size, 0, strlen($size) - strlen($key)) * $scan[$key];
- break;
- }
- }
- return $size;
- } // end function
-
/**
* Displays the maximum size for an upload
*
@@ -791,14 +856,12 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
} // end function
/**
- * Send HTTP header, taking IIS limits into account
- * ( 600 seems ok)
- *
- * @param string the header to send
+ * Send HTTP header, taking IIS limits into account ( 600 seems ok)
*
+ * @param string $uri the header to send
* @return boolean always true
*/
- function PMA_sendHeaderLocation($uri)
+ function PMA_sendHeaderLocation( $uri )
{
if (PMA_IS_IIS && strlen($uri) > 600) {
@@ -1760,7 +1823,8 @@ window.parent.updateTableTitle( '', '', ' $par_value ) {
// htmlentities() only on non javascript
- $par_value = substr( $par_name,0 ,2 ) == 'on' ? $par_value : htmlentities( $par_value );
+ $par_value = substr( $par_name,0 ,2 ) == 'on'
+ ? $par_value
+ : htmlentities( $par_value );
$tag_params_strings[] = $par_name . '="' . $par_value . '"';
}
// previously the limit was set to 2047, it seems 1000 is better
if (strlen($url) <= 1000) {
- $ret = '' . "\n"
- . ' ' . $message . '' . "\n";
+ $ret = '' . "\n"
+ . ' ' . $message . '' . "\n";
}
else {
// no spaces (linebreaks) at all
@@ -1819,23 +1886,32 @@ window.parent.updateTableTitle( '', '';
+ $ret .= '';
} // end while
if (stristr($message, '
';
+ $ret .= '';
} else {
- $ret .= '';
+ $ret .= '';
}
} else {
$message = trim( strip_tags( $message ) );
- $ret .= '';
+ $ret .= '';
}
if ($new_form) {
$ret .= '';
@@ -1872,9 +1948,11 @@ window.parent.updateTableTitle( '', '\n")
@@ -2070,17 +2148,26 @@ window.parent.updateTableTitle( '', ' */
/* IE has trouble with