getmodmsg.pl
74 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 Html qw(pre_html_header header html_end);
18
use Bc_chef qw(cookie_get);
19
use Bc_misc qw(get_param referrer get_params_asHash);
20
use Bc_sql qw(sql_execute
21
              get_constant
22
              user_exists
23
              $QUERY_PAGE
24
              $QUERY_UID
25
              $LOGGEDIN
26
27
              $DB
28
             );
29
use Redir qw(notice_redir error_redir);
30
use User qw(isUserModerator $USER_DATA);
31
use Security qw(banned);
32
33
my $DEBUG = 0;
34
35
my %params = get_params_asHash();
36
37
my $output = pre_html_header({type=>"text/plain"});
38
39
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserModerator($LOGGEDIN)) {
40
  $output .= "0\n";
41
} else {
42
  ############################################################
43
  ### YOUR CONTENT HERE
44
45
  if ($DEBUG) {
46
    $output = pre_html_header();
47
    $output .= header(
48
                     "TEMPLATE_MODERATOR",
49
                     "?nobg_img=1&nogrid=1",
50
                     0,
51
                     "setTimeout(removeMsg, " . get_constant("REMOVE_MSG_TIMEOUT") . ");",
52
                     "",
53
                     "style=\"padding: 2px;\""
54
                    );
55
56
    $output .= "DEBUGGING GET MOD MSG<hr>\n";
57
    $output .= "<div class=translucent>\n";
58
    $output .= "  id: <b>$params{id}</b><br>\n";
59
    $output .= "</div>\n";
60
    $output .= html_end();
61
  } else {
62
    my $sql = "select value from mod_msgs where ID=" . $DB->quote($params{id});
63
    my $result = sql_execute($sql, "getmodmsg.pl?id=$params{id}");
64
65
    if (ref $result eq "HASH") { $output .= $result->{value}; }
66
  }
67
68
  ### END YOUR CONTENT
69
  ############################################################
70
}
71
72
print $output;
73
74
exit 1;