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

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

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