<?php
define('NO_REGISTER_GLOBALS', 1);
define('SKIP_SESSIONCREATE', 1);
define('NOCOOKIES', 1);
define('DIE_QUIETLY', 1);
require_once('./global.php');
$vbulletin->input->clean_array_gpc('p', array('username' => TYPE_STR));
$vbulletin->GPC['username']= @ convert_urlencoded_unicode($vbulletin->GPC['username']);

if ($vbulletin->GPC['username'] != '')
{
	header("Content-Type: text/plain;");
	$username2 = $username = trim(preg_replace('#\s+#si', ' ', strip_blank_ascii($vbulletin->GPC['username'], ' ')));
	if (preg_match('~&#(\d+);~', $username2))
	{
		if (function_exists('iconv'))
		{
			$username2 = @iconv($stylevar['charset'], 'UTF-8', $username2);
		}
	}
	$username2 = preg_replace(
		'~&#(\d+);~e',
		"convert_int_to_utf8('\\1')",
		$username2
	);
	switch(true)
	{
		case preg_match('/(?<!&#\d{3}|&#\d{4}|&#\d{5});/', $username):
			echo 3;
			break;
		case $username != fetch_censored_text($username):
			echo 2;
			break;
		case $username2 != fetch_censored_text($username2):
			echo 2;
			break;
		case @strpos(strtolower($username), strtolower($vbulletin->options['illegalusernames'])) !== false:
			echo 1;
			break;
		case @strpos(strtolower($username2), strtolower($vbulletin->options['illegalusernames'])) !== false:
			echo 1;
			break;
		case $existinguser = $db->query_first("
			SELECT
				username
			FROM
				" . TABLE_PREFIX . "user
			WHERE
				username
			IN
				(
					'" . $db->escape_string(htmlspecialchars_uni($username)) . "',
					'" . $db->escape_string(htmlspecialchars_uni($username2)) . "'
				)
			")
			:
			echo 1;
			break;
		default;
			echo 0;
	}
}
?>