-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathabuseToUser.php
60 lines (50 loc) · 1.61 KB
/
abuseToUser.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
<?php
/**
* Apache License 2.0
* @author Trapenok Victor, [email protected], 89244269357
* I will be glad to new orders for the development of anything.
*
* Skype:Levhav
* 89244269357
*
* https://github.com/Levhav/Star.Comet-Chat
*/
include './config.php';
include './common.php';
$user_id = getUserIdOrDie();
$abuse_to_user_id = (int)$_POST['abuse_to'];
if($abuse_to_user_id <= 0)
{
die("Invalid parameter user_id_to");
}
// Determine the type of connection of users (favorites are banned neutral)
$result = mysqli_query(StarCometChat::conf()->getDB(),
"INSERT INTO `abuse` (`id`, `user_id_from`, `user_id_to`, `time`) VALUES (NULL, '".$user_id."', '".$abuse_to_user_id."', '".date("U")."');");
$abuse_id = mysqli_insert_id(StarCometChat::conf()->getDB());
$msg = array("abuse_id" => $abuse_id, "user_id_from" => $user_id, "user_id_to"=>$abuse_to_user_id, "time" => date("U"));
$result = mysqli_query(StarCometChat::conf()->getDB(),"SELECT id, login, avatar_url FROM `users` where id in(".$abuse_to_user_id.",".$user_id.")");
$row = mysqli_fetch_assoc($result);
if($row['id'] == $user_id)
{
$msg["loginFrom"] = $row['login'];
$msg["avatarFrom"] = $row['avatar_url'];
}
else
{
$msg["loginTo"] = $row['login'];
$msg["avatarTo"] = $row['avatar_url'];
}
$row = mysqli_fetch_assoc($result);
if($row['id'] == $user_id)
{
$msg["loginFrom"] = $row['login'];
$msg["avatarFrom"] = $row['avatar_url'];
}
else
{
$msg["loginTo"] = $row['login'];
$msg["avatarTo"] = $row['avatar_url'];
}
sendMsgToAdmin("newAbuseForUser", $msg);
echo json_encode(array("abuse_id" => $abuse_id));