Changeset 784 in svn for branches/1.3/admin/common.php


Ignore:
Timestamp:
2011-04-22T17:18:42+02:00 (4 years ago)
Author:
Xuefer
Message:

merge from trunk

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/admin/common.php

    r625 r784  
    11<?php
     2
     3function xcache_validateFileName($name)
     4{
     5    return preg_match('!^[a-zA-Z0-9._-]+$!', $name);
     6}
    27
    38function get_language_file_ex($name, $l, $s)
     
    1621        $l = $lmap[$l];
    1722    }
    18     if (file_exists($file = "$name-$l-$s.lang.php")) {
     23    $file = "$name-$l-$s.lang.php";
     24    if (xcache_validateFileName($file) && file_exists($file)) {
    1925        return $file;
    2026    }
    2127    if (isset($smap[$s])) {
    2228        $s = $smap[$s];
    23         if (file_exists($file = "$name-$l-$s.lang.php")) {
     29        $file = "$name-$l-$s.lang.php";
     30        if (xcache_validateFileName($file) && file_exists($file)) {
    2431            return $file;
    2532        }
    2633    }
    27     if (file_exists($file = "$name-$l.lang.php")) {
     34    $file = "$name-$l.lang.php";
     35    if (xcache_validateFileName($file) && file_exists($file)) {
    2836        return $file;
    2937    }
     
    3947        $file = get_language_file_ex($name, $l, $s);
    4048        if (!isset($file)) {
    41             $l = strtok($l, '-');
     49            $l = strtok($l, ':-');
    4250            $file = get_language_file_ex($name, $l, $s);
    4351        }
     
    4553    else if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    4654        foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $l) {
    47             $l = strtok($l, ';');
     55            $l = strtok($l, ':;');
    4856            $file = get_language_file_ex($name, $l, $s);
    4957            if (isset($file)) {
     
    5260            }
    5361            if (strpos($l, '-') !== false) {
    54                 $ll = strtok($l, '-');
     62                $ll = strtok($l, ':-');
    5563                $file = get_language_file_ex($name, $ll, $s);
    5664                if (isset($file)) {
Note: See TracChangeset for help on using the changeset viewer.