mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 05:37:32 +02:00
Improved duplicate LAN check - still experimental.
This commit is contained in:
@@ -188,19 +188,59 @@ if (varset($action) == "tools")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function findIncludedFiles($script)
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = file_get_contents($script);
|
||||||
|
|
||||||
|
preg_match_all("/.*(include_lan|require_once|include|include_once) ?\((.*e_LANGUAGE.*?\.php)/i",$data,$match);
|
||||||
|
|
||||||
|
|
||||||
|
$srch = array(" ",'e_PLUGIN.', 'e_LANGUAGEDIR', '.e_LANGUAGE.', "'", '"', "'.");
|
||||||
|
$repl = array("", e_PLUGIN, e_LANGUAGEDIR, "English", "", "", "");
|
||||||
|
|
||||||
|
foreach($match[2] as $lanFile)
|
||||||
|
{
|
||||||
|
$arrt = str_replace($srch,$repl,$lanFile);
|
||||||
|
if(strpos($arrt,'admin'))
|
||||||
|
{
|
||||||
|
return $arrt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arr[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans']))
|
if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans']))
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
$lanfile = $_POST['deprecatedLans'];
|
// $lanfile = $_POST['deprecatedLans'];
|
||||||
|
$script = $_POST['deprecatedLans'];
|
||||||
|
|
||||||
|
|
||||||
$scriptname = str_replace("lan_","",basename($lanfile));
|
// $scriptname = str_replace("lan_","",basename($lanfile));
|
||||||
|
|
||||||
if(is_readable(e_ADMIN.$script))
|
if(strpos($script,'admin')!=true) // Plugin
|
||||||
{
|
{
|
||||||
$script = e_ADMIN.$scriptname; // matching files. lan_xxxx.php and xxxx.php
|
$lanfile = e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_".basename($script);
|
||||||
}
|
}
|
||||||
|
else // admin area.
|
||||||
|
{
|
||||||
|
$lanfile = findIncludedFiles($script);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_readable($script))
|
||||||
|
{
|
||||||
|
$mes->addError("Not Readable: ".$script);
|
||||||
|
// $script = $scriptname; // matching files. lan_xxxx.php and xxxx.php
|
||||||
|
}
|
||||||
|
|
||||||
|
$found = findIncludedFiles($script);
|
||||||
|
|
||||||
|
// print_a($found);
|
||||||
|
|
||||||
// Exceptions - same language loaded by several scripts.
|
// Exceptions - same language loaded by several scripts.
|
||||||
if($lanfile == e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_e107_update.php")
|
if($lanfile == e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_e107_update.php")
|
||||||
@@ -208,8 +248,13 @@ if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans']))
|
|||||||
$script = e_ADMIN."update_routines.php,".e_ADMIN."e107_update.php";
|
$script = e_ADMIN."update_routines.php,".e_ADMIN."e107_update.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$mes->addDebug("LanFile: ".$lanfile);
|
||||||
|
$mes->addDebug("Script: ".$script);
|
||||||
|
|
||||||
|
|
||||||
if(is_readable($lanfile))
|
if(is_readable($lanfile))
|
||||||
{
|
{
|
||||||
|
$mes->addDebug("Reading LanFile... ");
|
||||||
if($res = unused($lanfile,$script))
|
if($res = unused($lanfile,$script))
|
||||||
{
|
{
|
||||||
$ns -> tablerender($res['caption'],$mes->render(). $res['text']);
|
$ns -> tablerender($res['caption'],$mes->render(). $res['text']);
|
||||||
@@ -217,7 +262,8 @@ if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans']))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// echo 'PROBLEM';
|
$mes->addDebug("Couldn't Read LanFile... ");
|
||||||
|
$ns -> tablerender($res['caption'],$mes->render(). $res['text']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -587,7 +633,7 @@ function show_tools()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$text .= "</select>".
|
$text .= "</select>".
|
||||||
$frm->admin_button('language_sel','no-value','update',LAN_CHECK_2)."
|
$frm->admin_button('language_sel','no-value','other',LAN_CHECK_2)."
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -623,7 +669,7 @@ function show_tools()
|
|||||||
}
|
}
|
||||||
$text .= "
|
$text .= "
|
||||||
</select>
|
</select>
|
||||||
".$frm->admin_button('ziplang','no-value','update',LANG_LAN_24)."
|
".$frm->admin_button('ziplang','no-value','other',LANG_LAN_24)."
|
||||||
<input type='checkbox' name='contribute_pack' value='1' /> Check to share your language-pack with the e107 community.
|
<input type='checkbox' name='contribute_pack' value='1' /> Check to share your language-pack with the e107 community.
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
@@ -638,11 +684,15 @@ function show_tools()
|
|||||||
|
|
||||||
$fl = e107::getFile();
|
$fl = e107::getFile();
|
||||||
$fl->mode = 'full';
|
$fl->mode = 'full';
|
||||||
$lans = $fl->get_files(e_LANGUAGEDIR."English/admin");
|
$omit = array('languages','\.png','\.gif');
|
||||||
|
$lans = $fl->get_files(e_ADMIN,'.php','standard',0);
|
||||||
|
$plugs = $fl->get_files(e_PLUGIN,'.*?/?admin.*?\.php',$omit,2);
|
||||||
|
|
||||||
$exclude = array('lan_admin.php');
|
$exclude = array('lan_admin.php');
|
||||||
|
|
||||||
|
$srch = array(e_ADMIN,e_PLUGIN);
|
||||||
|
|
||||||
|
$text .= "<optgroup label='Admin Area'>";
|
||||||
foreach($lans as $script=>$lan)
|
foreach($lans as $script=>$lan)
|
||||||
{
|
{
|
||||||
if(in_array(basename($lan),$exclude))
|
if(in_array(basename($lan),$exclude))
|
||||||
@@ -650,11 +700,28 @@ function show_tools()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$selected = ($lan == varset($_POST['deprecatedLans'])) ? "selected='selected'" : "";
|
$selected = ($lan == varset($_POST['deprecatedLans'])) ? "selected='selected'" : "";
|
||||||
$text .= "<option value='".$lan."' {$selected}>".str_replace(e_LANGUAGEDIR."English/","",$lan)."</option>\n";
|
$text .= "<option value='".$lan."' {$selected}>".str_replace($srch,"",$lan)."</option>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$text .= "</optgroup>";
|
||||||
|
|
||||||
|
$text .= "<optgroup label='Plugins'>";
|
||||||
|
foreach($plugs as $script=>$lan)
|
||||||
|
{
|
||||||
|
if(in_array(basename($lan),$exclude))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$selected = ($lan == varset($_POST['deprecatedLans'])) ? "selected='selected'" : "";
|
||||||
|
$text .= "<option value='".$lan."' {$selected}>".str_replace($srch,"",$lan)."</option>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= "</optgroup>";
|
||||||
|
|
||||||
|
|
||||||
$text .= "
|
$text .= "
|
||||||
</select>".$frm->admin_button('searchDeprecated',"Check")."
|
</select>".$frm->admin_button('searchDeprecated',"Check",'other')."
|
||||||
|
<span class='field-help'>".(count($lans) + count($plugs))." files found</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
@@ -872,6 +939,11 @@ function grab_lans($path, $language, $filter = "")
|
|||||||
*/
|
*/
|
||||||
function unused($lanfile,$script)
|
function unused($lanfile,$script)
|
||||||
{
|
{
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
// $mes->addInfo("LAN=".$lanfile."<br />Script = ".$script);
|
||||||
|
|
||||||
|
|
||||||
$lanDefines = file_get_contents($lanfile);
|
$lanDefines = file_get_contents($lanfile);
|
||||||
|
|
||||||
$tmp = explode(",",$script);
|
$tmp = explode(",",$script);
|
||||||
@@ -903,7 +975,11 @@ function unused($lanfile,$script)
|
|||||||
if($lanDefines && $compare)
|
if($lanDefines && $compare)
|
||||||
{
|
{
|
||||||
|
|
||||||
$text = "<table class='table adminlist' style='width:100%'>
|
$text = "<table class='table adminlist'>
|
||||||
|
<colgroup>
|
||||||
|
<col style='width:40%' />
|
||||||
|
<col style='auto' />
|
||||||
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>".$lanfile."</th>";
|
<th>".$lanfile."</th>";
|
||||||
@@ -935,7 +1011,7 @@ function unused($lanfile,$script)
|
|||||||
$text .= "</tbody></table>";
|
$text .= "</tbody></table>";
|
||||||
|
|
||||||
|
|
||||||
$mes->addInfo("Pink is unused LAN");
|
$mes->addInfo("<b>Pink items are likely to be unused LANs.<br />Comment out and test thoroughly.</b>");
|
||||||
|
|
||||||
$ret['text'] = $mes->render().$text;
|
$ret['text'] = $mes->render().$text;
|
||||||
$ret['caption'] = "Deprecated LAN Check (experimental!)";
|
$ret['caption'] = "Deprecated LAN Check (experimental!)";
|
||||||
|
@@ -48,8 +48,8 @@ require_once(e_HANDLER.'message_handler.php');
|
|||||||
$emessage = eMessage::getInstance();
|
$emessage = eMessage::getInstance();
|
||||||
|
|
||||||
//@FIXME mix up in banner language files
|
//@FIXME mix up in banner language files
|
||||||
//include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_menus.php');
|
//include_//lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_menus.php');
|
||||||
include_lan(e_PLUGIN.'banner/languages/'.e_LANGUAGE.'.php');
|
include_lan(e_PLUGIN.'banner/languages/'.e_LANGUAGE.'_admin_banner.php');
|
||||||
include_lan(e_PLUGIN.'banner/languages/'.e_LANGUAGE.'_menu_banner.php');
|
include_lan(e_PLUGIN.'banner/languages/'.e_LANGUAGE.'_menu_banner.php');
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user