-
Notifications
You must be signed in to change notification settings - Fork 5
/
userconnection.php
executable file
·71 lines (60 loc) · 1.55 KB
/
userconnection.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
<?php
session_start();
if($_SESSION['authuser']!=1)
{
header("Location:index.php");
exit;
}
include('lib/connectionfile.php');
$username1=$_POST['username1'];
$username2=$_POST['username2'];
$status=$_POST['status'];
switch ($status)
{
case "A":
$count1=dbconfn()->prepare("DELETE FROM w_connections WHERE (username1='$username1' and username2='$username2') or (username1='$username2' and username2='$username1')");
$count1->execute();
header("Location:profile?id=$username1");
exit;
break;
case "R":
case "S":
$count1=dbconfn()->prepare("DELETE FROM w_connections WHERE username1='$username1' and username2='$username2'");
$count1->execute();
if($status=='S') //Status S: For Sent Invites from Homepage
{
header("Location:home");
exit;
}
else
{
header("Location:profile?id=$username2");
exit;
}
break;
case "I":
case "J":
$count1=dbconfn()->prepare("UPDATE w_connections SET status='A' WHERE username1='$username1' and username2='$username2'");
$count1->execute();
if($status=='J') //Status J: For Requests from Homepage
{
header("Location:home");
exit;
}
else
{
header("Location:profile?id=$username1");
exit;
}
break;
case "O":
$count1=dbconfn()->exec("INSERT INTO w_connections VALUES('$username1','$username2','R')");
header("Location:profile?id=$username2");
exit;
break;
default:
//This error should be handled better in the future -WILLIAMKNAUSS
die("Unknown status: ".$status);
break;
}
?>