Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Secure My Account - Beta 0.01
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <mysql>
- #define GOLD_COL "{E5C100}"
- #define function%0(%1) forward%0(%1);public%0(%1)
- // db
- #define SQL_HOST ""
- #define SQL_USER ""
- #define SQL_DB ""
- #define SQL_PASS ""
- public OnFilterScriptInit()
- {
- mysql_init();
- mysql_connect(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- CMD:securemyaccount(playerid,params[])
- {
- Call_SecureMyAccount(playerid);
- return 1;
- }
- forward Call_SecureMyAccount(playerid);
- public Call_SecureMyAccount(playerid)
- {
- new query[400];
- new string[128];
- new random_code[6];
- Random_Code(random_code, 6);
- format(query, sizeof(query),"SELECT * FROM `codes` WHERE `code` = '%s' LIMIT 1", random_code);
- mysql_query(query);
- mysql_store_result();
- new rows = mysql_num_rows();
- if(rows == 1)
- {
- Call_SecureMyAccount(playerid);
- return 1;
- }
- new uquery[200];
- format(uquery, sizeof(uquery),"DELETE FROM `codes` WHERE user='%s'", PlayerName(playerid));
- mysql_query(uquery);
- new bquery[200];
- new string_1[64];
- new Year, Month, Day;
- getdate(Year, Month, Day);
- format(string_1, sizeof(string_1), "%02d/%02d/%d", Day, Month, Year);
- format(string,sizeof(string),""GOLD_COL"Server:{FFFFFF} Your new account security access code is: {AFAFAF}%s{FFFFFF}!",random_code);
- SendClientMessage(playerid,0xFFFFFFAA,string);
- SendClientMessage(playerid,0xFFFFFFAA,""GOLD_COL"Server:{FFFFFF} Please do NOT lose this code or you will not be able to log in.");
- SendClientMessage(playerid,0xFFFFFFAA,""GOLD_COL"Server:{FFFFFF} Please screen shot this code in case you won't remember.");
- format(bquery, sizeof(bquery),"INSERT INTO admincodes(admin, code, date_generated) VALUES('%s', '%s', '%s')", PlayerName(playerid),random_code, string_1);
- mysql_query(bquery);
- mysql_free_result();
- EscapeString();
- return 1;
- }
- PlayerName(playerid)
- {
- new CName[24];
- GetPlayerName(playerid, CName, 24);
- return CName;
- }
- Random_Code(strDest[], strLen = 6)
- {
- while(strLen--)
- strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'a')) : (random(10) + '0');
- }
- EscapeString(const string[])
- {
- new escape[128];
- mysql_real_escape_string(string, escape);
- return escape;
- }
- // USAGE EXAMPLE//
- /*
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_REGISTER:
- {
- if (response == 0)
- {
- SendClientMessage(playerid,0xFFFFFFAA,""GOLD_COL"Server:{FFFFFF} You must register before playing on this server.");
- SetTimerEx("KickPlayer",700,false,"i",playerid);
- return 1;
- }
- if (response == 1)
- {
- if (strlen(inputtext)==0)
- {
- SendClientMessage(playerid,0xFFFFFFAA,""GOLD_COL"Server:{FFFFFF} Please enter a password in the box below.");
- ShowRegisterScreen(playerid);
- return 1;
- }
- if(strlen(inputtext) < 4 || strlen(inputtext) > 34)
- {
- SendClientMessage(playerid,0xFFFFFFAA,""GOLD_COL"Server:{FFFFFF} Please enter a password between 4-34 characters in the box.");
- ShowRegisterScreen(playerid);
- return 1;
- }
- new stringdate[200];
- new Year, Month, Day;
- getdate(Year, Month, Day);
- format(stringdate, sizeof(stringdate), "%02d/%02d/%d",Day, Month, Year);
- SendClientMessage(playerid,0xFFFFFFAA,""GOLD_COL"Server: {FFFFFF}Please wait while the system creates and stores your account into the Database!");
- SetTimerEx("ShowLoginScreen_Reg",1000,false,"i",playerid);
- new pIp[16];
- PlayerPlaySound(playerid,5205,0.0,0.0,0.0);
- GetPlayerIp(playerid, pIp, sizeof(pIp));
- mysql_real_escape_string(inputtext, HashPass);
- WP_Hash(HashPass, sizeof(HashPass), inputtext);
- format(Query, sizeof(Query), "INSERT INTO `zaplayerinfo` (`user`, `password`, `xp`, `kills`, `deaths`, `rank`, `adminlevel`, `viplevel`, `adminduty`, `hour`, `min`, `sec`, `mapsplayed`, `coins`, `banned`, `cleader`, `cmember`, `bans`, `reg_IP`, `regdate`) VALUES\
- ('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', '%s')", escpname(playerid), HashPass, pIp, stringdate);
- mysql_query(Query);
- mysql_store_result();
- return true;
- }
- return 1;
- }
- case DIALOG_LOGIN:
- {
- if (response == 0)
- {
- SendClientMessage(playerid,0xFFFFFFAA,""ADMIN_COL"OutBreak:{FFFFFF} You must login before playing on this server.");
- SetTimerEx("KickPlayer",700,false,"i",playerid);
- return 1;
- }
- if (response == 1)
- {
- mysql_real_escape_string(inputtext, HashPass);
- WP_Hash(HashPass, sizeof(HashPass), inputtext);
- if(!strcmp(HashPass, MyPassword))
- {
- format(Query, sizeof(Query), "SELECT * FROM `zaplayerinfo` WHERE `user` = '%s' AND `password` = '%s'", escpname(playerid), HashPass);
- mysql_query(Query);
- mysql_store_result();
- if(mysql_num_rows() > 0)
- {
- format(Query, sizeof(Query), "SELECT * FROM `codes` WHERE `user` = '%s' LIMIT 1", escpname(playerid));
- mysql_query(Query);
- mysql_store_result();
- if(mysql_num_rows() > 0)
- {
- ShowSecurityScreen(playerid);
- return 1;
- }
- MySQL_Login(playerid);
- return 1;
- }
- }
- ShowLoginScreen(playerid);
- return 1;
- }
- return 1;
- }
- case DIALOG_UserSECURITY:
- {
- if (response == 0)
- {
- SendClientMessage(playerid,0xFFFFFFAA,""ADMIN_COL"OutBreak:{FFFFFF} You must enter your security access code before playing on this server.");
- SetTimerEx("KickPlayer",700,false,"i",playerid);
- return 1;
- }
- if (response == 1)
- {
- format(Query, sizeof(Query), "SELECT * FROM `codes` WHERE `user` = '%s'", PlayerName(playerid));
- mysql_query(Query);
- mysql_store_result();
- if(mysql_num_rows() <= 0)
- {
- Kick(playerid);
- }
- new random_code_string[24];
- mysql_real_escape_string(inputtext,random_code_string);
- format(Query, sizeof(Query), "SELECT * FROM `codes` WHERE `user` = '%s' AND `code` = '%s'", PlayerName(playerid),random_code_string);
- mysql_query(Query);
- mysql_store_result();
- //if(!strcmp(code_string, random_code_entry))
- //{
- // if(mysql_num_rows() > 0)
- // {
- if(mysql_num_rows() == 1)
- {
- MySQL_Login(playerid);
- return 1;
- }
- // }
- //}
- ShowSecurityScreen(playerid);
- return 1;
- }
- return 1;
- }
- ShowSecurityScreen(playerid)
- {
- new string[184];
- format(string,sizeof(string),""ADMIN_COL"OutBreak:{FFFFFF} Security Check!");
- ShowPlayerDialog(playerid, DIALOG_ADMINSECURITY, DIALOG_STYLE_PASSWORD,string,"Please enter your security 6 digit access code in order to login.","Enter","Quit");
- return 1;
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement