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

Размер файла: 18.98Kb
<?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";
}
?>