-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinbox.php
More file actions
141 lines (136 loc) · 3.76 KB
/
inbox.php
File metadata and controls
141 lines (136 loc) · 3.76 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
session_start();
include 'system.php';
page_header();
if(isset($_SESSION['is_logged'])===true){
$user_id= $_SESSION['user_info']['id'];
db_init();
?>
<script type="text/javascript">
checked=false;
function checkedAll (form1) {
var aa= document.getElementById('form1');
if (checked == false)
{
checked = true
}
else
{
checked = false
}
for (var i =0; i < aa.elements.length; i++)
{
aa.elements[i].checked = checked;
}
}
</script>
<article id="main_content_body">
<header>
<hgroup>
<div id="main_content_title">Inbox</div>
<a id="link" class="underline" href="send_message.php">Sent Message</a><br />
</hgroup>
</header><br />
<center>
<p>
<?php
$q_messages="SELECT *
FROM messages
WHERE receiver_id='$user_id'
ORDER BY `time` DESC";
$r_messages=run_mysql_query($q_messages) or die (mysql_error());
$count=mysql_num_rows($r_messages);
if ($count==0){
echo '<div><img src="img/text-chat.png" width="24" height="24" />Няма съобщения!</div>';
} else {
?>
<p><img src="img/text-chat.png" width="24" height="24" /> <span style="bottom:3px; position:relative;">You can see the content of a message by clicking on his subject.</span></p>
<form name="form1" id="form1" method="post" action="inbox.php">
<table class="list">
<tr>
<th id="link" ><input type='checkbox' name='checkall' onclick='checkedAll(form1);'></th>
<th id="link"><span class="display_color">№</span></th>
<th id="link"><span class="display_color">From</span></th>
<th id="link"><span class="display_color">Subject</span></th>
<th id="link"><span class="display_color">Sent on</span></th>
</tr>
<?php
function get_sender(){
global $sender_id;
/*global $sender_name;*/
global $name;
global $surname;
$q_function="SELECT name, surname
FROM users
WHERE id='$sender_id'";
$r_function=run_mysql_query($q_function) or die (mysql_error());
$row=mysql_fetch_array($r_function);
/*$sender_name=$row['username']; $q_function="SELECT username
FROM users
WHERE id='$sender_id'";*/
$name=$row['name'];
$surname=$row['surname'];
}
$nomer=1;
date_default_timezone_set('Europe/Sofia');
while ($userData=mysql_fetch_array($r_messages)){
$sender_id=$userData['sender_id'];
$title=$userData['title'];
$message=$userData['message'];
$time=$userData['time'];
$message_id=$userData['id'];
$readed=$userData['readed'];
$date=date('d-m-Y | G:i ', $time);
echo "<tr><td><input name='checkbox[]' type='checkbox' id='checkbox[]' value='";
echo $message_id;
echo "'></td><td>";
echo $nomer;
echo "</td><td>"; /*<a id='link' class='underline' href='view_user.php?user_id=
echo $sender_id;
echo "'>";*/
get_sender();
echo ''.$name.' '.$surname.''; /*$sender_name;*/
echo "</a></td><td><a id='link' class='underline' href='view_message.php?id=";
echo $message_id;
echo "'>";
if ($readed==1){
echo "<font color='#555555'>";
}
echo $title;
if ($readed==1){
echo "</font>";
}
echo "</a></td><td>";
echo $date;
echo "</td></tr>";
$nomer++;
}
?>
<td colspan="5" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>
<?php
if(isset($_POST['delete'])){
for($i=0;$i<$count;$i++){
$del_id = $_POST['checkbox'][$i];
$sql = "DELETE FROM messages WHERE id='$del_id'";
$result = run_mysql_query($sql) or die (mysql_error());
}
if($result){
echo "<meta http-equiv='refresh' content='0;URL=inbox.php'>";
}
}
?>
</table>
</form>
</P>
</center>
<footer>
</footer>
</article>
<?php
}
}else{
header('Location: index.php');
exit;
}
page_footer();
?>