File:  [mozdev] / boincuserstats / www / cn.inc
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Tue Mar 1 23:14:04 2005 UTC (12 years, 9 months ago) by tamcap
Branches: MAIN
CVS tags: HEAD
cn bug

<?php
function getit()
{
	$myvar = explode("=",$_SERVER['QUERY_STRING']);
	return $myvar[count($myvar)-1];
}
function get_lang($acc_l)
{
	/*TODO - make the $acc_l depend on available files!!! - this will require an argument??*/
	
	//$acc_l = array("en","pl"); //an array of accepted languages. The $acc_l[0] is treated as a default one - thus if $langs doesn't contain any language that we support, the default one will be served.
	$langs = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); //array of accepted languages is created. Now we have to go through it and try to match any 
	for($i=0;$i<count($langs);$i++)
	{
		$exp = explode(";",$langs[$i]);
		if (in_array($exp[0],$acc_l)) //check if we got it in accepted languages
		{
			$lang = $exp[0];
			break; //set it and leave
		}
	}
	if(!$lang)
		$lang=$acc_l[0]; //getting the default value
return $lang;
}
function get_my_name()
{
	$look_for = basename(getit(),get_my_ending()); //what file was requested?
	return $look_for;
}
function get_my_ending()
{
	$dotarray = explode(".",getit());
	$fileending = $dotarray[(count($dotarray)-1)];
	return $fileending;
}
function get_avail()
{
	$def_lang = "en";
	$look_for = get_my_name();
	$dir_list = explode("\n",`ls | grep $look_for`); //what files we have?
	if($def_lang)
		$match[0] = $def_lang;
	else
		$match[0] = "";
	for ($i=0;$i<count($dir_list);$i++)
	{
	 $what = explode(".",$dir_list[$i]);
	 if (count($what)>2)
	 	$match[] = $what[count($what)-2];
	}
	return $match;
}
?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>