-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmessages.php
220 lines (163 loc) · 9.7 KB
/
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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?php
/**
* Allomani Audio & Video (Songs) v3.0
*
* @package Allomani.Songs
* @version 3.0
* @copyright (c) 2006-2018 Allomani , All rights reserved.
* @author Ali Allomani <[email protected]>
* @link http://allomani.com
* @license GNU General Public License version 3.0 (GPLv3)
*
*/
require("global.php");
require(CWD . "/includes/framework_start.php");
//---------------------------------------------------------
if(check_member_login()){
open_table();
print "
<center>
<table width=70%><tr><td align=center><a href='messages.php?action=new'>
<img src='images/msg_send.gif' title=\"$phrases[send_new_msg]\" border=0><br>$phrases[send_new_msg]</a></td>
<td align=center><a href='messages.php?action=inbox'>
<img src='images/received_msgs.gif' title=\"$phrases[received_msgs]\" border=0><br>$phrases[received_msgs]</a></td>
<td align=center><a href='messages.php?action=sent'>
<img src='images/sent_msgs.gif' title=\"$phrases[sent_messages]\" border=0><br>$phrases[sent_messages]</a></td>
</tr></table></center>";
close_table();
//------------------------------------- Messages ---------------------------------------
if(!$action || $action=="inbox" || $action=="sent"){
if($op == "del"){
db_query("delete from songs_members_msgs where id='$id' and owner='$member_data[id]'");
}
open_table(iif($action=="sent",$phrases['sent_messages'],$phrases['received_msgs']));
$qr = db_query("select * from songs_members_msgs where owner='$member_data[id]' and sent=".iif($action=="sent","1","0")." order by id DESC");
$msgs_count = intval(db_num($qr));
//-----------------
if($action != "sent"){
print "<div align=$global_align_x>$msgs_count / $settings[msgs_count_limit] $phrases[used_messages]";
if($msgs_count >= $settings['msgs_count_limit']){
print "<b><font color=#FF0000> $phrases[pm_box_full_warning] </font></b>";
}
print "</div><br><br>";
}
//------------------
if(db_num($qr)){
print "<table width=100%>";
print "<tr><td></td><td width=33%><b>".iif($action == "sent",$phrases['to'],$phrases['the_sender'])."</b></td><td width=33% align=center><b>$phrases[the_subject]</b></td><td width=33% align=center><b>$phrases[the_date]</b></td><td><b> $phrases[the_options] </b></td></tr>";
while($data = db_fetch($qr)){
if($tr_class=="row_1"){
$tr_class = "row_2";
}else{
$tr_class = "row_1";
}
print "<tr class='$tr_class'>
<td align=center><img src=\"images/".iif(!$data['opened'] && $action !="sent","new_msg.gif","old_msg.gif")."\"></td>
<td><a href='messages.php?action=view&id=$data[id]'>$data[username]</a></td>
<td align=center><a href='messages.php?action=view&id=$data[id]'>$data[title]</a></td>
<td align=center>".date("d-m-Y h:i",$data['date'])."</td>
<td align=center><a href='messages.php?action=".htmlspecialchars($action)."&op=del&id=$data[id]' onclick=\"return confirm('".$phrases['are_you_sure']."')\" ><img src='images/delete.gif' title=\"$phrases[delete]\"></a></td></tr>";
}
print "</table>";
}else{
print "<center> $phrases[no_messages] </center>" ;
}
close_table();
}
//-------------- view ----------------
if($action=="view"){
$qr = db_query("select * from songs_members_msgs where id='$id' and owner='$member_data[id]'");
open_table();
if(db_num($qr)){
$data = db_fetch($qr);
db_query("update songs_members_msgs set opened=1 where id='$id'");
print "<table width=100%>
<tr><td width=7%><b> ".iif($data['sent'],$phrases['to'],$phrases['the_sender'])." : </b></td><td><a href=\"".str_replace("{id}","$data[uid]",$links['links_profile'])."\">$data[username]</a></td></tr>
<tr><td><b> $phrases[the_date] : </b></td><td>".date("d-m-Y h:i",$data['date'])."</td></tr>
<tr><td><b> $phrases[the_subject] :</b> </td><td>$data[title]</td></tr>
<tr><td colspan=2 height=25 align=center>
".iif(!$data['sent'],"<a href='messages.php?action=reply&msg_id=$data[id]'><img alt='$phrases[reply]' src='images/mail_send.gif' border=0></a> ")."
<a href=\"messages.php?action=".iif($data['sent'],"sent","inbox")."&op=del&id=$data[id]\" onclick=\"return confirm('$phrases[are_you_sure]');\"><img src='images/del.gif' alt='$phrases[delete]' border=0></a>
</td></tr>
<tr><td colspan=2 align=center>
<table width=96%><tr><td class=messages>
".nl2br($data['content'])."
</td></tr></table>
</td></tr></table>";
}else{
print "<center> $phrases[err_wrong_url] </center>";
}
close_table();
}
//-------------- snd ------------------
if($action=="new" || $action=="reply"){
$id = (int) $id;
if($msg_snd_ok){
$qr = db_query("select ".members_fields_replace("id").",".members_fields_replace("username").",".members_fields_replace("email").",pm_email_notify,privacy_settings from ".members_table_replace("songs_members")." where ".members_fields_replace("username")."='".db_escape($to_username)."'");
if(db_num($qr)){
$data=db_fetch($qr);
unset($prv_data);
$prv_data = unserialize($data['privacy_settings']);
$continue = get_privacy_settings($data['id'],$member_data['id'],$prv_data['messages'],$phrases['pm_send_denied'],true);
if($continue){
$data_count = db_qr_fetch("select count(id) as count from songs_members_msgs where owner='$data[id]'");
$msgs_count = $data_count['count'];
if($msgs_count >= $settings['msgs_count_limit']){
open_table();
print "<center> $phrases[err_sendto_pm_box_full] </center>";
close_table();
}else{
db_query("insert into songs_members_msgs (owner,uid,username,title,content,date,sent) values('$data[id]','{$member_data['id']}','{$member_data['username']}','".db_escape($to_subject)."','".db_escape($to_msg)."','".time()."','0')");
db_query("insert into songs_members_msgs (owner,uid,username,title,content,date,sent) values('{$member_data['id']}','$data[id]','$data[username]','".db_escape($to_subject)."','".db_escape($to_msg)."','".time()."','1')");
//---------- send email to receiver ------------
if($data['pm_email_notify']){
$msg_url = "$scripturl/messages.php";
$msg = get_template("pm_email_notify_msg",array("{name_from}","{url}"),array($member_data['username'],$msg_url));
$email_result = send_email($sitename,$mailing_email,$data[members_fields_replace("email")],"$phrases[pm_email_notify_subject]",$msg,$settings['mailing_default_use_html'],$settings['mailing_default_encoding']);
}
//----------------------------------------------
open_table();
print "<center> $phrases[pm_sent_successfully] </center>";
close_table();
}
}
}else{
open_table();
print "<center> $phrases[err_sendto_username_invalid] </center>";
close_table();
}
}else{
open_table();
unset($recevie_user,$to_subject,$to_msg);
if($action=="reply"){
$msg_id = (int) $msg_id;
$data = db_qr_fetch("select * from songs_members_msgs where id='$msg_id'");
$recevie_user = $data['username'];
$to_subject = " $phrases[reply] : " .$data['title'];
$to_msg = "\n\n\n\n--------------------------\n".date("d-m-Y h:i",$data['date'])."\n\n$data[content]";
}else{
if($id){
$from_data = db_qr_fetch("select ".members_fields_replace("username")." from ".members_table_replace("songs_members")." where ".members_fields_replace("id")."='$id'");
$recevie_user = $from_data['username'] ;
}
}
print "<form action='messages.php' method=post>
<input type=hidden name='msg_snd_ok' value=1>
<input type=hidden name=action value='new'>
<table width=100%>
<tr><td width=100> $phrases[username] : </td><td><input type=text name=to_username value='$recevie_user' size=25></td></tr>
<tr><td> $phrases[the_subject] : </td><td><input type=text size=25 name=to_subject value='$to_subject'></td></tr>
<tr><td> $phrases[the_message] : </td><td>
<textarea name='to_msg' cols=40 rows=10>$to_msg</textarea>
</td></tr>
<tr><td colspan=2 align=center><input type=submit value=' $phrases[send] '></td></tr>
</table></form>";
close_table();
}
}
//---------------------------------------------
}else{
login_redirect();
}
//---------------------------------------------
require(CWD . "/includes/framework_end.php");