PageRenderTime 28ms CodeModel.GetById 1ms RepoModel.GetById 1ms app.codeStats 0ms

/root/inbox.php

https://gitlab.com/JLHasson/Wordflow
PHP | 274 lines | 223 code | 41 blank | 10 comment | 19 complexity | 3822827c4757db80d9a609c9786b38a6 MD5 | raw file
  1. <?php
  2. include_once("mysql_server/checkuserlog.php");
  3. if (!isset($_SESSION['idx'])) {
  4. echo '<br /><br /><font color="#FF0000">Your session has timed out</font>
  5. <p><a href="inbox.php">Please Click Here</a></p>';
  6. exit();
  7. }
  8. // Decode the Session IDX variable and extract the user's ID from it
  9. $decryptedID = base64_decode($_SESSION['idx']);
  10. $id_array = explode("p3h9xfn8sq03hs2234", $decryptedID);
  11. $my_id = $id_array[1];
  12. $my_name = $_SESSION['firstname']; // Put user's first name into a local variable
  13. // ------- ESTABLISH THE INTERACTION TOKEN ---------
  14. $thisRandNum = rand(9999999999999,999999999999999999);
  15. $_SESSION['token'] = base64_encode($thisRandNum); // Will always overwrite itself each time this script runs
  16. // ------- END ESTABLISH THE INTERACTION TOKEN ---------
  17. // Mailbox Parsing for deleting inbox messages
  18. if (isset($_POST['deleteBtn'])) {
  19. foreach ($_POST as $key => $value) {
  20. $value = urlencode(stripslashes($value));
  21. if ($key != "deleteBtn") {
  22. $sql = mysql_query("UPDATE messaging SET recipientDelete='1', opened='1' WHERE id='$value' AND to_id='$my_id' LIMIT 1");
  23. // Check to see if sender also removed from sent box, then it is safe to remove completely from system
  24. }
  25. }
  26. header("location: inbox.php");
  27. }
  28. ?>
  29. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  30. <html xmlns="http://www.w3.org/1999/xhtml">
  31. <head>
  32. <meta http-equiv="Content-Type"/>
  33. <title>Word of Mouth | Inbox</title>
  34. <link href="style.css" rel="stylesheet" type="text/css" />
  35. <link rel="icon" href="images/favicon.ico" type="image/x-icon" />
  36. <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
  37. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  38. <script language="javascript" type="text/javascript">
  39. var MYAPP = {};
  40. function toggleChecks(field) {
  41. if (document.myform.toggleAll.checked == true){
  42. for (i = 0; i < field.length; i++) {
  43. field[i].checked = true;
  44. }
  45. } else {
  46. for (i = 0; i < field.length; i++) {
  47. field[i].checked = false;
  48. }
  49. }
  50. }
  51. $(document).ready(function() {
  52. $(".toggle").click(function () {
  53. var $hiddenDiv = $(this).find(".hiddenDiv");
  54. if ($hiddenDiv.is(":hidden")) {
  55. $hiddenDiv.slideDown("fast");
  56. } else {
  57. $hiddenDiv.slideUp("fast");
  58. }
  59. });
  60. $('#newMessageLink').click(function() {
  61. var hiddenNewMessage = getElementById(hiddenNewMessageContain);
  62. $('#hiddenNewMessageContain').fadeIn('slow');
  63. hiddenNewMessage.style.display = inline;
  64. return false;
  65. });
  66. }); //END document.ready()
  67. function markAsRead(msgID) {
  68. $.post("markAsRead.php",{ messageid: msgID, ownerid:<?php echo $my_id; ?> } ,function(data) {
  69. $('#subj_line_'+msgID).addClass('msgRead');
  70. });
  71. }
  72. function toggleReplyBox(subject,sendername,senderid,recName,recID) {
  73. $("#subjectShow").text(subject);
  74. $("#recipientShow").text(recName);
  75. document.replyForm.pmSubject.value = subject;
  76. document.replyForm.pm_sender_name.value = sendername;
  77. document.replyForm.pm_sender_id.value = senderid;
  78. document.replyForm.pm_rec_name.value = recName;
  79. document.replyForm.pm_rec_id.value = recID;
  80. document.replyForm.replyBtn.value = "Send reply to "+recName;
  81. if ($('#replyBox').is(":hidden")) {
  82. $('#replyBox').fadeIn(1000);
  83. } else {
  84. $('#replyBox').hide();
  85. }
  86. }
  87. function processReply() {
  88. // our form post variables
  89. var pmSubject = $("#pmSubject");
  90. var pmTextArea = $("#pmTextArea");
  91. var sendername = $("#pm_sender_name");
  92. var senderid = $("#pm_sender_id");
  93. var recName = $("#pm_rec_name");
  94. var recID = $("#pm_rec_id");
  95. var url = "http://word-flow.com/messaging_parse.php";
  96. if (pmTextArea.val() == "") {
  97. $("#PMStatus").text("Please type in your message.").show().fadeOut(6000);
  98. } else {
  99. $("#pmFormProcessGif").show();
  100. $.post(url, {
  101. subject: pmSubject.val(),
  102. message: pmTextArea.val(),
  103. senderName: sendername.val(),
  104. senderID: senderid.val(),
  105. recName: recName.val(),
  106. recID: recID.val()
  107. },
  108. function(data) {
  109. document.replyForm.pmTextArea.value = "";
  110. $("#pmFormProcessGif").hide();
  111. $('#replyBox').slideUp("fast");
  112. $("#PMFinal").html("&nbsp; &nbsp;"+data).show().fadeOut(8000);
  113. });
  114. }
  115. }
  116. </script>
  117. <style type="text/css">
  118. .hiddenDiv{display:none}
  119. #pmFormProcessGif{display:none}
  120. .msgDefault {font-weight:bold;}
  121. .msgRead {font-weight:100;color:#666;}
  122. </style>
  123. </head>
  124. <body>
  125. <?php include_once "templates/header_template.php"; ?>
  126. <div class="wrapOverall">
  127. <table width="920" border="0" align="center" cellpadding="0" cellspacing="0">
  128. <tr>
  129. <td width="732" valign="top">
  130. <h2 style="margin-left:24px;">Messages:</h2>
  131. <!-- START THE PM FORM AND DISPLAY LIST -->
  132. <form name="myform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
  133. <table width="94%" border="0" align="center" cellpadding="4">
  134. <tr>
  135. <td width="3%" align="right" valign="bottom"><img src="images/right_arrow.png" width="16" height="17" /></td>
  136. <td width="40%" valign="top"><input type="submit" name="deleteBtn" id="deleteBtn" value="Delete" />
  137. <span id="jsbox" style="display:none"></span>
  138. </td>
  139. <td>
  140. <span style="float:right;" class="black_text">To Send a New Message to Someone, Visit their Profile</span>
  141. </td>
  142. </tr>
  143. </table>
  144. <table width="96%" border="0" align="center" cellpadding="4" style="background-repeat:repeat-x; border: #999 1px solid;">
  145. <tr>
  146. <td width="4%" valign="top">
  147. <input name="toggleAll" id="toggleAll" type="checkbox" onclick="toggleChecks(document.myform.cb)" />
  148. </td>
  149. <td width="20%" valign="top">From</td>
  150. <td width="58%" valign="top"><span class="style2">Subject</span></td>
  151. <td width="18%" valign="top">Date</td>
  152. </tr>
  153. </table>
  154. <?php
  155. ///////////End take away///////////////////////
  156. // SQL to gather their entire PM list
  157. $sql = mysql_query("SELECT * FROM messaging WHERE to_id='$my_id' AND recipientDelete='0' ORDER BY id DESC LIMIT 100");
  158. while($row = mysql_fetch_array($sql)){
  159. $date = strftime("%b %d, %Y",strtotime($row['time_sent']));
  160. if($row['opened'] == "0"){
  161. $textWeight = 'msgDefault';
  162. } else {
  163. $textWeight = 'msgRead';
  164. }
  165. $fr_id = $row['from_id'];
  166. // SQL - Collect username for sender inside loop
  167. $ret = mysql_query("SELECT id, firstname, lastname FROM myMembers WHERE id='$fr_id' LIMIT 1");
  168. while($raw = mysql_fetch_array($ret)){ $Sid = $raw['id']; $Fname = $raw['firstname']; $Lname = $raw['lastname']; }
  169. $fullName = "".$Fname." ".$Lname."";
  170. $i = 0;
  171. ?>
  172. <table width="96%" border="0" align="center" cellpadding="4">
  173. <tr class="toggle" id="messageRow">
  174. <td width="4%" valign="top">
  175. <input type="checkbox" name="cb<?php echo $row['id']; ?>" id="cb" value="<?php echo $row['id']; ?>" />
  176. </td>
  177. <td width="20%" valign="top"><div class="message_name"><a href="profile.php?id=<?php echo $Sid; ?>"><?php echo $Fname.' '. $Lname ;?></a></div></td>
  178. <td width="58%" valign="top">
  179. <span style="padding:3px;">
  180. <a class="<?php echo $textWeight; ?>" id="subj_line_<?php echo $row['id']; ?>" style="cursor:pointer;" onclick="markAsRead(<?php echo $row['id']; ?>)"><?php echo stripslashes($row['subject']); ?></a>
  181. </span>
  182. <div class="hiddenDiv" id="hiddenDivId"> <br />
  183. <?php echo stripslashes(wordwrap(nl2br($row['message']), 54, "\n", true)); ?>
  184. <br /><br /><a href="javascript:toggleReplyBox('<?php echo stripslashes($row['subject']); ?>','<?php echo $my_name; ?>','<?php echo $my_id; ?>','<?php echo $fullName; ?>','<?php echo $fr_id; ?>','<?php echo $thisRandNum; ?>')">Reply</a><br />
  185. </div>
  186. </td>
  187. <td width="18%" valign="top"><span style="font-size:10px;"><?php echo $date; ?></span></td>
  188. </tr>
  189. </table>
  190. <hr style="margin-left:20px; margin-right:20px;" />
  191. <?php
  192. $i + 1;
  193. }// Close Main while loop
  194. ?>
  195. </form>
  196. <!-- END THE PM FORM AND DISPLAY LIST -->
  197. <!-- Start Hidden Container the holds the Reply Form -->
  198. <div id="replyBox" style="display:none; width:680px; height:264px; background-color: #0099FF; background-repeat:repeat; top:100px; position:fixed; margin:auto; margin-left:60px; z-index:50; padding:20px; color:#FFF;">
  199. <div align="right">
  200. <a href="javascript:toggleReplyBox('close')">
  201. <font color="#FFFFFF">
  202. <strong>CLOSE</strong>
  203. </font>
  204. </a>
  205. </div>
  206. <h2>Reply to: <span style="color:#FFFFFF;" id="recipientShow"></span></h2>
  207. Subject: <strong><span style="color:#FFFFFF;" id="subjectShow"></span></strong> <br>
  208. <form action="javascript:processReply();" name="replyForm" id="replyForm" method="post">
  209. <textarea id="pmTextArea" rows="8" style="width:98%;"></textarea><br />
  210. <input type="hidden" id="pmSubject" />
  211. <input name="pm_sender_id" id="pm_sender_id" type="hidden" value="'. $_SESSION['id'] .'" />
  212. <input name="pm_sender_name" id="pm_sender_name" type="hidden" value="'. $_SESSION['firstname'] .'" />
  213. <input name="pm_rec_id" id="pm_rec_id" type="hidden" value="'. $fr_id .'" />
  214. <input name="pm_rec_name" id="pm_rec_name" type="hidden" value="'. $fullName .'" />
  215. <br />
  216. <input name="replyBtn" type="button" onclick="javascript:processReply()" /> &nbsp;&nbsp;&nbsp;
  217. <span id="pmFormProcessGif">
  218. <img src="images/loading.gif" width="28" height="10" alt="Loading" />
  219. </span>
  220. <div id="PMStatus" style="color:#FFFFFF; font-size:14px; font-weight:700;">&nbsp;</div>
  221. </form>
  222. </div>
  223. <!-- End Hidden Container the holds the Reply Form -->
  224. <!-- Start PM Reply Final Message box showing user message status when needed -->
  225. <div id="PMFinal" style="display:none; width:652px; background-color:#0099FF; top:51px; position:fixed; margin:auto; z-index:50; padding:40px; color:#FFFFFF; font-size:16px;">Congratulations You're Message has been sent!</div>
  226. <!-- End PM Reply Final Message box showing user message status when needed -->
  227. </td>
  228. </tr>
  229. </table>
  230. </div>
  231. <?php include_once "templates/footer_template.php"; ?>
  232. </body>
  233. </html>