|
From: Florin C B. <ory...@us...> - 2012-10-08 08:59:29
|
Update of /cvsroot/mxbb/core/includes
In directory vz-cvs-4.sog:/tmp/cvs-serv14020
Modified Files:
mx_functions.php
Log Message:
Index: mx_functions.php
===================================================================
RCS file: /cvsroot/mxbb/core/includes/mx_functions.php,v
retrieving revision 1.107
retrieving revision 1.108
diff -C2 -d -r1.107 -r1.108
*** mx_functions.php 8 Oct 2012 08:46:02 -0000 1.107
--- mx_functions.php 8 Oct 2012 08:59:27 -0000 1.108
***************
*** 40,44 ****
static $msg_history;
!
$default_lang = ($mx_user->lang['default_lang']) ? $mx_user->lang['default_lang'] : $board_config['default_lang'];
--- 40,44 ----
static $msg_history;
!
$default_lang = ($mx_user->lang['default_lang']) ? $mx_user->lang['default_lang'] : $board_config['default_lang'];
***************
*** 46,51 ****
{
$msg_history = array();
! }
!
$msg_history[] = array(
'msg_code' => $msg_code,
--- 46,51 ----
{
$msg_history = array();
! }
!
$msg_history[] = array(
'msg_code' => $msg_code,
***************
*** 56,59 ****
--- 56,63 ----
'sql' => $sql
);
+
+ //
+ //This will check whaever we are installing
+ //
if(defined('HAS_DIED'))
***************
*** 72,76 ****
$custom_error_message = sprintf($custom_error_message, '', '');
}
! echo "<html>\n<body>\n<b>Critical Error!</b><br />\nmx_message_die() was called multiple times.<br /> <hr />";
for( $i = 0; $i < count($msg_history); $i++ )
{
--- 76,80 ----
$custom_error_message = sprintf($custom_error_message, '', '');
}
! echo "<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<body>\n<b>Critical Error!</b><br />\nmx_message_die() was called multiple times.<br /> <hr />";
for( $i = 0; $i < count($msg_history); $i++ )
{
***************
*** 91,100 ****
echo " <hr />\n";
}
! echo $custom_error_message . '<hr /><br clear="all">';
die("</body>\n</html>");
}
!
define('HAS_DIED', 1);
-
$sql_store = $sql;
--- 95,103 ----
echo " <hr />\n";
}
! echo $custom_error_message . '<hr /><br clear="all" />';
die("</body>\n</html>");
}
!
define('HAS_DIED', 1);
$sql_store = $sql;
***************
*** 103,107 ****
// subsequent queries from overwriting the status of sql_error()
//
! if ( DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) )
{
$sql_error = $db->sql_error();
--- 106,110 ----
// subsequent queries from overwriting the status of sql_error()
//
! if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR))
{
$sql_error = $db->sql_error();
***************
*** 464,474 ****
$session_id = $_SID;
}
!
! if ( !empty($url) && preg_match('#'.PORTAL_URL.'#', $url) )
{
$url = preg_replace('#' . PORTAL_URL . '#', '', $url);
! }
! if ( is_array($session_id) )
{
$session_id = $mx_user->session_id;
--- 467,477 ----
$session_id = $_SID;
}
!
! if ( !empty($url) && preg_match('#'.PORTAL_URL.'#', $url) && !defined('IN_ADMIN') )
{
$url = preg_replace('#' . PORTAL_URL . '#', '', $url);
! }
! if (is_array($session_id))
{
$session_id = $mx_user->session_id;
***************
*** 552,559 ****
global $SID, $_SID, $mx_mod_rewrite, $userdata;
! if ( !empty($url) && preg_match('#'.PORTAL_URL.'#', $url) )
{
$url = preg_replace('#' . PORTAL_URL . '#', '', $url);
! }
// Is mod_rewrite enabled? If so, do some url rewrites...
--- 555,562 ----
global $SID, $_SID, $mx_mod_rewrite, $userdata;
! if ( !empty($url) && preg_match('#'.PORTAL_URL.'#', $url) && !defined('IN_ADMIN') )
{
$url = preg_replace('#' . PORTAL_URL . '#', '', $url);
! }
// Is mod_rewrite enabled? If so, do some url rewrites...
***************
*** 642,645 ****
--- 645,653 ----
mx_message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
}
+
+ if (defined('IN_ADMIN'))
+ {
+ $url = PORTAL_URL . $url;
+ }
// Redirect via an HTML form for PITA webservers
***************
*** 654,662 ****
// Behave as per HTTP/1.1 spec for others
//header('Location: ' . PORTAL_URL . $url);
! header('Location: ' . $url);
exit;
}
/**
* Generate Pagination.
*
--- 662,728 ----
// Behave as per HTTP/1.1 spec for others
//header('Location: ' . PORTAL_URL . $url);
! header('Location: ' . $url);
exit;
}
/**
+ * Generate portal url (example: http://www.example.com/phpBB)
+ * @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com)
+ */
+ function generate_portal_url($without_script_path = false)
+ {
+ global $board_config, $portal_config, $mx_user;
+
+ $script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($portal_config['script_path']));
+ $server_name = $mx_user->host ? $mx_user->host : trim($portal_config['server_name']);
+ $server_protocol = ( $portal_config['cookie_secure'] ) ? 'https://' : 'http://';
+ $server_port = (($portal_config['server_port']) && ($portal_config['server_port'] <> 80)) ? ':' . trim($portal_config['server_port']) . '/' : '/';
+ $server_url = $server_protocol . str_replace("//", "/", $server_name . $server_port . $script_name . '/'); //On some server the slash is not added and this trick will fix it
+ $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
+
+ // Forcing server vars is the only way to specify/override the protocol
+ if ($board_config['force_server_vars'] || !$server_name)
+ {
+ $server_protocol = ($server_protocol) ? $server_protocol : (($portal_config['cookie_secure']) ? 'https://' : 'http://');
+ $server_name = $portal_config['server_name'];
+ $server_port = (int) $config['server_port'];
+ $script_path = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($portal_config['script_path']));
+
+ $url = $server_protocol . $server_name;
+ $cookie_secure = $portal_config['cookie_secure'];
+ }
+ else
+ {
+ // Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection
+ $cookie_secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
+ $url = (($cookie_secure) ? 'https://' : 'http://') . $server_name;
+
+ $script_path = $mx_user->page['root_script_path'];
+ }
+
+ if ($server_port && (($cookie_secure && $server_port <> 443) || (!$cookie_secure && $server_port <> 80)))
+ {
+ // HTTP HOST can carry a port number (we fetch $user->host, but for old versions this may be true)
+ if (strpos($server_name, ':') === false)
+ {
+ $url .= ':' . $server_port;
+ }
+ }
+
+ if (!$without_script_path)
+ {
+ $url .= $script_path;
+ }
+
+ // Strip / from the end
+ if (substr($url, -1, 1) == '/')
+ {
+ $url = substr($url, 0, -1);
+ }
+
+ return $url;
+ }
+
+ /**
* Generate Pagination.
*
***************
*** 1451,1455 ****
$multiple_select_option = 'multiple="multiple"';
}
!
$column_list = '<select name="' . $name_select . '" '.$multiple_select_option.'>';
if( $type == 'page_list' )
--- 1517,1525 ----
$multiple_select_option = 'multiple="multiple"';
}
! else
! {
! $multiple_select_option = '';
! }
!
$column_list = '<select name="' . $name_select . '" '.$multiple_select_option.'>';
if( $type == 'page_list' )
***************
*** 1783,1787 ****
// $do_gzip_compress = FALSE;
! if ( $board_config['gzip_compress'] && !defined('MX_GZIP_DISABLED') )
{
$phpver = phpversion();
--- 1853,1857 ----
// $do_gzip_compress = FALSE;
! if ($board_config['gzip_compress'] && !defined('MX_GZIP_DISABLED'))
{
$phpver = phpversion();
***************
*** 1789,1795 ****
$useragent = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : getenv('HTTP_USER_AGENT');
! if ( $phpver >= '4.0.4pl1' && ( strstr($useragent,'compatible') || strstr($useragent,'Gecko') ) )
{
! if ( extension_loaded('zlib') )
{
ob_end_clean();
--- 1859,1865 ----
$useragent = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : getenv('HTTP_USER_AGENT');
! if ($phpver >= '4.0.4pl1' && (strstr($useragent,'compatible') || strstr($useragent,'Gecko')))
{
! if (extension_loaded('zlib'))
{
ob_end_clean();
***************
*** 1797,1805 ****
}
}
! else if ( $phpver > '4.0' )
{
! if ( strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') )
{
! if ( extension_loaded('zlib') )
{
$do_gzip_compress = TRUE;
--- 1867,1875 ----
}
}
! else if ($phpver > '4.0')
{
! if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
{
! if (extension_loaded('zlib') )
{
$do_gzip_compress = TRUE;
***************
*** 1816,1820 ****
// Initialize PHP session
//
! @session_start();
}
--- 1886,1892 ----
// Initialize PHP session
//
! //phpinfo();
! session_start();
! //
}
***************
*** 2051,2054 ****
--- 2123,2127 ----
$curicons = 1;
+ $posticons = '';
if ( $file_posticon == 'none' || $file_posticon == 'none.gif' or empty( $file_posticon ) )
{
***************
*** 2554,2556 ****
--- 2627,2693 ----
return $message;
}
+
+ function mx_clean_string($text)
+ {
+ global $mx_root_path, $phpEx;
+
+ //Unicode control characters
+ static $homographs = array();
+ if (empty($homographs) && ($homographs = @include($mx_root_path . 'includes/utf/data/confusables.' . $phpEx)))
+ {
+ $text = @utf8_case_fold_nfkc($text);
+ $text = strtr($text, $homographs);
+ }
+ else
+ {
+ // ASCI control characters
+ $text = preg_replace("/[^[:space:]a-zA-Z0-9åäöÅÄÖ.,-:]/", " ", $text);
+ $text = preg_replace("/[^[:space:]a-zA-Z0-9îãâºþÎêÞ.,-:]/", " ", $text);
+
+ // we need to reduce multiple spaces to a single one
+ $text = preg_replace('/\s+/', ' ', $text);
+ }
+
+ // Other control characters
+ $text = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $text);
+
+ // we need to reduce multiple spaces to a single one
+ $text = preg_replace('# {2,}#', ' ', $text);
+
+ // we can use trim here as all the other space characters should have been turned
+ // into normal ASCII spaces by now
+ return trim($text);
+ }
+
+ /**
+ * function eregi
+ *
+ * temp replacement for eregi()
+ *
+ *
+ */
+ if (!@function_exists('eregi'))
+ {
+ function eregi($find, $str)
+ {
+ return stristr($str, $find);
+ }
+ }
+
+ /**
+ * function ereg
+ *
+ * temp replacement for ereg()
+ *
+ *
+ */
+ /*
+ if(!function_exists('ereg'))
+ {
+ function ereg($pattern, $string, &$array)
+ {
+ return preg_match('#'.$pattern.'#', $string, $array);
+ }
+ }
+ */
?>
\ No newline at end of file
|