1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

language-check error counting etc.

This commit is contained in:
CaMer0n
2009-11-05 08:07:53 +00:00
parent 7d690f1084
commit 3cf3d709d1
8 changed files with 533 additions and 478 deletions

View File

@@ -10,8 +10,8 @@
* With code from Izydor and Lolo.
*
* $Source: /cvs_backup/e107_0.8/e107_admin/lancheck.php,v $
* $Revision: 1.18 $
* $Date: 2009-10-24 07:52:32 $
* $Revision: 1.19 $
* $Date: 2009-11-05 08:07:48 $
* $Author: e107coders $
*
*/
@@ -30,6 +30,8 @@ require_once(e_HANDLER."form_handler.php");
$frm = new e_form();
$emessage = &eMessage::getInstance();
$lck = new lancheck;
$qry = explode("|",e_QUERY);
$f = $qry[0];
@@ -151,6 +153,8 @@ if(isset($_POST['submit']))
</div>
</form>";
$e107->ns->tablerender($caption, $emessage->render().$message);
require_once(e_ADMIN."footer.php");
exit;
@@ -180,7 +184,7 @@ if($f != ""){
$dir2 = dirname($fullpath_trans)."/";
}
edit_lanfiles($dir1,$dir2,$f1,$f2);
$lck->edit_lanfiles($dir1,$dir2,$f1,$f2);
}
@@ -201,7 +205,7 @@ $core_themes = array("_blank", "e107v4a", "jayya", "khatru", "leaf", "vekna_blue
if(isset($_POST['language_sel']) && isset($_POST['language']))
{
$text = check_core_lanfiles($_POST['language']).check_core_lanfiles($_POST['language'],"admin/");
$text = $lck->check_core_lanfiles($_POST['language']).$lck->check_core_lanfiles($_POST['language'],"admin/");
$text .= "
<fieldset id='core-lancheck-plugin'>
@@ -228,7 +232,7 @@ if(isset($_POST['language_sel']) && isset($_POST['language']))
{
if(is_readable(e_PLUGIN.$plugs))
{
$text .= check_lanfiles('P',$plugs,"English",$_POST['language']);
$text .= $lck->check_lanfiles('P',$plugs,"English",$_POST['language']);
}
}
$text .= "
@@ -261,7 +265,7 @@ if(isset($_POST['language_sel']) && isset($_POST['language']))
{
if(is_readable(e_THEME.$them))
{
$text .= check_lanfiles('T',$them,"English",$_POST['language']);
$text .= $lck->check_lanfiles('T',$them,"English",$_POST['language']);
}
}
$text .= "
@@ -270,17 +274,36 @@ if(isset($_POST['language_sel']) && isset($_POST['language']))
</fieldset>
";
$ns->tablerender(LAN_CHECK_25, $text);
$mes = e107::getMessage();
if($lck->error_count == 0)
{
e107::getConfig()->setPref('lancheck/'.$_POST['language'],1);
e107::getConfig()->save(FALSE);
$mes->add(LAN_CHECK_27.'<b>'.$lck->error_count.'</b>', E_MESSAGE_SUCCESS);
}
else
{
$mes->add(LAN_CHECK_27.'<b>'.$lck->error_count.'</b>', E_MESSAGE_WARNING);
}
$ns->tablerender(LAN_CHECK_25, $mes->render(). $text);
require_once(e_ADMIN."footer.php");
exit;
}
class lancheck
{
var $error_count=0;
function check_core_lanfiles($checklan,$subdir=''){
function check_core_lanfiles($checklan,$subdir=''){
global $frm;
$English = get_comp_lan_phrases(e_LANGUAGEDIR."English/".$subdir,$checklan);
$check = get_comp_lan_phrases(e_LANGUAGEDIR.$checklan."/".$subdir,$checklan);
$English = $this->get_comp_lan_phrases(e_LANGUAGEDIR."English/".$subdir,$checklan);
$check = $this->get_comp_lan_phrases(e_LANGUAGEDIR.$checklan."/".$subdir,$checklan);
$legend_txt = LAN_CHECK_3.": ".$_POST['language']."/".$subdir;
$fieldset_id = $subdir ? str_replace('/', '', $_POST['language'])."-".str_replace('/', '', $subdir) : str_replace('/', '', $_POST['language']);
$text .= "
@@ -332,7 +355,7 @@ function check_core_lanfiles($checklan,$subdir=''){
foreach($subkeys as $sk)
{
if($utf_error == "" && !is_utf8($check[$k][$sk]))
if($utf_error == "" && !$this->is_utf8($check[$k][$sk]))
{
$utf_error = "<span class='error'><em>".LAN_CHECK_19."</em></span><br />";
}
@@ -346,6 +369,7 @@ function check_core_lanfiles($checklan,$subdir=''){
$er .= ($er) ? "<br />" : "";
$er .= $sk." ".LAN_CHECK_5;
$this->error_count++;
}
}
@@ -355,7 +379,15 @@ function check_core_lanfiles($checklan,$subdir=''){
<div class='smalltext'>
";
$text .= $bom_error . $utf_error;
$text .= (!$er && !$bom_error && !$utf_error) ? LAN_OK : $er."<br />";
if(!$er && !$bom_error && !$utf_error)
{
$text .= LAN_OK;
}
else
{
$text .= $er."<br />";
$this->error_count++;
}
$text .= "
</div>
</td>
@@ -368,6 +400,7 @@ function check_core_lanfiles($checklan,$subdir=''){
<td>{$lnk}</td>
<td><span class='error'>".LAN_CHECK_4."</span></td>
";
$this->error_count++;
}
// Leave in EDIT button for all entries - to allow re-translation of bad entries.
@@ -390,10 +423,10 @@ function check_core_lanfiles($checklan,$subdir=''){
";
return $text;
}
}
function get_lan_file_phrases($dir1,$dir2,$file1,$file2){
function get_lan_file_phrases($dir1,$dir2,$file1,$file2){
$ret = array();
$fname = $dir1.$file1;
@@ -402,7 +435,7 @@ function get_lan_file_phrases($dir1,$dir2,$file1,$file2){
if(is_file($fname))
{
$data = file($fname);
$ret=$ret + fill_phrases_array($data,$type);
$ret=$ret + $this->fill_phrases_array($data,$type);
if(substr($data[0],0,5) != "<?php")
{
$key = str_replace(".php","",$fname);
@@ -416,7 +449,7 @@ function get_lan_file_phrases($dir1,$dir2,$file1,$file2){
if(is_file($fname))
{
$data = file($fname);
$ret=$ret + fill_phrases_array($data,$type);
$ret=$ret + $this->fill_phrases_array($data,$type);
if(substr($data[0],0,5) != "<?php")
{
$key = str_replace(".php","",$fname);
@@ -424,13 +457,13 @@ function get_lan_file_phrases($dir1,$dir2,$file1,$file2){
}
}
return $ret;
}
}
function get_comp_lan_phrases($comp_dir,$lang,$depth=0)
{
require_once(e_HANDLER."file_class.php");
$fl = new e_file;
function get_comp_lan_phrases($comp_dir,$lang,$depth=0)
{
$fl = e107::getFile();
$ret = array();
if($lang_array = $fl->get_files($comp_dir, '\.php','standard',$depth)){
@@ -460,26 +493,26 @@ function get_comp_lan_phrases($comp_dir,$lang,$depth=0)
$f['fname'] = "English_custom.php"; // change the key for the main language file.
}
$ret=$ret + fill_phrases_array($data,$relpath.$f['fname']);
$ret=$ret + $this->fill_phrases_array($data,$relpath.$f['fname']);
}
}
return $ret;
}
}
// for plugins and themes - checks what kind of language files directory structure we have
function check_lanfiles($mode, $comp_name, $base_lan="English", $target_lan)
{
// for plugins and themes - checks what kind of language files directory structure we have
function check_lanfiles($mode, $comp_name, $base_lan="English", $target_lan)
{
global $frm;
$folder['P'] = e_PLUGIN.$comp_name;
$folder['T'] = e_THEME.$comp_name;
$comp_dir = $folder[$mode];
$baselang = get_comp_lan_phrases($comp_dir."/languages/","English",1);
$check = get_comp_lan_phrases($comp_dir."/languages/",$target_lan,1);
$baselang = $this->get_comp_lan_phrases($comp_dir."/languages/","English",1);
$check = $this->get_comp_lan_phrases($comp_dir."/languages/",$target_lan,1);
$text = "";
$keys = array_keys($baselang);
@@ -519,6 +552,7 @@ function check_lanfiles($mode, $comp_name, $base_lan="English", $target_lan)
{
$er .= ($er) ? "<br />" : "";
$er .= $sk." ".LAN_CHECK_5;
$this->error_count++;
}
}
@@ -539,8 +573,9 @@ function check_lanfiles($mode, $comp_name, $base_lan="English", $target_lan)
$text .= "
<td>".$comp_name."</td>
<td>".str_replace("English/","",$lnk)."</td>
<td><span style='cursor:pointer' title='".str_replace("English",$target_lan,$lnk)."'>".LAN_CHECK_4."</span></td>
<td><span class='error' style='cursor:pointer' title='".str_replace("English",$target_lan,$lnk)."'>".LAN_CHECK_4."</span></td>
";
$this->error_count++;
}
$text .="
@@ -555,9 +590,9 @@ function check_lanfiles($mode, $comp_name, $base_lan="English", $target_lan)
}
return $text;
}
}
function edit_lanfiles($dir1,$dir2,$f1,$f2){
function edit_lanfiles($dir1,$dir2,$f1,$f2){
global $e107, $emessage, $lan;
/* echo "<br />dir1 = $dir1";
@@ -584,7 +619,7 @@ function edit_lanfiles($dir1,$dir2,$f1,$f2){
$writable = (is_writable($dir2)) ? TRUE : FALSE;
$trans = get_lan_file_phrases($dir1,$dir2,$f1,$f2);
$trans = $this->get_lan_file_phrases($dir1,$dir2,$f1,$f2);
$keys = array_keys($trans);
sort($keys);
@@ -681,9 +716,9 @@ function edit_lanfiles($dir1,$dir2,$f1,$f2){
require_once(e_ADMIN."footer.php");
exit;
}
}
function fill_phrases_array($data,$type) {
function fill_phrases_array($data,$type) {
$retloc = array();
@@ -736,7 +771,7 @@ function fill_phrases_array($data,$type) {
$rep = array(");","\n",'""');
$val = str_replace($rep,"",$pos);
$retloc[$type]['LC_ALL']= $val;
// $retloc['orig']['LC_ALL']= "'en'";
// $retloc['orig']['LC_ALL']= "'en'";
}
else
{
@@ -760,24 +795,25 @@ function fill_phrases_array($data,$type) {
}
return $retloc;
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function is_utf8($str) {
function is_utf8($str) {
/*
* @see http://hsivonen.iki.fi/php-utf8/ validation.php
*/
//@TODO: always TRUE
// if(strtolower(CHARSET) != "utf-8" || $str == "")
//@TODO: always TRUE
// if(strtolower(CHARSET) != "utf-8" || $str == "")
{
return TRUE;
}
return (preg_match('/^.{1}/us',$str,$ar) == 1);
}
}
}
function lancheck_adminmenu() {

View File

@@ -9,8 +9,8 @@
* Administration Area - Languages
*
* $Source: /cvs_backup/e107_0.8/e107_admin/language.php,v $
* $Revision: 1.22 $
* $Date: 2009-10-24 07:52:32 $
* $Revision: 1.23 $
* $Date: 2009-11-05 08:07:48 $
* $Author: e107coders $
*
*/
@@ -161,10 +161,16 @@ if (varset($action) == 'db')
}
if (varset($_POST['ziplang']) && varset($_POST['language']))
{
if(varset($pref['lancheck'][$_POST['language']]) == 1)
{
$text = zip_up_lang($_POST['language']);
$admin_log->log_event('LANG_04', $_POST['language'], E_LOG_INFORMATIVE, '');
//$ns -> tablerender(LANG_LAN_25, $text);
$emessage->add(LANG_LAN_25.': '.$text);
}
else
{
$emessage->add(LANG_LAN_36,E_MESSAGE_WARNING);
}
}
if (varset($action) == "tools")
{
@@ -575,8 +581,8 @@ function show_tools()
function available_langpacks()
{
require_once(e_HANDLER.'xml_class.php');
$xml = new xmlClass;
$xml = e107::getXml();
$feed = e107::getPref('xmlfeed_languagepacks');

View File

@@ -3,7 +3,7 @@
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| <20>Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/file_class.php,v $
| $Revision: 1.2 $
| $Date: 2008-11-20 20:34:44 $
| $Author: e107steved $
| $Revision: 1.3 $
| $Date: 2009-11-05 08:07:48 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -68,11 +68,17 @@ class e_file
function setDefaults()
{
$this->dirFilter = array('/', 'CVS', '.svn'); // Default directory filter (exact matches only)
$this->fileFilter = array('^thumbs\.db$','^Thumbs\.db$','.*\._$','^\.htaccess$','^index\.html$','^null\.txt$','\.bak$'); // Default file filter (regex format)
$this->fileFilter = array('^thumbs\.db$','^Thumbs\.db$','.*\._$','^\.htaccess$','^index\.html$','^null\.txt$','\.bak$','^.tmp'); // Default file filter (regex format)
}
/**
*
* @param object $path
* @param object $fmask [optional]
* @param object $omit [optional]
* @param object $recurse_level [optional]
* @return
*/
function get_files($path, $fmask = '', $omit='standard', $recurse_level = 0)
{
$ret = array();

View File

@@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/login.php,v $
| $Revision: 1.26 $
| $Date: 2009-10-22 13:00:11 $
| $Revision: 1.27 $
| $Date: 2009-11-05 08:07:48 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -345,7 +345,9 @@ class userlogin
$this->logNote('LAN_ROLL_LOG_02', $username);
break;
case LOGIN_NOT_ACTIVATED :
define("LOGINMESSAGE", LAN_LOGIN_22."<br /><br />");
$srch = array("[","]");
$repl = array("<a href='".e_BASE_ABS."signup.php?resend'>","</a>");
define("LOGINMESSAGE", str_replace($srch,$repl,LAN_LOGIN_22)."<br /><br />");
$this->logNote('LAN_ROLL_LOG_05', $username);
$this->genNote($fip, $username, LAN_LOGIN_27);
$doCheck = TRUE;

View File

@@ -1,7 +1,7 @@
<?php
/*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: lan_admin.php,v 1.32 2009-11-04 03:07:44 e107coders Exp $
* $Id: lan_admin.php,v 1.33 2009-11-05 08:07:53 e107coders Exp $
*
* Admin Language File
*/
@@ -308,3 +308,4 @@ define("LAN_COMMENTMAN", "Comments Manager");
define("LAN_FILTER", "Filter");
define("LAN_NO_RECORDS", "No Records Found");

View File

@@ -1,13 +1,13 @@
<?php
/*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: lan_lancheck.php,v 1.5 2009-09-08 23:53:13 e107coders Exp $
* $Id: lan_lancheck.php,v 1.6 2009-11-05 08:07:53 e107coders Exp $
*
* Admin Language File
*
*/
define("LAN_CHECK_1", "Verify/Edit Language-Pack Files"); // modified in 0.7.6
define("LAN_CHECK_2", "Begin Verify");
define("LAN_CHECK_2", "Verify");
define("LAN_CHECK_3", "Verification of");
define("LAN_CHECK_4", "File missing!");
define("LAN_CHECK_5", "Phrase missing!");
@@ -37,4 +37,7 @@ define('LAN_CHECK_PAGE_TITLE', 'Languages');
define('LAN_CHECK_24', 'Edit/Create file');
define('LAN_CHECK_25', 'Language verification');
define('LAN_CHECK_26', 'No data');
define('LAN_CHECK_27', 'Number of language-pack errors found: ');
?>

View File

@@ -1,7 +1,7 @@
<?php
/*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: lan_language.php,v 1.7 2009-09-08 23:53:13 e107coders Exp $
* $Id: lan_language.php,v 1.8 2009-11-05 08:07:53 e107coders Exp $
*
* Admin Language File
*
@@ -48,6 +48,7 @@ define('LANG_LAN_33', 'Delete all tables in %s?');
define('LANG_LAN_09', 'Are you sure?');
define('LANG_LAN_34', 'Available Language Packs');
define('LANG_LAN_35', "The following language packs are available for this version of e107.");
define('LANG_LAN_36', "Language-Pack errors found! Please first verify your language files are without errors, before creating a language-pack.");
?>

View File

@@ -4,9 +4,9 @@
| e107 website system - Language File.
|
| $Source: /cvs_backup/e107_0.8/e107_languages/English/lan_login.php,v $
| $Revision: 1.5 $
| $Date: 2009-07-05 18:47:52 $
| $Author: e107steved $
| $Revision: 1.6 $
| $Date: 2009-11-05 08:07:53 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
define('LAN_LOGIN_1', 'User name');
@@ -30,7 +30,7 @@ define('LAN_LOGIN_18', 'Auto-ban: More than 10 failed login attempts');
define('LAN_LOGIN_19', '> 10 failed login attempts');
define('LAN_LOGIN_20', 'You left required field(s) blank');
define('LAN_LOGIN_21', "Incorrect login. The entered data doesn't match to a registered user. Check if you have the CAPS-LOCK key activated as logins on this site are case sensitive");
define('LAN_LOGIN_22', "You have not activated your account. You should have received an email with instructions on how to confirm your account. If not, please click <a href='".e_BASE."signup.php?resend'>here</a>.");
define('LAN_LOGIN_22', "You have not activated your account. You should have received an email with instructions on how to confirm your account. If not, please click [here].");
define('LAN_LOGIN_23', 'Incorrect code entered.');
define('LAN_LOGIN_24', 'That username/password combination is already in use.');
define('LAN_LOGIN_25', 'Banned user attempted to login');