29.03.2015, 21:28
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
OnPlayerconnect:
PlayerFile:
The problem is i can register with No password+i can login with no password too
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
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(year, month, day);
new buf[256];
WP_Hash(buf, sizeof(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(playerid, 0xFFFFFF00, "The password cannot be empty.");
SetTimerEx("KickEx", 1000, false, "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(buf, sizeof(buf), inputtext);
if(strcmp(Account[playerid][Password], buf, false) == 0)
{
LoginPlayer(playerid);
}
else
{
Account[playerid][FailLogin]++;
new string[256];
format(string, sizeof(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(string, sizeof(string), "Player %s has been automatically kicked (Reason: Many attempts Incorrect Passwords)", GetName(playerid));
SendClientMessageToAll(Red, string);
KickPlayer(playerid,"Many attempts Incorrect Passwords");
}
}
}
else if(!response)
{
Kick(playerid);
}
PHP код:
if(fexist(file))
{
if(!strcmp(pIP, Account[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(string, sizeof(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(string, sizeof(string), "Nick \"%s\" registered.Please enter your password to login",GetName(playerid));
SendClientMessageToAll(Red, string);
}
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;
}
Код:
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