12 Errors
#6

PHP код:
Dialog:REGISTER_OPTIONS(playeridresponselistiteminputtext[])
{
    if (!
response)
    {
        return 
Dialog_Show(playeridREGISTERDIALOG_STYLE_PASSWORD"Account Registeration... [Step: 1/3]"COL_WHITE "We will take you through "COL_GREEN"3 simple steps "COL_WHITE"to register your account with a backup option in case you forgot your password!\nInsert your password below (Passwords are "COL_TOMATO"Case Sensitive"COL_WHITE")""Continue""Options");
    }
    switch (
listitem)
    {
        case 
0:
        {
            
dialog_LOGIN_OPTIONS(playerid11"\1");
            
            const 
MASK = (-<< (32 36));
            
            new 
ip[18];
            
GetPlayerIp(playeridip18);
            
            new 
string[256];
            
format(stringsizeof(string), "SELECT `name`, `lastlogin_timestamp` FROM `users` WHERE ((`longip` & %i) = %i) LIMIT 1"MASK, (IpToLong(ip) & MASK));
            new 
DBResult:result db_query(dbstring);
            if (
db_num_rows(result) == 0)
            {
                
SendClientMessage(playeridCOLOR_TOMATO"There are no accounts realted to this ip, this seems to be your first join!");
                 
Dialog_Show(playeridREGISTER_OPTIONSDIALOG_STYLE_LIST"Account Options...""Forgot username\nExit to desktop""Select""Back");
                return 
1;
            }
            new list[
25 * (MAX_PLAYER_NAME 32)],
                
name[MAX_PLAYER_NAME],
                
lastlogin_timestamp,
                
i,
                
= ((db_num_rows(result) > 10) ? (10) : (db_num_rows(result)));
            do
            {
                
db_get_field_assoc(result"name"nameMAX_PLAYER_NAME);
                
lastlogin_timestamp db_get_field_assoc_int(result"lastlogin_timestamp");
                
format(list, sizeof(list), "%s"COL_TOMATO"%s "COL_WHITE"|| Last login: %s ago\n", list, nameReturnTimelapse(lastlogin_timestampgettime()));
            }
            while (
db_next_row(result) && j);
            
db_free_result(result);
            
Dialog_Show(playeridFORGOT_USERNAMEDIALOG_STYLE_LIST"Your username history...", list, "Close""");
        }
        case 
1:
        {
            return 
Kick(playerid);
        }
    }
    return 
1;
}
Dialog:FORGOT_PASSWORD(playeridresponselistiteminputtext[])
{
    if (!
response)
    {
        
Kick(playerid);
        return 
1;
    }
    new 
string[256];
    
    new 
hash[64];
    
SHA256_PassHash(inputtextplayerData[playerid][E_PLAYER_DATA_SALT], hashsizeof(hash));
    if (
strcmp(hashplayerData[playerid][E_PLAYER_DATA_SEC_ANSWER]))
    {
        if (++
playerAnswerAttempts[playerid] == MAX_LOGIN_ATTEMPTS)
        {
            new 
lock_timestamp gettime() + (MAX_ACCOUNT_LOCKTIME 60);
            
            new 
ip[18];
            
GetPlayerIp(playeridip18);
            
            
format(stringsizeof(string), "INSERT INTO `temp_blocked_users` VALUES('%s', %i, %i)"iplock_timestampplayerData[playerid][E_PLAYER_DATA_SQLID]);
            
db_query(dbstring);
            
SendClientMessage(playeridCOLOR_TOMATO"Sorry! The account has been temporarily locked on your IP. due to "#MAX_LOGIN_ATTEMPTS"/"#MAX_LOGIN_ATTEMPTS" failed login attempts.");
            
format(stringsizeof(string), "If you forgot your password/username, click on 'Options' in login window next time (you may retry in %s)."ReturnTimelapse(gettime(), lock_timestamp));
            
SendClientMessage(playeridCOLOR_TOMATOstring);
            return 
Kick(playerid);
        }
        
format(stringsizeof(string), COL_WHITE "Answer your security question to reset password.\n\n"COL_TOMATO"%s"playerData[playerid][E_PLAYER_DATA_SEC_QUESTION]);
        
Dialog_Show(playeridFORGOT_PASSWORDDIALOG_STYLE_INPUT"Forgot Password:"string"Next""Cancel");
        
format(stringsizeof(string), "Incorrect answer! Your tries left: %i/"#MAX_LOGIN_ATTEMPTS" attempts.", playerAnswerAttempts[playerid]);
        
SendClientMessage(playeridCOLOR_TOMATOstring);
        return 
1;
    }
    
Dialog_Show(playeridRESET_PASSWORDDIALOG_STYLE_PASSWORD"Reset Password:"COL_WHITE "Insert a new password for your account. Also in case you want to change security question for later, use /changeques.""Confirm""");
    
SendClientMessage(playeridCOLOR_GREEN"Successfully answered your security question! You shall now reset your password.");
    
PlayerPlaySound(playerid10570.00.00.0);
    return 
1;
}
Dialog:RESET_PASSWORD(playeridresponselistiteminputtext[])
{
    if (!
response)
    {
        
Dialog_Show(playeridRESET_PASSWORDDIALOG_STYLE_PASSWORD"Reset Password:"COL_WHITE "Insert a new password for your account. Also in case you want to change security question for later, use /changeques.""Confirm""");
        return 
1;
    }
    new 
string[256];
    if (!(
MIN_PASSWORD_LENGTH <= strlen(inputtext) <= MAX_PASSWORD_LENGTH))
    {
        
Dialog_Show(playeridRESET_PASSWORDDIALOG_STYLE_PASSWORD"Reset Password:"COL_WHITE "Insert a new password for your account. Also in case you want to change security question for later, use /changeques.""Confirm""");
        
SendClientMessage(playeridCOLOR_TOMATO"Invalid password length, must be between "#MIN_PASSWORD_LENGTH" - "#MAX_PASSWORD_LENGTH" characters.");
        
return 1;
    }
    
SHA256_PassHash(inputtextplayerData[playerid][E_PLAYER_DATA_SALT], playerData[playerid][E_PLAYER_DATA_PASSWORD], 64);
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    
    new 
ip[18];
    
GetPlayerIp(playeridip18);
    
format(stringsizeof(string), "UPDATE `users` SET `password` = '%q', `ip` = '%s', `longip` = %i, `lastlogin_timestamp` = %i WHERE `id` = %i"playerData[playerid][E_PLAYER_DATA_PASSWORD], ipIpToLong(ip), gettime(), playerData[playerid][E_PLAYER_DATA_SQLID]);
    
db_query(dbstring);
    
format(stringsizeof(string), "Successfully logged in with new password! Welcome back to our server %s, we hope you enjoy your stay. [Last login: %s ago]"nameReturnTimelapse(playerData[playerid][E_PLAYER_DATA_LASTLOG_TIMESTAMP], gettime()));
    
SendClientMessage(playeridCOLOR_GREENstring);
    
    
PlayerPlaySound(playerid10570.00.00.0);
    
    
SetPVarInt(playerid"LoggedIn"1);
    
CallRemoteFunction("OnPlayerLogin""i"playerid);
    return 
1;

Reply


Messages In This Thread
12 Errors - by T1 - 28.01.2018, 10:40
Re: 12 Errors - by edyun - 28.01.2018, 11:09
Re: 12 Errors - by T1 - 28.01.2018, 11:22
Re: 12 Errors - by edyun - 28.01.2018, 11:35
Re: 12 Errors - by T1 - 28.01.2018, 11:38
Re: 12 Errors - by T1 - 28.01.2018, 11:59

Forum Jump:


Users browsing this thread: 4 Guest(s)