admin_update_help.pl
Copying Source is Forbidden
90 lines of code
1
#!/usr/local/bin/perl
2
3
binmode(STDIN, ":utf8");
4
binmode(STDOUT, ":utf8");
5
6
# must have's!
7
use strict;
8
use warnings;
9
use CGI::Carp qw(fatalsToBrowser);
10
use DBI;
11
use URI::Escape;
12
13
use lib "/var/www/html/Pm";
14
15
use Html qw(pre_html_header header display_debug_code display_debug_one);
16
use Html2 qw(tag br hr embolden italicize);
17
use Bc_chef qw(cookie_get);
18
use Bc_misc qw(get_param referrer get_param_unfiltered);
19
use Bc_sql qw(sql_execute
20
get_constant
21
user_exists
22
$QUERY_PAGE
23
$QUERY_UID
24
$LOGGEDIN
25
26
$DB
27
);
28
use Redir qw(notice_redir error_redir);
29
use User qw(isUserSuperAdmin $USER_DATA);
30
use Security qw(banned);
31
32
my $DEBUG = 0; #get_param("dce");
33
34
my $TABLE_NAME = "misc";
35
my $COLUMN_NAME = "help";
36
37
my $output;
38
39
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserSuperAdmin($LOGGEDIN)) {
40
my $msg = "Access Denied";
41
if ($DEBUG) { $msg .= " (admin_update_$COLUMN_NAME.pl)"; }
42
$output = error_redir("/", $msg);
43
} else {
44
############################################################
45
46
### YOUR CONTENT HERE
47
my $value = get_param($COLUMN_NAME, 0, 1);
48
49
my $sql = "update $TABLE_NAME set value=" . $DB->quote($value) . " where name='$COLUMN_NAME'";
50
my $result = sql_execute($sql, "admin update help.pl");
51
52
if ($DEBUG) {
53
$output = pre_html_header();
54
$output .= "DEBUG MODE ENABLED" . hr . br;
55
56
$output .= "input is" . br;
57
{ my %ta;
58
$ta{tag} = "textarea";
59
$ta{cols} = 150;
60
$ta{rows} = 5;
61
$ta{innerHTML} = $value;
62
63
$output .= tag(\%ta) . br;
64
}
65
$output .= "sql for $TABLE_NAME is" . br;
66
{ my %ta;
67
$ta{tag} = "textarea";
68
$ta{cols} = 150;
69
$ta{rows} = 5;
70
$ta{innerHTML} = $sql;
71
72
$output .= tag(\%ta) . br;
73
}
74
if ($result) { $output .= "yay!" . br; } else { $output .= "booo!" . br; }
75
} else {
76
my $r = referrer();
77
if (not $r) { $r = "/"; }
78
if ($result) {
79
$output = notice_redir($r, ucfirst($COLUMN_NAME) . " page updated");
80
} else {
81
$output = error_redir($r, "update failed!");
82
}
83
}
84
85
############################################################
86
}
87
88
print $output;
89
90
exit 1;