Annotation of boincuserstats/www/cn.inc, revision 1.2

1.1       tamcap      1: <?php
1.2     ! tamcap      2: function getit()
        !             3: {
        !             4:        $myvar = explode("=",$_SERVER['QUERY_STRING']);
        !             5:        return $myvar[count($myvar)-1];
        !             6: }
        !             7: $get_it = getit();
1.1       tamcap      8: function get_lang($acc_l)
                      9: {
                     10:        /*TODO - make the $acc_l depend on available files!!! - this will require an argument??*/
                     11:        
                     12:        //$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.
                     13:        $langs = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); //array of accepted languages is created. Now we have to go through it and try to match any 
                     14:        for($i=0;$i<count($langs);$i++)
                     15:        {
                     16:                $exp = explode(";",$langs[$i]);
                     17:                if (in_array($exp[0],$acc_l)) //check if we got it in accepted languages
                     18:                {
                     19:                        $lang = $exp[0];
                     20:                        break; //set it and leave
                     21:                }
                     22:        }
                     23:        if(!$lang)
                     24:                $lang=$acc_l[0]; //getting the default value
                     25: return $lang;
                     26: }
                     27: function get_my_name()
                     28: {
1.2     ! tamcap     29:        $look_for = basename($get_it,get_my_ending()); //what file was requested?
1.1       tamcap     30:        return $look_for;
                     31: }
                     32: function get_my_ending()
                     33: {
1.2     ! tamcap     34:        $dotarray = explode(".",$get_it);
1.1       tamcap     35:        $fileending = $dotarray[(count($dotarray)-1)];
                     36:        return $fileending;
                     37: }
                     38: function get_avail()
                     39: {
                     40:        $look_for = get_my_name();
                     41:        $dir_list = explode("\n",`ls | grep $look_for`); //what files we have?
                     42:        if($def_lang)
                     43:                $match[0] = $def_lang;
                     44:        else
                     45:                $match[0] = "";
                     46:        for ($i=0;$i<count($dir_list);$i++)
                     47:        {
                     48:         $what = explode(".",$dir_list[$i]);
                     49:         if ((count($what)>2)&&($what[count($what)-2]!=$match[0]))
                     50:                $match[] = $what[count($what)-2];
                     51:        }
                     52:        return $match;
                     53: }
                     54: ?>

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