game/ajax_checklogin.php
2022-06-07 00:30:34 +03:00

95 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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(
'Ìóñîðùèê' => 1,
'Ìèðîçäàòåëü' => 1
);
//
function en_ru($txt) {
$g = false;
$en = preg_match("/^(([0-9a-zA-Z _-])+)$/i", $txt);
$ru = preg_match("/^(([0-9à-ÿÀ-ß _-])+)$/i", $txt);
if(($ru && $en) || (!$ru && !$en)) {
$g = true;
}
return $g;
}
//
function testBad($txt) {
$white = '-_ 0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM¨ÉÖÓÊÅÍÃØÙÇÕÚÔÛÂÀÏÐÎËÄÆÝß×ÑÌÈÒÜÁÞ¸éöóêåíãøùçõúôûâàïðîëäæýÿ÷ñìèòüáþ';
$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">Ëîãèí çàíÿò.</b>';
}else{
$true = true;
//
/*
Ëîãèí ìîæåò ñîäåðæàòü îò 4 äî 16 ñèìâîëîâ, è ñîñòîÿòü òîëüêî èç áóêâ ðóññêîãî ÈËÈ àíãëèéñêîãî àëôàâèòà, öèôð, ñèìâîëîâ '_', '-' è ïðîáåëà.
Ëîãèí íå ìîæåò íà÷èíàòüñÿ èëè çàêàí÷èâàòüñÿ ñèìâîëàìè '_', '-' èëè ïðîáåëîì.
*/
//
$_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('¸','å',str_replace('¨','Å',$_GET['login']))) == true ) {
$true = false;
}
//
if( $true == false ) {
echo '<b style="color:red">Íåâåðíûé ëîãèí.</b>';
}else{
echo '<b style="color:green">Ëîãèí ñâîáîäåí!</b>';
}
}
}
?>