forked from aorti017/CS180-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
147 lines (140 loc) · 5.61 KB
/
Copy pathprofile.php
File metadata and controls
147 lines (140 loc) · 5.61 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
<?php
include "./database.php";
session_start();
if(!isset($_COOKIE['username'])) {
header('Location: index.php');
}
setcookie("username", $_SESSION['username'], 0);
$user = $_GET['userVar'];
$sql = "SELECT * FROM Users WHERE username = '".$user."'";
$results = executeStatement($sql);
$username = $results[0][0];
$firstname = $results[0][2];
$lastname = $results[0][3];
$birthday = $results[0][4];
$gender = $results[0][5];
$email = $results[0][6];
$status = $results[0][7];
?>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script src="javascript.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<title>Home</title>
<link rel="stylesheet" type="text/css" href="navigation.css">
</head>
<body>
<div>
<nav class="main-menu">
<ul>
<li><a href="logout.php">Logout</a></li>
<li><a href="contacts.php">Contacts</a></li>
<li><a href="messages.php">Messages</a></li>
<li id="currentpage"><a id="userProf">Profile</a></li>
</ul>
</nav>
</div>
<div class="twitter-widget">
<div class="header cf">
<a href="https://www.facebook.com/" target="_blank" class="avatar"><img src="https://upload.wikimedia.org/wikipedia/en/b/b1/Portrait_placeholder.png" alt="Edwin Delgado"></a>
<h2><?php echo $firstname?> <?php echo $lastname ?></h2>
<p><?php echo $status ?><br>Contact email: <?php if($email!=null) {echo $email;} else {echo "N/A";}?></p>
</div>
<div class="stats cf">
<a class="stat"><strong><?php if($birthday!=null) {echo $birthday;} else {echo "N/A";}?></strong>Birthday</a>
<a class="stat"><strong><?php if($gender!=null) {echo $gender;} else {echo "N/A";}?></strong>Gender</a>
<a class="stat"><strong><?php echo $username ?></strong>Username</a>
</div>
<ul class="menu cf">
<li><a id="compose" class="ico-compose">Compose</a></li>
<?php if($_GET['userVar'] != $_COOKIE['username']){ echo "<li><a id='block' href='' class='ico-mentions'>Block/Unblock</a></li>";}?>
<?php if($_GET['userVar'] == $_COOKIE['username']){ echo "<li><a id='settings' href='getnewinfo.php' class='ico-settings'>Settings</a></li>";}?>
</ul>
<div align="center" style="display: none; width: 100%;" id="updateStatus">
<form id="statUpdate" action="./updateStatus.php" type="GET">
<input type="text" name="status" placeholder="Update Status" style="width: 100%;">
<div><input type="submit" value="Update"></div>
</form>
</div>
</div>
</body>
</html>
<script type="text/javascript">
document.getElementById("userProf").setAttribute("href", "profile.php?userVar="+parse());
//gets the userVar GET variable from the URL
var parts = window.location.href;
var userVar = parts.substring(parts.indexOf("=")+1, parts.length);
document.getElementById("compose").href = "./messages.php?contacts=" + userVar;
document.getElementById("compose").title = "Write a message to " + userVar;
if (parse() != userVar) {
document.getElementById("block").title = "Block or unblock " + userVar;
document.getElementById("block").onclick = function(){
$.ajax({
type:'GET',
url: './blockUser.php',
data: {username: parse(), contact: userVar}
});
};
}
if (parse() == userVar) {
document.getElementById("updateStatus").style.display = "block";
document.getElementById("settings").title = "Update your profile information";
}
document.addEventListener('DOMContentLoaded', function(){
if(Notification.permission != "granted"){
Notification.requestPermission();
}
});
function initNotifications(x, tracked, runCount){
var username = parse();
$.ajax({
type: 'GET',
url: './notifications.php',
data: {username: username, time: x},
success: function(data){
var obj = jQuery.parseJSON(data);
var messages = obj.message;
var senders = obj.sender;
var times = obj.times;
if(messages.length > 0 && senders.length > 0){
console.log(messages);
}
for(i = 0; i < messages.length; i++){
//make sure the array doesnt grow too large
if(runCount >= 500){
tracked = []
}
if(tracked.indexOf(times[i]) > -1){
continue;
}
else{
runCount += 1;
tracked.push(times[i]);
}
temp = document.cookie;
document.cookie = "sender="+senders[i];
document.cookie = "message="+messages[i];
if (Notification.permission != "granted")
Notification.requestPermission();
else {
var notification = new Notification(parseSender(), {body: parseMessage()});
notification.onclick = function () {
window.location.replace("./messages.php?contacts="+parseSender());};
setTimeout(function(){
notification.close();
}, 5000);
}
document.cookie = temp;
}
initNotifications(obj.time, tracked, runCount);
}
});
}
var d = new Date();
var tracked = [];
initNotifications(d.getTime(), tracked, 0);
</script>