Register System
#1

hi guys i have problem in the Register Systйm
The problem is i can register with No password+i can login with no password too

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{  
if(
dialogid == DIALOGID_REGISTER)
    {
        if(
response)
        {
            if(!
strlen(inputtext))
            {
                 new 
string[256];
                
format(string,256,"{FFFFFF}Welcome to the {0049FF}'%s'\n\n{FFFFFF}Account {0049FF}'%s' {FFFFFF}is not registred!\n\n{FFFFFF}Enter the {F3FF02}password {FFFFFF}to Register your Account:",GetServerHostName(),GetName(playerid));
                
ShowPlayerDialog(playerid,DIALOGID_REGISTER,DIALOG_STYLE_INPUT,"Register",string,"Register","Quit");
            }
            else
            {
                new 
pfile[256];
                 new 
strdate[20], year,month,day,ip[128];
                
getdate(yearmonthday);
                new 
buf[256];
                
WP_Hash(bufsizeof(buf), inputtext);
                
format(strdate,sizeof(strdate),"%d/%d/%d",day,month,year);
                 
format(pfile,sizeof(pfile),PLAYER_FILE,GetName(playerid));
                 
GetPlayerIp(playerid,ip,sizeof(ip));
                 new 
INI:file INI_Open(pfile);
                  
INI_WriteString(file,"Password",buf);
                  
INI_WriteString(file,"RegisteredDate",strdate);
                  
INI_WriteString(file,"Ip",ip);
                  
INI_WriteInt(file,"Registered",1);
                  
INI_WriteInt(file,"Banned",0);
                  
INI_WriteInt(file,"Kills",0);
                  
INI_WriteInt(file,"Level",0);
                  
INI_WriteInt(file,"VipLevel",0);
                  
INI_WriteInt(file,"Warnings",0);
                  
INI_WriteInt(file,"LastOn",0);
                  
INI_WriteInt(file,"Hours",0);
                  
INI_WriteInt(file,"Minutes",0);
                  
INI_WriteInt(file,"Seconds",0);
                  
INI_WriteInt(file,"Deaths",0);
                  
INI_WriteInt(file,"Score",0);
                  
INI_WriteInt(file,"Cash",0);
                  
INI_Close(file);
                  
Account[playerid][Registered] = 1;
                  
Account[playerid][Logged] = true;
                  
Account[playerid][Muted] = 0;
                  
SendClientMessage(playerid,COLOR_LBLUE,"*-* You are now registered and automatically logged in *-*");
            }
        }
        else if(!
response)
        {
            
Kick(playerid);
        }
        return 
1;
    }
    if(
dialogid == DIALOGID_LOGIN)
    {
        if(
response)
        {
            if(
isnull(inputtext))
            {
                
SendClientMessage(playerid0xFFFFFF00"The password cannot be empty.");
                
SetTimerEx("KickEx"1000false"d"playerid);
                return 
1;
            }
            new 
file[128];
            
format(file,128,PLAYER_FILE,GetName(playerid));
            
INI_ParseFile(file"GetPassword", .bExtra true, .extra playerid);
            new 
buf[256];
            
WP_Hash(bufsizeof(buf), inputtext);
            if(
strcmp(Account[playerid][Password], buffalse) == 0)
            {
                
LoginPlayer(playerid);
            }
            else
            {
                
Account[playerid][FailLogin]++;
                new 
string[256];
                
format(stringsizeof(string), "{0049FF}'%s'\n\n{FFFFFF}Welcome back {0049FF}%s\n\n{FFFFFF}Before playing you must login\n\nEnter your {F3FF02}password {FFFFFF}below and click login\n\n{F81414}Wrong password Attempt %d/%d",GetServerHostName(),GetName(playerid),Account[playerid][FailLogin],MAX_FAIL_LOGINS);
                
ShowPlayerDialog(playerid,DIALOGID_LOGIN,DIALOG_STYLE_INPUT,"Login Error",string,"Login","Cancel");
                if(
Account[playerid][FailLogin] == MAX_FAIL_LOGINS)
                {
                    
format(stringsizeof(string), "Player %s has been automatically kicked (Reason: Many attempts Incorrect Passwords)"GetName(playerid));
                    
SendClientMessageToAll(Redstring);
                    
KickPlayer(playerid,"Many attempts Incorrect Passwords");
                }
            }
        }
        else if(!
response)
        {
            
Kick(playerid);
        } 
OnPlayerconnect:
PHP код:
    if(fexist(file))
    {
        if(!
strcmp(pIPAccount[playerid][Ip_],true))
        {
            if(
ServerInfo[AutoLogin] == 1)
            {
                
LoginPlayer(playerid);
                
Account[playerid][Registered] = 1;
                
Account[playerid][Logged] = false;
                
Account[playerid][Muted] = 0;
            }
            else
            {
                new 
string[256];
                
format(string,256,"{FFFFFF}Welcome to the {0049FF}'%s'\n\n{FFFFFF}Account {0049FF}'%s' {FFFFFF}is not registred!\n\n{FFFFFF}Enter the {F3FF02}password {FFFFFF}to Register your Account:",GetServerHostName(),GetName(playerid));
                
ShowPlayerDialog(playerid,DIALOGID_REGISTER,DIALOG_STYLE_INPUT,"Register",string,"Register","Quit");
            }
            new 
ip[128];
            
GetPlayerIp(playerid,ip,sizeof(ip));
            
dini_Set("ZeroAdmin/Config/Zero_Info.ini",GetName(playerid),ip);
         }
         else
         {
            new 
string[256];
            
format(stringsizeof(string), "{0049FF}'%s'\n\n{FFFFFF}Welcome back {0049FF}%s\n\n{FFFFFF}Before playing you must login\n\nEnter your {F3FF02}password {FFFFFF}below and click login",GetServerHostName(),GetName(playerid));
            
ShowPlayerDialog(playerid,DIALOGID_LOGIN,DIALOG_STYLE_INPUT,"Login",string,"Login","Cancel");
            
format(stringsizeof(string), "Nick \"%s\" registered.Please enter your password to login",GetName(playerid));
            
SendClientMessageToAll(Redstring);
         }
        return 
1;
    }
    if(!
fexist(file))
    {
        new 
ip[128];
        
GetPlayerIp(playerid,ip,sizeof(ip));
        
dini_Set("ZeroAdmin/Config/Zero_Info.ini",GetName(playerid),ip);
        
#if MustRegister == true
        
SendClientMessage(playerid,COLOR_ERROR,"* Your account is not registered. To save stats you need register!");
        new 
string[256];
        
format(string,256,"{FFFFFF}Welcome to the {0049FF}'%s'\n\n{FFFFFF}Account {0049FF}'%s' {FFFFFF}is not registred!\n\n{FFFFFF}Enter the {F3FF02}password {FFFFFF}to Register your Account:",GetServerHostName(),GetName(playerid));
        
ShowPlayerDialog(playerid,DIALOGID_REGISTER,DIALOG_STYLE_INPUT,"Register",string,"Register","Quit");
        
Account[playerid][Registered] = 0;
        
Account[playerid][Logged] = false;
        
#else
        
SendClientMessage(playerid,COLOR_ERROR,"* Your account is not registered. To save stats you need register! - Use /Register");
          
#endif
        //
        
return 1;
    } 
PlayerFile:
Код:
Banned = 0
Kills = 1
Deaths = 1
Score = 3
Cash = 161100
Hours = 0
Minutes = 57
Seconds = 58
LastOn = 29.3.2015
Level = 5
VipLevel = 3
TempVip = 1
Reply
#2

This can be signs that your login system isn't really checking passwords.

Although I suggest using something like this:

pawn Код:
if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, Dialog_Register, DIALOG_STYLE_INPUT, "Register", "Welcome to [Enter Server Name Here]\nYour password must be longer than 6 Characters!", "Register", "Quit");
Reply
#3

As said above, you need to check password lengths. There are also other checks you might want to include such as the type of characters the player is entering.

To be honest, if you're having problems with a registration system, it'd probably be a better idea to download one made by a more experienced coder, then change the design to match your server's design. It's a lot more secure and reliable that way!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)