[Phpfreechat-svn] SF.net SVN: phpfreechat: [1020] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-04-18 15:25:30
|
Revision: 1020 http://svn.sourceforge.net/phpfreechat/?rev=1020&view=rev Author: kerphi Date: 2007-04-18 08:25:30 -0700 (Wed, 18 Apr 2007) Log Message: ----------- [en] Bug fix: $GLOBALS['i18n'] array could overlap with external codes, now pfc uses $GLOBALS[$serverid]['i18n'], I think it's more secure. [1h30] [fr] Bug fix : le tableau $GLOBALS['i18n'] pouvait entrer en collision avec des programmes externes, maintenant pfc utilise le tableau $GLOBALS[$serverid]['i18n'] qui permettra d'?\195?\169viter ces situations. [1h30] Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/pfci18n.class.php trunk/src/phpfreechat.class.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2007-04-18 13:59:38 UTC (rev 1019) +++ trunk/src/pfcglobalconfig.class.php 2007-04-18 15:25:30 UTC (rev 1020) @@ -147,10 +147,12 @@ var $_query_string = ''; function pfcGlobalConfig( $params = array() ) - { - // setup the local for translated messages - pfcI18N::Init(isset($params["language"]) ? $params["language"] : ""); - + { + // @todo find a cleaner way to forward serverid to i18n functions + $GLOBALS['serverid'] = isset($params['serverid']) ? $params['serverid'] : '_serverid_'; + // setup the locales for the translated messages + pfcI18N::Init(isset($params['language']) ? $params['language'] : ''); + // check the serverid is really defined if (!isset($params["serverid"])) $this->errors[] = _pfc("'%s' parameter is mandatory by default use '%s' value", "serverid", "md5(__FILE__)"); Modified: trunk/src/pfci18n.class.php =================================================================== --- trunk/src/pfci18n.class.php 2007-04-18 13:59:38 UTC (rev 1019) +++ trunk/src/pfci18n.class.php 2007-04-18 15:25:30 UTC (rev 1020) @@ -25,10 +25,11 @@ function _pfc() { $args = func_get_args(); - $args[0] = isset($GLOBALS["i18n"][$args[0]]) && $GLOBALS["i18n"][$args[0]] != "" ? + $serverid = $GLOBALS['serverid']; // serverid is used to avoid conflicts with external code using same 'i18n' key + $args[0] = isset($GLOBALS[$serverid]["i18n"][$args[0]]) && $GLOBALS[$serverid]["i18n"][$args[0]] != "" ? ($GLOBALS["output_encoding"] == "UTF-8" ? - $GLOBALS["i18n"][$args[0]] : - iconv("UTF-8", $GLOBALS["output_encoding"], $GLOBALS["i18n"][$args[0]])) : + $GLOBALS[$serverid]["i18n"][$args[0]] : + iconv("UTF-8", $GLOBALS["output_encoding"], $GLOBALS[$serverid]["i18n"][$args[0]])) : "_".$args[0]."_"; return call_user_func_array('sprintf', $args); } @@ -39,10 +40,11 @@ function _pfc2() { $args = func_get_args(); - $args[0] = isset($GLOBALS["i18n"][$args[0]]) && $GLOBALS["i18n"][$args[0]] != "" ? + $serverid = $GLOBALS['serverid']; // serverid is used to avoid conflicts with external code using same 'i18n' key + $args[0] = isset($GLOBALS[$serverid]["i18n"][$args[0]]) && $GLOBALS[$serverid]["i18n"][$args[0]] != "" ? ($GLOBALS["output_encoding"] == "UTF-8" ? - $GLOBALS["i18n"][$args[0]] : - iconv("UTF-8", $GLOBALS["output_encoding"], $GLOBALS["i18n"][$args[0]])) : + $GLOBALS[$serverid]["i18n"][$args[0]] : + iconv("UTF-8", $GLOBALS["output_encoding"], $GLOBALS[$serverid]["i18n"][$args[0]])) : "_".$args[0]."_"; return $args[0]; } @@ -61,6 +63,10 @@ require_once(dirname(__FILE__)."/../i18n/".$language."/admin.php"); else require_once(dirname(__FILE__)."/../i18n/".$language."/main.php"); + + $serverid = $GLOBALS['serverid']; // serverid is used to avoid conflicts with external code using same 'i18n' key + $GLOBALS[$serverid]['i18n'] = $GLOBALS['i18n']; // do not pass by reference because $GLOBALS['i18n'] is maybe used by unknown external code + $GLOBALS["output_encoding"] = "UTF-8"; // by default client/server communication is utf8 encoded } Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2007-04-18 13:59:38 UTC (rev 1019) +++ trunk/src/phpfreechat.class.php 2007-04-18 15:25:30 UTC (rev 1020) @@ -38,19 +38,14 @@ function phpFreeChat( &$params ) { - if (!is_object($params) && - isset($params["debug"]) && - $params["debug"]) + if (!is_array($params)) + die('phpFreeChat parameters must be an array'); + + if ( isset($params["debug"]) && $params["debug"] ) require_once dirname(__FILE__)."/../debug/log.php"; - // check if the given parameters is a simple array - // or a allready created phpfreechat object - $c = NULL; - if (is_object($params) && - get_class($params) == "pfcglobalconfig") - $c =& $params; - else - $c =& pfcGlobalConfig::Instance( $params ); + // initialize the global config object + $c =& pfcGlobalConfig::Instance( $params ); // need to initiate the user config object here because it uses sessions $u =& pfcUserConfig::Instance(); @@ -76,19 +71,11 @@ } /** - * printJavaScript must be called into html header - * usage: - * <code> - * <?php $chat->printJavascript(); ?> - * </code> + * depreciated */ function printJavaScript( $return = false ) { $output = ''; - $c =& pfcGlobalConfig::Instance(); - $u =& pfcUserConfig::Instance(); - - // display output if ($return) return $output; else @@ -96,19 +83,11 @@ } /** - * printStyle must be called in the header - * it inserts CSS in order to style the chat - * usage: - * <code> - * <?php $chat->printStyle(); ?> - * </code> + * depreciated */ function printStyle( $return = false ) { - $c =& pfcGlobalConfig::Instance(); - $output = ''; - if($return) return $output; else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |