-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathprofile.php
More file actions
executable file
·135 lines (104 loc) · 3.64 KB
/
profile.php
File metadata and controls
executable file
·135 lines (104 loc) · 3.64 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
<?php
session_start();
include('settings.php');
$cn=mysqli_connect(localhost,$DBUSER,$DBPASS,$DBNAME) ;
if(!isset($_GET['username'])) $username = $_SESSION['username'];
else $username = mysqli_real_escape_string($cn,$_GET['username']);
if(!isset($username)){
echo"No username selected....Redirecting to homepage";
echo'<meta HTTP-EQUIV="REFRESH" content="3; url=index.php">';
exit(0);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Online Judge </title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="description" content="Site Description Here" />
<meta name="keywords" content="keywords, here" />
<meta name="robots" content="index, follow, noarchive" />
<meta name="googlebot" content="noarchive" />
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
</head>
<body>
<!-- wrap starts here -->
<div id="wrap">
<?php include('header.php');
$cn=mysql_connect(localhost,$DBUSER,$DBPASS) or die(mysql_error());
mysql_select_db($DBNAME,$cn);
if(isset($_GET['username'])){
$query = "select * from users where username='$username'";
$logged = mysql_query($query);
$logg = mysql_fetch_array($logged);
$lastname=$logg['lastname'];
$firstname=$logg['firstname'];
$college=$logg['college'];
$newuserid=$logg['userID'];
}
else{
$lastname=$_SESSION['lastname'];
$firstname=$_SESSION['firstname'];
$college=$_SESSION['college'];
$newuserid=$_SESSION['userid'];
}
?>
<div id="content-outer" class="clear">
<div id="left">
<div id="featured" class="clear">
<div class="image-block" ><img src='images/2.jpg' ></img></div>
<?php echo "<div class='text-block' ><p></br></br>".$firstname." ".$lastname."</br></p><p>".$college."</p></div>"; ?>
<!-- graph comes here -->
</div>
<div class="entry">
<?php
$query = "select count(*) from submissions where userID='$newuserid'";
$logged = mysql_query($query);
$logg = mysql_fetch_array($logged);
$count = $logg['count(*)'];
if(isset($_GET['page'])) $page = intval($_GET['page']);
else $page = 1;
if($page>=$count/10+1)$page=1;
echo" <h3>Recent Submissions for $username</h3>";
echo "<table border='0' width='100%'";
echo"<tr class='altrow'>";
$status = array("Accepted","Compilation-Error","Wrong-Answer","TLE","Illegal-File","Runtime-error","Waiting" );
for($i=-3;$i<4;$i++){
$temp=$page+$i;
echo("<td>");
if($i==0) echo $temp;
else if($temp > 0 && $temp < $count/10+1)
echo "<a href=profile.php?page=".$temp."&&username=$username>".$temp."</a>";
echo"</td>";
}
echo "</tr></table>";
$query = "select * from `submissions` where username='$username' order by submID desc limit ".(($page-1)*10).",10";
$logged = mysql_query($query);
echo <<<EOHTML
<p>
<table border='1' width='100%' >
<tr>
<th>Username</th><th>Problem</th><th>Run Time</th><th>Language</th><th>Status</th>
</tr>
EOHTML;
for($i=0;$logg = mysql_fetch_array($logged);$i++){
echo "
<tr class='".$status[$logg['status']]."'>
<td><a href='profile.php?username=".$logg['username']."'>".$logg['username']."</a></td>
<td><a href='problem.php?problemID=".$logg['problemID']."'>".$logg['problemName']."</a></td>
<td> ".$logg['runtime']." sec</td>
<td> ".$logg['submlang']."</td><td><a href='view.php?submID=".$logg['submID']."'> ".$status[$logg['status']]."</a></td>
</tr>";
}
echo "</table>";
mysql_close($cn);
?>
</div>
<div class="entry" id="graph1" style="width: auto; height: 500px;"><?php include('graph.php'); ?></div>
</div>
<?php include("sidebar.php"); ?>
</div>
</div>
</body>
<?php include("footer.php"); ?>
</html>