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

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

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