";
$input .= chr(60)."?php\n";
if ($old_kom == "")
{
// create CVS compatible description.
$diz = chr(47)."*\n";
$diz .= "+---------------------------------------------------------------+\n";
$diz .= "| e107 website system ".$lan." Language File\n";
$diz .= "| Released under the terms and conditions of the\n";
$diz .= "| GNU General Public License (http://gnu.org).\n";
$diz .= "|\n";
$diz .= "| ".chr(36)."Source: $writeit ".chr(36)."\n";
$diz .= "| ".chr(36)."Revision: 1.0 ".chr(36)."\n";
$diz .= "| ".chr(36)."Date: ".date("Y/m/d H:i:s")." ".chr(36)."\n";
$diz .= "| ".chr(36)."Author: ".USERNAME." ".chr(36)."\n";
$diz .= "+---------------------------------------------------------------+\n";
$diz .= "*".chr(47)."\n\n";
}
else
{
$diz = $old_kom;
}
$input .= $diz;
$message .= str_replace("\n","
",$diz);
for ($i=0; $i'.$notdef_end;
$input .= $notdef_start."setlocale(".$defvar.",".$deflang.");".$notdef_end;
}
else
{
$message .= $notdef_start.$func.'('.$quote.htmlentities($defvar).$quote.',"'.$deflang.'");
'.$notdef_end;
$input .= $notdef_start.$func."(".$quote.$defvar.$quote.", ".chr(34).$deflang.chr(34).");".$notdef_end;
}
}
$message .="
";
$message .="";
$input .= "\n\n?>";
// Write to file.
$fp = @fopen($writeit,"w");
if(!@fwrite($fp, $input))
{
$caption = LAN_ERROR;
$message = LAN_CHECK_17;
}
else
{
$caption = LAN_SAVED." $lan/".$writeit."";
}
fclose($writeit);
$message .= "";
$ns -> tablerender($caption, $message);
require_once(e_ADMIN."footer.php");
exit;
}
// ============================================================================
// Edit the Language File.
if($f != ""){
if (!$mode)
{
$dir1 = e_BASE.$LANGUAGES_DIRECTORY."English/";
$f1=$f;
$dir2 = e_BASE.$LANGUAGES_DIRECTORY.$lan."/";
$f2=$f;
}
else
{
$fullpath_orig = $f;
$fullpath_trans = str_replace("English",$lan,$f);
$f1 = basename($fullpath_orig);
$f2 = basename($fullpath_trans);
$dir1 = dirname($fullpath_orig)."/";
$dir2 = dirname($fullpath_trans)."/";
}
edit_lanfiles($dir1,$dir2,$f1,$f2);
}
// ===========================================================================
$core_plugins = array(
"alt_auth","banner_menu","blogcalendar_menu","calendar_menu","chatbox_menu",
"clock_menu","comment_menu","compliance_menu","content","counter_menu",
"featurebox","forum","gsitemap","integrity_check","lastseen","links_page",
"linkwords","list_new","log","login_menu","newforumposts_main","newsfeed",
"newsletter","online_extended_menu","online_menu","other_news_menu","pdf",
"pm","poll","powered_by_menu","rss_menu","search_menu","sitebutton_menu",
"trackback","tree_menu","userlanguage_menu","usertheme_menu"
);
$core_themes = array("crahan","e107v4a","human_condition","interfectus","jayya",
"khatru","kubrick","lamb","leaf","reline","sebes","vekna_blue");
if(isset($_POST['language_sel']) && isset($_POST['language'])){
$ns -> tablerender(LAN_CHECK_3.": ".$_POST['language'],check_core_lanfiles($_POST['language']));
$ns -> tablerender(LAN_CHECK_3.": ".$_POST['language']."/admin",check_core_lanfiles($_POST['language'],"admin/"));
$plug_text = "
".LAN_PLUGIN." |
".LAN_CHECK_16." |
".$_POST['language']." |
".LAN_OPTIONS." |
";
foreach($core_plugins as $plugs)
{
if(is_readable(e_PLUGIN.$plugs))
{
$plug_text .= check_lanfiles('P',$plugs,"English",$_POST['language']);
}
}
$plug_text .= "
";
$ns -> tablerender(ADLAN_CL_7,$plug_text);
$theme_text = "
Theme |
".LAN_CHECK_16." |
".$_POST['language']." |
".LAN_OPTIONS." |
";
foreach($core_themes as $them)
{
if(is_readable(e_THEME.$them))
{
$theme_text .= check_lanfiles('T',$them,"English",$_POST['language']);
}
}
$theme_text .= "
";
$ns -> tablerender("Themes",$theme_text);
require_once(e_ADMIN."footer.php");
exit;
}
function check_core_lanfiles($checklan,$subdir=''){
global $lanfiles,$_POST;
$English = get_comp_lan_phrases(e_LANGUAGEDIR."English/".$subdir,$checklan);
$check = get_comp_lan_phrases(e_LANGUAGEDIR.$checklan."/".$subdir,$checklan);
$text .= "
".LAN_CHECK_16." |
".$_POST['language']." File |
".LAN_OPTIONS." |
";
$keys = array_keys($English);
sort($keys);
foreach($keys as $k)
{
if($k != "bom")
{
$lnk = $k;
$k_check = str_replace("English",$checklan,$k);
if(array_key_exists($k,$check))
{
$text .= "";
$subkeys = array_keys($English[$k]);
$er="";
$utf_error = "";
$bomkey = str_replace(".php","",$k_check);
$bom_error = ($check['bom'][$bomkey]) ? "".LAN_CHECK_15."
" : ""; // illegal chars
foreach($subkeys as $sk)
{
if($utf_error == "" && !is_utf8($check[$k][$sk]))
{
$utf_error = "".LAN_CHECK_19."
";
}
if($sk == "LC_ALL"){
$check[$k][$sk] = str_replace(chr(34).chr(34),"",$check[$k][$sk]);
}
if((!array_key_exists($sk,$check[$k]) && $English[$k][$sk] != "") || (trim($check[$k][$sk]) == "" && $English[$k][$sk] != ""))
{
$er .= ($er) ? "
" : "";
$er .= $sk." ".LAN_CHECK_5;
}
}
$style = ($er) ? "forumheader2" : "forumheader3";
$text .= "";
$text .= $bom_error . $utf_error;
$text .= (!$er && !$bom_error && !$utf_error) ? LAN_OK : $er." ";
$text .= " | ";
}
else
{
$text .= "
"; // file missing.
}
// Leave in EDIT button for all entries - to allow re-translation of bad entries.
$subpath = ($subdir!='') ? $subdir.$k : $k;
$text .="
";
}
}
$text .= "
";
return $text;
}
function get_lan_file_phrases($dir1,$dir2,$file1,$file2){
$ret = array();
$fname = $dir1.$file1;
$type='orig';
if(is_file($fname))
{
$data = file($fname);
$ret=$ret + fill_phrases_array($data,$type);
if(substr($data[0],0,5) != "get_files($comp_dir, ".php","standard",$depth)){
sort($lang_array);
}
$regexp = (strpos($comp_dir,e_LANGUAGEDIR) !== FALSE) ? "#.php#" : "#".$lang."#";
foreach($lang_array as $f)
{
if(preg_match($regexp,$f['path'].$f['fname']) && is_file($f['path'].$f['fname']))
{
$data = file($f['path'].$f['fname']);
$relpath = str_replace($comp_dir,"",$f['path']);
if(substr($data[0],0,5) != "";
$k_check = str_replace("English",$target_lan,$k);
if(array_key_exists($k_check,$check))
{
$text .= "
";
$subkeys = array_keys($baselang[$k]);
$er="";
$utf_error = "";
$bomkey = str_replace(".php","",$k_check);
$bom_error = ($check['bom'][$bomkey]) ? "".LAN_CHECK_15."
" : ""; // illegal chars
foreach($subkeys as $sk)
{
if($utf_error == "" && !is_utf8($check[$k_check][$sk]))
{
$utf_error = "".LAN_CHECK_19."
";
}
if(!array_key_exists($sk,$check[$k_check]) || (trim($check[$k_check][$sk]) == "" && $baselang[$k][$sk] != ""))
{
$er .= ($er) ? "
" : "";
$er .= $sk." ".LAN_CHECK_5;
}
}
$style = ($er) ? "forumheader2" : "forumheader3";
$text .= "";
$text .= $bom_error . $utf_error;
$text .= (!$er && !$bom_error && !$utf_error) ? LAN_OK : $er." ";
$text .= " | ";
}
else
{
$text .= "
";
}
$text .="
";
}
// if (!$known) {$text = LAN_CHECK_18." : --> ".$fname." :: ".$dname;}
return $text;
}
function edit_lanfiles($dir1,$dir2,$f1,$f2){
global $ns,$sql,$lan;
/* echo "
dir1 = $dir1";
echo "
file1 = $f1";
echo "
dir2 = $dir2";
echo "
file2 = $f2";*/
if($dir2.$f2 == e_LANGUAGEDIR.$lan."/English.php") // it's a language config file.
{
$f2 = $lan.".php";
$root_file = e_LANGUAGEDIR.$lan."/".$lan.".php";
}
else
{
$root_file = $dir2.$f2;
}
if($dir2.$f2 == e_LANGUAGEDIR.$lan."/English_custom.php") // it's a language config file.
{
$f2 = $lan."_custom.php";
$root_file = e_LANGUAGEDIR.$lan."/".$lan."_custom.php";
}
$writable = (is_writable($dir2)) ? TRUE : FALSE;
$trans = get_lan_file_phrases($dir1,$dir2,$f1,$f2);
$keys = array_keys($trans);
sort($keys);
$text = "";
$text .= "";
$caption = LAN_CHECK_3." ".$dir2.$f2." -> ".$lan."";
$ns -> tablerender($caption, $text);
require_once(e_ADMIN."footer.php");
exit;
}
function fill_phrases_array($data,$type) {
$retloc = array();
foreach($data as $line){
//echo "line--> ".$line."
";
if (strpos($line,"define(") !== FALSE && strpos($line,");") === FALSE)
{
$indef=1;
$bigline="";
// echo "big1 -->".$line."
";
}
if ($indef)
{
$bigline.=str_replace("\n","",$line);
// echo "big2 -->".$line."
";
}
if (strpos($line,"define(") === FALSE && strpos($line,");") !== FALSE)
{
$indef=0;
$we_have_bigline=1;
// echo "big3 -->".$line."
";
}
if(strpos($line,"setlocale(") !== FALSE)
{
$indef=1;
$we_have_bigline=0;
}
if ((strpos($line,"define(") !== FALSE && strpos($line,");") !== FALSE && substr(ltrim($line),0,2) != "//") || $we_have_bigline || strpos($line,"setlocale(") !== FALSE)
{
if ($we_have_bigline)
{
$we_have_bigline=0;
$line=$bigline;
// echo "big -->".$line."
";
}
$ndef = "";
//echo "_ndefline -->".$line."
";
if (strpos($line,"defined(") !== FALSE )
{
$ndef = "ndef++";
$line = substr($line,strpos($line,"define("));
}
if(strpos($line,"setlocale(") !== FALSE)
{
$pos = substr(strstr($line,","),1);
$rep = array(");","\n",'""');
$val = str_replace($rep,"",$pos);
$retloc[$type]['LC_ALL']= $val;
$retloc['orig']['LC_ALL']= "'en'";
}
else
{
//echo "ndefline: ".$line."
";
if(preg_match("#\"(.*?)\".*?\"(.*)\"#",$line,$matches) ||
preg_match("#\'(.*?)\'.*?\"(.*)\"#",$line,$matches) ||
preg_match("#\"(.*?)\".*?\'(.*)\'#",$line,$matches) ||
preg_match("#\'(.*?)\'.*?\'(.*)\'#",$line,$matches) ||
preg_match("#\((.*?)\,.*?\"(.*)\"#",$line,$matches) ||
preg_match("#\((.*?)\,.*?\'(.*)\'#",$line,$matches))
{
//echo "get_lan -->".$matches[1]." :: ".$ndef.$matches[2]."
";
if(!isset($retloc[$type][$matches[1]]))
{
$retloc[$type][$matches[1]]= $ndef.$matches[2];
}
}
}
}
}
return $retloc;
}
//--------------------------------------------------------------------
function is_utf8($str) {
/*
* @see http://hsivonen.iki.fi/php-utf8/ validation.php
*/
if(strtolower(CHARSET) != "utf-8" || $str == "")
{
return TRUE;
}
return (preg_match('/^.{1}/us',$str,$ar) == 1);
}
function lancheck_adminmenu() {
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_language.php");
global $action,$pref;
if ($action == "") {
$action = "tools";
}
if($action == "modify"){
$action = "db";
}
$var['main']['text'] = LAN_PREFS;
$var['main']['link'] = e_ADMIN."language.php";
if(isset($pref['multilanguage']) && $pref['multilanguage']){
$var['db']['text'] = LANG_LAN_03;
$var['db']['link'] = e_ADMIN."language.php?db";
}
$var['tools']['text'] = ADLAN_CL_6;
$var['tools']['link'] = e_ADMIN."language.php?tools";
show_admin_menu(ADLAN_132, $action, $var);
}