Repository navigation
Expand file tree
/
Copy pathgetnewinbox.php
More file actions
89 lines (86 loc) · 2.55 KB
/
Copy pathgetnewinbox.php
File metadata and controls
89 lines (86 loc) · 2.55 KB
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
<?php
session_start();
require_once 'config.php';
date_default_timezone_set("America/New_York");
$halt = $_GET['halt'];
if ($halt)
{
$lastmsg = $_SESSION['lastInbox'];
}
$image = $_GET['image'];
$submit = $_POST['submit'];
$email = $_SESSION['email'];
$displayName = $_SESSION['displayName'];
$toRec = strip_tags($_POST['toRecipient']);
$fillTo = strip_tags($_GET['fillTo']);
if (!($email))
{ $email = strip_tags($_POST['Email']); }
if (!($displayName))
{ $displayName = strip_tags($_POST['DisplayName']); }
$message = strip_tags($_POST['Message']);
$date = date("Y-m-d H:i:s");
$headBack = "inbox.php";
$_SESSION['lastPage'] = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
if ($headBack)
{
$headBack = "Location: $headBack";
}
if (empty($lastmsg))
{
$toSend = "Select `MsgID`, `Nickname`, `DateTime`, `Message` FROM `chatter` WHERE `recipient` = :displayName AND ( NOT `read` OR `read` IS NULL) ;";
$lastmsg=0;
}
else
{
$toSend = "Select `MsgID`, `Nickname`, `DateTime`, `Message` FROM `chatter` WHERE `MsgID` > :lastmsg AND `recipient` = :displayName AND (NOT `read` OR `read` IS NULL);";
}
$connect = connect_tsbac();
$stmt = $connect->prepare($toSend, $GLOBALS['PDO_ATTRIBS']);
if ($lastmsg > 0)
$stmt->execute(array(":lastmsg"=>$lastmsg, ":displayName"=>$displayName)) or errormail($email, "Couldn't load inbox contents lastmsg: $lastmsg ", "Couldn't load your inbox!");
else
$stmt->execute(array(":displayName"=>$displayName)) or errormail($email, "Couldn't load inbox contents.", "Couldn't load your inbox!");
$numrows= $stmt->rowCount();
$rows = $stmt->fetchAll();
if ($numrows>0)
{
echo "\n<div id='log'>";
foreach ($rows as $row)
{
echo "<p>";
$msgID = $row['MsgID'];
echo "\n<table id='message$msgID'>";
$nick = $row['Nickname'];
$link = '<a href="inbox.php?fillTo='. $nick .'">';
$nick = $link . $nick . '</a>';
$time = $row['DateTime'];
$msg = $row['Message'];
$isRead = $row['read'];
echo "\n <tr> ";
echo "\n <td><span class='username'>$nick : </span></td>";
echo "\n <td><span class='small'> [$time] ";
if (($isRead=0)||(!($isRead)))
{
echo "<a href=\"#\" alt=\"mark read\" onclick=\"markRead($msgID);\">x</a>";
}
else
{
echo "[Read]";
}
echo "</span></td>";
echo "\n </tr> ";
echo "\n <tr> ";
echo "\n <td colspan='2'>$msg</td>";
echo "\n </tr>";
echo "\n</table>";
echo "</p>";
$lastmsg = $msgID;
}
$_SESSION['lastInbox'] = $lastmsg;
echo "\n</div> ";
if ($halt > 0)
{
exit;
}
}
?>