game/ajax_checklogin.php

95 lines
2.5 KiB
PHP
Raw Normal View History

2022-06-06 21:30:34 +00:00
<?php
define('GAME',true);
include_once('_incl_data/__config.php');
include_once('_incl_data/class/__db_connect.php');
if(isset($_GET['login'])) {
//
$_GET['login'] = htmlspecialchars($_GET['login'],NULL,'cp1251');
//
$bad = array(
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' => 1,
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' => 1
);
//
function en_ru($txt) {
$g = false;
$en = preg_match("/^(([0-9a-zA-Z _-])+)$/i", $txt);
$ru = preg_match("/^(([0-9<>-<2D><>-<2D> _-])+)$/i", $txt);
if(($ru && $en) || (!$ru && !$en)) {
$g = true;
}
return $g;
}
//
function testBad($txt) {
$white = '-_ 0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM<4E><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
$r = false;
$i = 0;
while( $i != -1 ) {
if( isset($txt[$i]) ) {
$g = false;
$j = 0;
while( $j != -1 ) {
if(isset($white[$j])) {
if( $white[$j] == $txt[$i] ) {
$g = true;
}
}else{
$j = -2;
}
$j++;
}
if( $g == false ) {
$r = true;
}
}else{
$i = -2;
}
$i++;
}
return $r;
}
//
$login = mysql_fetch_array(mysql_query('SELECT `id` FROM `users` WHERE `login` = "'.mysql_real_escape_string($_GET['login']).'" LIMIT 1'));
if( isset($login['id']) || isset($bad[$_GET['login']]) ) {
echo '<b style="color:red"><3E><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>.</b>';
}else{
$true = true;
//
/*
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 4 <EFBFBD><EFBFBD> 16 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '_', '-' <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '_', '-' <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
*/
//
$_GET['login'] = str_replace(' ',' ',$_GET['login']);
$_GET['login'] = str_replace('%',' ',$_GET['login']);
$_GET['login'] = str_replace('&nbsp;',' ',$_GET['login']);
//
if( strlen($_GET['login']) > 16 ) {
$true = false;
}elseif( strlen($_GET['login']) < 4 ) {
$true = false;
}elseif( strripos($_GET['login'],' ') == true ) {
$true = false;
}elseif( substr($_GET['login'],1) == ' ' || substr($_GET['login'],-1) == ' ' ) {
$true = false;
}elseif( substr($_GET['login'],1) == '-' || substr($_GET['login'],-1) == '-' ) {
$true = false;
}elseif( substr($_GET['login'],1) == '_' || substr($_GET['login'],-1) == '_' ) {
$true = false;
}elseif( testBad($_GET['login']) == true ) {
$true = false;
}elseif( en_ru(str_replace('<27>','<27>',str_replace('<27>','<27>',$_GET['login']))) == true ) {
$true = false;
}
//
if( $true == false ) {
echo '<b style="color:red"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>.</b>';
}else{
echo '<b style="color:green"><3E><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!</b>';
}
}
}
?>