-
Notifications
You must be signed in to change notification settings - Fork 0
/
puresp.php
66 lines (64 loc) · 2.11 KB
/
puresp.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
61
62
63
64
65
66
<?php
class pumsg {
private $conn,$how,$res;
public function __construct(){
$this->conn=mysqli_connect("localhost","nerds","bunchofnerds","pictest");
}
public function __destruct(){
mysqli_close($this->conn);
}
public function ptnmsg(){
$msg=mysqli_real_escape_string($this->conn, $_REQUEST["mesg"]);
$usname=$_REQUEST["usuqnm"];
$dt=date('Y-m-d H:i:s');
$this->how="INSERT INTO think (message,usname,dt) VALUES ('$msg','$usname','$dt')";
$this->res=mysqli_query($this->conn,$this->how);
if($this->res){
echo "Thanks for your patience and honest truth";
}
}
public function gtnmsg(){
$usname=$_REQUEST["usname"];
$this->how="SELECT message,dt,id from think where usname='$usname' AND dime=0 order by dt desc";
$this->res=mysqli_query($this->conn,$this->how);
$response=array();
$response["products"]=array();
if($this->res){
while(list($msg,$dt,$id)=$this->res->fetch_row()){
$products=array();
$products["dt"]=$dt;
$products["id"]=$id;
$products["msg"]=$msg;
array_push($response["products"],$products);
}
echo json_encode($response);
}
}
public function dlt(){
$usid=$_REQUEST["del"];
$this->how="DELETE from think where id='$usid'";
$this->res=mysqli_query($this->conn,$this->how);
if($this->res){
echo "Deleted";
}
}
public function dsme(){
$usname=$_REQUEST["usname"];
$this->how="UPDATE think SET dime=1 where usname='$usname'";
$this->res=mysqli_query($this->conn,$this->how);
if($this->res){
echo "Sorry if these offensive thoughts hurt you, no messages will be displayed anymore. Thank You!";
}
}
}
$kal=new pumsg();
if(isset($_REQUEST["usuqnm"])){
$kal->ptnmsg();
}else if(isset($_REQUEST["tme"])){
$kal->gtnmsg();
}else if(isset($_REQUEST["del"])){
$kal->dlt();
}else if(isset($_REQUEST["dsme"])){
$kal->dsme();
}
?>