mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-03 18:38:31 +03:00
Remove unused console scripts
This commit is contained in:
parent
3ca9395d69
commit
48408c6547
@ -1,56 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
sub read_transl($) {
|
||||
my($from) = @_;
|
||||
my %translation = ();
|
||||
open(IN, "mibew/locales/$from/properties");
|
||||
while(<IN>) {
|
||||
chomp;
|
||||
if(/^([\w\.]+)=(.*)$/) {
|
||||
if($1 ne "encoding" && $1 ne "output_charset" && $1 ne "output_encoding") {
|
||||
$translation{$1} = $2;
|
||||
}
|
||||
} else {
|
||||
die "wrong line in $from: $_\n";
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
return %translation;
|
||||
}
|
||||
|
||||
%tr_en = read_transl("en");
|
||||
|
||||
@all_keys = keys %tr_en;
|
||||
|
||||
sub check_transl($%) {
|
||||
my($name,%tr) = @_;
|
||||
print "checking $name...\n";
|
||||
my @totransl = ();
|
||||
for $key (@all_keys) {
|
||||
unless(exists $tr{$key}) {
|
||||
push @totransl, "$key=".$tr_en{$key};
|
||||
}
|
||||
}
|
||||
for $key(keys %tr) {
|
||||
unless(exists $tr_en{$key}) {
|
||||
print "unknown key in $name: $key\n";
|
||||
}
|
||||
}
|
||||
if($#totransl >= 0) {
|
||||
print "@{[$#totransl+1]} lines absent in locales/$name/properties\n";
|
||||
open(OUT, "> absent_$name");
|
||||
for(sort @totransl) {
|
||||
print OUT "$_\n";
|
||||
}
|
||||
close(OUT);
|
||||
}
|
||||
}
|
||||
|
||||
check_transl("ru", read_transl("ru"));
|
||||
check_transl("fr", read_transl("fr"));
|
||||
check_transl("de", read_transl("de"));
|
||||
check_transl("sp", read_transl("sp"));
|
||||
check_transl("it", read_transl("it"));
|
||||
check_transl("pl", read_transl("pl"));
|
||||
check_transl("zh-tw", read_transl("zh-tw"));
|
||||
|
@ -1,245 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use Digest::MD5 qw(md5 md5_hex md5_base64);
|
||||
|
||||
@rules = (
|
||||
["redirect(ed)?\\.tpl", 1],
|
||||
["\\.tpl", 0],
|
||||
|
||||
["view/license.php", 0],
|
||||
["view/themes.php", 2],
|
||||
["view/translate.php", 2],
|
||||
["view/translatelist.php", 2],
|
||||
["view/settings.php", 2],
|
||||
["view/updates.php", 2],
|
||||
["view/features.php", 2],
|
||||
["view/performance.php", 2],
|
||||
["view/avatar.php", 2],
|
||||
["view/permissions.php", 2],
|
||||
["view/agent.php", 2],
|
||||
["view/agents.php", 2],
|
||||
["view/group.php", 2],
|
||||
["view/groupmembers.php", 2],
|
||||
["view/groups.php", 2],
|
||||
["view/operator_groups.php", 2],
|
||||
["view/gen_button.php", 2],
|
||||
["view/install_err.php", 2],
|
||||
["view/install_index.php", 2],
|
||||
["view/.*\\.php", 1],
|
||||
|
||||
["install/.*\\.php", 2],
|
||||
|
||||
["operator/themes.php", 2],
|
||||
["operator/translate.php", 2],
|
||||
["operator/settings.php", 2],
|
||||
["operator/updates.php", 2],
|
||||
["operator/features.php", 2],
|
||||
["operator/performance.php", 2],
|
||||
["operator/avatar.php", 2],
|
||||
["operator/permissions.php", 2],
|
||||
["operator/operator.php", 2],
|
||||
["operator/operators.php", 2],
|
||||
["operator/group.php", 2],
|
||||
["operator/groupmembers.php", 2],
|
||||
["operator/groups.php", 2],
|
||||
["operator/opgroups.php", 2],
|
||||
["operator/getcode.php", 2],
|
||||
["operator/.*\\.php", 1],
|
||||
|
||||
["mibew/client.php", 0],
|
||||
["mibew/leavemessage.php", 0],
|
||||
["mibew/captcha.php", 0],
|
||||
["mibew/license.php", 0],
|
||||
["mibew/mail.php", 0],
|
||||
|
||||
["libs/operator_settings.php", 2],
|
||||
["mibew/libs/chat.php", 0],
|
||||
["libs/pagination.php", 1],
|
||||
["libs/settings.php", 2],
|
||||
["libs/groups.php", 2],
|
||||
["libs/demothread.php", 2],
|
||||
|
||||
["mibew/thread.php", 0],
|
||||
["mibew/b.php", 0],
|
||||
["mibew/button.php", 0],
|
||||
["mibew/index.php", 0],
|
||||
|
||||
["mibew/libs/.*\\.php", 1],
|
||||
);
|
||||
|
||||
%messagekeys = (
|
||||
"localeid" => 0,
|
||||
"output_charset" => 0,
|
||||
"output_encoding" => 0,
|
||||
"harderrors.header" => 0,
|
||||
|
||||
"errors.required" => 0,
|
||||
"errors.wrong_field" => 0,
|
||||
"errors.file.move.error" => 2,
|
||||
"errors.invalid.file.type" => 2,
|
||||
"errors.file.size.exceeded" => 2,
|
||||
|
||||
"permission.admin" => 1,
|
||||
"permission.takeover" => 1,
|
||||
"permission.viewthreads" => 1,
|
||||
|
||||
"chat.thread.state_chatting_with_agent" => 1,
|
||||
"chat.thread.state_closed" => 1,
|
||||
"chat.thread.state_loading" => 1,
|
||||
"chat.thread.state_wait" => 1,
|
||||
"chat.thread.state_wait_for_another_agent" => 1,
|
||||
|
||||
"clients.queue.chat" => 1,
|
||||
"clients.queue.prio" => 1,
|
||||
"clients.queue.wait" => 1,
|
||||
);
|
||||
|
||||
|
||||
$mibewPath = "mibew";
|
||||
|
||||
%urls = ();
|
||||
|
||||
%usermessages = ();
|
||||
%operatormessages = ();
|
||||
$current_level = 0;
|
||||
|
||||
sub usemsg($) {
|
||||
my ($m) = @_;
|
||||
$messagekeys{$m} = exists $messagekeys{$m} && $messagekeys{$m} < $current_level ? $messagekeys{$m} : $current_level;
|
||||
if($current_level == -1) {
|
||||
print " .. $m\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub file_content($) {
|
||||
my $input = $_[0];
|
||||
open( IN1, "< $input" ) or die "cannot find file $input";
|
||||
my $oldslash = $/;
|
||||
$/ = EOI;
|
||||
$content = <IN1>;
|
||||
close( IN1 );
|
||||
if($content =~ s/\r//g) {
|
||||
open( OUT1, "> $input") or die "cannot fix $input";
|
||||
print OUT1 $content;
|
||||
close(OUT1);
|
||||
}
|
||||
$/ = $oldslash;
|
||||
return $content;
|
||||
}
|
||||
|
||||
sub process_tpl($) {
|
||||
my ($filename) = @_;
|
||||
my $m = file_content($filename);
|
||||
while( $m =~ /\${msg:([\w\.]+)(,[\w\.]+)?}/g ) {
|
||||
usemsg($1);
|
||||
}
|
||||
while( $m =~ /\${url:([\w\.]+)(,[\w\.]+)?}/g ) {
|
||||
usemsg($1);
|
||||
$urls{"%$1"} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub process_php($) {
|
||||
my ($source) = @_;
|
||||
my $content = file_content($source);
|
||||
$content =~ s/<\?xml version=\\"1\.0\\" encoding=\\"UTF-8\\"\?>//;
|
||||
|
||||
while( $content =~ s/<\?(?!xml)(.*?)\?>//s ) {
|
||||
my $inner = $1;
|
||||
while($inner =~ s/(getlocal|no_field)2?_?\((.*?)[,\)]//s) {
|
||||
my $firstarg = $2;
|
||||
if( $firstarg =~ /^["']([\w\.]+)['"]$/) {
|
||||
usemsg($1);
|
||||
} elsif($firstarg =~ /^\$\w+$/ || $firstarg eq '"$var.header"' || $firstarg eq '"permission.$permid"' || $firstarg eq '$threadstate_key[$thread[\'istate\']]') {
|
||||
# skip
|
||||
} else {
|
||||
print "> unknown: $firstarg\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub file_checksum($) {
|
||||
my ($source) = @_;
|
||||
if($source =~ /\.(png|gif|jpg|ico|wav)$/ || $source =~ /config\.php$/) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
my $content = file_content($source);
|
||||
return md5_hex($content);
|
||||
}
|
||||
|
||||
@allsources = ();
|
||||
|
||||
sub process_one($) {
|
||||
my($source) = @_;
|
||||
push @allsources, $source unless $source =~ /$mibewPath\/locales/ && $source !~ /$mibewPath\/locales\/(en|names)/ || $source =~ /\/package$/;
|
||||
|
||||
if($source !~ /\.(php|tpl)$/) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current_level = -1;
|
||||
|
||||
A: foreach $rule (@rules) {
|
||||
my $key = $$rule[0];
|
||||
if($source =~ /$key/) {
|
||||
$current_level = $$rule[1];
|
||||
last A;
|
||||
}
|
||||
}
|
||||
if($current_level < 0 || $current_level > 2) {
|
||||
print "not detected for: $source\n";
|
||||
$current_level = 0;
|
||||
}
|
||||
|
||||
if($source =~ /\.php$/) {
|
||||
# print "$source ($current_level)\n";
|
||||
process_php($source);
|
||||
} elsif($source =~ /\.tpl$/) {
|
||||
process_tpl($source);
|
||||
} else {
|
||||
#print ". $source\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub process_files($) {
|
||||
my($from) = @_;
|
||||
opendir(DIR, $from) || die "can't opendir $from: $!";
|
||||
my @content = readdir(DIR);
|
||||
closedir DIR;
|
||||
|
||||
for(grep { -f "$from/$_" && ($_ !~ /^\./ || $_ eq ".htaccess") } @content) {
|
||||
process_one("$from/$_");
|
||||
}
|
||||
for(grep { -d "$from/$_" && $_ !~ /^\./ } @content) {
|
||||
process_files("$from/$_");
|
||||
}
|
||||
}
|
||||
|
||||
process_files($mibewPath);
|
||||
|
||||
# fix
|
||||
$messagekeys{'page.analysis.userhistory.title'} = 1;
|
||||
$messagekeys{'errors.failed.uploading.file'} = 2;
|
||||
|
||||
|
||||
open( OUT, "> $mibewPath/locales/names/level1") or die "cannot write file, $!";
|
||||
for $key(sort grep { $messagekeys{$_} == 0 } keys %messagekeys) {
|
||||
print OUT "$key\n";
|
||||
}
|
||||
close( OUT );
|
||||
|
||||
open( OUT, "> $mibewPath/locales/names/level2") or die "cannot write file, $!";
|
||||
for $key(sort grep { $messagekeys{$_} == 1 } keys %messagekeys) {
|
||||
print OUT "$key\n";
|
||||
}
|
||||
close( OUT );
|
||||
|
||||
open( OUT, "> $mibewPath/install/package") or die "cannot write file, $!";
|
||||
for $key(sort @allsources) {
|
||||
$digest = file_checksum($key);
|
||||
$key =~ s/$mibewPath\///;
|
||||
print OUT "$key $digest\n";
|
||||
}
|
||||
close( OUT );
|
66
src/pack.pl
66
src/pack.pl
@ -1,66 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
##################################################################
|
||||
# Arguments
|
||||
##################################################################
|
||||
|
||||
$targetFolder = "deploy";
|
||||
$suffix = "165";
|
||||
|
||||
##################################################################
|
||||
# Copies tree into target folder, preprocess .phps
|
||||
##################################################################
|
||||
|
||||
sub process_dir($$) {
|
||||
my ($from,$to) = @_;
|
||||
opendir(DIR, $from) || die "can't opendir $from: $!";
|
||||
my @content = readdir(DIR);
|
||||
closedir DIR;
|
||||
mkdir $to;
|
||||
|
||||
for(grep { -f "$from/$_" && ($_ !~ /^\./ || $_ eq ".htaccess" || $_ eq ".keep") } @content) {
|
||||
my ($source,$target) = ("$from/$_","$to/$_");
|
||||
|
||||
open (IN,"$source");
|
||||
binmode(IN);
|
||||
open (OUT,">$target");
|
||||
binmode(OUT);
|
||||
print OUT $buffer while (read (IN,$buffer,65536));
|
||||
}
|
||||
|
||||
for(grep { -d "$from/$_" && $_ !~ /^\./ } @content) {
|
||||
process_dir("$from/$_","$to/$_");
|
||||
}
|
||||
}
|
||||
|
||||
##################################################################
|
||||
# Main
|
||||
##################################################################
|
||||
|
||||
`rm -rf $targetFolder`;
|
||||
die "Target folder exists: $targetFolder" if -e $targetFolder;
|
||||
|
||||
process_dir("./mibew", $targetFolder);
|
||||
|
||||
`rm -rf release$suffix`;
|
||||
die "release folder exists: release$suffix" if -e "release$suffix";
|
||||
mkdir "release$suffix";
|
||||
|
||||
chdir "$targetFolder";
|
||||
|
||||
`zip -r ../release$suffix/mibew${suffix}_all.zip * .htaccess`;
|
||||
|
||||
chdir "locales";
|
||||
|
||||
foreach $locale qw ( ar be bg ca cs da de el fa fi fr he hr hu id it ka lv nl pl pt-br pt-pt ro ru sp sv th tr ua zh-cn zh-tw ) {
|
||||
|
||||
`zip -r ../../release$suffix/mibew${suffix}_$locale.zip $locale`;
|
||||
`rm -rf $locale`;
|
||||
|
||||
}
|
||||
|
||||
chdir "..";
|
||||
`zip -r ../release$suffix/mibew$suffix.zip * .htaccess`;
|
||||
|
||||
chdir "..";
|
||||
`rm -rf $targetFolder`;
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
sub sort_transl($) {
|
||||
my($from) = @_;
|
||||
my @translation = ();
|
||||
my $header = "";
|
||||
open(IN, "$from");
|
||||
while(<IN>) {
|
||||
chomp;
|
||||
my $curr = $_;
|
||||
if(/^([\w\.]+)=(.*)$/) {
|
||||
if($1 ne "encoding" && $1 ne "output_charset" && $1 ne "output_encoding") {
|
||||
push @translation, $curr;
|
||||
} else {
|
||||
$header .= "$curr\n";
|
||||
}
|
||||
} else {
|
||||
die "wrong line in $from: $curr\n";
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
open(OUT, "> $from");
|
||||
print OUT $header;
|
||||
for$line(sort @translation) {
|
||||
print OUT "$line\n";
|
||||
}
|
||||
close(OUT);
|
||||
}
|
||||
|
||||
die "no parameter\n" if $#ARGV < 0;
|
||||
die "doesn't exists\n" unless -e $ARGV[0];
|
||||
|
||||
sort_transl($ARGV[0]);
|
Loading…
Reference in New Issue
Block a user