-
Notifications
You must be signed in to change notification settings - Fork 0
/
likeProcessor.php
53 lines (40 loc) · 1.42 KB
/
likeProcessor.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
<?php
require_once 'AndLib/AndCore.php';
session_start();
if (empty($_SESSION['user_id'])) {
$isLogin = false;
header('Location:' . AndPath::getHost() . AndPath::getPath() . '/index.php');
} else{
$isLogin = true;
}
$owner = $_SESSION['user_id'];
$ref = $_GET['ref'];
$reciever = $_GET['trigger'];
$uref = $_GET['uref'];
$ureciever = $_GET['utrigger'];
AndDevDebug::printNice($_GET);
$timeNow = date("Y-m-d H:i:s", time());
// ---------------- handle database ------------------
$con = new AndDatabase();
if (isset($ref) && isset($reciever)) {
$messagesFeed = $con->queryObj("
INSERT INTO `openpen`.`like` (`writing_id`, `reciever`, `sender`, `counter`)
VALUES ('$ref', '$reciever', '$owner', '1')
");
if ($reciever == $owner) {
echo NULL;
}else{
$broadcaster = $con->query("
INSERT INTO `openpen`.`notifications` (`reciever`, `sender`, `activity`, `object_id`, `notif_created`, `notif_status`)
VALUES ('$reciever', '$owner', '3', '$ref', '$timeNow', '0')
");
}
header('Location:' . AndPath::getHost() . AndPath::getPath() . '/profile.php?regist_id=' . $reciever );
}elseif (isset($uref) && isset($ureciever)) {
$messagesFeed = $con->queryObj("
DELETE FROM `openpen`.`like` WHERE `writing_id`='$uref' AND `sender`='$owner' ;
");
header('Location:' . AndPath::getHost() . AndPath::getPath() . '/profile.php?regist_id=' . $ureciever );
}
$con->closeConnection();
// ---------------- handle database ------------------