Login Password..
#1

I shut off my server after I learned that anyone can access anyone's account. Say if I type into the dialog: "Pogfdgshnih" it'll log me in. (No, that is not my password). Can anyone help?



pawn Код:
enum gPInfo
{
Password[256]
};
pawn Код:
public OnPlayerConnect(playerid)
{
        new name[MAX_PLAYER_NAME], file[128], string[150];
    GetPlayerName(playerid,name,sizeof(name));
    Login(playerid,name);
return 1;
}
pawn Код:
stock Login(playerid,name[])
{
    new file[64],n[MAX_PLAYER_NAME];
    GetPlayerName(playerid,n,sizeof(n));
    format(file,128,SERVER_USER_FILE,n);
    INI_ParseFile(file,"Stats", .bExtra = true, .extra = playerid);
    return 1;
}
pawn Код:
forward Stats(playerid, name[], value[]);
public Stats(playerid, name[], value[])
{
    if(!strcmp(name,"Password"))
    {
        format(PInfo[playerid][Password],256,"%s",value);
    }
   
    return 1;
}
My login dialog:

pawn Код:
else if(dialogid == 2)
    {
        new name[MAX_PLAYER_NAME],file[128],string[70],buf[129];
        GetPlayerName(playerid,name,sizeof(name));
        format(file,sizeof(file),SERVER_USER_FILE,name);
        if(!response) return Kick(playerid);
        WP_Hash(buf,sizeof(buf),inputtext);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
        if(strcmp(buf,PInfo[playerid][Password],true))
        {
            PInfo[playerid][Logged] = 1;
            PInfo[playerid][Regged] = 1;
            if(PInfo[playerid][Level] == 0) SendClientMessage(playerid,limegreen,"You have logged in as a Normal Player");
            if(PInfo[playerid][Level] == 1) SendClientMessage(playerid,limegreen,"You have logged in as a Level 1 Admin");
            if(PInfo[playerid][Level] == 2) SendClientMessage(playerid,limegreen,"You have logged in as a Level 2 Admin");
            if(PInfo[playerid][Level] == 3) SendClientMessage(playerid,limegreen,"You have logged in as a Level 3 Admin");
            if(PInfo[playerid][Level] == 4) SendClientMessage(playerid,limegreen,"You have logged in as a Level 4 Admin");
            if(PInfo[playerid][Level] == 5) SendClientMessage(playerid,limegreen,"You have logged in as a Level 5 Admin");
            if(PInfo[playerid][Level] == 6) SendClientMessage(playerid,limegreen,"You have logged in as a Level 6 Admin (Scripter)");
            if(PInfo[playerid][Level] == 7) SendClientMessage(playerid,limegreen,"You have logged in as a Level 7 Admin (Owner)");
            format(string,sizeof(string),"[Donor Level %d]",PInfo[playerid][VIP]);
            SendClientMessage(playerid,limegreen,string);
        }
        else
        {
            SendClientMessage(playerid, RED, "Incorrect Password!");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
        }
    }
Sorry for the indentions, blame the forums.
Reply
#2

Try this:
pawn Код:
if(strcmp(buf,PInfo[playerid][Password],true)== 0)
Not sure that it will work but I think you need an == 0.
Reply
#3

you auto loggining in the player when he connects from what is see on OnPlayerConnect.... Your supposed to put :
Код:
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
On OnPlayerConnect.

next on dialog response, open his file and store the password in a tmp variable. compare the input text and the cariable and it is the same callLoginPlayer function you have
Reply
#4

Quote:
Originally Posted by THE_KNOWN
Посмотреть сообщение
you auto loggining in the player when he connects from what is see on OnPlayerConnect.... Your supposed to put :
Код:
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
On OnPlayerConnect.

next on dialog response, open his file and store the password in a tmp variable. compare the input text and the cariable and it is the same callLoginPlayer function you have
No, not auto-login.

