-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtr_mailer.inc
123 lines (83 loc) · 2.31 KB
/
tr_mailer.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
About: Mailer v2.1
Author: kalixis
*/
#if !defined _samp_included
#error "Please include a_samp or a_npc before tr_mailer"
#endif
#if !defined HTTP_ERROR_MALFORMED_RESPONSE
#error "You must have a_http include in order to use this one."
#endif
#if defined _tr_mailer_included_
#endinput
#endif
#define _tr_mailer_included_
/*
Define const
*/
#if !defined TR_MAILER_URL
#error Please define the URL of the mailer script. Example: #define TR_MAILER_URL "example.com/mailer.php"
#endif
#if !defined TR_EMAIL_ADDRESS
#error Please define E-Mail address to send messages. Example: #define TR_EMAIL_ADDRESS "mymail@example.com"
#endif
#if !defined MAILER_TYPE_NORMAL
#define MAILER_TYPE_NORMAL 0
#endif
#if !defined MAILER_TYPE_HTML
#define MAILER_TYPE_HTML 1
#endif
#if !defined MAX_FUNCTION_NAME
#define MAX_FUNCTION_NAME 32
#endif
#if !defined MAX_PLAYER_EMAIL
#define MAX_PLAYER_EMAIL 64
#endif
#if !defined MAX_MAILER_SIZE
#define MAX_MAILER_SIZE 512
#endif
/*
Define functions
*/
#define Mail_Create:%0(%1) \
forward MC_%0(%1); \
public MC_%0(%1)
#define Mail_Show::%0(%1) \
MC_%0(%1)
#define Mail_Response:%0(%1) \
forward MR_%0(%1); \
public MR_%0(%1)
#define Mail: #
#if !defined isnull
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
/*
Forwards
*/
forward OnPlayerMailerScriptResponse(playerid, response_code, const data[]);
/*
Vars
*/
static
mail_player_function[MAX_PLAYERS][MAX_FUNCTION_NAME + 1 char];
/*
Public functions
*/
stock Mail_Send(playerid, const function[], const to[], const additional_headers[], const subject[], const message[], type = MAILER_TYPE_NORMAL)
{
new
info[MAX_MAILER_SIZE + 1];
mail_player_function[playerid] = !"MR_";
strcat(mail_player_function[playerid], function);
format(info, sizeof(info), "to=%s&additional_headers=%s&subject=%s&message=%s&additional_parameters="TR_EMAIL_ADDRESS"&type=%i", to, additional_headers, subject, message, type);
HTTP(playerid, HTTP_POST, TR_MAILER_URL, info, !"OnPlayerMailerScriptResponse");
}
/*
OnPlayerMailerScriptResponse
*/
public OnPlayerMailerScriptResponse(playerid, response_code, const data[])
{
if (funcidx(mail_player_function[playerid]) != -1)
CallLocalFunction(mail_player_function[playerid], !"iis", playerid, response_code, isnull(data) ? !"\1" : data);
return 1;
}