delchat.pl
57 lines of code
1
#!/usr/local/bin/perl
2
3
# must have's!
4
use strict;
5
use warnings;
6
use CGI::Carp qw(fatalsToBrowser);
7
use DBI;
8
use URI::Escape;
9
10
use lib "/var/www/html/Pm";
11
12
use Html qw(pre_html_header);
13
use Bc_chef qw(cookie_get);
14
use Bc_misc qw(get_param);
15
use Bc_sql qw(get_constant
16
              sql_execute
17
              user_exists
18
              $QUERY_PAGE
19
              $QUERY_UID
20
              $LOGGEDIN
21
22
              $DB
23
             );
24
25
use Security qw(banned);
26
27
my $DEBUG = 0;
28
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN)) {
29
  my $msg =  "Access Denied";
30
  if ($DEBUG) { $msg .= " (delchat.pl)"; }
31
  print error_redir("/", $msg);
32
33
  exit 1;
34
}
35
36
my $output = pre_html_header();
37
38
my $uid = get_param($QUERY_UID);
39
my $sql = "delete from messages where subject='chatbox msg' and (";
40
   $sql .= " (to_ID=" . $DB->quote($LOGGEDIN) . " and";
41
   $sql .= "  from_ID=" . $DB->quote($uid);
42
   $sql .= " ) or ";
43
   $sql .= " (to_ID=" . $DB->quote($uid) . " and";
44
   $sql .= "  from_ID=" . $DB->quote($LOGGEDIN);
45
   $sql .= " )";
46
   $sql .= ")";
47
48
if ($DEBUG) {
49
  if (not sql_execute($sql, "delchat.pl")) { $output .= "<br>\n" . $sql; }
50
} else {
51
  sql_execute($sql, "delchat");
52
  $output .= 1;
53
}
54
55
print $output;
56
57
exit 1;