Here is my full callback:
pawn Код:
public OnPlayerConnect(playerid)
{
    ResetPlayerWeapons(playerid);
    TextDrawShowForPlayer(playerid,Website);
    PInfo[playerid][Spec] = 0;
    PInfo[playerid][Duty] = 0;
    PInfo[playerid][Dm] = 0;
    PInfo[playerid][Kills] = 0;
    PInfo[playerid][Deaths] = 0;
    new name[MAX_PLAYER_NAME], file[128], string[150];
    GetPlayerName(playerid,name,sizeof(name));
    Login(playerid,name);
    format(file,sizeof(file), SERVER_USER_FILE,name);
    format(string,sizeof(string),"[JOIN] %s has joined the server",name);
    SendClientMessageToAll(ORANGE,string);
    if(fexist(file))
    {
        SendClientMessage(playerid,limegreen,"You are registered, please login");
        PInfo[playerid][Regged] = 1;
        PInfo[playerid][Logged] = 0;
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
    }
    if(!fexist(file))
    {
        SendClientMessage(playerid,limegreen,"You are not registered, please register");
        PInfo[playerid][Regged] = 0;
        PInfo[playerid][Logged] = 0;
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You are not registered", "Type your password below", "Register", "Quit");
    }
    foreach(Player,i)
    {
        if(i == sizeof(RainbowGradient)) RainbowError = 0;
        if(IsPlayerConnected(i))
        {
            SetPlayerColor(i, RainbowGradient[i + RainbowError]);
        }
        else RainbowError -= 1;
    }
    return 1;
}
@austin, nope. When i used that like a week ago it would constantly say "Incorrect Password" even when the correct password was implemented.
Reply
#5

1st question: Why are you getting the players name when your already specifying in the Login function?

2nd question: Where are you specifying the params for the Stats function (the name and stuff)
Reply
#6

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 0)       //when it was the register dialog
    {
        if(!response)           //when the player clicked on "Quit"
        {
            Kick(playerid);
        }
        else if(response)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Registration", "You are new on this server!\nPlease enter your password below to regiser\n an account.", "Continue", "Quit");
                return 1;
            }
            new name[MAX_PLAYER_NAME], dat[200], ip[40];
            GetPlayerName(playerid, name, sizeof(name));
            GetPlayerIp(playerid, ip, sizeof(ip));
            format(dat, sizeof(dat), "MyData/User/%s.txt", name);
            new File:fi = fopen(dat, io_write);         //this creates the new file
            fclose(fi);
            new day, year, month, date[10];
            getdate(year, month, day);
            format(date, sizeof(date), "%d/%d/%d", day, month, year);
            dini_Set(dat, "Name", name);
            dini_Set(dat, "IP", ip);
            dini_Set(dat, "Password", inputtext);
            dini_Set(dat, "Registered", date);
            dini_IntSet(dat, "Money", 0);
            dini_IntSet(dat, "Score", 0);
            dini_IntSet(dat, "Level", 0);
            SetPlayerScore(playerid, 0);
            SetPlayerMoney(playerid, 0);
            PlayerData[playerid][Level] = 0;
            new string[150];
            format(string, sizeof(string), "*%s registered and joined the server!", name);
            SendClientMessageToAll(COLOR_GREEN, string);
            SetPVarInt(playerid, "Logged", 1);
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by jaami
Посмотреть сообщение
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 0)       //when it was the register dialog
    {
        if(!response)           //when the player clicked on "Quit"
        {
            Kick(playerid);
        }
        else if(response)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Registration", "You are new on this server!\nPlease enter your password below to regiser\n an account.", "Continue", "Quit");
                return 1;
            }
            new name[MAX_PLAYER_NAME], dat[200], ip[40];
            GetPlayerName(playerid, name, sizeof(name));
            GetPlayerIp(playerid, ip, sizeof(ip));
            format(dat, sizeof(dat), "MyData/User/%s.txt", name);
            new File:fi = fopen(dat, io_write);         //this creates the new file
            fclose(fi);
            new day, year, month, date[10];
            getdate(year, month, day);
            format(date, sizeof(date), "%d/%d/%d", day, month, year);
            dini_Set(dat, "Name", name);
            dini_Set(dat, "IP", ip);
            dini_Set(dat, "Password", inputtext);
            dini_Set(dat, "Registered", date);
            dini_IntSet(dat, "Money", 0);
            dini_IntSet(dat, "Score", 0);
            dini_IntSet(dat, "Level", 0);
            SetPlayerScore(playerid, 0);
            SetPlayerMoney(playerid, 0);
            PlayerData[playerid][Level] = 0;
            new string[150];
            format(string, sizeof(string), "*%s registered and joined the server!", name);
            SendClientMessageToAll(COLOR_GREEN, string);
            SetPVarInt(playerid, "Logged", 1);
        }
    }
    return 1;
}
I'm using Y_INI not dini.. and THE_KNOWN, can you explain a bit more? i didnt understand that..
Reply
#8

