Guest User

Sistema de Registro By mau.tito

a guest
Dec 28th, 2012
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.06 KB | None | 0 0
  1. /******************************************************************************
  2. *
  3. *
  4. * Sistema de registro com codigo de ativacao via email
  5. * Creditos a mau.tito
  6. *
  7. *
  8. *******************************************************************************/
  9. #include a_samp
  10. #include DOF2
  11. #include a_http
  12.  
  13. #define USERS "Contas/%s.ini"
  14.  
  15. #define MAILER_URL \
  16. "geradoresjfs.site90.net/mailer.php"
  17. #define Destinatario \
  18.  
  19. #define DIALOG_REGISTRO 1
  20. #define DIALOG_LOGIN 2
  21. #define DIALOG_EMAIL 3
  22. #define DIALOG_ATIVACAO 4
  23.  
  24. #define Random_Maiuscula() (random(25) + 65)
  25. #define Random_Minuscula() (random(25) + 97)
  26. #define Random_Numero() (random(9) + 48)
  27.  
  28. #define CallBack::%0(%1) forward %0(%1); \
  29. public %0(%1)
  30. new Nome[MAX_PLAYER_NAME];
  31. enum pInfo
  32. {
  33. pLevel,
  34. pGrana,
  35. TotalVezesLogado,
  36. }
  37. new PlayerInfo[MAX_PLAYERS][pInfo];
  38.  
  39. public OnFilterScriptInit()
  40. {
  41. print("\n Sistema de registro by mau tito");
  42. return 1;
  43. }
  44. public OnFilterScriptExit()
  45. {
  46. DOF2::Exit();
  47. return 1;
  48. }
  49.  
  50. public OnPlayerConnect(playerid)
  51. {
  52. new str[30];
  53. GetPlayerName(playerid, Nome, sizeof(Nome));
  54. format(str, sizeof(str), "Contas/%s.ini", Nome);
  55. if(!DOF2_GetBool(str, "ContaAtivado"))
  56. {
  57. ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Bote o codigo de ativao da conta !", "Continuar", "");
  58. }
  59. if(!DOF2_FileExists(str))
  60. {
  61. ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_PASSWORD, "Registro", "Bem vindo ao servidor voce nao possue registro \n bote uma senha para pode se registrar.", "Registrar", "Cancelar");
  62. }
  63. else
  64. {
  65. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "login", "Voce ja possue um registro em nosso servidor \n bote sua senha para poder logar corretamente.", "Logar", "Cancelar");
  66. }
  67. return 1;
  68. }
  69.  
  70. public OnPlayerDisconnect(playerid, reason)return SalvarConta(playerid);
  71. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  72. {
  73. if(dialogid == DIALOG_REGISTRO)
  74. {
  75. if(response)
  76. {
  77. new str[100];
  78. GetPlayerName(playerid, Nome, sizeof(Nome));
  79. format(str, sizeof(str), USERS, Nome);
  80.  
  81. DOF2_CreateFile(str);
  82. DOF2_SetString(str, "Senha", inputtext);
  83.  
  84. SendClientMessage(playerid, -1, "Registrado corretamente preencha os dados pedidos adiante");
  85.  
  86. DOF2_SetString(str, "Email", "SemEmail");
  87. DOF2_SetBool(str, "ContaAtivado", false);
  88.  
  89. new var[90];
  90. format(var, sizeof var, "%c%c%c%c", Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero());
  91. DOF2_SetString(str, "CodeAtivacao", var);
  92.  
  93. ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Bote um email valido para ser mandado codigo de ativaçao da conta!", "Continuar", "");
  94. DOF2_SaveFile();
  95. }
  96. else
  97. {
  98. SendClientMessage(playerid, 0xFF0000AA, "Voce Foi Kickado pelo bot");
  99. Kick(playerid);
  100. }
  101. }
  102. if(dialogid == DIALOG_LOGIN)
  103. {
  104. if(response)
  105. {
  106. if(!strlen(inputtext))
  107. {
  108. GetPlayerName(playerid, Nome, sizeof(Nome));
  109. SendClientMessage(playerid,-1 ,"Senha Incorreta !");
  110. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "login", "Voce ja possue um registro em nosso servidor \n bote sua senha para poder logar corretamente.", "Logar", "Cancelar");
  111. return 0;
  112. }
  113. new str[100];
  114. GetPlayerName(playerid, Nome, sizeof(Nome));
  115. format(str, sizeof(str), USERS, Nome);
  116. if(!strcmp(inputtext,DOF2_GetString(str,"Senha"),false))
  117. {
  118. PlayerInfo[playerid][TotalVezesLogado]++;
  119. CarregarConta(playerid);
  120. }
  121. else
  122. {
  123. SendClientMessage(playerid,0x00FF00AA,"Senha incorreta digite-a novamente");
  124. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "login", "Voce ja possue um registro em nosso servidor \n bote sua senha para poder logar corretamente.", "Logar", "Cancelar");
  125. }
  126. }
  127. else
  128. {
  129. SendClientMessage(playerid, 0xFF0000AA, "Voce Foi Kickado .");
  130. Kick(playerid);
  131. }
  132. }
  133. if(dialogid == DIALOG_EMAIL)
  134. {
  135. if(response)
  136. {
  137. new str[60], tito[320];
  138. GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
  139. format(str, sizeof(str), USERS, Nome);
  140. DOF2_SetString(str,"Email", inputtext);
  141.  
  142. format(tito, sizeof(tito), "Bem vindo ao servidor \n\n Acabamos de detectar que voce acaba de registrar em nosso servido\
  143. \n Seja bem vindo !\n Para voce poder logar voce tem que ativar sua conta para poder jogar coretamente!\n\n\n\
  144. Codigo de ativaçao: %0.4s", DOF2_GetString(str, "CodeAtivacao"));
  145.  
  146. EnviarEmail(DOF2_GetString(str, "Email"),Destinatario, "Ativaçao da Conta Sa-mp", "TT Ativacao da conta", tito);
  147. ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Bote o codigo de ativao da conta !", "Continuar", "");
  148. DOF2_SaveFile();
  149. }
  150. }
  151. if(dialogid == DIALOG_ATIVACAO)
  152. {
  153. if(response)
  154. {
  155. if(!strlen(inputtext))
  156. {
  157. ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Este nao e seu codigo de ativao!\n Bote o codigo de ativacao correto .", "Continuar", "");
  158. return 0;
  159. }
  160. new str[60];
  161. GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
  162. format(str, sizeof(str), USERS, Nome ) ;
  163. if(!strcmp(inputtext, DOF2_GetString(str,"CodeAtivacao"),false))
  164. {
  165. SendClientMessage(playerid, -1, "Sua conta foi ativada(o) com o codigo de ativaçao mandado em seu e-mail .");
  166. DOF2_SetBool(str, "ContaAtivado", true);
  167. new tito[290];
  168. format(tito, sizeof(tito), "Bem Vindo ao Servidor \n \
  169. Personagem : %s \n Level: %i\n Grana: %i \n\n \
  170. As suas informaçoes forao citados acima , obrigado por registrar em nosso servidor de sa-mp !\n\n \n\
  171. Att mau.tito", Nome, GetPlayerScore(playerid), GetPlayerMoney(playerid));
  172.  
  173. EnviarEmail(DOF2_GetString(str, "Email"),Destinatario, "Ativaçao da Conta Sa-mp", "TT Ativacao da conta", tito);
  174. DOF2_SaveFile();
  175. }
  176. else
  177. {
  178. ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Este nao e seu codigo de ativao!\n Bote o codigo de ativacao correto .", "Continuar", "");
  179. }
  180. }
  181. }
  182. return 1;
  183. }
  184.  
  185. CallBack::SalvarConta(playerid)
  186. {
  187. new file[40];
  188. GetPlayerName(playerid, Nome, sizeof(Nome));
  189. format(file, sizeof(file), USERS, Nome);
  190. DOF2_SetInt(file, "Level", GetPlayerMoney(playerid));
  191. DOF2_SetInt(file, "Dinheiro", GetPlayerScore(playerid));
  192. DOF2_SetInt(file, "VezesLogou", PlayerInfo[playerid][TotalVezesLogado]);
  193. DOF2_SaveFile();
  194. return 1;
  195. }
  196. CallBack::CarregarConta(playerid)
  197. {
  198. new file[40];
  199. GetPlayerName(playerid, Nome, sizeof(Nome));
  200. format(file, sizeof(file), USERS, Nome);
  201.  
  202. GivePlayerMoney(playerid, DOF2_GetInt(file, "Level"));
  203. SetPlayerScore(playerid, DOF2_GetInt(file, "Dinheiro"));
  204. PlayerInfo[playerid][TotalVezesLogado] = DOF2_GetInt(file, "VezesLogou");
  205. DOF2_SaveFile();
  206. return 1;
  207. }
  208. /* Include mailer By Sliceo */
  209.  
  210. #if ( !defined MAILER_MAX_MAIL_SIZE )
  211. #define MAILER_MAX_MAIL_SIZE (1024)
  212. #endif
  213.  
  214. #if ( !defined MAILER_URL )
  215. #error Please define MAILER_URL before including the mailer include.
  216. #endif
  217.  
  218. stock EnviarEmail( const szReceiver[ ], const szSenderMail[ ], const szSenderName[ ], const szSubject[ ], const szMessage[ ] )
  219. {
  220. new
  221. szBuffer[ MAILER_MAX_MAIL_SIZE ] = "t=",
  222. iPos = strlen( szBuffer ),
  223. iLength = strlen( szReceiver )
  224. ;
  225.  
  226. memcpy( szBuffer, szReceiver, iPos * 4, ( iLength + 1 ) * 4 );
  227.  
  228. StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
  229.  
  230. strcat( szBuffer, "&f=" );
  231.  
  232. iPos = strlen( szBuffer );
  233. iLength = strlen( szSenderName );
  234.  
  235. memcpy( szBuffer, szSenderName, iPos * 4, ( iLength + 1 ) * 4 );
  236.  
  237. StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
  238.  
  239. strcat( szBuffer, "&n=" );
  240.  
  241. iPos = strlen( szBuffer );
  242. iLength = strlen( szSenderMail );
  243.  
  244. memcpy( szBuffer, szSenderMail, iPos * 4, ( iLength + 1 ) * 4 );
  245.  
  246. StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
  247.  
  248. strcat( szBuffer, "&s=" );
  249.  
  250. iPos = strlen( szBuffer );
  251. iLength = strlen( szSubject );
  252.  
  253. memcpy( szBuffer, szSubject, iPos * 4, ( iLength + 1 ) * 4 );
  254.  
  255. StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
  256.  
  257. strcat( szBuffer, "&m=" );
  258.  
  259. iPos = strlen( szBuffer );
  260. iLength = strlen( szMessage );
  261.  
  262. memcpy( szBuffer, szMessage, iPos * 4, ( iLength + 1 ) * 4 );
  263.  
  264. StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
  265.  
  266. HTTP( 0xD00D, HTTP_POST, MAILER_URL, szBuffer, "OnMailScriptResponse" );
  267. }
  268.  
  269. forward OnMailScriptResponse( iIndex, iResponseCode, const szData[ ] );
  270. public OnMailScriptResponse( iIndex, iResponseCode, const szData[ ] )
  271. {
  272. if ( szData[ 0 ] )
  273. printf( "Mailer script says: %s", szData );
  274. }
  275.  
  276. stock StringURLEncode( szString[ ], iSize = sizeof( szString ) )
  277. {
  278. for ( new i = 0, l = strlen( szString ); i < l; i++ )
  279. {
  280. switch ( szString[ i ] )
  281. {
  282. case '!', '(', ')', '\'', '*',
  283. '0' .. '9',
  284. 'A' .. 'Z',
  285. 'a' .. 'z':
  286. {
  287. continue;
  288. }
  289.  
  290. case ' ':
  291. {
  292. szString[ i ] = '+';
  293.  
  294. continue;
  295. }
  296. }
  297.  
  298. new
  299. s_szHex[ 8 ]
  300. ;
  301.  
  302. if ( i + 3 >= iSize )
  303. {
  304. szString[ i ] = EOS;
  305.  
  306. break;
  307. }
  308.  
  309. if ( l + 3 >= iSize )
  310. szString[ iSize - 3 ] = EOS;
  311.  
  312. format( s_szHex, sizeof( s_szHex ), "%02h", szString[ i ] );
  313.  
  314. szString[ i ] = '%';
  315.  
  316. strins( szString, s_szHex, i + 1, iSize );
  317.  
  318. l += 2;
  319. i += 2;
  320.  
  321. if ( l > iSize - 1 )
  322. l = iSize - 1;
  323. }
  324. }
Advertisement
Add Comment
Please, Sign In to add comment