settheme.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);
16
use Bc_chef qw(cookie_get);
17
use Bc_misc qw(get_param referrer);
18
use Bc_sql qw(
19
get_constant
20
sql_execute
21
user_exists
22
theme_exists
23
get_theme_purchases
24
25
$QUERY_PAGE
26
$QUERY_UID
27
$LOGGEDIN
28
29
$DB
30
);
31
32
use Security qw(banned);
33
use Redir qw(error_redir notice_redir);
34
use User qw(
35
isThemePurchased
36
set_user_theme
37
);
38
39
my $DEBUG = 0;
40
41
my $output;
42
43
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN)) {
44
my $msg = "Access Denied";
45
if ($DEBUG) { $msg .= " (settheme.pl)"; }
46
$output = error_redir("/", $msg);
47
} else {
48
############################################################
49
50
### YOUR CONTENT HERE
51
52
if ($DEBUG) {
53
$output = pre_html_header();
54
$output .= "DEBUG MODE ENABLED<hr><br>\n";
55
} else {
56
$output = pre_html_header({type=>"text/plain"});
57
}
58
59
my $tid = get_param('tid');
60
if (isThemePurchased($tid) and $tid ne '1111111111') {
61
if ($DEBUG) {
62
$output .= "Loggedin ID: $LOGGEDIN<br>\n";
63
my @ptids = get_theme_purchases();
64
if (@ptids) {
65
$output .= "found " . (@ptids) . " purchased themes<br>\n";
66
foreach my $ptid (@ptids) {
67
$output .= $ptid . "<br>\n";
68
}
69
} else {
70
$output .= "no theme purchases found<br>\n";
71
}
72
$output .= "$tid exists and is purchased!<br>\n";
73
} else {
74
set_user_theme($tid);
75
$output = notice_redir(referrer(), "theme ($tid) applied");
76
}
77
} else {
78
if ($DEBUG) {
79
$output .= "this theme cannot been applied because it is either not purchased, or doesn't exist<br>\n";
80
} else {
81
$output = error_redir(referrer(), "theme not found or not purchased");
82
}
83
}
84
85
############################################################
86
}
87
88
print $output;
89
90
exit 1;