Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for phpPlatonLib/Platon/Platon.php between version 1.14 and 1.15

version 1.14, 2003/01/22 23:50:17 version 1.15, 2003/01/26 00:21:47
Line 628  class Platon
Line 628  class Platon
         return $uri;          return $uri;
     } /* }}} */      } /* }}} */
   
       /**
        * Parses Accept-Language HTTP header.
        *
        * @param  string  $accept_lang    special Accept-Language header (if not
        *                                 present, it will be extracted from env)
        * @param  string  $strict         strict parsing (it means that in example
        *                                 "en-us" does not result into "en")
        * @return string  array of accepted languages according to Q
        */
       function parseHttpAcceptLanguage($accept_lang = null, $strict = 0) /* {{{ */
       {
           $accept_lang == null && $accept_lang = (string) @$_SERVER['HTTP_ACCEPT_LANGUAGE'];
           $accept_lang = strtolower($accept_lang);
           $accept_lang = str_replace(array("'", '"'), '', $accept_lang);
           $accepted    = split(',[[:space:]]*', $accept_lang);
           $candidates  = array();
           for ($i = 0; $i < count($accepted); $i++) {
               if (eregi('^([a-z0-9_-]+);[[:space:]]*q=([0-9\.]+)', $accepted[$i], $arr)) {
                   $q = (double)$arr[2];
                   $l = $arr[1];
               } else {
                   $q = 42.0;
                   $l = $accepted[$i];
               }
               $l = trim($l);
               if (strlen($l) <= 0) {
                   continue;
               }
               $candidates[$l] = $q;
               if (! $strict && strpos($l, '-') !== false) {
                   $l = explode('-', $l, 2);
                   $l = $l[0];
                   isset($candidates[$l]) || $candidates[$l] = $q - 0.01;
               }
           }
           arsort($candidates);
           return array_keys($candidates);
       } /* }}} */
   
       /**
        * Returns top level domain name
        *
        * @param  string  $remote_host    remote hostname (if not present, it will
        *                                 extracted from environment)
        * @return string  top level domain name
        */
       function getTopLevelDomain($remote_host = null) /* {{{ */
       {
           $remote_host == null && $remote_host = @$HTTP_SERVER_VARS['REMOTE_HOST'];
           if (empty($remote_host)) {
               $remote_host = @gethostbyaddr(@$HTTP_SERVER_VARS['REMOTE_ADDR']);
           }
           if (!empty($remote_host) && ereg("\.[^\.]+$", $remote_host, $arr)) {
               $lang = strtolower($arr[1]);
               return $lang;
           }
           return false;
       } /* }}} */
   
 }  }
   
 /* vim: set expandtab tabstop=4 shiftwidth=4:  /* vim: set expandtab tabstop=4 shiftwidth=4:

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top