PEAK XOOPS - Re: Easiestml hack and xoops languages in englishin japanese

Re: Easiestml hack and xoops languages

List posts in the topic

question Re: Easiestml hack and xoops languages

msg# 1.2.1.1.1.1
depth:
5
Previous post - Next post | Parent - Children.1 | Posted on 2005/4/5 17:35
GIJOE  ÀèǤ·³Áâ   Posts: 4110
make diff.
That's all.

*** common.php	Tue Mar 29 05:32:52 2005
--- common.php.nobunobu	Mon Apr  4 16:32:26 2005
***************
*** 119,146 ****
  	$xoopsConfig['xoops_url'] = XOOPS_URL;
  	$xoopsConfig['root_path'] = XOOPS_ROOT_PATH."/";
  
- 
- 	// #################### Include site-wide lang file ##################
- 	if ( file_exists(XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/global.php") ) {
- 		include_once XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/global.php";
- 	} else {
- 		include_once XOOPS_ROOT_PATH."/language/english/global.php";
- 	}
- 
- 	// ################ Include page-specific lang file ################
- 	if (isset($xoopsOption['pagetype']) && false === strpos($xoopsOption['pagetype'], '.')) {
- 		if ( file_exists(XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/".$xoopsOption['pagetype'].".php") ) {
- 			include_once XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/".$xoopsOption['pagetype'].".php";
- 		} else {
- 			include_once XOOPS_ROOT_PATH."/language/english/".$xoopsOption['pagetype'].".php";
- 		}
- 	}
- 	$xoopsOption = array();
- 
- 	if ( !defined("XOOPS_USE_MULTIBYTES") ) {
- 		define("XOOPS_USE_MULTIBYTES",0);
- 	}
- 
  	/**#@+
  	 * Host abstraction layer
  	 */
--- 119,124 ----
***************
*** 263,268 ****
--- 241,308 ----
  			$xoopsUserIsAdmin = $xoopsUser->isAdmin();
  		}
  	}
+ 	/**
+ 	* Modify for The Easiest MultiLanguag Hack Enhancement for XOOPS by nobunobu
+ 	* Original is XOOPS Multilanguages by marcan
+ 	* Set the languages files, language cookie, etc...
+ 	**/
+ 	
+ 	// Validation to be sure that no malicious code is include in sel_lang
+ 	function validateLanguage($easiestml_lang = '')
+ 	{
+ 		include_once XOOPS_ROOT_PATH."/class/xoopslists.php";
+ 		$easiestml_langs = explode(',', EASIESTML_LANGS);
+ 		$idx = array_search($easiestml_lang,  $easiestml_langs);
+ 		$easiestml_langnames = explode(',', EASIESTML_LANGNAMES);
+ 		$easiestml_langname = $easiestml_langnames[$idx];
+ 		$lang_available = XoopsLists::getLangList();
+ 
+ 		If ( ($easiestml_langname != '') && (in_array($easiestml_langname, $lang_available)) ) {
+ 			return $easiestml_langname;
+ 		}
+ 		return false;
+ 	}
+ 	
+ 	// If user just switched language, do the change
+ 	if ((!empty($_GET['easiestml_lang'])) && ($easiestml_langname = validateLanguage($_GET['easiestml_lang']))) {
+ 		$xoopsConfig['language'] = $easiestml_langname;
+ 		
+ 		// Save this preference in a cookie, for when user is not logged in yet
+ 		$xoops_cookie_path = defined('XOOPS_COOKIE_PATH') ? XOOPS_COOKIE_PATH : preg_replace( '?http://[^/]+(/.*)$?' , "$1" , XOOPS_URL ) ;
+ 		if( $xoops_cookie_path == XOOPS_URL ) $xoops_cookie_path = '/' ;
+ 		setcookie('easiestml_langname', $easiestml_langname, time() + EASIESTML_COOKIELIFETIME, $xoops_cookie_path, '' , 0);
+ 
+ 		unset($_GET['easiestml_lang']);
+ 		$_SERVER['QUERY_STRING'] = preg_replace('/(^|&)easiestml_lang\=.*$/','',$_SERVER['QUERY_STRING']);
+ 		$_SERVER['argv'][0] = preg_replace('/(^|&)easiestml_lang\=.*$/','',$_SERVER['argv'][0]);;
+ 	} else {
+ 		// The user is anonymous, retreive the selected language from the cookie
+ 		if ((isset($_COOKIE['easiestml_langname'])) && ($_COOKIE['easiestml_langname'] > '')) {
+ 			$xoopsConfig['language'] = $_COOKIE['easiestml_langname'];
+ 		}
+ 		/** End of The Easiest ML enhancement Hack by nobunobu **/
+ 	}
+ 	
+ 	// #################### Include site-wide lang file ##################
+ 	if ( file_exists(XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/global.php") ) {
+ 		include_once XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/global.php";
+ 	} else {
+ 		include_once XOOPS_ROOT_PATH."/language/english/global.php";
+ 	}
+ 	
+ 	// ################ Include page-specific lang file ################
+ 	if (isset($xoopsOption['pagetype']) && false === strpos($xoopsOption['pagetype'], '.')) {
+ 		if ( file_exists(XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/".$xoopsOption['pagetype'].".php") ) {
+ 			include_once XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/".$xoopsOption['pagetype'].".php";
+ 		} else {
+ 			include_once XOOPS_ROOT_PATH."/language/english/".$xoopsOption['pagetype'].".php";
+ 		}
+ 	}
+ 	$xoopsOption = array();
+ 	
+ 	if ( !defined("XOOPS_USE_MULTIBYTES") ) {
+ 		define("XOOPS_USE_MULTIBYTES",0);
+ 	}
  	if (!empty($_POST['xoops_theme_select']) && in_array($_POST['xoops_theme_select'], $xoopsConfig['theme_set_allowed'])) {
  		$xoopsConfig['theme_set'] = $_POST['xoops_theme_select'];
  		$_SESSION['xoopsUserTheme'] = $_POST['xoops_theme_select'];
Votes:1 Average:0.00

Posts tree

  Advanced search


Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!