-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolve-requests.php
121 lines (102 loc) · 2.96 KB
/
resolve-requests.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* @Author: Prabhakar Gupta
* @Date: 2016-02-16 01:57:09
* @Last Modified by: Prabhakar Gupta
* @Last Modified time: 2016-02-20 07:27:08
*/
require_once 'inc/connection.inc.php';
require_once 'inc/func.inc.php';
if(!isadmin()){
header('Location: index.php');
}
if(!empty($_POST)){
if(!empty($_POST['res'])){
$request_array = json_decode($_POST['res'], true);
$message_id = (int)$request_array[0];
$item = $request_array[1];
$defination = $request_array[2];
$query = "INSERT INTO `requests` (`item`,`defination`) VALUES ('$item','$defination')";
mysqli_query($connection, $query);
} else {
$message_id = (int)$_POST['rej'];
}
/**
* soft delete request from requests table
*/
delete_request($connection, $message_id);
}
?>
<!DOCTYPE html>
<html>
<head>
<?php
include 'layout/meta.inc.php';
?>
</head>
<body class="skin-black">
<?php
include 'layout/header.inc.php';
?>
<div class="wrapper row-offcanvas row-offcanvas-left">
<?php
include 'layout/leftpanel.inc.php';
?>
<aside class="right-side">
<section class="content">
<div class="row">
<div class="col-lg-12">
<section class="panel">
<header class="panel-heading">inbox</header>
<div class="panel-body">
<table class="table table-bordered">
<tbody>
<tr>
<th style="width: 10px">#</th>
<th>Sender</th>
<th>Message</th>
<th>Defination</th>
<th style="width: 120px">Resolve?</th>
<th style="width: 120px">Reject?</th>
</tr>
<?php
$query_fetch = "SELECT R.request, U.name, R.requests_raised_id FROM requests_raised R INNER JOIN users U ON R.sender_id = U.id WHERE R.status = 0 ORDER BY R.timestamp DESC";
$query_fetch_run = mysqli_query($connection, $query_fetch);
$i = 0;
while($query_row = mysqli_fetch_assoc($query_fetch_run)){
$request_text = clean_string($query_row['request']);
/**
* this is to check if duckduckgo API is giving any definition or not
* if it fails to provide any definition, it would automically be
* soft deltetd.
*/
if(duckduckgoreturn($request_text) == null){
delete_request($connection, $query_row['requests_raised_id']);
} else {
echo '<tr>
<td>' . ++$i . '</td>
<td>' . $query_row['name'] . '</td>
<td>' . $request_text . '</td>
<td>' . duckduckgoreturn($request_text) . '</td>
<form method="POST">
<td><button value=\'' . json_encode(array($query_row['requests_raised_id'],$request_text, duckduckgoreturn($request_text))) . '\' type="submit" name="res" class="btn btn-sm btn-success">Resolve</button></td>
<td><button value="' . $query_row['requests_raised_id'] . '" type="submit" name="rej" class="btn btn-sm btn-danger">Reject</button></td>
</form>
</tr>';
}
}
?>
</tbody>
</table>
</div>
</section>
</div>
</div>
</section>
</aside>
</div>
<?php
include 'layout/scripts.inc.php';
?>
</body>
</html>