emailcheck.pwn 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. CMD:togemailcheck(playerid, params[])
  2. {
  3. if(PlayerInfo[playerid][pAdmin] < 1337) return 1;
  4. SendClientMessageEx(playerid, -1, emailcheck ? ("Email checks disabled"):("Email checks enabled"));
  5. emailcheck = !emailcheck;
  6. return 1;
  7. }
  8. InvalidEmailCheck(playerid, email[], task)
  9. {
  10. if(isnull(email))
  11. return ShowPlayerDialogEx(playerid, EMAIL_VALIDATION, DIALOG_STYLE_INPUT, "E-mail Registration", "Please enter a valid e-mail address to associate with your account.", "Submit", "");
  12. szMiscArray[0] = 0;
  13. format(szMiscArray, sizeof(szMiscArray), "%s/email_check.php?t=%d&e=%s", SAMP_WEB, task, email);
  14. HTTP(playerid, HTTP_GET, szMiscArray, "", "OnInvalidEmailCheck");
  15. return 1;
  16. }
  17. forward OnInvalidEmailCheck(playerid, response_code, data[]);
  18. public OnInvalidEmailCheck(playerid, response_code, data[])
  19. {
  20. if(response_code == 200)
  21. {
  22. new result = strval(data);
  23. if(result == 0) // Invalid, Show dialog
  24. ShowPlayerDialogEx(playerid, EMAIL_VALIDATION, DIALOG_STYLE_INPUT, "E-mail Registration - {FF0000}Error", "Please enter a valid e-mail address to associate with your account.", "Submit", "");
  25. if(result == 1) // Valid from login check
  26. if(!GetPVarInt(playerid, "EmailConfirmed"))
  27. {
  28. SendClientMessageEx(playerid, COLOR_LIGHTRED, "Your email has not yet been confirmed. Please take steps to confirm it or go to cp.ng-gaming.net to change your email.");
  29. }
  30. if(result == 2) // Valid from dialog
  31. {
  32. szMiscArray[0] = 0;
  33. GetPVarString(playerid, "pEmail", szMiscArray, 128);
  34. mysql_escape_string(szMiscArray, PlayerInfo[playerid][pEmail]);
  35. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `accounts` SET `Email` = '%s', `EmailConfirmed` = 0 WHERE `id` = %d", PlayerInfo[playerid][pEmail], PlayerInfo[playerid][pId]);
  36. mysql_tquery(MainPipeline, szMiscArray, "OnQueryFinish", "i", SENDDATA_THREAD);
  37. format(szMiscArray, sizeof(szMiscArray), "A confirmation email will be sent to '%s' soon.\n\
  38. This email will need to be confirmed within 7 days or you will be prompted to enter a new one.\n\
  39. Please make an effort to confirm it as it will be used for important changes and notifications in regards to your account.", PlayerInfo[playerid][pEmail]);
  40. ShowPlayerDialogEx(playerid, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX, "Email Confirmation", szMiscArray, "Okay", "");
  41. format(szMiscArray, sizeof(szMiscArray), "%s/mail.php?id=%d", CP_WEB, PlayerInfo[playerid][pId]);
  42. HTTP(playerid, HTTP_HEAD, szMiscArray, "", "");
  43. }
  44. }
  45. return 1;
  46. }
  47. #include <YSI\y_hooks>
  48. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  49. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  50. if(dialogid == EMAIL_VALIDATION)
  51. {
  52. if(!response || isnull(inputtext))
  53. ShowPlayerDialogEx(playerid, EMAIL_VALIDATION, DIALOG_STYLE_INPUT, "E-mail Registration - {FF0000}Error", "Please enter a valid e-mail address to associate with your account.", "Submit", "");
  54. SetPVarString(playerid, "pEmail", inputtext);
  55. InvalidEmailCheck(playerid, inputtext, 2);
  56. }
  57. return 0;
  58. }