Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include_once('include/sys.inc.php'); ?>
- <?php
- require('Pusher.php');
- $app_id = 'xxxxxxx';
- $app_key = 'xxxxxx';
- $app_secret = 'xxxxxxxxx';
- $pusher = new Pusher($app_key, $app_secret, $app_id);
- if (ISSET($_POST['user'])) {
- $_SESSION['msg']['msg_user_id'] = $_POST['user'];
- $msg_hide_id = $_POST['user'];
- }
- if (ISSET($_POST['submit_message']) && !EMPTY($_POST['message'])) {
- if (EMPTY($_POST['from_id']) && EMPTY($_POST['to_id'])) {
- $error = 'No Sender Selected';
- } else {
- if (ISSET($_POST['from_id'])) {
- $from_id = $_POST['from_id'];
- } else {
- $from_id = NULL;
- }
- if (ISSET($_POST['to_id'])) {
- $to_id = $_POST['to_id'];
- } else {
- $to_id = NULL;
- }
- $message = str_replace('<br />', PHP_EOL, $_POST['message']);
- $message = htmlentities('<p>'.$_POST['message'].'</p>');
- $sql="INSERT INTO `messaging` (`from_id`, `to_id`, `message`)
- VALUES
- ('$from_id', '$to_id', '$message')";
- if (!mysqli_query($con, $sql))
- {
- die('Error: ' . mysqli_error($con));
- }
- $data['message'] = '<a href="messaging.php"><div class="yes_msg"></div></a>';
- $data['userid'] = $to_id;
- $pusher->trigger('gsm_channel', 'gms_chat', $data);
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
- <meta name="viewport" content="width=1080" />
- <meta name="description" content="">
- <meta name="author" content="">
- <link href="css/style.css?v=<?php echo filemtime("css/style.css"); ?>" rel="stylesheet">
- <link rel="stylesheet" href="css/jquery-ui.css">
- <script src="js/jquery.min.js"></script>
- <script src="//js.pusher.com/2.2/pusher.min.js" type="text/javascript"></script>
- <script src="js/jquery.autosize.min.js"</script>
- <script type="text/javascript">
- $(document).ready(function(){
- //Check if the current URL contains '#'
- if(document.URL.indexOf("#")==-1)
- {
- // Set the URL to whatever it was plus "#".
- url = document.URL+"#";
- location = "#";
- //Reload the page
- location.reload(true);
- }
- });
- </script>
- <script>
- $(function(){
- $('.normal').autosize();
- $('.animated').autosize();
- });
- </script>
- <title>Project Detail</title>
- </head>
- <body>
- <audio id="audiotag1" src="http://test.dyn.hk/ding.wav" preload="auto"></audio>
- <?php
- if (ISSET($error)) {
- echo $error;
- }
- if (ISSET($_POST['msg_reload_time'])) {
- $_SESSION['msg']['reload_time'] = $_POST['msg_reload_time'];
- } else {
- $_SESSION['msg']['reload_time'] = '60';
- }
- if (ISSET($_POST['msg_user_id'])) {
- $_SESSION['msg']['msg_user_id'] = $_POST['msg_user_id'];
- } else if ($_SESSION['user']['usergroup'] != 'admin') {
- $_SESSION['msg']['msg_user_id'] = $_SESSION['user']['id'];
- } else {}
- ?>
- <?php include('head_banner.inc.php'); ?>
- <div class="wrapper">
- <iframe id="chat" src="messages.php#end" scrolling="yes" style="width: 100%; border: none; height: 400px; margin: 25px 0 25px 0; padding: 0;"></iframe>
- <?php /*
- <form style="float: right;" action="" method="POST" id="msg_reload" onchange='document.getElementById("msg_reload").submit();'>
- Message Reload Time: <select name="msg_reload_time">
- <option value="10" <?php if ($_SESSION['msg']['reload_time'] == 10) { echo "selected"; } ?>>10 seconds</option>
- <option value="60" <?php if ($_SESSION['msg']['reload_time'] == 60) { echo "selected"; } ?>>60 seconds</option>
- <option value="120" <?php if ($_SESSION['msg']['reload_time'] == 120) { echo "selected"; } ?>>2 minutes</option>
- <option value="999999" <?php if ($_SESSION['msg']['reload_time'] == 999999) { echo "selected"; } ?>>Stop</option>
- </select>
- </form>
- */ ?>
- <?php
- if($_SESSION['user']['usergroup'] == 'admin') {
- ?>
- <form style="float: left;" action="" method="POST" id="user_select" style="margin-top: 15px;" onchange='document.getElementById("user_select").submit();'>
- <?php
- $query_user = "SELECT * FROM `user` WHERE `usergroup` != 'admin' ORDER BY `company_name`";
- if ($result_user = $con->query($query_user)) {
- $row_cnt = $result_user->num_rows;
- if($row_cnt > 0){
- echo '<b>Message To</b>: <select name="msg_user_id">';
- echo '<option value="">Please Select</option>';
- while($row = $result_user->fetch_assoc()){
- ?>
- <option value="<?php echo $row['id']; ?>"<?php if (ISSET($_SESSION['msg']['msg_user_id'])) { if ($_SESSION['msg']['msg_user_id'] == $row['id']) { echo ' selected'; }} ?>><?php echo $row['company_name'].' - '.$row['username']; ?></option>
- <?php
- }
- echo '</select>';
- }
- }
- ?>
- </form>
- <?php
- }
- ?>
- <form action="" method="POST">
- <div class="message_send_box" style="clear: both;" >
- <b><?php if ($_SESSION['user']['usergroup'] == 'admin') { echo 'Message'; } else { echo 'Message To Site Administrator'; } ?></b>: <br />
- <textarea class="message_send normal" name="message"></textarea><br />
- <?php
- if ($_SESSION['user']['usergroup'] == 'admin'){
- ?>
- <input type="hidden" name="to_id" value="<?php if(ISSET($_SESSION['msg']['msg_user_id'])) { echo $_SESSION['msg']['msg_user_id']; } ?>" />
- <input type="hidden" name="from_id" value="admin" />
- <input type="hidden" name="msg_user_id" value="<?php echo $_SESSION['msg']['msg_user_id']; ?>" />
- <?php
- } else {
- ?>
- <input type="hidden" name="from_id" value="<?php echo $_SESSION['user']['id']; ?>" />
- <input type="hidden" name="to_id" value="admin" />
- <?php
- }
- ?>
- <input type="submit" name="submit_message" accesskey="s" value="Send (Alt + S)" style="float: right; margin-top: 10px;" />
- </div>
- </form>
- <?php $msg_hide_id = ''; ?>
- <?php
- $query_recheck_msg = "SELECT from `message` WHERE `to_id` = '".$_SESSION['user']['msgid']."' AND `read` = 0 GROUP BY `from_id`";
- if ($query_recheck_msg_result = $con->query($query_recheck_msg)) {
- $row_cnt = $result_recheck_msg_result->num_rows;
- if($row_cnt > 0){
- $data = '<li><a href="messaging.php"><div class="yes_msg"></div></a><ul>';
- while ($row_recheck_msg_result = $result_recheck_msg_result ->fetch_assoc()){
- $msg_list .= '<li><a href="messaging.php?user='.$row_recheck_msg_result['from_id'].'">'.$row_recheck_msg_result['from_id'].'</a></li>';
- }
- $data .= '</ul></li>';
- $data['userid'] = $_SESSION['user']['msgid'];
- $pusher->trigger('gms_channel', 'gms_chat', $data);
- } else {
- $data = '<div class="no_msg"></div>';
- $data['userid'] = $_SESSION['user']['msgid'];
- $pusher->trigger('gms_channel', 'gms_chat', $data);
- }
- }
- ?>
- </div>
- <?php include('footer.inc.php'); ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement