verifynickname.pl
Copying Source is Forbidden
67 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 HTML::Restrict;
8
9
use lib "/var/www/html/Pm";
10
11
use Security;
12
Security::count_hits();
13
14
use Bc_misc qw(get_param);
15
use Bc_sql qw(
16
get_constant
17
sql_execute
18
user_exists
19
20
is_badname
21
22
$QUERY_PAGE
23
$QUERY_UID
24
$LOGGEDIN
25
26
$DB
27
);
28
29
my $nn = get_param("nn");
30
my $usable = 1;
31
32
print "cache-control: no-cache, no-store\ncontent-type: text/plain\n\n";
33
34
# check if we have a nickname
35
# and see if that exists in the DB or not
36
if ($nn) {
37
if (length $nn < 4) {
38
$usable = 0;
39
} else {
40
if (is_badname($nn)) {
41
$usable = 0;
42
} else {
43
if ($nn =~ /^test-/i or $nn =~ /^test_/i) {
44
$usable = 0;
45
} else {
46
my $result = sql_execute("select nickname from users where nickname like " . $DB->quote($nn), "verifynickname.pl");
47
if (ref $result eq "HASH") {
48
$usable = 0;
49
} elsif (ref $result eq "ARRAY") {
50
if (@$result) { $usable = 0; }
51
}
52
}
53
}
54
}
55
} else {
56
$usable = 0;
57
}
58
59
# now, limit what characters they can use?
60
# definitely no html, or javascript!
61
my $nohtml = HTML::Restrict->new();
62
my $processed = $nohtml->process($nn);
63
if ($processed ne $nn) { $usable = 0; }
64
65
print $usable;
66
67
exit 1;