-
Notifications
You must be signed in to change notification settings - Fork 0
/
friendprofile.py.txt
52 lines (41 loc) · 1.43 KB
/
friendprofile.py.txt
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
#!/usr/bin/python
#import CGI handling modules
import cgi, cgitb
#GET
form = cgi.FieldStorage()
#get friend's name
friend = form.getvalue('friend')
friend = friend.strip()
#get current username
userName = form.getvalue('user')
#open user files
with open('/home/2016/yliu236/public_html/users.txt', 'r') as userInfo:
info = userInfo.readlines()
print 'Content-type:text/html\r\n\r\n'
print '<html>'
print '<head>'
print '<title> %s\'s profile </title>'%friend
print '</head>'
print '<body style=\"margin:42; font-family:arial;background-color:#333333;color:#d3ffce;\"alink=\"#fac7d0\" vlink=\"#fac7d0\"link=\"#faeb7\">'
print '%s\'s profile' %friend
print '<br /><br />'
counter = 0
for i, line in enumerate(info):
if (counter%4==0):
currentLine=line.strip('\n')
#if found user,
if (currentLine==friend):
#print user info
fullName = info[i+2].strip('\n')
job = info[i+3].strip('\n')
print 'Username: %s <br />' %friend
print 'Full name: %s <br />' %fullName
print 'Job description: %s <br />' %job
break
counter+=1
print '<br /><br />'
#link back to see a friend page
print '<a href=\"http://cs.mcgill.ca/~tli43/seefriends.cgi?user=%s\">'%userName
print 'See more friends </a>'
print '</body>'
print '</html>'