-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetmsgshtml.php
More file actions
86 lines (74 loc) · 2.25 KB
/
getmsgshtml.php
File metadata and controls
86 lines (74 loc) · 2.25 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
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
include_once "not4everyone.php";
include_once "constants.php";
include_once "tea.php";
include_once "checktoken.php";
header("Content-type: text/plain");
if (!$token_ok)
die("Content blocked.<br>Your security token is invalid ($token_msg)");
function writeMsg($cu, $mid, $fid, $tid, $from, $text, $ts, $read)
{
$text = str_replace("\n\n", '<p class="nps">', $text);
$text = str_replace("\n", '<br>', $text);
$s = '<div class="msgitem" id="m'.$mid.'">'."\n";
// Poster name and details
$sclass = ($fid == $cu)? " from": "";
$s .= '<span class="noclicktext" id="sns'.$mid.'">'.$from.'</span>'."\n";
// Date/time
$s .= ' <span class="datetime">('.$ts.')</span>'."\n";
// The post text
$s .= ' <div class="posttxt">'.$text.'</div>'."\n";
$s .= '<div style="clear:both; border-top:solid 1px #bbbbdd; margin-top:5px; height:5px;"></div>'."\n";
$s .= "</div>\n";
return $s;
}
$db = dbConnect();
if (!$db) die(sql_error());
$cu = $_GET["cu"];
$other = (isset($_GET["other"]))? $_GET["other"]: "*";
$ip = $_SERVER["REMOTE_ADDR"];
$count = 0;
$sql =
"select a.id, a.fromid, a.toid, a.mbody, a.readflag, a.ts, b.id, b.name, c.id, c.name from ffmessages as a, ffmembers as b, ffmembers as c ".
"where ((a.fromid=$cu and a.toid=$other) or (a.fromid=$other and a.toid=$cu)) and b.id=a.fromid and c.id=a.toid order by b.ts desc";
$result = $db->query($sql);
if (!$result) die($db->error);
$count = $result->num_rows;
$oname = "";
$from = "";
$oid= "";
$first = true;
for ($i = 0; $i < $count; $i++)
{
$row = $result->fetch_row();
//print_r($row);
$mid = $row[0];
$fid = $row[1];
$tid = $row[2];
$text = $row[3];
$read = $row[4];
$ts = $row[5];
$from = $row[7];
if ($first)
{
if ($fid == $cu)
{
$oid = $other;
$oname = $row[9];
}
else
{
$oid = $cu;
$oname = $row[7];
}
$first = false;;
}
echo writeMsg($cu, $mid, $fid, $tid, $from, $text, $ts, $read);
}
echo '<input type="hidden" id="ml_oname" value="'.$oname.'">'."\n";
echo '<input type="hidden" id="ml_oid" value="'.$oid.'">'."\n";
$sql = "update ffmessages set readflag=1 where fromid=$cu and toid=$oid";
$db->query($sql);
?>