-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
44983ba
commit d0f9557
Showing
5 changed files
with
221 additions
and
201 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
-- phpMyAdmin SQL Dump | ||
-- version 4.4.11 | ||
-- http://www.phpmyadmin.net | ||
-- | ||
-- Host: localhost | ||
-- Generation Time: Feb 20, 2016 at 07:27 AM | ||
-- Server version: 5.5.47-0ubuntu0.14.04.1 | ||
-- PHP Version: 5.5.9-1ubuntu4.14 | ||
|
||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; | ||
SET time_zone = "+00:00"; | ||
|
||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8mb4 */; | ||
|
||
-- | ||
-- Database: `inout` | ||
-- | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `requests_raised` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `requests_raised`; | ||
CREATE TABLE IF NOT EXISTS `requests_raised` ( | ||
`requests_raised_id` int(11) NOT NULL, | ||
`sender_id` int(11) NOT NULL, | ||
`request` varchar(500) NOT NULL, | ||
`status` int(1) NOT NULL DEFAULT '0', | ||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
|
||
-- | ||
-- Indexes for dumped tables | ||
-- | ||
|
||
-- | ||
-- Indexes for table `requests_raised` | ||
-- | ||
ALTER TABLE `requests_raised` | ||
ADD PRIMARY KEY (`requests_raised_id`), | ||
ADD UNIQUE KEY `request` (`request`); | ||
|
||
-- | ||
-- AUTO_INCREMENT for dumped tables | ||
-- | ||
|
||
-- | ||
-- AUTO_INCREMENT for table `requests_raised` | ||
-- | ||
ALTER TABLE `requests_raised` | ||
MODIFY `requests_raised_id` int(11) NOT NULL AUTO_INCREMENT; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,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 'inc/connection.inc.php'; | ||
require 'inc/func.inc.php'; | ||
require_once 'inc/connection.inc.php'; | ||
require_once 'inc/func.inc.php'; | ||
|
||
if(!loggedin()){ | ||
header('Location: login.php'); | ||
if(!isadmin()){ | ||
header('Location: index.php'); | ||
} | ||
|
||
if(!empty($_POST)){ | ||
if(!empty($_POST['res'])){ | ||
$test = json_decode($_POST['res'], true); | ||
|
||
$message_id = (int)$test[0]; | ||
$item = $test[1]; | ||
$defination = $test[2]; | ||
|
||
$query = "INSERT INTO `requests` (`item`,`defination`) VALUES ('$item','$defination')"; | ||
mysqli_query($connection, $query); | ||
delete_message($connection, $message_id); | ||
} else { | ||
$message_id = (int)$_POST['rej']; | ||
delete_message($connection, $message_id); | ||
} | ||
} | ||
// requests | ||
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'; ?> | ||
<?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 | ||
|
||
$reciever_id = (int)($_SESSION['id']); | ||
$query_fetch = "SELECT M.message, U.name, M.m_id FROM messages M INNER JOIN users U ON M.sender_id = U.id WHERE ((M.reciever_id='$reciever_id' OR M.reciever_id=0) AND M.sender_id != '$reciever_id') AND M.message LIKE 'request%' ORDER BY M.timestamp DESC"; | ||
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)){ | ||
|
||
$message = explode('-', trim($query_row['message'])); | ||
unset($message[0]); | ||
$message = trim(implode('-', $message)); | ||
|
||
echo '<tr> | ||
<td>' . ++$i . '</td> | ||
<td>' . $query_row['name'] . '</td> | ||
<td>' . $message . '</td> | ||
<td>' . duckduckgoreturn($message) . '</td> | ||
<form method="POST"> | ||
<td><button value=\'' . json_encode(array($query_row['m_id'],$message, duckduckgoreturn($message))) . '\' type="submit" name="res" class="btn btn-sm btn-success">Resolve</button></td> | ||
<td><button value="' . $query_row['m_id'] . '" type="submit" name="rej" class="btn btn-sm btn-danger">Reject</button></td> | ||
</form> | ||
</tr>'; | ||
$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> | ||
|
||
<?php | ||
include 'layout/scripts.inc.php'; | ||
</tbody> | ||
</table> | ||
</div> | ||
</section> | ||
</div> | ||
</div> | ||
</section> | ||
</aside> | ||
</div> | ||
<?php | ||
|
||
include 'layout/scripts.inc.php'; | ||
|
||
?> | ||
</body> | ||
</html> | ||
</html> |