1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-05 23:25:30 +02:00
php-phpbb/phpBB/develop/lang_duplicates.php
Meik Sievertsen 2f4a618900 ok... i hope i haven't messed too much with the code and everything is still working.
Changes:
- Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed.
- A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added.

git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-05-29 12:25:56 +00:00

140 lines
3.2 KiB
PHP

<html>
<head>
<title>Duplicate Language Keys</title>
</head>
<body>
<?php
//
// Security message:
//
// This script is potentially dangerous.
// Remove or comment the next line (die(".... ) to enable this script.
// Do NOT FORGET to either remove this script or disable it after you have used it.
//
die("Please read the first lines of this script for instructions on how to enable it");
// -------------------------------------------------------------
//
// $Id$
//
// @copyright (c) 2005 phpBB Group
// @license http://opensource.org/licenses/gpl-license.php GNU Public License
//
// -------------------------------------------------------------
// Thanks to arod-1
define('IN_PHPBB', 1);
define('PHPBB_ROOT_PATH', './../');
define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
$mode = request_var('mode', '');
$modules = find_modules(PHPBB_ROOT_PATH . 'language/en');
$kkeys = $keys = array();
$langdir = dirname(__FILE__);
if (isset($lang))
{
unset($lang);
}
foreach($modules as $module)
{
require_once("$langdir$module");
if (isset($lang))
{
$kkeys[$module] = $lang;
$keys[] = $module;
unset($lang);
}
}
$equal = $case = $diff = 0;
$output = array();
while ($module = array_shift($keys))
{
$keys_1 = array_keys($kkeys[$module]);
foreach ($keys as $other_module)
{
$keys_2 = array_keys($kkeys[$other_module]);
foreach(array_intersect($keys_1, $keys_2) as $dup)
{
if ($kkeys[$module][$dup] == $kkeys[$other_module][$dup])
{
$compare = "Equal";
$equal++;
}
else if (strcasecmp($kkeys[$module][$dup], $kkeys[$other_module][$dup]) == 0)
{
$compare = "Differ in case";
$case++;
}
else
{
$compare = "'{$kkeys[$module][$dup]}' - '{$kkeys[$other_module][$dup]}'";
$diff++;
}
$color = '';
if ((basename($module) == "common." . PHP_EXT) || (basename($other_module) == "common." . PHP_EXT))
{
$color = ' style="color:#B00000;"';
}
switch ($mode)
{
case 'module':
$output[$module][] = "<tr$color><td>" . ((isset($output[$module])) ? '&nbsp;' : "<b>$module</b>" ) . "</td><td>$dup</td><td>$other_module</td><td>$compare</td></tr>";
break;
default:
$output[$dup][] = "<tr$color><td><b>$dup</b></td><td>$module</td><td>$other_module</td><td>$compare</td></tr>";
break;
}
}
}
}//var_dump($output);
echo "<p><a href=\"lang_duplicates.php\">By Key</a> <a href=\"lang_duplicates.php?mode=module\">By Module</a></p><p>Equal: <b>$equal</b>, Differ in case only: $case, differ in content: $diff</p>";
switch ($mode)
{
case 'module':
echo "<table cellpadding=\"4\"><tr><th>Key</th><th>First File</th><th>Second File</th><th>Difference</th></tr>";
foreach ($output as $module => $html)
{
echo implode('', $html);
}
break;
default:
ksort($output);
echo "<table cellpadding=\"4\"><tr><th>File</th><th>Key</th><th>Conflicting File</th><th>Difference</th></tr>";
foreach ($output as $dup)
{
echo implode('', $dup);
}
break;
}
echo "</table>";
function find_modules($dirname)
{
$list = glob("$dirname/*.php");
foreach(glob("$dirname/*", GLOB_ONLYDIR) as $name)
{
$list = array_merge($list, find_modules($name));
}
return $list;
}
?>
</body>
</html>