-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtwitter_messages.php
104 lines (81 loc) · 2.65 KB
/
twitter_messages.php
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* File of miniTwitter
*
* @author Daniel Plewinski
* @author email: [email protected]
* @link https://github.com/daniel-plewinski/miniTwitter
*/
session_start();
ob_start();
if (!isset($_SESSION["userID"])) {
header("location: twitter_login.php");
die();
}
require 'config.php';
require 'src/User.php';
require 'src/Comment.php';
require 'src/Tweet.php';
require 'src/Message.php';
include 'template/header.php';
?>
<div class="container">
<?php
$inboxAr = Message::showInbox($conn, $_SESSION['userID']);
$outboxAr = Message::showOutbox($conn, $_SESSION['userID']);
echo '<div class="panel panel-default">';
echo '<div class="panel-heading">Wiadomości otrzymane</div>';
echo '<table class="table">';
echo '<tr><th>Nadawca</th><th>Treść wiadomości</th><th>Data</th><th>Status</th></tr>';
foreach ($inboxAr as $inMessage) {
try {
$sql1 = "SELECT username FROM Users WHERE id =" . $inMessage['from_id'] . " LIMIT 1";
$result1 = $conn->query($sql1);
$result1 = $result1->fetchAll(PDO::FETCH_ASSOC);
foreach ($result1 as $value) {
$username1 = $value['username'];
}
} catch (PDOException $e) {
echo $e->getMessage();
}
echo '<tr><td>' . $username1 . '</td><td><a href="twitter_readmessage.php?message_id=' . $inMessage['id'] . '">' . substr($inMessage['content'], 0, 20) . '</a>';
echo ' ...</td><td>' . $inMessage['message_date'] . '<td>';
if ($inMessage['is_read'] == 0) {
echo "Nieprzeczytana";
} else {
echo "Przeczytana";
}
echo '</td></tr>';
}
echo '</table>';
echo '</div>';
echo '<div class="panel panel-default">';
echo '<div class="panel-heading">Wiadomości wysłane</div>';
echo '<table class="table">';
echo '<tr><th>Odbiorca</th><th>Treść wiadomości</th><th>Data</th><th>Status</th></tr>';
foreach ($outboxAr as $outMessage) {
try {
$sql1 = "SELECT username FROM Users WHERE id =" . $outMessage['to_id'] . " LIMIT 1";
$result1 = $conn->query($sql1);
$result1 = $result1->fetchAll(PDO::FETCH_ASSOC);
foreach ($result1 as $value) {
$username1 = $value['username'];
}
} catch (PDOException $e) {
echo $e->getMessage();
}
echo '<tr><td>' . $username1 . '</td><td><a href="twitter_readsentmessage.php?message_id=' . $outMessage['id'] . '">' . substr($outMessage['content'], 0, 20) . '</a>';
echo ' ...</td><td>' . $outMessage['message_date'] . '<td>';
if ($outMessage['is_read'] == 0) {
echo "Nieprzeczytana";
} else {
echo "Przeczytana";
}
echo '</td></tr>';
}
echo '</table>';
echo '</div>';
?>
</div>
</body>
</html>