Просмотр файла reg.php

Размер файла: 18.6Kb
<?php
header("Cache-Control: no-cache");
header("Content-type:text/vnd.wap.wml");  
require("inc.php");
if(!@$go)
{
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"reg\" title=\"Регистрация\">\n";
echo "<p mode=\"wrap\">\n";
echo "*Желаемый ник:<br/>\n"; 
echo "<input name=\"user\" maxlength=\"15\" title=\"nick\"/><br/>\n";    
echo "*Пароль:<br/>\n"; 
echo "<input name=\"pass\"  maxlength=\"10\" title=\"pass\"/><br/>\n";      
echo "*Повторите пароль:<br/>\n"; 
echo "<input name=\"pass2\"  maxlength=\"10\" title=\"verpass\"/><br/>\n";  
echo "*Подпольная кличка:<br/>\n";     
echo "<input name=\"name\" maxlength=\"15\" title=\"name\"/><br/>\n";   
echo "Пол:<br/>\n";
echo "<select name=\"sex\">\n";
echo "<option value=\"М\">&#x041C;</option>\n";
echo "<option value=\"Ж\">&#x0416;</option>\n";
echo "</select><br/>\n";
echo "*Дата рождения:<br/>\n";     
echo "День:<input name=\"day\" maxlength=\"2\" title=\"day\" format=\"*N\"/><br/>\n";  
echo "Месяц:<input name=\"month\" maxlength=\"2\" title=\"month\" format=\"*N\"/><br/>\n";  echo "Год:<input name=\"year\" maxlength=\"4\" title=\"year\" format=\"*N\"/><br/>\n";  
echo "*Город:<br/>\n";     
echo "<input name=\"city\" maxlength=\"40\" title=\"city\"/><br/>\n";

echo "*Кратко о себе:<br/>\n";     
echo "<input name=\"infa\" maxlength=\"200\" title=\"infa\"/><br/>\n";    
echo "<anchor title=\"go\">OK<go href=\"reg.php?go=reg\" method=\"post\">\n";
echo "<postfield name=\"user\" value=\"$(user)\"/>\n";
echo "<postfield name=\"pass\" value=\"$(pass)\"/>\n";
echo "<postfield name=\"pass2\" value=\"$(pass2)\"/>\n";
echo "<postfield name=\"name\" value=\"$(name)\"/>\n";
echo "<postfield name=\"sex\" value=\"$(sex)\"/>\n";
echo "<postfield name=\"day\" value=\"$(day)\"/>\n";
echo "<postfield name=\"month\" value=\"$(month)\"/>\n";
echo "<postfield name=\"year\" value=\"$(year)\"/>\n";
echo "<postfield name=\"city\" value=\"$(city)\"/>\n";
echo "<postfield name=\"infa\" value=\"$(infa)\"/>\n";
echo "</go></anchor><br/>\n";    
echo "*********<br/>\n";
echo "<a href=\"../index.php\">На главную</a>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
exit;
}       
                 function rus_to_k($str)
                $str = str_replace("а","a",$str); 
                $str = str_replace("б","b",$str);
                $str = str_replace("в","v",$str);
                $str = str_replace("г","g",$str);
                $str = str_replace("д","d",$str);
                $str = str_replace("е","e",$str); 
                $str = str_replace("ё","e",$str); 
                $str = str_replace("ж","j",$str);
                $str = str_replace("з","z",$str);
                $str = str_replace("и","i",$str);
                $str = str_replace("й","y",$str);
                $str = str_replace("к","k",$str);
                $str = str_replace("л","l",$str); 
                $str = str_replace("м","m",$str);
                $str = str_replace("н","n",$str);
                $str = str_replace("о","o",$str);
                $str = str_replace("п","p",$str);
                $str = str_replace("р","r",$str);
                $str = str_replace("с","s",$str); 
                $str = str_replace("т","t",$str);
                $str = str_replace("у","u",$str);
                $str = str_replace("ф","f",$str);
                $str = str_replace("х","h",$str);
                $str = str_replace("ч","c",$str);
                $str = str_replace("ц","q",$str);//� 
                $str = str_replace("ш","w",$str);
                $str = str_replace("щ",">",$str);//�
                $str = str_replace("ь","<",$str);//�
                $str = str_replace("ы","x",$str);//�
                $str = str_replace("ъ",".",$str);//�
                $str = str_replace("э",":",$str);//� 
                $str = str_replace("ю",";",$str);//�
                $str = str_replace("я","}",$str);//�
                $str = str_replace("А","a",$str);
                $str = str_replace("Б","b",$str);
                $str = str_replace("В","v",$str);
                $str = str_replace("Г","g",$str); 
                $str = str_replace("Д","d",$str);
                $str = str_replace("Е","e",$str);
                $str = str_replace("Ё","e",$str);
                $str = str_replace("Ж","j",$str);
                $str = str_replace("З","z",$str);
                $str = str_replace("И","i",$str); 
                $str = str_replace("Й","y",$str);
                $str = str_replace("К","k",$str);
                $str = str_replace("Л","l",$str);
                $str = str_replace("М","m",$str);
                $str = str_replace("Н","n",$str);
                $str = str_replace("О","o",$str); 
                $str = str_replace("П","p",$str);
                $str = str_replace("Р","r",$str);
                $str = str_replace("С","s",$str);
                $str = str_replace("Т","t",$str);
                $str = str_replace("У","u",$str);
                $str = str_replace("Ф","f",$str);
                $str = str_replace("Х","h",$str);
                $str = str_replace("Ч","c",$str);
                $str = str_replace("Ц","q",$str);
                $str = str_replace("Ш","w",$str); 
                $str = str_replace("Щ",">",$str);
                $str = str_replace("Ь","<",$str);
                $str = str_replace("Ы","x",$str);
                $str = str_replace("Ъ",".",$str);
                $str = str_replace("Э",":",$str);
                $str = str_replace("Ю",";",$str);
                $str = str_replace("Я","}",$str);
                return $str;
                }

                function replace_rus($str){
                $str = str_replace("а","|",$str); 
                $str = str_replace("б","|",$str);
                $str = str_replace("в","|",$str);
                $str = str_replace("г","|",$str);
                $str = str_replace("д","|",$str);
                $str = str_replace("е","|",$str); 
                $str = str_replace("ё","|",$str); 
                $str = str_replace("ж","|",$str);
                $str = str_replace("з","|",$str);
                $str = str_replace("и","|",$str);
                $str = str_replace("й","|",$str);
                $str = str_replace("к","|",$str);
                $str = str_replace("л","|",$str); 
                $str = str_replace("м","|",$str);
                $str = str_replace("н","|",$str);
                $str = str_replace("о","|",$str);
                $str = str_replace("п","|",$str);
                $str = str_replace("р","|",$str);
                $str = str_replace("с","|",$str); 
                $str = str_replace("т","|",$str);
                $str = str_replace("у","|",$str);
                $str = str_replace("ф","|",$str);
                $str = str_replace("х","|",$str);
                $str = str_replace("ч","|",$str);
                $str = str_replace("ц","|",$str); 
                $str = str_replace("ш","|",$str);
                $str = str_replace("щ","|",$str);
                $str = str_replace("ь","|",$str);
                $str = str_replace("ы","|",$str);
                $str = str_replace("ъ","|",$str);
                $str = str_replace("э","|",$str); 
                $str = str_replace("ю","|",$str);
                $str = str_replace("я","|",$str);
                $str = str_replace("А","|",$str);
                $str = str_replace("Б","|",$str);
                $str = str_replace("В","|",$str);
                $str = str_replace("Г","|",$str); 
                $str = str_replace("Д","|",$str);
                $str = str_replace("Е","|",$str);
                $str = str_replace("Ё","|",$str);
                $str = str_replace("Ж","|",$str);
                $str = str_replace("З","|",$str);
                $str = str_replace("И","|",$str); 
                $str = str_replace("Й","|",$str);
                $str = str_replace("К","|",$str);
                $str = str_replace("Л","|",$str);
                $str = str_replace("М","|",$str);
                $str = str_replace("Н","|",$str);
                $str = str_replace("О","|",$str); 
                $str = str_replace("П","|",$str);
                $str = str_replace("Р","|",$str);
                $str = str_replace("С","|",$str);
                $str = str_replace("Т","|",$str);
                $str = str_replace("У","|",$str);
                $str = str_replace("Ф","|",$str);
                $str = str_replace("Х","|",$str);
                $str = str_replace("Ч","|",$str);
                $str = str_replace("Ц","|",$str);
                $str = str_replace("Ш","|",$str); 
                $str = str_replace("Щ","|",$str);
                $str = str_replace("Ь","|",$str);
                $str = str_replace("Ы","|",$str);
                $str = str_replace("Ъ","|",$str);
                $str = str_replace("Э","|",$str);
                $str = str_replace("Ю","|",$str);
                $str = str_replace("Я","|",$str);
                return $str;
                }

    $error = true; 