pawn Код:
forward Stats(playerid, name[], value[]);
public Stats(playerid, name[], value[])
{
    if(!strcmp(name, "Level", false) ) {
        PInfo[playerid][Level] = strval(value);
    }
    if(!strcmp(name,"Password")) SetPVarString(playerid,"pass",value);
   
    if(!strcmp(name, "VIP", false) ) {
        PInfo[playerid][VIP] = strval(value);
    }
    if(!strcmp(name, "Cash", false) ) {
        PInfo[playerid][Cash] = strval(value);
    }
    if(!strcmp(name, "Score", false) ) {
        PInfo[playerid][Score] = strval(value);
    }
    if(!strcmp(name, "Kills", false) ) {
        PInfo[playerid][Kills] = strval(value);
    }
    if(!strcmp(name, "Deaths", false) ) {
        PInfo[playerid][Deaths] = strval(value);
    }
    if(!strcmp(name, "Horn", false) ) {
        PInfo[playerid][Horn] = strval(value);
    }
    return 1;
}
pawn Код:
else if(dialogid == 2)
    {
        new name[MAX_PLAYER_NAME],file[128],string[70],buf[129];
        GetPlayerName(playerid,name,sizeof(name));
        format(file,sizeof(file),SERVER_USER_FILE,name);
        if(!response) return Kick(playerid);
        WP_Hash(buf,sizeof(buf),inputtext);
        GetPVarString(playerid, "pass", pass, sizeof(pass));
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
        if(strcmp(buf,pass,true))
        {
            PInfo[playerid][Logged] = 1;
            PInfo[playerid][Regged] = 1;
            if(PInfo[playerid][Level] == 0) SendClientMessage(playerid,limegreen,"You have logged in as a Normal Player");
            if(PInfo[playerid][Level] == 1) SendClientMessage(playerid,limegreen,"You have logged in as a Level 1 Admin");
            if(PInfo[playerid][Level] == 2) SendClientMessage(playerid,limegreen,"You have logged in as a Level 2 Admin");
            if(PInfo[playerid][Level] == 3) SendClientMessage(playerid,limegreen,"You have logged in as a Level 3 Admin");
            if(PInfo[playerid][Level] == 4) SendClientMessage(playerid,limegreen,"You have logged in as a Level 4 Admin");
            if(PInfo[playerid][Level] == 5) SendClientMessage(playerid,limegreen,"You have logged in as a Level 5 Admin");
            if(PInfo[playerid][Level] == 6) SendClientMessage(playerid,limegreen,"You have logged in as a Level 6 Admin (Scripter)");
            if(PInfo[playerid][Level] == 7) SendClientMessage(playerid,limegreen,"You have logged in as a Level 7 Admin (Owner)");
            format(string,sizeof(string),"[Donor Level %d]",PInfo[playerid][VIP]);
            SendClientMessage(playerid,limegreen,string);
        }
        else
        {
            SendClientMessage(playerid, RED, "Incorrect Password!");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
        }
    }
I use a PVar now, but I dont really know how to use Pvars, as this is my first time. It still lets me login with any password.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)