edit_umsgs.pl
Copying Source is Forbidden
135 lines of code
1
#!/usr/local/bin/perl
2
3
($<,$>) = (getpwnam('nobody'), getpwnam('nobody')) or die $!;
4
5
binmode(STDIN, ":utf8");
6
binmode(STDOUT, ":utf8");
7
8
# must have's!
9
use strict;
10
use warnings;
11
use CGI::Carp qw(fatalsToBrowser);
12
use DBI;
13
use URI::Escape;
14
15
use lib "/var/www/html/Pm";
16
17
use Date qw(expand_date);
18
use Html qw(pre_html_header header html_end);
19
use Html2 qw(tag);
20
use Bc_chef qw(cookie_get);
21
use Bc_misc qw(
22
get_param
23
referrer
24
get_params_asHash
25
pluralize
26
);
27
use Bc_sql qw(sql_execute
28
get_constant
29
user_exists
30
$QUERY_PAGE
31
$QUERY_UID
32
$LOGGEDIN
33
34
$DB
35
);
36
use Redir qw(notice_redir error_redir);
37
use User qw(
38
isUserAdmin
39
get_user_message
40
get_user_messages
41
get_user_stat
42
$USER_DATA
43
);
44
use Security qw(banned);
45
46
my $DEBUG = 0;
47
48
my %params = get_params_asHash();
49
50
my $output;
51
52
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserAdmin($LOGGEDIN)) {
53
my $msg = "Access Denied";
54
if ($DEBUG) { $msg .= " (edit_umsgs.pl)"; }
55
$output = error_redir("/", $msg);
56
} else {
57
############################################################
58
### YOUR CONTENT HERE
59
$output = pre_html_header();
60
$output .= header(
61
"User Messages",
62
"?nobg_img=1&nogrid=1",
63
0,
64
"setTimeout(removeMsg, " . get_constant("REMOVE_MSG_TIMEOUT") . ");",
65
"",
66
"style='display: flex; height: min-content;'"
67
);
68
69
my $uid = $params{$QUERY_UID};
70
my @msgs = get_user_messages($uid, 1);
71
72
{ my %container;
73
$container{tag} = "div";
74
#$container{class} = "bordered";
75
$container{style} = "margin: 0 0; width: 100%;";
76
$container{innerHTML} = "";
77
78
if ($DEBUG) {
79
$container{innerHTML} .= "DEBUGGING edit_umsgs.pl - <a href=\"javascript:document.location.reload();\">Reload</a><hr><br>\n\n";
80
81
$container{innerHTML} .= "uid: <b>$uid</b><br>\n";
82
$container{innerHTML} .= "# of msgs (including chat): <b>" . (@msgs) . "</b> received<br>\n";
83
84
$container{innerHTML} .= "<hr>\n";
85
}
86
87
# Load up ALL messages for supplied uid
88
$container{innerHTML} .= "<div class='subnavbar sticky' style='width: 100%; text-align: left;'>\n";
89
$container{innerHTML} .= " <table border=0 cellpadding=0 cellspacing=0 width=100%><tr><td width=1>\n";
90
$container{innerHTML} .= " <button class=yellow onclick=\"document.location.reload();\"><img src='/img.pl?i=site/reload.png&s=u'></button>\n";
91
$container{innerHTML} .= " </td><td class=spacerx></td><td class=subtitle>\n";
92
$container{innerHTML} .= " Messages Manager";
93
$container{innerHTML} .= " </td></tr></table>\n";
94
$container{innerHTML} .= "</div>\n";
95
$container{innerHTML} .= "<table border=0 cellpadding=0 cellspacing=0 width=100%><tr><td>\n";
96
$container{innerHTML} .= " <b>" . (@msgs) . "</b> " . pluralize("message", @msgs) . " received<hr>\n";
97
98
my $msg_count = 0;
99
foreach my $msgid (@msgs) {
100
my $msgdata = get_user_message($msgid);
101
$msg_count++;
102
$container{innerHTML} .= "<fieldset style='margin-bottom: 15px;'>\n";
103
$container{innerHTML} .= " <legend style='padding-top: 6px; padding-bottom: 0;'>\n";
104
$container{innerHTML} .= " <div class='inline blue-panel'>$msg_count</div>\n";
105
$container{innerHTML} .= " Message ID: <i>$msgdata->{ID}</i> \n";
106
$container{innerHTML} .= " <button class=green title='View Message'><img src=\"/images/site/read.png\" height=14></button>\n";
107
$container{innerHTML} .= " <button class=red title='Delete Message'><img src=\"/images/site/delete.png\" height=14></button>\n";
108
$container{innerHTML} .= " </legend>\n";
109
$container{innerHTML} .= " Subject: <b>$msgdata->{subject}</b><br>\n";
110
$container{innerHTML} .= " Sent: <b>" . expand_date($msgdata->{sent}) . "</b> -\n";
111
$container{innerHTML} .= " <b>";
112
if ($msgdata->{seen} eq "1") { $container{innerHTML} .= "not "; }
113
$container{innerHTML} .= "seen</b> -\n";
114
$container{innerHTML} .= " <b>";
115
if ($msgdata->{deled} eq "1")
116
{ $container{innerHTML} .= "not "; }
117
$container{innerHTML} .= "deleted</b><br>\n";
118
$container{innerHTML} .= " From: <a title='View Profile' target=_top href=\"/?$QUERY_PAGE=" . get_constant("PROFILE_PAGE") . "&$QUERY_UID=$msgdata->{from_ID}\">" . get_user_stat($msgdata->{from_ID}, "nickname") . "</a>\n";
119
$container{innerHTML} .= " - <a title='User Manager' target=_top href=\"/?$QUERY_PAGE=" . get_constant("ADMIN_PAGE") . "&" . get_constant("QUERY_ADMIN_PAGE") . "=" . get_constant("ADMIN_USER_EDITOR_PAGE") . "&$QUERY_UID=$msgdata->{from_ID}\">Manage</a><br>\n";
120
$container{innerHTML} .= "</fieldset>\n";
121
}
122
123
$container{innerHTML} .= "</td></tr></table>\n";
124
125
$output .= tag(\%container);
126
} # end container;
127
128
### END YOUR CONTENT
129
$output .= html_end();
130
############################################################
131
}
132
133
print $output;
134
135
exit 1;