beta.pl
Copying Source is Forbidden
135 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 Date qw(get_today);
16
use Html qw(pre_html_header header);
17
use Html2 qw(tag br hr embolden italicize);
18
use Bc_chef qw(cookie_get);
19
use Bc_misc qw(get_param get_params_asHash referrer);
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(
31
isUserAdmin
32
isUserBeta
33
$USER_DATA
34
);
35
use Security qw(banned);
36
37
my $DEBUG = 1;
38
39
my $output;
40
41
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) and not isUserAdmin($LOGGEDIN)) {
42
my $msg = "Access Denied";
43
if ($DEBUG) { $msg .= " (beta.pl)"; }
44
$output = error_redir("/", $msg);
45
} else {
46
############################################################
47
48
### YOUR CONTENT HERE
49
50
if ($DEBUG) {
51
$output = pre_html_header();
52
$output .= header("set as beta tester", 0, 0, 0, "", "style='background-image: none;'");
53
$output .= "<table align=center border=0 cellpadding=0 cellspacing=0 height=100% width=100%><tr><td align=center class=subtitle height=1>\n";
54
$output .= " DEBUG MODE ENABLED\n";
55
$output .= hr;
56
$output .= "</td></tr><tr><td align=center height=1>\n";
57
$output .= " The database will " . italicize("not") . " be updated\n";
58
$output .= hr;
59
$output .= "</td></tr><tr><td align=center>\n";
60
}
61
62
my %params = get_params_asHash();
63
64
if ($params{$QUERY_UID}) {
65
if (user_exists($params{$QUERY_UID})) {
66
if (isUserBeta($params{$QUERY_UID})) {
67
if ($DEBUG) {
68
$output .= "$params{$QUERY_UID} is a beta tester!" . br;
69
} else {
70
$output = error_redir(referrer(), "User is a beta tester");
71
}
72
# end if is user beta
73
} else {
74
my $sql = "insert into beta_users values (NULL, " . $DB->quote($params{$QUERY_UID}) . ", '" . get_today('db', 1) . "', NULL, '1', '1', '1')";
75
if ($DEBUG) {
76
$output .= "$params{$QUERY_UID} is " . italicize("not") . " a beta tester!" . br;
77
$output .= "sql: " . embolden($sql) . br;
78
} else {
79
# actually insert the user into the beta_users table
80
}
81
# end else of if is user beta
82
}
83
# end if user exists
84
} else {
85
if ($DEBUG) {
86
$output .= "no such user: " . embolden($params{$QUERY_UID}) . br;
87
} else {
88
$output = error_redir(referrer(), "Bad params");
89
}
90
# end else of if user exists
91
}
92
# end if params{query_uid}
93
} else {
94
if ($DEBUG) {
95
$output .= "Missing UID parameter" . br;
96
} else {
97
$output = error_redir(referrer(), "Bad params");
98
}
99
# end else of if params{query_uid}
100
}
101
102
############################################################
103
}
104
105
if ($DEBUG) {
106
$output .= "</td></tr><tr><td height=1>\n";
107
$output .= hr;
108
$output .= "</td></tr><tr><td align=center height=1>\n";
109
110
{ my %button;
111
$button{tag} = "button";
112
$button{type} = "button";
113
$button{class} = "yellow";
114
$button{onclick} = "previous_page();";
115
$button{innerHTML} = "Back";
116
117
$output .= tag(\%button);
118
}
119
120
{ my %button;
121
$button{tag} = "button";
122
$button{type} = "button";
123
$button{class} = "yellow";
124
$button{onclick} = "reload();";
125
$button{innerHTML} = "Reload";
126
127
$output .= tag(\%button);
128
}
129
130
$output .= "</td></tr></table>\n";
131
}
132
133
print $output;
134
135
exit 1;