1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
| 1. / 2. / ...
<?php
@error_reporting(E_ALL);
$lang = empty($_GET['lang']) ? 'German' : $_GET['lang'];
$file = 'lang/'.$lang.'/'.$_GET['file'].'.php';
$url_link = '?lang='.$lang.'&file='.$_GET['file'];
$fp = file($file);
$output = '';
$file_new = '';
$count = 0;
$errors = 0;
$errors_fixable = 0;
$cs_lang = array();
include 'lang/'.$lang.'/system/main.php';
$cs_lang_global = $cs_lang;
$cs_lang = array();
function cs_validate ($matches) {
global $cs_lang, $cs_lang_global;
if (array_key_exists($matches[1],$cs_lang)) {
if ($cs_lang[$matches[1]] == $matches[3])
return '00';
return '-1'.$cs_lang[$matches[1]];
}
if (array_key_exists($matches[1],$cs_lang_global)) {
if ($cs_lang_global[$matches[1]] == $matches[3])
return '00main.php';
return '-1main.php: '.$cs_lang_global[$matches[1]];
}
return '01';
}
foreach ($fp as $line) {
$count++;
if (substr($line,0,9) != '$cs_lang[' || strpos($line,'.=') !== false || substr($line,-2,1) != ';') {
$file_new .= $line;
continue;
}
$check = preg_replace_callback('=\$cs_lang\[\'(.*?)\'\](.*?)\'(.*?)\';=si',"cs_validate",$line);
$valid = (int) substr($check,0,2);
$comment = substr($check,2,-1);
if ($valid == 1) {
eval($line);
$file_new .= $line;
} else {
$errors++;
$countout = $count < 100 ? '0' . $count : $count;
$output .= '\''.$countout.'\' => ';
$line1 = substr($line,0,-1);
if ($valid == 0) {
$output .= '\'double\' => '.$line1;
$errors_fixable++;
} else {
$output .= '\'change\' => '.$line1;
$file_new .= $line;
}
$output .= empty($comment) ? "\r\n" : ' // '.$comment."\r\n";
}
}
if (isset($_GET['validate'])) {
$fp2 = fopen($file,'w');
fwrite($fp2,$file_new);
fclose($fp2);
header('Location: '.$url_link);
}
$nl = "\r\n";
// Output
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.$nl;
echo '<html xmlns="http://www.w3.org/1999/xhtml">'.$nl;
echo '<head>'.$nl;
echo '<title>Clansphere lang file Validator</title>'.$nl;
echo '</head>'.$nl;
echo '<body>'.$nl;
echo '<h1>Clansphere lang file Validator</h1>'.$nl;
echo 'File: <u>'.$file.'</u><br />'.$nl;
echo 'Errors found: <u>'.$errors.'</u><br />'.$nl;
echo 'Errors fixable: <u>'.$errors_fixable.'</u><br />'.$nl;
echo 'Validate: ';
echo isset($_GET['validate']) || empty($errors_fixable) ? '-' : '<a href="'.$url_link.'&validate?phpMyAdmin=a7d6a530ea7fe797a049ba44b388371f">Go</a>';
echo $nl.'<br /><br />'.$nl.$nl;
echo highlight_string('<?php'."\r\n\r\n".$output."\r\n".'?>');
echo $nl.'<br /><br />'.$nl.$nl;
echo 'New file:<br /><br />'.$nl.$nl;
echo highlight_string($file_new);
echo $nl.'</body>';
?> |