-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathajax_comment_save.php
More file actions
54 lines (53 loc) · 1.51 KB
/
ajax_comment_save.php
File metadata and controls
54 lines (53 loc) · 1.51 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
<?
// ===================================================================
// Sim Roulette -> AJAX
// License: GPL v3 (http://www.gnu.org/licenses/gpl.html)
// Copyright (c) 2016-2025 Sim Roulette, https://sim-roulette.com
// ===================================================================
include("_func.php");
$id=(int)str_replace('ce_','',$_POST['id']);
$comment=trim(urldecode($_POST['comment']));
if ($id && $comment)
{
if ($sv_staff_id)
{
$qry='SELECT `ext`,`name` FROM `staff` WHERE `id`='.$sv_staff_id;
if ($result = mysqli_query($db, $qry))
{
if ($row = mysqli_fetch_assoc($result))
{
$ext=$row['ext'];
$staff=$row['name'];
}
}
}
else
{
$ext=3;
}
if ($ext==2)
{
$qry='SELECT `comment`,`id` FROM `cards` WHERE `number`="'.$id.'"';
if ($result = mysqli_query($db, $qry))
{
if ($row = mysqli_fetch_assoc($result))
{
$comment=trim($row['comment'].'
user:'.$staff.' time:'.srdate('d.m.Y H:i:s',$row['time']).'
'.$comment);
$qry='UPDATE `cards` SET `comment`="'.mysqli_real_escape_string($db,$comment).'" WHERE `number`="'.$id.'"';
mysqli_query($db,$qry);
$comment=preg_replace('/\n(user:(.*)time:(.*))\n/Us', "\n".'<user>${2} • ${3}</user>'."\n",$comment);
}
}
}
else
{
$qry='UPDATE `cards` SET `comment`="'.mysqli_real_escape_string($db,$comment).'" WHERE `number`="'.$id.'"';
mysqli_query($db,$qry);
$comment=preg_replace('/\n(user:(.*)time:(.*))\n/Us', "\n".'<user>${2} • ${3}</user>'."\n",$comment);
}
echo str_replace('
','<br>',$comment);
}
?>