-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathnamecheck.php
59 lines (59 loc) · 2.15 KB
/
namecheck.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* https://github.com/Bigjoos/
* Licence Info: GPL
* Copyright (C) 2010 U-232 v.3
* A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
* Project Leaders: Mindless, putyn.
*
*/
if (empty($_GET['wantusername'])) {
die('Silly Rabbit - Twix are for kids - You cant post nothing please enter a username !');
}
sleep(1);
require_once (dirname(__FILE__).DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
dbconn();
$HTMLOUT = "";
$lang = array_merge(load_language('global') , load_language('takesignup'));
function validusername($username)
{
global $lang;
if ($username == "") return false;
$namelength = strlen($username);
if (($namelength < 3) OR ($namelength > 32)) {
$HTMLOUT = "";
$HTMLOUT.= "<font color='#cc0000'>{$lang['takesignup_username_length']}</font>";
echo $HTMLOUT;
exit();
}
// The following characters are allowed in user names
$allowedchars = $lang['takesignup_allowed_chars'];
for ($i = 0; $i < $namelength; ++$i) {
if (strpos($allowedchars, $username[$i]) === false) return false;
}
return true;
}
if (!validusername($_GET["wantusername"])) {
$HTMLOUT.= "<font color='#cc0000'>{$lang['takesignup_allowed_chars']}</font>";
echo $HTMLOUT;
exit();
}
if (strlen($_GET["wantusername"]) > 12) {
$HTMLOUT.= "<font color='#cc0000'>{$lang['takesignup_username_length']}</font>";
echo $HTMLOUT;
exit();
}
$checkname = sqlesc($_GET["wantusername"]);
$sql = "SELECT username FROM users WHERE username = $checkname";
$result = sql_query($sql);
$numbers = mysqli_num_rows($result);
if ($numbers > 0) {
while ($namecheck = mysqli_fetch_assoc($result)) {
$HTMLOUT.= "<font color='#cc0000'><img src='{$INSTALLER09['pic_base_url']}cross.png' alt='Cross' title='Username Not Available' align='absmiddle' /><b>Sorry... Username - ".htmlsafechars($namecheck["username"])." is already in use.</b></font>";
}
} else {
$HTMLOUT.= "<font color='#33cc33'><img src='{$INSTALLER09['pic_base_url']}tick.png' alt='Tick' title='Username Available' align='absmiddle' /><b>Username Available</b></font>";
}
echo $HTMLOUT;
exit();
?>