]>
Commit | Line | Data |
---|---|---|
b263aa79 | 1 | /* |
2 | * chanservdb_updates.c: | |
3 | * Handle all the update requests for the database. | |
4 | */ | |
5 | ||
183b8e2f P |
6 | #include "chanserv.h" |
7 | #include "../pqsql/pqsql.h" | |
8 | #include "../core/config.h" | |
9 | #include "../lib/sstring.h" | |
10 | #include "../parser/parser.h" | |
11 | #include "../core/events.h" | |
b263aa79 | 12 | |
13 | #include <string.h> | |
14 | #include <libpq-fe.h> | |
15 | #include <stdio.h> | |
16 | #include <sys/poll.h> | |
17 | #include <stdarg.h> | |
18 | ||
19 | void csdb_updateauthinfo(reguser *rup) { | |
80d2de64 | 20 | char eschost[2*HOSTLEN+1]; |
b263aa79 | 21 | |
22 | PQescapeString(eschost,rup->lastuserhost->content,rup->lastuserhost->length); | |
522e2b8c | 23 | pqquery("UPDATE chanserv.users SET lastauth=%lu,lastuserhost='%s' WHERE ID=%u", |
b263aa79 | 24 | rup->lastauth,eschost,rup->ID); |
25 | } | |
26 | ||
27 | void csdb_updatelastjoin(regchanuser *rcup) { | |
522e2b8c | 28 | pqquery("UPDATE chanserv.chanusers SET usetime=%lu WHERE userID=%u and channelID=%u", |
b263aa79 | 29 | rcup->usetime, rcup->user->ID, rcup->chan->ID); |
30 | } | |
31 | ||
32 | void csdb_updatetopic(regchan *rcp) { | |
33 | char esctopic[TOPICLEN*2+5]; | |
34 | ||
35 | if (rcp->topic) { | |
36 | PQescapeString(esctopic,rcp->topic->content,rcp->topic->length); | |
37 | } else { | |
38 | esctopic[0]='\0'; | |
39 | } | |
522e2b8c | 40 | pqquery("UPDATE chanserv.channels SET topic='%s' WHERE ID=%u",esctopic,rcp->ID); |
b263aa79 | 41 | } |
42 | ||
43 | void csdb_updatechannel(regchan *rcp) { | |
80d2de64 P |
44 | char escwelcome[WELCOMELEN*2+1]; |
45 | char esctopic[TOPICLEN*2+1]; | |
b263aa79 | 46 | char esckey[70]; |
47 | char escreason[510]; | |
48 | char esccomment[510]; | |
49 | char escname[1000]; | |
50 | ||
51 | PQescapeString(escname, rcp->index->name->content, rcp->index->name->length); | |
52 | ||
53 | if (rcp->welcome) | |
54 | PQescapeString(escwelcome, rcp->welcome->content, | |
55 | rcp->welcome->length); | |
56 | else | |
57 | escwelcome[0]='\0'; | |
58 | ||
59 | if (rcp->topic) | |
60 | PQescapeString(esctopic, rcp->topic->content, rcp->topic->length); | |
61 | else | |
62 | esctopic[0]='\0'; | |
63 | ||
64 | if (rcp->key) | |
65 | PQescapeString(esckey, rcp->key->content, rcp->key->length); | |
66 | else | |
67 | esckey[0]='\0'; | |
68 | ||
69 | if (rcp->suspendreason) | |
70 | PQescapeString(escreason, rcp->suspendreason->content, | |
71 | rcp->suspendreason->length); | |
72 | else | |
73 | escreason[0]='\0'; | |
74 | ||
75 | if (rcp->comment) | |
76 | PQescapeString(esccomment, rcp->comment->content, | |
77 | rcp->comment->length); | |
78 | else | |
79 | esccomment[0]='\0'; | |
80 | ||
522e2b8c | 81 | pqquery("UPDATE chanserv.channels SET name='%s', flags=%d, forcemodes=%d," |
b263aa79 | 82 | "denymodes=%d, chanlimit=%d, autolimit=%d, banstyle=%d," |
83 | "lastactive=%lu,statsreset=%lu, banduration=%lu, founder=%u," | |
e086bfee | 84 | "addedby=%u, suspendby=%u, suspendtime=%lu, chantype=%d, totaljoins=%u," |
b263aa79 | 85 | "tripjoins=%u, maxusers=%u, tripusers=%u," |
86 | "welcome='%s', topic='%s', chankey='%s', suspendreason='%s'," | |
87 | "comment='%s', lasttimestamp=%d WHERE ID=%u",escname,rcp->flags,rcp->forcemodes, | |
88 | rcp->denymodes,rcp->limit,rcp->autolimit, rcp->banstyle, | |
89 | rcp->lastactive,rcp->statsreset,rcp->banduration, | |
88d191e3 | 90 | rcp->founder, rcp->addedby, rcp->suspendby, rcp->suspendtime, |
b263aa79 | 91 | rcp->chantype,rcp->totaljoins,rcp->tripjoins, |
92 | rcp->maxusers,rcp->tripusers, | |
93 | escwelcome,esctopic,esckey,escreason,esccomment,rcp->ltimestamp,rcp->ID); | |
94 | } | |
95 | ||
96 | void csdb_updatechannelcounters(regchan *rcp) { | |
522e2b8c | 97 | pqquery("UPDATE chanserv.channels SET " |
b263aa79 | 98 | "lastactive=%lu, totaljoins=%u," |
99 | "tripjoins=%u, maxusers=%u, tripusers=%u " | |
100 | "WHERE ID=%u", | |
101 | rcp->lastactive, | |
102 | rcp->totaljoins,rcp->tripjoins, | |
103 | rcp->maxusers,rcp->tripusers, | |
104 | rcp->ID); | |
105 | } | |
106 | ||
107 | void csdb_updatechanneltimestamp(regchan *rcp) { | |
522e2b8c | 108 | pqquery("UPDATE chanserv.channels SET " |
b263aa79 | 109 | "lasttimestamp=%u WHERE ID=%u", |
110 | rcp->ltimestamp, rcp->ID); | |
111 | } | |
112 | ||
113 | void csdb_createchannel(regchan *rcp) { | |
80d2de64 P |
114 | char escwelcome[WELCOMELEN*2+1]; |
115 | char esctopic[TOPICLEN*2+1]; | |
b263aa79 | 116 | char esckey[70]; |
117 | char escreason[510]; | |
118 | char esccomment[510]; | |
119 | char escname[510]; | |
120 | ||
121 | PQescapeString(escname, rcp->index->name->content, rcp->index->name->length); | |
122 | ||
123 | if (rcp->welcome) | |
124 | PQescapeString(escwelcome, rcp->welcome->content, | |
125 | rcp->welcome->length); | |
126 | else | |
127 | escwelcome[0]='\0'; | |
128 | ||
129 | if (rcp->topic) | |
130 | PQescapeString(esctopic, rcp->topic->content, rcp->topic->length); | |
131 | else | |
132 | esctopic[0]='\0'; | |
133 | ||
134 | if (rcp->key) | |
135 | PQescapeString(esckey, rcp->key->content, rcp->key->length); | |
136 | else | |
137 | esckey[0]='\0'; | |
138 | ||
139 | if (rcp->suspendreason) | |
140 | PQescapeString(escreason, rcp->suspendreason->content, | |
141 | rcp->suspendreason->length); | |
142 | else | |
143 | escreason[0]='\0'; | |
144 | ||
145 | if (rcp->comment) | |
146 | PQescapeString(esccomment, rcp->comment->content, | |
147 | rcp->comment->length); | |
148 | else | |
149 | esccomment[0]='\0'; | |
150 | ||
522e2b8c | 151 | pqquery("INSERT INTO chanserv.channels (ID, name, flags, forcemodes, denymodes," |
b263aa79 | 152 | "chanlimit, autolimit, banstyle, created, lastactive, statsreset, " |
88d191e3 | 153 | "banduration, founder, addedby, suspendby, suspendtime, chantype, totaljoins, tripjoins," |
b263aa79 | 154 | "maxusers, tripusers, welcome, topic, chankey, suspendreason, " |
155 | "comment, lasttimestamp) VALUES (%u,'%s',%d,%d,%d,%d,%d,%d,%lu,%lu,%lu,%lu,%u," | |
88d191e3 | 156 | "%u,%u,%lu,%d,%u,%u,%u,%u,'%s','%s','%s','%s','%s',%d)", |
b263aa79 | 157 | rcp->ID, escname, rcp->flags,rcp->forcemodes, |
158 | rcp->denymodes,rcp->limit,rcp->autolimit, rcp->banstyle, rcp->created, | |
159 | rcp->lastactive,rcp->statsreset,rcp->banduration, | |
88d191e3 | 160 | rcp->founder, rcp->addedby, rcp->suspendby, rcp->suspendtime, |
b263aa79 | 161 | rcp->chantype,rcp->totaljoins,rcp->tripjoins, |
162 | rcp->maxusers,rcp->tripusers, | |
163 | escwelcome,esctopic,esckey,escreason,esccomment,rcp->ltimestamp); | |
164 | } | |
165 | ||
166 | void csdb_deletechannel(regchan *rcp) { | |
522e2b8c | 167 | pqquery("DELETE FROM chanserv.channels WHERE ID=%u",rcp->ID); |
168 | pqquery("DELETE FROM chanserv.chanusers WHERE channelID=%u",rcp->ID); | |
169 | pqquery("DELETE FROM chanserv.bans WHERE channelID=%u",rcp->ID); | |
b263aa79 | 170 | } |
171 | ||
172 | void csdb_deleteuser(reguser *rup) { | |
522e2b8c | 173 | pqquery("DELETE FROM chanserv.users WHERE ID=%u",rup->ID); |
174 | pqquery("DELETE FROM chanserv.chanusers WHERE userID=%u",rup->ID); | |
b263aa79 | 175 | } |
176 | ||
177 | void csdb_updateuser(reguser *rup) { | |
178 | char escpassword[25]; | |
b263aa79 | 179 | char escemail[210]; |
180 | char esclastuserhost[160]; | |
181 | char escreason[510]; | |
182 | char esccomment[510]; | |
183 | char escinfo[210]; | |
9708f78f CP |
184 | char esclastemail[210]; |
185 | ||
b263aa79 | 186 | PQescapeString(escpassword, rup->password, strlen(rup->password)); |
b263aa79 | 187 | |
188 | if (rup->email) | |
189 | PQescapeString(escemail, rup->email->content, rup->email->length); | |
190 | else | |
191 | escemail[0]='\0'; | |
192 | ||
9708f78f CP |
193 | if (rup->lastemail) |
194 | PQescapeString(esclastemail, rup->lastemail->content, rup->lastemail->length); | |
195 | else | |
196 | esclastemail[0]='\0'; | |
197 | ||
b263aa79 | 198 | if (rup->lastuserhost) |
199 | PQescapeString(esclastuserhost, rup->lastuserhost->content, rup->lastuserhost->length); | |
200 | else | |
201 | esclastuserhost[0]='\0'; | |
202 | ||
203 | if (rup->suspendreason) | |
204 | PQescapeString(escreason, rup->suspendreason->content, rup->suspendreason->length); | |
205 | else | |
206 | escreason[0]='\0'; | |
207 | ||
208 | if (rup->comment) | |
209 | PQescapeString(esccomment, rup->comment->content, rup->comment->length); | |
210 | else | |
211 | esccomment[0]='\0'; | |
212 | ||
213 | if (rup->info) | |
214 | PQescapeString(escinfo, rup->info->content, rup->info->length); | |
215 | else | |
216 | escinfo[0]='\0'; | |
217 | ||
522e2b8c | 218 | pqquery("UPDATE chanserv.users SET lastauth=%lu, lastemailchng=%lu, flags=%u," |
b438f642 | 219 | "language=%u, suspendby=%u, suspendexp=%lu, suspendtime=%lu, lockuntil=%lu, password='%s', email='%s'," |
9708f78f | 220 | "lastuserhost='%s', suspendreason='%s', comment='%s', info='%s', lastemail='%s' WHERE ID=%u", |
b263aa79 | 221 | rup->lastauth, rup->lastemailchange, rup->flags, rup->languageid, rup->suspendby, rup->suspendexp, |
9708f78f | 222 | rup->suspendtime, rup->lockuntil, escpassword, escemail, esclastuserhost, escreason, esccomment, escinfo, esclastemail, |
b263aa79 | 223 | rup->ID); |
224 | } | |
225 | ||
226 | void csdb_createuser(reguser *rup) { | |
227 | char escpassword[25]; | |
b263aa79 | 228 | char escemail[210]; |
229 | char esclastuserhost[160]; | |
230 | char escreason[510]; | |
231 | char esccomment[510]; | |
232 | char escusername[35]; | |
233 | char escinfo[210]; | |
9708f78f | 234 | char esclastemail[210]; |
b263aa79 | 235 | |
236 | PQescapeString(escusername, rup->username, strlen(rup->username)); | |
237 | PQescapeString(escpassword, rup->password, strlen(rup->password)); | |
b263aa79 | 238 | |
239 | if (rup->email) | |
240 | PQescapeString(escemail, rup->email->content, rup->email->length); | |
241 | else | |
242 | escemail[0]='\0'; | |
243 | ||
9708f78f CP |
244 | if (rup->lastemail) |
245 | PQescapeString(esclastemail, rup->lastemail->content, rup->lastemail->length); | |
246 | else | |
247 | esclastemail[0]='\0'; | |
248 | ||
b263aa79 | 249 | if (rup->lastuserhost) |
250 | PQescapeString(esclastuserhost, rup->lastuserhost->content, rup->lastuserhost->length); | |
251 | else | |
252 | esclastuserhost[0]='\0'; | |
253 | ||
254 | if (rup->suspendreason) | |
255 | PQescapeString(escreason, rup->suspendreason->content, rup->suspendreason->length); | |
256 | else | |
257 | escreason[0]='\0'; | |
258 | ||
259 | if (rup->comment) | |
260 | PQescapeString(esccomment, rup->comment->content, rup->comment->length); | |
261 | else | |
262 | esccomment[0]='\0'; | |
263 | ||
264 | if (rup->info) | |
265 | PQescapeString(escinfo, rup->info->content, rup->info->length); | |
266 | else | |
267 | escinfo[0]='\0'; | |
268 | ||
522e2b8c | 269 | pqquery("INSERT INTO chanserv.users (ID, username, created, lastauth, lastemailchng, " |
b438f642 | 270 | "flags, language, suspendby, suspendexp, suspendtime, lockuntil, password, email, lastuserhost, " |
f5fd3158 | 271 | "suspendreason, comment, info, lastemail) VALUES (%u,'%s',%lu,%lu,%lu,%u,%u,%u,%lu,%lu,%lu,'%s','%s'," |
9708f78f | 272 | "'%s','%s','%s','%s','%s')", |
b263aa79 | 273 | rup->ID, escusername, rup->created, rup->lastauth, rup->lastemailchange, rup->flags, |
b438f642 | 274 | rup->languageid, rup->suspendby, rup->suspendexp, rup->suspendtime, rup->lockuntil, |
9708f78f | 275 | escpassword, escemail, esclastuserhost, escreason, esccomment, escinfo, esclastemail); |
b263aa79 | 276 | } |
277 | ||
278 | ||
279 | void csdb_updatechanuser(regchanuser *rcup) { | |
280 | char escinfo[210]; | |
281 | ||
282 | if (rcup->info) | |
283 | PQescapeString(escinfo, rcup->info->content, rcup->info->length); | |
284 | else | |
285 | escinfo[0]='\0'; | |
286 | ||
522e2b8c | 287 | pqquery("UPDATE chanserv.chanusers SET flags=%u, changetime=%lu, " |
b263aa79 | 288 | "usetime=%lu, info='%s' WHERE channelID=%u and userID=%u", |
289 | rcup->flags, rcup->changetime, rcup->usetime, escinfo, rcup->chan->ID,rcup->user->ID); | |
290 | } | |
291 | ||
292 | void csdb_createchanuser(regchanuser *rcup) { | |
293 | char escinfo[210]; | |
294 | ||
295 | if (rcup->info) | |
296 | PQescapeString(escinfo, rcup->info->content, rcup->info->length); | |
297 | else | |
298 | escinfo[0]='\0'; | |
299 | ||
522e2b8c | 300 | pqquery("INSERT INTO chanserv.chanusers VALUES(%u, %u, %u, %lu, %lu, '%s')", |
b263aa79 | 301 | rcup->user->ID, rcup->chan->ID, rcup->flags, rcup->changetime, |
302 | rcup->usetime, escinfo); | |
303 | } | |
304 | ||
305 | void csdb_deletechanuser(regchanuser *rcup) { | |
522e2b8c | 306 | pqquery("DELETE FROM chanserv.chanusers WHERE channelid=%u AND userID=%u", |
b263aa79 | 307 | rcup->chan->ID, rcup->user->ID); |
308 | } | |
309 | ||
310 | void csdb_createban(regchan *rcp, regban *rbp) { | |
311 | char escreason[500]; | |
312 | char banstr[100]; | |
313 | char escban[200]; | |
314 | ||
315 | strcpy(banstr,bantostring(rbp->cbp)); | |
316 | PQescapeString(escban,banstr,strlen(banstr)); | |
317 | ||
318 | if (rbp->reason) | |
319 | PQescapeString(escreason, rbp->reason->content, rbp->reason->length); | |
320 | else | |
321 | escreason[0]='\0'; | |
322 | ||
522e2b8c | 323 | pqquery("INSERT INTO chanserv.bans (banID, channelID, userID, hostmask, " |
b263aa79 | 324 | "expiry, reason) VALUES (%u,%u,%u,'%s',%lu,'%s')", rbp->ID, rcp->ID, |
325 | rbp->setby, escban, rbp->expiry, escreason); | |
326 | } | |
327 | ||
3fbc2554 CP |
328 | void csdb_updateban(regchan *rcp, regban *rbp) { |
329 | char escreason[500]; | |
330 | char banstr[100]; | |
331 | char escban[200]; | |
332 | ||
333 | strcpy(banstr,bantostring(rbp->cbp)); | |
334 | PQescapeString(escban,banstr,strlen(banstr)); | |
335 | ||
336 | if (rbp->reason) | |
337 | PQescapeString(escreason, rbp->reason->content, rbp->reason->length); | |
338 | else | |
339 | escreason[0]='\0'; | |
340 | ||
522e2b8c | 341 | pqquery("UPDATE chanserv.bans set channelID=%u, userID=%u, hostmask='%s', expiry=%lu, reason='%s' " |
3fbc2554 CP |
342 | "WHERE banID=%u", rcp->ID, rbp->setby, escban, rbp->expiry, escreason, rbp->ID); |
343 | } | |
344 | ||
b263aa79 | 345 | void csdb_deleteban(regban *rbp) { |
522e2b8c | 346 | pqquery("DELETE FROM chanserv.bans WHERE banID=%u", rbp->ID); |
b263aa79 | 347 | } |
348 | ||
349 | void csdb_createmail(reguser *rup, int type) { | |
350 | char sqlquery[6000]; | |
351 | char escemail[210]; | |
352 | ||
353 | if (type == QMAIL_NEWEMAIL) { | |
354 | if (rup->email) { | |
355 | PQescapeString(escemail, rup->email->content, rup->email->length); | |
522e2b8c | 356 | sprintf(sqlquery, "INSERT INTO chanserv.email (userID, emailType, prevEmail) " |
b263aa79 | 357 | "VALUES (%u,%u,'%s')", rup->ID, type, escemail); |
358 | } | |
359 | } else { | |
522e2b8c | 360 | sprintf(sqlquery, "INSERT INTO chanserv.email (userID, emailType) VALUES (%u,%u)", rup->ID, type); |
b263aa79 | 361 | } |
362 | ||
363 | pqquery("%s", sqlquery); | |
183b8e2f P |
364 | } |
365 | ||
366 | void csdb_deletemaildomain(maildomain *mdp) { | |
522e2b8c | 367 | pqquery("DELETE FROM chanserv.maildomain WHERE ID=%u", mdp->ID); |
183b8e2f P |
368 | } |
369 | ||
370 | void csdb_createmaildomain(maildomain *mdp) { | |
371 | char escdomain[210]; | |
80d2de64 | 372 | PQescapeString(escdomain, mdp->name->content, mdp->name->length); |
183b8e2f | 373 | |
522e2b8c | 374 | pqquery("INSERT INTO chanserv.maildomain (id, name, domainlimit, actlimit, flags) VALUES(%u, '%s', %u, %u, %u)", mdp->ID,escdomain,mdp->limit,mdp->actlimit,mdp->flags); |
183b8e2f P |
375 | } |
376 | ||
377 | void csdb_updatemaildomain(maildomain *mdp) { | |
378 | char escdomain[210]; | |
80d2de64 | 379 | PQescapeString(escdomain, mdp->name->content, mdp->name->length); |
183b8e2f | 380 | |
522e2b8c | 381 | pqquery("UPDATE chanserv.maildomain SET domainlimit=%u, actlimit=%u, flags=%u, name='%s' WHERE ID=%u", mdp->limit,mdp->actlimit,mdp->flags,escdomain,mdp->ID); |
183b8e2f P |
382 | } |
383 | ||
183b8e2f P |
384 | void csdb_chanlevhistory_insert(regchan *rcp, nick *np, reguser *trup, flag_t oldflags, flag_t newflags) { |
385 | reguser *rup=getreguserfromnick(np); | |
386 | ||
522e2b8c | 387 | pqquery("INSERT INTO chanserv.chanlevhistory (userID, channelID, targetID, changetime, authtime, " |
183b8e2f P |
388 | "oldflags, newflags) VALUES (%u, %u, %u, %lu, %lu, %u, %u)", rup->ID, rcp->ID, trup->ID, getnettime(), np->accountts, |
389 | oldflags, newflags); | |
390 | } | |
391 | ||
392 | void csdb_accounthistory_insert(nick *np, char *oldpass, char *newpass, sstring *oldemail, sstring *newemail) { | |
393 | reguser *rup=getreguserfromnick(np); | |
394 | char escoldpass[30]; | |
395 | char escnewpass[30]; | |
396 | char escoldemail[130]; | |
397 | char escnewemail[130]; | |
398 | ||
399 | if (!rup || UHasOperPriv(rup)) | |
400 | return; | |
401 | ||
402 | if (oldpass) | |
403 | PQescapeString(escoldpass, oldpass, strlen(oldpass)); | |
404 | else | |
405 | escoldpass[0]='\0'; | |
406 | ||
407 | if (newpass) | |
408 | PQescapeString(escnewpass, newpass, strlen(newpass)); | |
409 | else | |
410 | escnewpass[0]='\0'; | |
411 | ||
412 | if (oldemail) | |
80d2de64 | 413 | PQescapeString(escoldemail, oldemail->content, oldemail->length); |
183b8e2f P |
414 | else |
415 | escoldemail[0]='\0'; | |
416 | if (newemail) | |
80d2de64 | 417 | PQescapeString(escnewemail, newemail->content, newemail->length); |
183b8e2f P |
418 | else |
419 | escnewemail[0]='\0'; | |
420 | ||
522e2b8c | 421 | pqquery("INSERT INTO chanserv.accounthistory (userID, changetime, authtime, oldpassword, newpassword, oldemail, " |
183b8e2f P |
422 | "newemail) VALUES (%u, %lu, %lu, '%s', '%s', '%s', '%s')", rup->ID, getnettime(), np->accountts, escoldpass, escnewpass, |
423 | escoldemail, escnewemail); | |
424 | ||
425 | if (newemail) | |
426 | freesstring(newemail); | |
427 | } | |
428 | ||
429 | void csdb_cleanuphistories() { | |
430 | time_t expire_time=getnettime()-604800; | |
431 | ||
432 | Error("chanserv", ERR_INFO, "Cleaning histories."); | |
522e2b8c | 433 | pqquery("DELETE FROM chanserv.authhistory WHERE authtime < %lu", expire_time); |
434 | pqquery("DELETE FROM chanserv.chanlevhistory WHERE changetime < %lu", expire_time); | |
435 | pqquery("DELETE FROM chanserv.accounthistory WHERE changetime < %lu", expire_time); | |
183b8e2f P |
436 | } |
437 | ||
97390b65 | 438 | void csdb_deletemaillock(maillock *mlp) { |
522e2b8c | 439 | pqquery("DELETE FROM chanserv.maillocks WHERE ID=%u", mlp->id); |
97390b65 CP |
440 | } |
441 | ||
442 | void csdb_createmaillock(maillock *mlp) { | |
443 | char escpattern[1024], escreason[1024]; | |
444 | ||
445 | PQescapeString(escpattern, mlp->pattern->content, mlp->pattern->length); | |
446 | ||
447 | if (mlp->reason) | |
448 | PQescapeString(escreason, mlp->reason->content, mlp->reason->length); | |
449 | else | |
450 | escreason[0]='\0'; | |
451 | ||
522e2b8c | 452 | pqquery("INSERT INTO chanserv.maillocks (id, pattern, reason, createdby, created) VALUES(%u, '%s', '%s', %u, %u)", |
97390b65 CP |
453 | mlp->id,escpattern,escreason,mlp->createdby,mlp->created); |
454 | } | |
455 | ||
456 | void csdb_updatemaillock(maillock *mlp) { | |
457 | char escpattern[1024], escreason[1024]; | |
458 | ||
459 | PQescapeString(escpattern, mlp->pattern->content, mlp->pattern->length); | |
460 | ||
461 | if (mlp->reason) | |
462 | PQescapeString(escreason, mlp->reason->content, mlp->reason->length); | |
463 | else | |
464 | escreason[0]='\0'; | |
465 | ||
522e2b8c | 466 | pqquery("UPDATE chanserv.maillocks SET pattern='%s', reason='%s', createdby=%u, created=%u WHERE ID=%u", escpattern, escreason, mlp->createdby, mlp->created, mlp->id); |
97390b65 CP |
467 | } |
468 |