-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathremove.cgi
More file actions
executable file
·158 lines (140 loc) · 5.1 KB
/
remove.cgi
File metadata and controls
executable file
·158 lines (140 loc) · 5.1 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/perl
# Copyright (C) 2004-2019
# Emmanuel Saracco <emmanuel@esaracco.fr>
#
# GNU GENERAL PUBLIC LICENSE
require './translator-lib.pl';
my $app = $in{'app'};
my $lang = $in{'t'};
my $target = $in{'c'};
my $webmin_lang = $in{'webmin_lang'};
my $finfo = (&trans_is_theme ($app)) ? 'theme' : 'module';
my $default_tab = $in{'tab'}||'';
##### POST action #####
#
# remove translation
if (defined ($in{'remove'}))
{
# remove lang files
if ($target eq 'all' || $target eq 'all_webmin' || $target eq 'lang')
{
unlink ("$root_directory/lang/$lang") if ($webmin_lang ne '');
unlink ("$root_directory/$app/lang/$lang");
# Webmin module exception (2 languages files)
unlink ("$root_directory/lang/$lang") if ($app eq 'webmin');
}
# remove ulang files
if ($target eq 'all' || $target eq 'all_usermin' || $target eq 'ulang')
{
unlink ("$config_usermin{'root'}/$app/ulang/$lang");
}
# remove config.info
if ($target eq 'all' || $target eq 'all_webmin' || $target eq 'config_info')
{
unlink ("$root_directory/$app/config.info.$lang");
}
# remove uconfig.info
if ($target eq 'all' || $target eq 'all_usermin' || $target eq 'uconfig_info')
{
unlink ("$config_usermin{'root'}/$app/uconfig.info.$lang");
}
# remove help files
if ($target eq 'all' || $target eq 'all_webmin')
{
opendir (DIR, "$root_directory/$app/help/");
while (my $file = readdir (DIR))
{
unlink ("$root_directory/$app/help/$file") if ($file =~ /\.$lang\./);
}
closedir (DIR);
}
# remove translation from webmin module.info/theme.info
if ($target eq 'all' || $target eq 'all_webmin' || $target eq 'module_info')
{
unlink ("$root_directory/$app/$finfo.info.$lang");
move ("$root_directory/$app/$finfo.info", "/$config{'trans_working_path'}/.translator/$remote_user/$app-$finfo.info$main::session_id");
open (SRC, '<', "/$config{'trans_working_path'}/.translator/$remote_user/$app-$finfo.info$main::session_id");
open (DST, '>', "$root_directory/$app/$finfo.info");
foreach my $line (<SRC>)
{
next if $line =~ /desc_$lang/i;
my ($name, $value) = split (/=/, $line, 2);
print DST "$name=$value";
}
close (DST);
close (SRC);
}
# remove translation from usermin module.info/theme.info
if ($target eq 'all' || $target eq 'all_usermin' || $target eq 'umodule_info')
{
unlink ("$config_usermin{'root'}/$app/$finfo.info.$lang");
move ("$config_usermin{'root'}/$app/$finfo.info",
"/$config{'trans_working_path'}/.translator/$remote_user/$app-u$finfo.info$main::session_id");
open (SRC, '<', "/$config{'trans_working_path'}/.translator/$remote_user/$app-u$finfo.info$main::session_id");
open (DST, '>', "$config_usermin{'root'}/$app/$finfo.info");
foreach my $line (<SRC>)
{
next if $line =~ /desc_$lang/i;
my ($name, $value) = split (/=/, $line, 2);
print DST "$name=$value";
}
close (DST);
close (SRC);
}
&redirect ("$in{'referer'}.cgi?app=$app&t=$lang&o=remove_trans&webmin_lang=$webmin_lang&tab=$default_tab");
exit;
}
#
########################
&trans_header ($text{'REMOVE_TRANSLATION_TITLE'}, $app, $lang);
print qq(<br/>);
if ($target eq 'all')
{
($webmin_lang ne '') ?
printf ($text{'REMOVE_TRANSLATION_SPECIAL_DESCRIPTION'}, $lang, $lang, $lang) :
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION_ALL'}, $lang, $lang, $lang, $lang, $app);
}
elsif ($target eq 'all_webmin')
{
($webmin_lang ne '') ?
printf ($text{'REMOVE_TRANSLATION_SPECIAL_DESCRIPTION'}, $lang, $lang, $lang) :
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION'}, $lang, $lang, $lang, $app);
}
elsif ($target eq 'all_usermin')
{
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION_USERMIN'}, $lang, $lang, $lang, $app);
}
elsif ($target eq 'lang')
{
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION_LANG'}, $lang, $app);
}
elsif ($target eq 'ulang')
{
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION_ULANG'}, $lang, $app);
}
elsif ($target eq 'module_info')
{
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION_MODULE_INFO'}, $lang, $lang, $app);
}
elsif ($target eq 'config_info')
{
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION_CONFIG_INFO'}, $lang, $lang, $app);
}
elsif ($target eq 'umodule_info')
{
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION_UMODULE_INFO'}, $lang, $lang, $app);
}
elsif ($target eq 'uconfig_info')
{
printf ($text{'REMOVE_TRANSLATION_DESCRIPTION_UCONFIG_INFO'}, $lang, $lang, $app);
}
print qq(<form action="remove.cgi" method="post">);
print qq(<input type="hidden" name="app" value="$app"/>);
print qq(<input type="hidden" name="tab" value="$default_tab"/>);
print qq(<input type="hidden" name="t" value="$lang"/>);
print qq(<input type="hidden" name="c" value="$target"/>);
print qq(<input type="hidden" name="webmin_lang" value="$webmin_lang"/>);
print qq(<input type="hidden" name="referer" value="$in{'referer'}"/>);
print qq(<p/><div><button type="submit" name="remove" class="btn btn-danger"><i class="fa fa-fw fa-trash"></i> <span>$text{'REMOVE_TRANSLATION'}</span></button></div>);
print qq(</form>);
&trans_footer("$in{'referer'}.cgi?app=$app&webmin_lang=$webmin_lang&tab=$default_tab", $text{'PREVIOUS'});