-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwolfpackSummary.php
210 lines (168 loc) · 6.21 KB
/
wolfpackSummary.php
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php session_start();
if(file_exists("./formatting/redirect.php")){
include "./formatting/redirect.php";
}
if(file_exists("./formatting/header.php")){
include "./formatting/header.php";
}
?>
<body>
<div data-role="page">
<div data-role="header" data-position="fixed">
<!--<a href="#" data-rel="back" data-icon="arrow-l" id="back" data-transition="slide" data-direction="reverse" data-role="button" class="ui-btn-left">Back</a>-->
<h1>My Wolfpack! <img src="images/logo_icon_invert.png" height="14px"/></h1>
<?php
if(file_exists("./formatting/logout.php")){
include "./formatting/logout.php";
}
?>
</div><!-- /header -->
<div data-role="content">
<?php
include("config.php");
if (isset($_POST["task"])){
$task = $_POST["task"];
$groupId = $_POST["groupId"];
}else{
$task = 1;
$groupId = $_SESSION["groupNumber"];
}
if($task=="join"){ //Joining an existing open group:
//$groupId = $_POST["groupId"];
try{
$queryString = "UPDATE users SET groupNumber=".$groupId.", status=1 WHERE userName=\"".$_SESSION['userName']."\"";
$result = mysql_query($queryString)or die(mysql_error());
}catch(Exception $e){
echo 'Message: ' .$e->getMessage();
}
}
if($task=="acceptInvitation"){
$queryString = "UPDATE users SET groupNumber=".$groupId.", status=1 WHERE userName=\"".$_SESSION['userName']."\"";
$result = mysql_query($queryString)or die(mysql_error());
}
if($task=="create"){ //Creating a new group:
$gn=$_POST["groupName"];
$buttonCount = $_POST["buttonCount"];
$loc = $_POST["location"];
echo "Mode: ".$_POST["radio-view"];
if($_POST["radio-view"] == "open")
{
$privacy = 2;
}
elseif($_POST["radio-view"] == "invite")
{
$privacy = 1;
}
else
{
$privacy = 0;
}
$input = $_POST["radio-view"];
$time = $_POST["startTimeWPCreate"];
//Create the new group:
$un=$_SESSION['userName'];
$queryString = "INSERT INTO groups (name,location,owner,timeStart,open) VALUES ('".$gn."','".$loc."','".$un."',".$time.",".$privacy.")";
$query = $queryString;
$result = mysql_query($query)or die(mysql_error());
//Find the current group number:
$query2 = "SELECT MAX(id) AS id FROM groups";
$result = mysql_query($query2)or die(mysql_error());
while($row = mysql_fetch_array($result)){
$groupId = $row['id'];
}
//Add group number and status of group owner to current session user:
$query3 = "UPDATE users SET groupNumber=".$groupId.", status=3 WHERE userName=\"".$un."\""; $result = mysql_query($query3)or die(mysql_error());
//Add group number to the friends and set status to pending (2):
for($i=1;$i<=$buttonCount;$i++){
$name = $_POST["name-".$i];
$value = $_POST["checkbox-".$i];
if($value=="on"){
$friendGroupQuery = "UPDATE users SET groupNumber=".$groupId.", status=2 WHERE userName=\"".$name."\"";
$result = mysql_query($friendGroupQuery)or die(mysql_error());
}
}
}
if($task=="banana"){ //Add more to group:
$queryForAdd = "SELECT * FROM users WHERE userName=\"".$_SESSION['userName']."\"";
$result = mysql_query($queryForAdd)or die(mysql_error());
while($row = mysql_fetch_array($result)){
$groupId = $row['groupNumber'];
}
//echo "Group Id: ".$groupId;
//echo "<br>";
$buttonCount = $_POST["buttonCount"];
//echo "Button Count: ".$buttonCount;
//echo "<br>";
for($i=1;$i<=$buttonCount;$i++){
//echo "Here we are again…";
//echo "<br>";
//echo "Value: ".$value;
//echo "<br>";
$name = $_POST["name-".$i];
//echo "Name: ".$name;
//echo "<br>";
$value = $_POST["checkbox-".$i];
//echo "Value: ".$value;
//echo "<br>";
if($value=="on"){
$friendGroupQuery = "UPDATE users SET groupNumber=".$groupId.", status=2 WHERE userName=\"".$name."\"";
//echo "Friend Group Query: ".$friendGroupQuery;
//echo "<br>";
$result = mysql_query($friendGroupQuery)or die(mysql_error());
}
}
}
?>
<div class="currentPackHeader" data-role="content" data-theme="a"></div>
<script type="text/javascript">
$(".logingout").click(function() {
localStorage.clear();
FB.logout(function() { window.location='account/logout' });
document.location = "login.php";
});
popupManager(".currentPackHeader", "This is the \"My Wolfpack\" page. Here you can see everything about your pack and your plans to eat. Tap the names below to see whether your friends have responded or not.");
</script>
<?php
$query = "SELECT * FROM groups WHERE id=\"".$groupId."\"";
$result = mysql_query($query)or die(mysql_error());
while($row = mysql_fetch_array($result)){
$groupName = $row['name'];
}
?>
<?php
if(file_exists("./formatting/myGroupList.php")){
include "./formatting/myGroupList.php";
}
?>
<?php
echo "<form action=\"addMoreFriends.php\" method=\"post\"><input type=\"submit\" onclick=\"eSource2.close();\" value=\"Invite More People!\"/></form>";
echo "<form action=\"mainPage.php\" method=\"post\"><input type=\"hidden\" value=\"leave\" name=\"task\"><input type=\"submit\" onclick=\"eSource2.close();\" value=\"Leave Group!\"/></form>";
echo "<form action=\"iAmHungryPage.php\" method=\"post\"><input type=\"hidden\" value=\"notHungry\" name=\"task\"><input type=\"submit\" onclick=\"eSource2.close();\" value=\"I'm Not Hungry Anymore!\"/></form>";
?>
<div class="chatPack" data-role="content" data-theme="a"></div>
<script type="text/javascript">
popupManager(".chatPack", "Join in the livechat and help decide where you're going!");
</script>
<?php
if(file_exists("./comments.php")){
include "./comments.php";
}
?>
<script type="text/javascript">
$(".logout").click(function() {
document.location = "login.php";
});
$("#logout").click(function() {
document.location = "login.php";
});
</script>
</div><!-- /content -->
<?php
if(file_exists("./formatting/footer.php"))
{
include "./formatting/footer.php";
}
?>
</div><!-- /page -->
</body>
</html>