-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmit.php
58 lines (43 loc) · 1.17 KB
/
submit.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
<?php
include("includes/funzioni.php");
?>
<?php
// Error reporting:
error_reporting(E_ALL^E_NOTICE);
include ("includes/comment.class.php");
/*
/ This array is going to be populated with either
/ the data that was sent to the script, or the
/ error messages.
/*/
$arr = array();
$validates = Comment::validate($arr);
if($validates)
{
/* Everything is OK, insert to database: */
mysql_query(" INSERT INTO av_comments(user_ID,video_ID,vote,comment,timestamp_insert,timestamp_edit)
VALUES (
'0',
'".$arr['video_ID']."',
'".$arr['vote']."',
'".$arr['comment']."',
'".$current_timestamp."',
'".$current_timestamp."'
)");
$arr['ID'] = mysql_insert_id();
/*
/ The data in $arr is escaped for the mysql query,
/ but we need the unescaped variables, so we apply,
/ stripslashes to all the elements in the array:
/*/
$arr = array_map('stripslashes',$arr);
$insertedComment = new Comment($arr);
/* Outputting the markup of the just-inserted comment: */
echo json_encode(array('status'=>1,'html'=>$insertedComment->markup()));
}
else
{
/* Outputtng the error messages */
echo '{"status":0,"errors":'.json_encode($arr).'}';
}
?>