-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowUserPageToOthers.cgi
More file actions
executable file
·130 lines (98 loc) · 3.38 KB
/
showUserPageToOthers.cgi
File metadata and controls
executable file
·130 lines (98 loc) · 3.38 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
#!/usr/bin/perl -w
use CGI qw/:all/;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use DataManipulation;
######this cgi file show user page to other users/his mates############
$user_zid = param("username") or die "do not have the zid cannot display user page";
#print header(-charset => "utf-8"),start_html(-title => "$user_zid user page");
if(-e "$users_dir/$user_zid/background.jpg"){
print header(-charset => "utf-8"),start_html(-title => "$user_zid user page",-background=>"$users_dir/$user_zid/background.jpg");
}else{
print header(-charset => "utf-8"),start_html(-title => "$user_zid user page");
}
print h2(returnUserNameWithZid($user_zid)." user page");
$tnjpgfile = returnUserImgWithZid($user_zid);
if($tnjpgfile){
print "<span><img src=\"$tnjpgfile\" alt=\"$user_zid image\" width=\"200\" height=\"200\"></span>","\n";
}
#print "show to others";
print logoutHtml();
### a strange technique, the submit button's name is showUserPage, which in matelook.cgi will triger to show the user's profile
print "<form action=\"matelook.cgi?showUserPage=1\">",
"<input type='submit' action = \"matelook.cgi?showUserPage=1\" value=\"Go Back To My Page\" name=\"showUserPage\">",
"</form>";
print "<br/>";
##check whether they're friends , and show add friends option if they are not
$current_user_cookie = cookie("zid");
if(! checkUsrsMateRelationship($user_zid,$current_user_cookie)){
print "<a href=\"matelook.cgi?sendMateRequest=1&from=$current_user_cookie&to=$user_zid\">send mate request</a><br/>";
}
print searchForNameAndPostHtml();
##display user information according to notificationAndPrivacy.cgi if they not mate
if(! -e "$users_dir/$user_zid/notificationAndPrivacySetting.txt"){
createDefaultNPStxt($user_zid);
}
open F,"<","$users_dir/$user_zid/notificationAndPrivacySetting.txt";
my @readLines=<F>;
close F;
#remove the notification setting
shift @readLines;
shift @readLines;
%displayToPublic=();
foreach my $line (@readLines){
#print "$line 123\n";
if($line=~/1$/){
$line =~ s/=1//;
#print "line:$line";
$displayToPublic{$line}=1;
}
}
if(checkUsrsMateRelationship($user_zid,cookie("zid"))){
open F,"<$users_dir/$user_zid/user.txt";
while(my $line = <F>){
#print "<p>user infomation, what should i display?</p>";
if($line =~ /password/){
next;
}else{
print "<p>$line</p>","\n";
}
}
close F;
}else{
open F,"<$users_dir/$user_zid/user.txt";
#print "come in here";
#print "display to public:@displayToPublic";
while(my $line = <F>){
my $tempLine = $line;
#print "tempLine1:$tempLine\n delimiter";
$tempLine =~ s/(.*?)\=.*/$1/;
#print "tempLine:$tempLine";
if($displayToPublic{$tempLine}){
#print "come in here2";
print p("$line");
}
}
close F;
}
open F,"<$users_dir/$user_zid/user.txt";
##display mate list
print "<p> MATES: </p>";
while(my $line = <F>){
if($line =~ /^\s*mates/){
my @matesZid = ($line =~ /z[0-9]{7}/g);
#print @matesZid;
foreach my $mateZid (@matesZid){
#print "$mateZid";
my $correspondingName = returnUserNameWithZid($mateZid);
print "<a href=\"matelook.cgi?showUserPage=1&userZid=$mateZid\">$correspondingName</a>";
my $tnjpgfile = returnUserImgWithZid($mateZid);
if($tnjpgfile){
print "<a href=\"matelook.cgi?showUserPage=1&userZid=$mateZid\"><img src=\"$tnjpgfile\" alt=\"go to $mateZid \" width=\"50\" height=\"30\"></a>";
}
print "<br/>";
}
}
}
close F;
##display posts
print end_html;