-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpComment.php
More file actions
87 lines (78 loc) · 2.28 KB
/
Copy pathpComment.php
File metadata and controls
87 lines (78 loc) · 2.28 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
session_start();
require 'include/lib.php';
$comment=new item_class();
$comment->set("comments");
$owner=new item_class();
$owner->set("notification");
?>
<?php
/************insert comments**************/
if (isset($_POST['aid'])){
$qid=$_POST['aqid'];
$body=$_POST['comment'];
$time=time();
$aid=$_POST['aid'];
$uid=$_POST['uid'];
$username=$_POST['username'];
$data=array("uid"=>$uid,"aid"=>$aid,"body"=>$body,"time"=>$time,"username"=>$username);
$comment->insert($data);
if($comment->affected_rows>0){
$cid=$comment::$link->insert_id;
echo $cid;
$owner->sql_query("select uid,body from answers where id=$aid");
$owner_data=$owner->load_datas();
$fid=$owner_data['uid'];
$a_body=substr($owner_data['body'],0,25);
$a_body.="...";
if($fid!=$uid){
$insertNot=array("message"=>$a_body,"cid"=>$cid,"aid"=>$aid,"fid"=>$uid,"uid"=>$fid,"qid"=>$qid);
$owner->insert($insertNot);
}
}
else echo "error";
}
elseif(isset($_POST['qid']))
{
$body=$_POST['comment'];
$time=time();
$qid=$_POST['qid'];
$uid=$_POST['uid'];
$username=$_POST['username'];
$data=array("uid"=>$uid,"qid"=>$qid,"body"=>$body,"time"=>$time,"username"=>$username);
$comment->insert($data);
if($comment->affected_rows>0){
$cid=$comment::$link->insert_id;
echo $cid;
$owner->sql_query("select owner_id,title from questions where id=$qid");
$owner_data=$owner->load_datas();
$fid=$owner_data['owner_id'];
$q_title=substr($owner_data['title'],0,25);
$q_title.="...";
if($fid!=$uid){
$insertNot=array("message"=>$q_title,"cid"=>$cid,"qid"=>$qid,"fid"=>$uid,"uid"=>$fid);
$owner->insert($insertNot);
}
}
else echo 0;
}
//header("location:question.php?id=$_GET[id]");
/************delete comments**************/
if(isset($_POST['cid']) && $_POST['action']=="delete"){
$comment->set("comments",$_POST['cid']);
$comment->delete();
if($comment->affected_rows>0){
echo 1;
}
else echo 0;
}
elseif(isset($_POST['cid']) && $_POST['action']=="edit"){
$comment->set("comments",$_POST['cid']);
$update=array("body"=>$_POST['cmt_body']);
$comment->update($update);
if($comment->affected_rows>0){
echo 1;
}
else echo 0;
}
?>