$user = trim(" $user ");
$user = ereg_replace(" +"," ",$user); 
$pass = trim(" $pass ");
$pass = ereg_replace(" +"," ",$pass);         
$name = trim(" $name ");
$name = ereg_replace(" +"," ",$name);        
$day = trim(" $day ");
$day = ereg_replace(" +"," ",$day);           
$month = trim(" $month ");
$month = ereg_replace(" +"," ",$month);         
$year = trim(" $year ");
$year = ereg_replace(" +"," ",$year);          
$city  = trim(" $city  ");
$city  = ereg_replace(" +"," ",$city);  
 
$infa  = trim(" $infa  ");
$infa  = ereg_replace(" +"," ",$infa);         
$infa=substr($infa,0,400);              
$user = eregi_replace("\\(P!\\)", "0", $user);
$user = eregi_replace("\\[P!\\]", "0", $user);
$user = str_replace("_", "0", $user);
$user = str_replace(" ", "_", $user);
$bak = $user;
$bak = replace_rus($bak);   
$emp = "Не заполнены обязательные поля!";              

        if ($user === "") {
        $msg = "$emp";
    } elseif ($pass === "") {
        $msg = "$emp";
    }elseif (strpos($user,"|")!==false) {$msg = "В нике обнаружены запрешенные знаки!";} 
    
    elseif((!preg_match("!^[a-z1-9@\\*\\)\\(\\?\\!\\-_\\.\\]\\[=~]+$!i",$user))&&(!preg_match("!^[1-9@\\*\\)\\(\\?\\!\\-_\\]\\|\\[=~]+$!i",$bak)))  {$msg = "В нике обнаружены запрешенные знаки!";} 

    elseif(!preg_match("!^[a-z0-9]+$!i",$pass))  {
        $msg = "В пароле обнаружены запрешенные знаки!";    
    } elseif ($name == "") {            
        $msg = "$emp";   
    } elseif ($day == "") {          
        $msg = "$emp";      
    } elseif ($month == "") {          
        $msg = "$emp";      
    } elseif ($year == "") {
        $msg = "$emp";       
    } elseif ($city == "") {
        $msg = "$emp";    
    } elseif ($infa == "") {
        $msg = "$emp";      
    } elseif ($pass !== $pass2) {
        $msg = "пароли не совпадают!";   
    } else {
                
                        
        $user = HtmlSpecialChars($user); 
        $pass = HtmlSpecialChars($pass); 
        $name = HtmlSpecialChars($name);     
        $day = HtmlSpecialChars($day);     
        $month = HtmlSpecialChars($month);     
        $year = HtmlSpecialChars($year);     
        $city = HtmlSpecialChars($city);           
         
        $infa = HtmlSpecialChars($infa);       
              
        $user = str_replace("", "", $user);
        $user = str_replace("", "", $user); 
        $user = str_replace("", "", $user);         
        $user = str_replace("", "", $user); 
        $user = str_replace("", "", $user);         
        $user = str_replace("", "", $user);        
        $user = str_replace("_", " ", $user);    
        $pass = str_replace("", "", $pass);
        $pass = str_replace("", "", $pass); 
        $pass = str_replace("", "", $pass);         
        $pass = str_replace("", "", $pass); 
        $pass = str_replace("", "", $pass);        
        $pass = str_replace("", "", $pass); 
        $name = str_replace("", "", $name);
        $name = str_replace("", "", $name); 
        $name = str_replace("", "", $name);         
        $name = str_replace("", "", $name); 
        $name = str_replace("", "", $name);         
        $name = str_replace("", "", $name);         
        $city = str_replace("", "", $city);
        $city = str_replace("", "", $city); 
        $city = str_replace("", "", $city);         
        $city = str_replace("", "", $city); 
        $city = str_replace("", "", $city);        
        $city = str_replace("", "", $city);           
              
        $infa = str_replace("", "", $infa);
        $infa = str_replace("", "", $infa); 
        $infa = str_replace("", "", $infa);         
        $infa = str_replace("", "", $infa); 
        $infa = str_replace("", "", $infa);    
        $infa = str_replace("", "", $infa);            
             
        $user = str_replace("$", "$$", $user);     
        $user = str_replace("|", "&#0166;", $user);        
        $pass = str_replace("$", "$$", $pass);     
        $pass = str_replace("|", "&#0166;", $pass);           
        $name = str_replace("$", "$$", $name);     
        $name = str_replace("|", "&#0166;", $name);               
        $day = str_replace("$", "$$", $day);     
        $day = str_replace("|", "&#0166;", $day);   
        $month = str_replace("$", "$$", $month);     
        $month = str_replace("|", "&#0166;", $month);           
        $year = str_replace("$", "$$", $year);     
        $year = str_replace("|", "&#0166;", $year);               
        $city = str_replace("$", "$$", $city);     
        $city = str_replace("|", "&#0166;", $city);           
                  
        $infa = str_replace("$", "$$", $infa);     
        $infa = str_replace("|", "&#0166;", $infa);      
                          
        $name = str_replace("'", "&#8216;", $name);               
        $day = str_replace("'", "&#8216;", $day);   
        $month = str_replace("'", "&#8216;", $month);              
        $year = str_replace("'", "&#8216;", $year);                 
        $city = str_replace("'", "&#8216;", $city);                       
        $infa = str_replace("'", "&#8216;", $infa);                  
           
$open=fopen("bannlist.dat","r");
while(!feof($open)) @$search.=fgets($open,1024);
fclose($open);
$nick = $user;
$nick = str_replace("*", "�1", $nick); 
$nick = str_replace(")", "�2", $nick); 
$nick = str_replace("(", "�3", $nick);
$nick = str_replace("?", "�4", $nick); 
$nick = str_replace("]", "�5", $nick); 
$nick = str_replace("[", "�6", $nick); 
$search = str_replace("*", "�1", $search); 
$search = str_replace(")", "�2", $search); 
$search = str_replace("(", "�3", $search);
$search = str_replace("?", "�4", $search); 
$search = str_replace("]", "�5", $search); 
$search = str_replace("[", "�6", $search);
 
if(eregi(strtolower("#$nick#"),strtolower($search)))
 {
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"error\" title=\"error\" ontimer=\"reg.php\"><timer value=\"10\"/>\n";
echo "<p>\n";
echo "Этот ник забанен!\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
 exit;
 }    
            
            $link = @mysql_connect ($MySQL_Hostname, $MySQL_Username, $MySQL_Password)
                or die ("<wml>
<card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">Can not connect to MySQL</p>
</card>
</wml>");
 
            if (mysql_select_db ($MySQLDatabasename)) {    
            $ruser = rus_to_k($user);       
            $latuser=strtolower($user);
            mysql_query ("select * from mafusers where ruser = '".$ruser."'");
            if (mysql_affected_rows()==0) $est = false; else if ($ruser!=$user) $est = true;
            $result = mysql_query ("Select * from mafusers where latuser = '".$latuser."'");

            if ((mysql_affected_rows() == 0)&&($est==false)) {

                $birth = "$day-$month-$year";
                $now = date("j-m-Y");
                if (strlen($ruser)<13)
                if ($ruser!=$user)$ins_str = "Insert into mafusers set user='".$user."', pass='".$pass."', name='".$name."', sex='".$sex."', birth='".$birth."', city='".$city."', infa='".$infa."', date='".$now."', ruser = '".$ruser."'";     
                else $ins_str = "Insert into mafusers set user='".$user."', pass='".$pass."', name='".$name."', sex='".$sex."', birth='".$birth."', city='".$city."', infa='".$infa."', date='".$now."', latuser = '".$latuser."'";
                if (mysql_query ($ins_str)) {
                    $id=mysql_insert_id();
                    $msg = "Вы успешно зарегистрированы!";
                    $error = False;
                } else {
                    $msg = " ".mysql_error()." ";
                              
                }
            } else {
                $msg = "Указанный вам ник \"$user\" уже занят, выберите другой";
            }
        } else {
            $msg = "error select the database...";
        }
        mysql_close($link);
    }
 if ($error) {
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"error\" title=\"error\" ontimer=\"reg.php\"><timer value=\"15\"/>\n";
echo "<p>\n";
echo "$msg<br/>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
    
    } else {

$ref=rand(10000,1000000); 

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"ok\" title=\"OK\">\n";
echo "<p>\n";
echo "$msg<br/>\n";
echo "Ваш ник:<br/>\n";
echo "$user<br/>\n";
echo "Пароль:<br/>\n";
echo "$pass<br/><br/>\n";
echo "<a href=\"enter.php?id=$id&amp;ps=$pass&amp;ref=$ref\">Играть!</a><br/>\n";
echo "<a href=\"../index.php\">На главную</a>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
}
?>