+ static $language_suffix = array(
+ // Reference: Apache 2.0.59 'AddLanguage' default
+ 'ca' => TRUE,
+ 'cs' => TRUE, // cs
+ 'cz' => TRUE, // cs
+ 'de' => TRUE,
+ 'dk' => TRUE, // da
+ 'el' => TRUE,
+ 'en' => TRUE,
+ 'eo' => TRUE,
+ 'es' => TRUE,
+ 'et' => TRUE,
+ 'fr' => TRUE,
+ 'he' => TRUE,
+ 'hr' => TRUE,
+ 'it' => TRUE,
+ 'ja' => TRUE,
+ 'ko' => TRUE,
+ 'ltz' => TRUE,
+ 'nl' => TRUE,
+ 'nn' => TRUE,
+ 'no' => TRUE,
+ 'po' => TRUE,
+ 'pt' => TRUE,
+ 'pt-br' => TRUE,
+ 'ru' => TRUE,
+ 'sv' => TRUE,
+ 'zh-cn' => TRUE,
+ 'zh-tw' => TRUE,
+
+ // Reference: Apache 2.0.59 default 'index.html' variants
+ 'ee' => TRUE,
+ 'lb' => TRUE,
+ 'var' => TRUE,
+ );
+
+ static $charset_suffix = array(
+ // Reference: Apache 2.0.59 'AddCharset' default
+ 'iso8859-1' => TRUE, // ISO-8859-1
+ 'latin1' => TRUE, // ISO-8859-1
+ 'iso8859-2' => TRUE, // ISO-8859-2
+ 'latin2' => TRUE, // ISO-8859-2
+ 'cen' => TRUE, // ISO-8859-2
+ 'iso8859-3' => TRUE, // ISO-8859-3
+ 'latin3' => TRUE, // ISO-8859-3
+ 'iso8859-4' => TRUE, // ISO-8859-4
+ 'latin4' => TRUE, // ISO-8859-4
+ 'iso8859-5' => TRUE, // ISO-8859-5
+ 'latin5' => TRUE, // ISO-8859-5
+ 'cyr' => TRUE, // ISO-8859-5
+ 'iso-ru' => TRUE, // ISO-8859-5
+ 'iso8859-6' => TRUE, // ISO-8859-6
+ 'latin6' => TRUE, // ISO-8859-6
+ 'arb' => TRUE, // ISO-8859-6
+ 'iso8859-7' => TRUE, // ISO-8859-7
+ 'latin7' => TRUE, // ISO-8859-7
+ 'grk' => TRUE, // ISO-8859-7
+ 'iso8859-8' => TRUE, // ISO-8859-8
+ 'latin8' => TRUE, // ISO-8859-8
+ 'heb' => TRUE, // ISO-8859-8
+ 'iso8859-9' => TRUE, // ISO-8859-9
+ 'latin9' => TRUE, // ISO-8859-9
+ 'trk' => TRUE, // ISO-8859-9
+ 'iso2022-jp'=> TRUE, // ISO-2022-JP
+ 'jis' => TRUE, // ISO-2022-JP
+ 'iso2022-kr'=> TRUE, // ISO-2022-KR
+ 'kis' => TRUE, // ISO-2022-KR
+ 'iso2022-cn'=> TRUE, // ISO-2022-CN
+ 'cis' => TRUE, // ISO-2022-CN
+ 'big5' => TRUE,
+ 'cp-1251' => TRUE, // ru, WINDOWS-1251
+ 'win-1251' => TRUE, // ru, WINDOWS-1251
+ 'cp866' => TRUE, // ru
+ 'koi8-r' => TRUE, // ru, KOI8-r
+ 'koi8-ru' => TRUE, // ru, KOI8-r
+ 'koi8-uk' => TRUE, // ru, KOI8-ru
+ 'ua' => TRUE, // ru, KOI8-ru
+ 'ucs2' => TRUE, // ru, ISO-10646-UCS-2
+ 'ucs4' => TRUE, // ru, ISO-10646-UCS-4
+ 'utf8' => TRUE,
+
+ // Reference: Apache 2.0.59 default 'index.html' variants
+ 'euc-kr' => TRUE,
+ 'gb2312' => TRUE,
+ );
+
+ // May uncompress by web browsers on the fly
+ // Must be at the last of the filename
+ // Reference: Apache 2.0.59 'AddEncoding'
+ static $encoding_suffix = array(
+ 'z' => TRUE,
+ 'gz' => TRUE,
+ );
+
+ if (! is_string($file)) return '';
+ $_file = strtolower($file);
+ if (isset($simple_defaults[$_file])) return '';
+
+
+ // Roughly removing language/character-set/encoding suffixes
+ // References:
+ // * Apache 2 document about 'Content-negotiaton', 'mod_mime' and 'mod_negotiation'
+ // http://httpd.apache.org/docs/2.0/content-negotiation.html
+ // http://httpd.apache.org/docs/2.0/mod/mod_mime.html
+ // http://httpd.apache.org/docs/2.0/mod/mod_negotiation.html
+ // * http://www.iana.org/assignments/character-sets
+ // * RFC3066: Tags for the Identification of Languages
+ // http://www.ietf.org/rfc/rfc3066.txt
+ // * ISO 639: codes of 'language names'
+ $suffixes = explode('.', $_file);
+ $body = array_shift($suffixes);
+ if ($suffixes) {
+ // Remove the last .gz/.z
+ $last_key = end(array_keys($suffixes));
+ if (isset($encoding_suffix[$suffixes[$last_key]])) {
+ unset($suffixes[$last_key]);
+ }
+ }
+ // Cut language and charset suffixes
+ foreach($suffixes as $key => $value){
+ if (isset($language_suffix[$value]) || isset($charset_suffix[$value])) {
+ unset($suffixes[$key]);
+ }