⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 languages.lib.php3

📁 使用PHP编程的聊天室
💻 PHP3
字号:
<?php
if (!isset($ChatPath)) $ChatPath = "";

// Available languages
$AvailableLanguages = array();
$languageDirectories = dir('./'.$ChatPath.'localization/');
while($name = $languageDirectories->read())
{
	if(is_dir('./'.$ChatPath.'localization/'.$name)
		&& file_exists('./'.$ChatPath.'localization/'.$name.'/regex.txt')
		&& file_exists('./'.$ChatPath.'localization/'.$name.'/localized.chat.php3')
		&& file_exists('./'.$ChatPath.'localization/'.$name.'/flag.gif'))
	{
		list($key) = file('./'.$ChatPath.'localization/'.$name.'/regex.txt');
		$AvailableLanguages[$key] = $name;
	};
};
$languageDirectories->close();
if (!function_exists("krsort")) include("./${ChatPath}localization/sort_languages.php3");
krsort($AvailableLanguages);

function Detect($Str,$From)
{
	global $AvailableLanguages;
	global $L;

	$NotFound = true;
	reset($AvailableLanguages);
	while($NotFound && list($key, $name) = each($AvailableLanguages))
	{
		if (($From == 1 && eregi("^".$key."$",$Str)) || ($From == 2 && eregi("(\(|\[|;[[:space:]])".$key."(;|\]|\))",$Str)))
		{
			$L = $AvailableLanguages[$key];
			$NotFound = false;
		};
	};
};

// finds the appropriate language file
if (isset($HTTP_COOKIE_VARS["CookieLang"])) $CookieLang = $HTTP_COOKIE_VARS["CookieLang"];
if ((isset($L) && $L != "") || C_MULTI_LANG == 0)
{
}	
elseif (isset($CookieLang) && file_exists('./'.$ChatPath.'localization/'.$CookieLang.'/localized.chat.php3'))
{
	$L = $CookieLang;
}
elseif (getenv("HTTP_ACCEPT_LANGUAGE") != "")
{	
	$Accepted = explode(",", getenv("HTTP_ACCEPT_LANGUAGE"));
	Detect($Accepted[0],1);
}
elseif (getenv("HTTP_USER_AGENT") != "")
{	
	Detect(getenv("HTTP_USER_AGENT"),2);
};

//if no language detected set default one
if (!isset($L)) $L = C_LANGUAGE;

//put language in a cookie
setcookie("CookieLang", $L, time() + 60*60*24*365);		// cookie expires in one year
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -