-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuspendOrDelete.cgi
More file actions
executable file
·91 lines (71 loc) · 2.13 KB
/
suspendOrDelete.cgi
File metadata and controls
executable file
·91 lines (71 loc) · 2.13 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
#!/usr/bin/perl -w
use CGI qw/:all/;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use DataManipulation;
use File::Path;
use File::Copy;
$zid_cookie=cookie("zid");
if(defined param("group") && param("group") eq "suspend"){
##remove mate relation ship from their friend, single direction, the user preserve the mate relationship information
open F,"<$users_dir/$zid_cookie/user.txt";
while(my $line = <F>){
if($line =~ /^\s*mates/){
my @matesZid = ($line =~ /z[0-9]{7}/g);
#print @matesZid;
foreach my $mateZid (@matesZid){
open F2,'<',"$users_dir/$mateZid/user.txt";
my @readFromFile = <F2>;
close F2;
open F2,'>',"$users_dir/$mateZid/user.txt";
foreach my $tempLine (@readFromFile){
if($tempLine =~ /^\s*mates/){
$tempLine =~ s/(,\Q$zid_cookie\E)|(\Q$zid_cookie\E)//;
print F2 $tempLine;
}else{
print F2 $tempLine;
}
}
close F2;
}
}
}
close F;
move("$users_dir/$zid_cookie","$suspend_dir/$zid_cookie");
print redirect("welcomeLoginPage.cgi");
}elsif(defined param("group") && param("group") eq "delete"){
open F,"<$users_dir/$zid_cookie/user.txt";
while(my $line = <F>){
if($line =~ /^\s*mates/){
my @matesZid = ($line =~ /z[0-9]{7}/g);
#print @matesZid;
foreach my $mateZid (@matesZid){
open F2,'<',"$users_dir/$mateZid/user.txt";
my @readFromFile = <F2>;
close F2;
open F2,'>',"$users_dir/$mateZid/user.txt";
foreach my $tempLine (@readFromFile){
if($tempLine =~ /^\s*mates/){
$tempLine =~ s/(,\Q$zid_cookie\E)|(\Q$zid_cookie\E)//;
print F2 $tempLine;
}else{
print F2 $tempLine;
}
}
close F2;
}
}
}
close F;
rmtree("$users_dir/$zid_cookie");
print redirect("welcomeLoginPage.cgi");
}
print header(-charset => "utf-8"), start_html('suspend or delete');
print start_form(-action=>"suspendOrDelete.cgi");
#print "I pressed suspend the result is:".param("group")."\n"."<br/>";
print "suspend<br>
<input type=\"radio\" name=\"group\" value=\"suspend\"><br>
Delete:<br>
<input type=\"radio\" name=\"group\" value=\"delete\"><br/>";
print submit;
print end_form;
print end_html;