Commit | Line | Data |
---|---|---|
81b5b746 | 1 | <?php |
2 | /*************************************************************************** | |
12262f13 | 3 | * Copyright (C) 2003-2011 Polytechnique.org * |
81b5b746 | 4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
22 | class EmailModule extends PLModule | |
23 | { | |
81b5b746 | 24 | function handlers() |
25 | { | |
26 | return array( | |
2914271e FB |
27 | 'emails' => $this->make_hook('emails', AUTH_COOKIE, 'mail'), |
28 | 'emails/alias' => $this->make_hook('alias', AUTH_MDP, 'mail'), | |
29 | 'emails/antispam' => $this->make_hook('antispam', AUTH_MDP, 'mail'), | |
eb5a266d | 30 | 'emails/broken' => $this->make_hook('broken', AUTH_COOKIE), |
2914271e FB |
31 | 'emails/redirect' => $this->make_hook('redirect', AUTH_MDP, 'mail'), |
32 | 'emails/send' => $this->make_hook('send', AUTH_MDP, 'mail'), | |
eb5a266d | 33 | 'emails/antispam/submit' => $this->make_hook('submit', AUTH_COOKIE), |
2914271e | 34 | 'emails/test' => $this->make_hook('test', AUTH_COOKIE, 'mail', NO_AUTH), |
9e570fe0 | 35 | |
eb5a266d SJ |
36 | 'emails/rewrite/in' => $this->make_hook('rewrite_in', AUTH_PUBLIC), |
37 | 'emails/rewrite/out' => $this->make_hook('rewrite_out', AUTH_PUBLIC), | |
3d17e48f | 38 | |
eb5a266d | 39 | 'emails/imap/in' => $this->make_hook('imap_in', AUTH_PUBLIC), |
2ee43273 | 40 | |
eb5a266d SJ |
41 | 'admin/emails/duplicated' => $this->make_hook('duplicated', AUTH_MDP, 'admin'), |
42 | 'admin/emails/watch' => $this->make_hook('duplicated', AUTH_MDP, 'admin'), | |
43 | 'admin/emails/lost' => $this->make_hook('lost', AUTH_MDP, 'admin'), | |
67e06366 | 44 | 'admin/emails/broken' => $this->make_hook('broken_addr', AUTH_MDP, 'admin'), |
81b5b746 | 45 | ); |
46 | } | |
47 | ||
26ba053e | 48 | function handler_emails($page, $action = null, $email = null) |
81b5b746 | 49 | { |
50 | global $globals; | |
e97e9b8f | 51 | require_once 'emails.inc.php'; |
81b5b746 | 52 | |
53 | $page->changeTpl('emails/index.tpl'); | |
46f272fe | 54 | $page->setTitle('Mes emails'); |
81b5b746 | 55 | |
2d997414 | 56 | $user = S::user(); |
81b5b746 | 57 | |
2d997414 | 58 | // Apply the bestalias change request. |
b7582015 | 59 | if ($action == 'best' && $email) { |
46504fb3 VZ |
60 | if (!S::has_xsrf_token()) { |
61 | return PL_FORBIDDEN; | |
62 | } | |
63 | ||
b4503762 SJ |
64 | // First delete the bestalias flag from all this user's emails. |
65 | XDB::execute("UPDATE email_source_account | |
2d997414 | 66 | SET flags = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', flags, ','), ',bestalias,', ',')) |
fe13bc1d | 67 | WHERE uid = {?}", $user->id()); |
b4503762 SJ |
68 | // Then gives the bestalias flag to the given email. |
69 | list($email, $domain) = explode('@', $email); | |
70 | XDB::execute("UPDATE email_source_account AS s | |
71 | INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) | |
72 | SET s.flags = CONCAT_WS(',', IF(s.flags = '', NULL, s.flags), 'bestalias') | |
73 | WHERE s.uid = {?} AND s.email = {?} AND d.name = {?}", $user->id(), $email, $domain); | |
2d997414 VZ |
74 | |
75 | // As having a non-null bestalias value is critical in | |
76 | // plat/al's code, we do an a posteriori check on the | |
77 | // validity of the bestalias. | |
78 | fix_bestalias($user); | |
81b5b746 | 79 | } |
80 | ||
2d997414 | 81 | // Fetch and display aliases. |
b4503762 SJ |
82 | $aliases = XDB::iterator("SELECT CONCAT(s.email, '@', d.name) AS email, (s.type = 'forlife') AS forlife, |
83 | (s.email REGEXP '\\\\.[0-9]{2}$') AS hundred_year, | |
84 | FIND_IN_SET('bestalias', s.flags) AS bestalias, s.expire, | |
85 | (d.name = {?}) AS alias | |
86 | FROM email_source_account AS s | |
87 | INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) | |
88 | WHERE s.uid = {?} | |
89 | ORDER BY !alias, s.email", | |
90 | $globals->mail->alias_dom, $user->id()); | |
91 | $page->assign('aliases', $aliases); | |
92 | ||
93 | $alias = XDB::fetchOneCell('SELECT COUNT(s.email) | |
94 | FROM email_source_account AS s | |
95 | INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) | |
96 | WHERE s.uid = {?} AND d.name = {?}', | |
97 | $user->id(), $globals->mail->alias_dom); | |
98 | $page->assign('alias', $alias); | |
99 | ||
81b5b746 | 100 | |
2d997414 | 101 | // Check for homonyms. |
777c5910 | 102 | $page->assign('homonyme', $user->homonyme); |
e1547442 | 103 | |
2d997414 VZ |
104 | // Display active redirections. |
105 | $redirect = new Redirect($user); | |
e97e9b8f | 106 | $page->assign('mails', $redirect->active_emails()); |
81b5b746 | 107 | } |
108 | ||
26ba053e | 109 | function handler_alias($page, $action = null, $value = null) |
81b5b746 | 110 | { |
81b5b746 | 111 | global $globals; |
112 | ||
113 | $page->changeTpl('emails/alias.tpl'); | |
46f272fe | 114 | $page->setTitle('Alias melix.net'); |
81b5b746 | 115 | |
2d997414 | 116 | $user = S::user(); |
b4503762 | 117 | $page->assign('request', AliasReq::get_request($user->id())); |
81b5b746 | 118 | |
2d997414 | 119 | // Remove the email alias. |
b4503762 | 120 | if ($action == 'delete') { |
40d428d8 VZ |
121 | S::assert_xsrf_token(); |
122 | ||
b4503762 SJ |
123 | XDB::execute('DELETE s |
124 | FROM email_source_account AS s | |
125 | INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) | |
126 | WHERE s.uid = {?} AND d.name = {?}', | |
127 | $user->id(), $globals->mail->alias_dom); | |
128 | ||
129 | require_once 'emails.inc.php'; | |
130 | fix_bestalias($user); | |
81b5b746 | 131 | } |
132 | ||
2d997414 | 133 | // Fetch existing @alias_dom aliases. |
b4503762 SJ |
134 | list($alias, $old_alias) = XDB::fetchOneRow('SELECT CONCAT(s.email, \'@\', d.name), s.email |
135 | FROM email_source_account AS s | |
136 | INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) | |
137 | WHERE s.uid = {?} AND d.name = {?}', | |
138 | $user->id(), $globals->mail->alias_dom); | |
139 | $visibility = $user->hasProfile() && ($user->profile(true)->alias_pub == 'public'); | |
140 | $page->assign('current', $alias); | |
5b6768e6 FB |
141 | $page->assign('user', $user); |
142 | $page->assign('mail_public', $visibility); | |
81b5b746 | 143 | |
b4503762 | 144 | if ($action == 'ask' && Env::has('alias') && Env::has('reason')) { |
40d428d8 | 145 | S::assert_xsrf_token(); |
81b5b746 | 146 | |
b4503762 SJ |
147 | // Retrieves user request. |
148 | $new_alias = Env::v('alias'); | |
149 | $reason = Env::v('reason'); | |
6a4f0f01 | 150 | $public = (Env::v('public', 'off') == 'on') ? 'public' : 'private'; |
81b5b746 | 151 | |
b4503762 SJ |
152 | $page->assign('r_alias', $new_alias); |
153 | $page->assign('r_reason', $reason); | |
81b5b746 | 154 | if ($public == 'public') { |
155 | $page->assign('r_public', true); | |
156 | } | |
157 | ||
b4503762 SJ |
158 | // Checks special charaters in alias. |
159 | if (!preg_match("/^[a-zA-Z0-9\-.]{3,20}$/", $new_alias)) { | |
a7d35093 FB |
160 | $page->trigError("L'adresse demandée n'est pas valide." |
161 | . " Vérifie qu'elle comporte entre 3 et 20 caractères" | |
162 | . " et qu'elle ne contient que des lettres non accentuées," | |
163 | . " des chiffres ou les caractères - et ."); | |
fd8f77de | 164 | return; |
81b5b746 | 165 | } else { |
b4503762 SJ |
166 | // Checks if the alias has already been given. |
167 | $res = XDB::query('SELECT COUNT(s.email) | |
168 | FROM email_source_account AS s | |
169 | INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) | |
170 | WHERE s.email = {?} AND d.name = {?}', | |
171 | $new_alias, $globals->mail->alias_dom); | |
81b5b746 | 172 | if ($res->fetchOneCell() > 0) { |
b4503762 | 173 | $page->trigError("L'alias $new_alias a déja été attribué. Tu ne peux donc pas l'obtenir."); |
fd8f77de | 174 | return; |
81b5b746 | 175 | } |
176 | ||
b4503762 | 177 | // Checks if the alias has already been asked for. |
7b094a73 | 178 | $it = Validate::iterate('alias'); |
81b5b746 | 179 | while($req = $it->next()) { |
b4503762 SJ |
180 | if ($req->alias == $new_alias) { |
181 | $page->trigError("L'alias $new_alias a déja été demandé. Tu ne peux donc pas l'obtenir pour l'instant."); | |
182 | return; | |
81b5b746 | 183 | } |
184 | } | |
185 | ||
b4503762 SJ |
186 | // Sends requests. This will erase any previous alias pending request. |
187 | $myalias = new AliasReq($user, $new_alias, $reason, $public, $old_alias); | |
81b5b746 | 188 | $myalias->submit(); |
b4503762 | 189 | $page->assign('success', $new_alias); |
fd8f77de | 190 | return; |
81b5b746 | 191 | } |
46504fb3 VZ |
192 | } elseif ($action == 'set' && ($value == 'public' || $value == 'private')) { |
193 | if (!S::has_xsrf_token()) { | |
194 | return PL_FORBIDDEN; | |
195 | } | |
196 | ||
3e53a496 | 197 | if ($user->hasProfile()) { |
b4503762 | 198 | XDB::execute('UPDATE profiles |
3e53a496 | 199 | SET alias_pub = {?} |
b4503762 | 200 | WHERE pid = {?}', |
3e53a496 | 201 | $value, $user->profile()->id()); |
81b5b746 | 202 | } |
8446dbd3 | 203 | exit; |
81b5b746 | 204 | } |
81b5b746 | 205 | } |
206 | ||
b4503762 | 207 | function handler_redirect($page, $action = null, $email = null, $rewrite = null) |
81b5b746 | 208 | { |
209 | global $globals; | |
81b5b746 | 210 | require_once 'emails.inc.php'; |
211 | ||
212 | $page->changeTpl('emails/redirect.tpl'); | |
213 | ||
2d997414 VZ |
214 | $user = S::user(); |
215 | $page->assign_by_ref('user', $user); | |
216 | $page->assign('eleve', $user->promo() >= date("Y") - 5); | |
3b83212e | 217 | |
2d997414 | 218 | $redirect = new Redirect($user); |
81b5b746 | 219 | |
6d6b65bf | 220 | // FS#703 : $_GET is urldecoded twice, hence |
221 | // + (the data) => %2B (in the url) => + (first decoding) => ' ' (second decoding) | |
222 | // Since there can be no spaces in emails, we can fix this with : | |
223 | $email = str_replace(' ', '+', $email); | |
224 | ||
2d997414 | 225 | // Apply email redirection change requests. |
1060c854 | 226 | $result = SUCCESS; |
81b5b746 | 227 | if ($action == 'remove' && $email) { |
1060c854 | 228 | $result = $redirect->delete_email($email); |
81b5b746 | 229 | } |
e1547442 FB |
230 | |
231 | if ($action == 'active' && $email) { | |
232 | $redirect->modify_one_email($email, true); | |
233 | } | |
234 | ||
235 | if ($action == 'inactive' && $email) { | |
236 | $redirect->modify_one_email($email, false); | |
237 | } | |
238 | ||
239 | if ($action == 'rewrite' && $email) { | |
e1547442 FB |
240 | $redirect->modify_one_email_redirect($email, $rewrite); |
241 | } | |
242 | ||
40d428d8 VZ |
243 | if (Env::has('emailop')) { |
244 | S::assert_xsrf_token(); | |
245 | ||
b4503762 | 246 | $actifs = Env::v('emails_actifs', array()); |
5e2307dc | 247 | if (Env::v('emailop') == "ajouter" && Env::has('email')) { |
0fbd1f3f | 248 | $error_email = false; |
b715c1e1 | 249 | $new_email = Env::v('email'); |
6ea6d9c1 | 250 | if ($new_email == "new@example.org") { |
b715c1e1 SJ |
251 | $new_email = Env::v('email_new'); |
252 | } | |
aef0283b VZ |
253 | $result = $redirect->add_email($new_email); |
254 | if ($result == ERROR_INVALID_EMAIL) { | |
0fbd1f3f | 255 | $error_email = true; |
b715c1e1 SJ |
256 | $page->assign('email', $new_email); |
257 | } | |
aef0283b | 258 | $page->assign('retour', $result); |
0fbd1f3f | 259 | $page->assign('error_email', $error_email); |
81b5b746 | 260 | } elseif (empty($actifs)) { |
1060c854 | 261 | $result = ERROR_INACTIVE_REDIRECTION; |
81b5b746 | 262 | } elseif (is_array($actifs)) { |
b4503762 | 263 | $result = $redirect->modify_email($actifs, Env::v('emails_rewrite', array())); |
81b5b746 | 264 | } |
265 | } | |
266 | ||
1060c854 | 267 | switch ($result) { |
44b071c2 SJ |
268 | case ERROR_INACTIVE_REDIRECTION: |
269 | $page->trigError('Tu ne peux pas avoir aucune adresse de redirection active, sinon ton adresse ' | |
4478f95e | 270 | . $user->forlifeEmail() . ' ne fonctionnerait plus.'); |
44b071c2 SJ |
271 | break; |
272 | case ERROR_INVALID_EMAIL: | |
0fbd1f3f | 273 | $page->trigError('Erreur : l\'email n\'est pas valide.'); |
44b071c2 SJ |
274 | break; |
275 | case ERROR_LOOP_EMAIL: | |
4478f95e | 276 | $page->trigError('Erreur : ' . $user->forlifeEmail() |
44b071c2 SJ |
277 | . ' ne doit pas être renvoyé vers lui-même, ni vers son équivalent en ' |
278 | . $globals->mail->domain2 . ' ni vers polytechnique.edu.'); | |
279 | break; | |
280 | } | |
2d997414 | 281 | // Fetch existing email aliases. |
b4503762 SJ |
282 | $alias = XDB::query('SELECT CONCAT(s.email, \'@\', d.name) AS email, s.expire |
283 | FROM email_source_account AS s | |
284 | INNER JOIN email_virtual_domains AS m ON (s.domain = m.id) | |
285 | INNER JOIN email_virtual_domains AS d ON (m.id = d.aliasing) | |
286 | WHERE s.uid = {?} | |
287 | ORDER BY NOT (m.name = {?}), s.email, d.name', | |
288 | $user->id(), $globals->mail->alias_dom); | |
289 | $page->assign('alias', $alias->fetchAllAssoc()); | |
290 | ||
2d997414 | 291 | $page->assign('emails', $redirect->emails); |
aab4661d | 292 | |
2d997414 | 293 | // Display GoogleApps acount information. |
f5c4bf30 | 294 | require_once 'googleapps.inc.php'; |
2d997414 | 295 | $page->assign('googleapps', GoogleAppsAccount::account_status($user->id())); |
b715c1e1 SJ |
296 | |
297 | require_once 'emails.combobox.inc.php'; | |
298 | fill_email_combobox($page); | |
81b5b746 | 299 | } |
300 | ||
b4503762 | 301 | function handler_antispam($page, $filter_status = null) |
81b5b746 | 302 | { |
303 | require_once 'emails.inc.php'; | |
8f201b69 FB |
304 | $wp = new PlWikiPage('Xorg.Antispam'); |
305 | $wp->buildCache(); | |
81b5b746 | 306 | |
307 | $page->changeTpl('emails/antispam.tpl'); | |
308 | ||
ea280814 SJ |
309 | $user = S::user(); |
310 | $bogo = new Bogo($user); | |
b4503762 SJ |
311 | if (isset($filter_status)) { |
312 | $bogo->change($filter_status + 0); | |
81b5b746 | 313 | } |
b4503762 | 314 | $page->assign('filter', $bogo->level()); |
81b5b746 | 315 | } |
316 | ||
26ba053e | 317 | function handler_submit($page) |
62ce6356 | 318 | { |
8f201b69 FB |
319 | $wp = new PlWikiPage('Xorg.Mails'); |
320 | $wp->buildCache(); | |
62ce6356 | 321 | $page->changeTpl('emails/submit_spam.tpl'); |
322 | ||
40d428d8 VZ |
323 | if (Post::has('send_email')) { |
324 | S::assert_xsrf_token(); | |
325 | ||
f3df6d38 | 326 | $upload = PlUpload::get($_FILES['mail'], S::user()->login(), 'spam.submit', true); |
15603084 | 327 | if (!$upload) { |
a7d35093 | 328 | $page->trigError('Une erreur a été rencontrée lors du transfert du fichier'); |
62ce6356 | 329 | return; |
330 | } | |
15603084 | 331 | $mime = $upload->contentType(); |
62ce6356 | 332 | if ($mime != 'text/x-mail' && $mime != 'message/rfc822') { |
15603084 | 333 | $upload->clear(); |
faefdbb7 | 334 | $page->trigError('Le fichier ne contient pas un email complet'); |
62ce6356 | 335 | return; |
336 | } | |
2d997414 VZ |
337 | $type = (Post::v('type') == 'spam' ? 'spam' : 'nonspam'); |
338 | ||
62ce6356 | 339 | global $globals; |
2d997414 | 340 | $box = $type . '@' . $globals->mail->domain; |
62ce6356 | 341 | $mailer = new PlMailer(); |
342 | $mailer->addTo($box); | |
2d997414 VZ |
343 | $mailer->setFrom('"' . S::user()->fullName() . '" <web@' . $globals->mail->domain . '>'); |
344 | $mailer->setTxtBody($type . ' soumis par ' . S::user()->login() . ' via le web'); | |
345 | $mailer->addUploadAttachment($upload, $type . '.mail'); | |
62ce6356 | 346 | $mailer->send(); |
a7d35093 | 347 | $page->trigSuccess('Le message a été transmis à ' . $box); |
15603084 | 348 | $upload->clear(); |
62ce6356 | 349 | } |
350 | } | |
351 | ||
26ba053e | 352 | function handler_send($page) |
81b5b746 | 353 | { |
81b5b746 | 354 | $page->changeTpl('emails/send.tpl'); |
355 | ||
46f272fe | 356 | $page->setTitle('Envoyer un email'); |
81b5b746 | 357 | |
358 | // action si on recoit un formulaire | |
3360c04f | 359 | if (Post::has('save')) { |
46504fb3 VZ |
360 | if (!S::has_xsrf_token()) { |
361 | return PL_FORBIDDEN; | |
362 | } | |
363 | ||
3360c04f FB |
364 | unset($_POST['save']); |
365 | if (trim(preg_replace('/-- .*/', '', Post::v('contenu'))) != "") { | |
ed06daba FB |
366 | Post::set('to_contacts', explode(';', Post::s('to_contacts'))); |
367 | Post::set('cc_contacts', explode(';', Post::s('cc_contacts'))); | |
3360c04f | 368 | $data = serialize($_POST); |
00ba8a74 SJ |
369 | XDB::execute('INSERT INTO email_send_save (uid, data) |
370 | VALUES ({?}, {?}) | |
371 | ON DUPLICATE KEY UPDATE data = VALUES(data)', | |
48e683dd | 372 | S::user()->id('uid'), $data); |
3360c04f FB |
373 | } |
374 | exit; | |
40d428d8 VZ |
375 | } else if (Env::v('submit') == 'Envoyer') { |
376 | S::assert_xsrf_token(); | |
377 | ||
91a14f73 | 378 | function getEmails($aliases) |
379 | { | |
380 | if (!is_array($aliases)) { | |
381 | return null; | |
382 | } | |
2d5264c6 FB |
383 | $uf = new UserFilter(new UFC_Hrpid($aliases)); |
384 | $users = $uf->iterUsers(); | |
91a14f73 | 385 | $ret = array(); |
2d5264c6 FB |
386 | while ($user = $users->next()) { |
387 | $ret[] = $user->forlife; | |
91a14f73 | 388 | } |
389 | return join(', ', $ret); | |
390 | } | |
391 | ||
5e68682e | 392 | $error = false; |
da419622 | 393 | foreach ($_FILES as &$file) { |
f3df6d38 | 394 | if ($file['name'] && !PlUpload::get($file, S::user()->login(), 'emails.send', false)) { |
a7d35093 | 395 | $page->trigError(PlUpload::$lastError); |
5e68682e FB |
396 | $error = true; |
397 | break; | |
da419622 | 398 | } |
399 | } | |
400 | ||
5e68682e FB |
401 | if (!$error) { |
402 | XDB::execute("DELETE FROM email_send_save | |
48e683dd FB |
403 | WHERE uid = {?}", |
404 | S::user()->id()); | |
5e68682e FB |
405 | |
406 | $to2 = getEmails(Env::v('to_contacts')); | |
407 | $cc2 = getEmails(Env::v('cc_contacts')); | |
408 | $txt = str_replace('^M', '', Env::v('contenu')); | |
3c7b9bad SJ |
409 | $to = str_replace(';', ',', Env::t('to')); |
410 | $subj = Env::t('sujet'); | |
411 | $from = Env::t('from'); | |
412 | $cc = str_replace(';', ',', Env::t('cc')); | |
413 | $bcc = str_replace(';', ',', Env::t('bcc')); | |
5e68682e | 414 | |
6ff4f8c0 SJ |
415 | $email_regex = '/^[a-z0-9.\-+_\$]+@([\-.+_]?[a-z0-9])+$/i'; |
416 | foreach (explode(',', $to . ',' . $cc . ',' . $bcc) as $email) { | |
417 | $email = trim($email); | |
418 | if ($email != '' && !preg_match($email_regex, $email)) { | |
419 | $page->trigError("L'adresse email " . $email . ' est erronée.'); | |
420 | $error = true; | |
421 | } | |
422 | } | |
5e68682e | 423 | if (empty($to) && empty($cc) && empty($to2) && empty($bcc) && empty($cc2)) { |
a7d35093 | 424 | $page->trigError("Indique au moins un destinataire."); |
6ff4f8c0 SJ |
425 | $error = true; |
426 | } | |
427 | ||
428 | if ($error) { | |
f3df6d38 | 429 | $page->assign('uploaded_f', PlUpload::listFilenames(S::user()->login(), 'emails.send')); |
5e68682e FB |
430 | } else { |
431 | $mymail = new PlMailer(); | |
432 | $mymail->setFrom($from); | |
433 | $mymail->setSubject($subj); | |
434 | if (!empty($to)) { $mymail->addTo($to); } | |
435 | if (!empty($cc)) { $mymail->addCc($cc); } | |
436 | if (!empty($bcc)) { $mymail->addBcc($bcc); } | |
437 | if (!empty($to2)) { $mymail->addTo($to2); } | |
438 | if (!empty($cc2)) { $mymail->addCc($cc2); } | |
f3df6d38 | 439 | $files =& PlUpload::listFiles(S::user()->login(), 'emails.send'); |
5e68682e FB |
440 | foreach ($files as $name=>&$upload) { |
441 | $mymail->addUploadAttachment($upload, $name); | |
442 | } | |
443 | if (Env::v('nowiki')) { | |
444 | $mymail->setTxtBody(wordwrap($txt, 78, "\n")); | |
445 | } else { | |
446 | $mymail->setWikiBody($txt); | |
447 | } | |
448 | if ($mymail->send()) { | |
faefdbb7 | 449 | $page->trigSuccess("Ton email a bien été envoyé."); |
2d997414 | 450 | $_REQUEST = array('bcc' => S::user()->bestEmail()); |
f3df6d38 | 451 | PlUpload::clear(S::user()->login(), 'emails.send'); |
5e68682e | 452 | } else { |
a7d35093 | 453 | $page->trigError("Erreur lors de l'envoi du courriel, réessaye."); |
f3df6d38 | 454 | $page->assign('uploaded_f', PlUpload::listFilenames(S::user()->login(), 'emails.send')); |
5e68682e | 455 | } |
81b5b746 | 456 | } |
457 | } | |
458 | } else { | |
3360c04f FB |
459 | $res = XDB::query("SELECT data |
460 | FROM email_send_save | |
461 | WHERE uid = {?}", S::i('uid')); | |
462 | if ($res->numRows() == 0) { | |
f3df6d38 | 463 | PlUpload::clear(S::user()->login(), 'emails.send'); |
2d997414 | 464 | $_REQUEST['bcc'] = S::user()->bestEmail(); |
3360c04f FB |
465 | } else { |
466 | $data = unserialize($res->fetchOneCell()); | |
467 | $_REQUEST = array_merge($_REQUEST, $data); | |
468 | } | |
81b5b746 | 469 | } |
470 | ||
2d5264c6 FB |
471 | $uf = new UserFilter(new PFC_And(new UFC_Contact(S::user()), |
472 | new UFC_Registered()), | |
473 | UserFilter::sortByName()); | |
474 | $contacts = $uf->getProfiles(); | |
48e683dd | 475 | $page->assign('contacts', $contacts); |
5e68682e | 476 | $page->assign('maxsize', ini_get('upload_max_filesize') . 'o'); |
2d997414 | 477 | $page->assign('user', S::user()); |
81b5b746 | 478 | } |
479 | ||
26ba053e | 480 | function handler_test($page, $hruid = null) |
5ff3f06b | 481 | { |
e4ecada4 VZ |
482 | require_once 'emails.inc.php'; |
483 | ||
46504fb3 VZ |
484 | if (!S::has_xsrf_token()) { |
485 | return PL_FORBIDDEN; | |
486 | } | |
d0c3e04d VZ |
487 | |
488 | // Retrieves the User object for the test email recipient. | |
dd70cd28 | 489 | if (S::admin() && $hruid) { |
d0c3e04d VZ |
490 | $user = User::getSilent($hruid); |
491 | } else { | |
492 | $user = S::user(); | |
493 | } | |
494 | if (!$user) { | |
495 | return PL_NOT_FOUND; | |
5ff3f06b | 496 | } |
e4ecada4 | 497 | |
d0c3e04d | 498 | // Sends the test email. |
12a587df | 499 | $redirect = new Redirect($user); |
e4ecada4 VZ |
500 | |
501 | $mailer = new PlMailer('emails/test.mail.tpl'); | |
d0c3e04d | 502 | $mailer->assign('email', $user->bestEmail()); |
e4ecada4 | 503 | $mailer->assign('redirects', $redirect->active_emails()); |
d0c3e04d VZ |
504 | $mailer->assign('display_name', $user->displayName()); |
505 | $mailer->assign('sexe', $user->isFemale()); | |
506 | $mailer->send($user->isEmailFormatHtml()); | |
5ff3f06b FB |
507 | exit; |
508 | } | |
509 | ||
26ba053e | 510 | function handler_rewrite_in($page, $mail, $hash) |
3d17e48f FB |
511 | { |
512 | $page->changeTpl('emails/rewrite.tpl'); | |
513 | $page->assign('option', 'in'); | |
514 | if (empty($mail) || empty($hash)) { | |
515 | return PL_NOT_FOUND; | |
516 | } | |
517 | $pos = strrpos($mail, '_'); | |
518 | if ($pos === false) { | |
519 | return PL_NOT_FOUND; | |
520 | } | |
521 | $mail{$pos} = '@'; | |
b4503762 SJ |
522 | $res = XDB::query('SELECT COUNT(*) |
523 | FROM email_redirect_account | |
524 | WHERE redirect = {?} AND hash = {?} AND type = \'smtp\'', | |
3d17e48f FB |
525 | $mail, $hash); |
526 | $count = intval($res->fetchOneCell()); | |
527 | if ($count > 0) { | |
b4503762 | 528 | XDB::query('UPDATE email_redirect_account |
3d17e48f | 529 | SET allow_rewrite = true, hash = NULL |
b4503762 SJ |
530 | WHERE redirect = {?} AND hash = {?} AND type = \'smtp\'', |
531 | $mail, $hash); | |
3d17e48f FB |
532 | $page->trigSuccess("Réécriture activée pour l'adresse " . $mail); |
533 | return; | |
534 | } | |
535 | return PL_NOT_FOUND; | |
536 | } | |
537 | ||
26ba053e | 538 | function handler_rewrite_out($page, $mail, $hash) |
3d17e48f FB |
539 | { |
540 | $page->changeTpl('emails/rewrite.tpl'); | |
541 | $page->assign('option', 'out'); | |
542 | if (empty($mail) || empty($hash)) { | |
543 | return PL_NOT_FOUND; | |
544 | } | |
545 | $pos = strrpos($mail, '_'); | |
546 | if ($pos === false) { | |
547 | return PL_NOT_FOUND; | |
548 | } | |
549 | $mail{$pos} = '@'; | |
b4503762 SJ |
550 | $res = XDB::query('SELECT COUNT(*) |
551 | FROM email_redirect_account | |
552 | WHERE redirect = {?} AND hash = {?} AND type = \'smtp\'', | |
3d17e48f FB |
553 | $mail, $hash); |
554 | $count = intval($res->fetchOneCell()); | |
555 | if ($count > 0) { | |
556 | global $globals; | |
b4503762 SJ |
557 | $res = XDB::query('SELECT e.redirect, e.rewrite, a.hruid |
558 | FROM email_redirect_account AS e | |
559 | INNER JOIN accounts AS a ON (e.uid = a.uid) | |
560 | WHERE e.redirect = {?} AND e.hash = {?}', | |
3d17e48f | 561 | $mail, $hash); |
b4503762 | 562 | XDB::query('UPDATE email_redirect_account |
3d17e48f | 563 | SET allow_rewrite = false, hash = NULL |
b4503762 SJ |
564 | WHERE redirect = {?} AND hash = {?}', |
565 | $mail, $hash); | |
566 | list($mail, $rewrite, $hruid) = $res->fetchOneRow(); | |
3d17e48f FB |
567 | $mail = new PlMailer(); |
568 | $mail->setFrom("webmaster@" . $globals->mail->domain); | |
569 | $mail->addTo("support@" . $globals->mail->domain); | |
570 | $mail->setSubject("Tentative de détournement de correspondance via le rewrite"); | |
b4503762 | 571 | $mail->setTxtBody("$hruid a tenté un rewrite de $mail vers $rewrite. Cette demande a été rejetée via le web"); |
3d17e48f FB |
572 | $mail->send(); |
573 | $page->trigWarning("Un mail d'alerte a été envoyé à l'équipe de " . $globals->core->sitename); | |
574 | return; | |
575 | } | |
576 | return PL_NOT_FOUND; | |
577 | } | |
578 | ||
26ba053e | 579 | function handler_imap_in($page, $hash = null, $login = null) |
2ee43273 FB |
580 | { |
581 | $page->changeTpl('emails/imap_register.tpl'); | |
12a587df | 582 | $user = null; |
2ee43273 | 583 | if (!empty($hash) || !empty($login)) { |
12a587df VZ |
584 | $user = User::getSilent($login); |
585 | if ($user) { | |
1bf36cd1 SJ |
586 | $req = XDB::query('SELECT 1 |
587 | FROM newsletter_ins | |
588 | WHERE uid = {?} AND hash = {?}', | |
589 | $user->id(), $hash); | |
12a587df VZ |
590 | if ($req->numRows() == 0) { |
591 | $user = null; | |
592 | } | |
593 | } | |
2ee43273 FB |
594 | } |
595 | ||
b4503762 | 596 | require_once 'emails.inc.php'; |
2ee43273 | 597 | $page->assign('ok', false); |
12a587df | 598 | if (S::logged() && (is_null($user) || $user->id() == S::i('uid'))) { |
b4503762 | 599 | Email::activate_storage(S::user(), 'imap'); |
2ee43273 | 600 | $page->assign('ok', true); |
2ab3486b SJ |
601 | $page->assign('yourself', S::user()->displayName()); |
602 | $page->assign('sexe', S::user()->isFemale()); | |
12a587df | 603 | } else if (!S::logged() && $user) { |
b4503762 | 604 | Email::activate_storage($user, 'imap'); |
2ee43273 | 605 | $page->assign('ok', true); |
2ab3486b | 606 | $page->assign('yourself', $user->displayName()); |
12a587df | 607 | $page->assign('sexe', $user->isFemale()); |
2ee43273 FB |
608 | } |
609 | } | |
610 | ||
26ba053e | 611 | function handler_broken($page, $warn = null, $email = null) |
81b5b746 | 612 | { |
613 | require_once 'emails.inc.php'; | |
8f201b69 FB |
614 | $wp = new PlWikiPage('Xorg.PatteCassée'); |
615 | $wp->buildCache(); | |
81b5b746 | 616 | |
617 | global $globals; | |
618 | ||
619 | $page->changeTpl('emails/broken.tpl'); | |
620 | ||
40d428d8 | 621 | if ($warn == 'warn' && $email) { |
d4b25d1a | 622 | S::assert_xsrf_token(); |
40d428d8 | 623 | |
a9fd3272 | 624 | // Usual verifications. |
81b5b746 | 625 | $email = valide_email($email); |
a9fd3272 SJ |
626 | $uid = XDB::fetchOneCell('SELECT uid |
627 | FROM email_redirect_account | |
628 | WHERE redirect = {?}', $email); | |
629 | ||
2c93e70e FB |
630 | if ($uid) { |
631 | $dest = User::getWithUID($uid); | |
632 | ||
633 | $mail = new PlMailer('emails/broken-web.mail.tpl'); | |
634 | $mail->assign('email', $email); | |
635 | $mail->assign('request', S::user()); | |
636 | $mail->sendTo($dest); | |
6bb2f79a | 637 | $page->trigSuccess('Email envoyé !'); |
81b5b746 | 638 | } |
40d428d8 VZ |
639 | } elseif (Post::has('email')) { |
640 | S::assert_xsrf_token(); | |
641 | ||
a9fd3272 SJ |
642 | $email = Post::t('email'); |
643 | list(, $domain) = explode('@', $email); | |
644 | $domain = strtolower($domain); | |
81b5b746 | 645 | |
a9fd3272 SJ |
646 | if ($domain == $globals->mail->alias_dom || $domain == $globals->mail->alias_dom2 |
647 | || $domain == $globals->mail->domain || $domain == $globals->mail->domain2) { | |
81b5b746 | 648 | $page->assign('neuneu', true); |
649 | } else { | |
a9fd3272 SJ |
650 | $user = mark_broken_email($email); |
651 | $page->assign('user', $user); | |
652 | $page->assign('email', $email); | |
81b5b746 | 653 | } |
654 | } | |
655 | } | |
9e570fe0 | 656 | |
26ba053e | 657 | function handler_duplicated($page, $action = 'list', $email = null) |
9e570fe0 | 658 | { |
659 | $page->changeTpl('emails/duplicated.tpl'); | |
660 | ||
661 | $states = array('pending' => 'En attente...', | |
a7de4ef7 | 662 | 'safe' => 'Pas d\'inquiétude', |
9e570fe0 | 663 | 'unsafe' => 'Recherches en cours', |
664 | 'dangerous' => 'Usurpations par cette adresse'); | |
665 | $page->assign('states', $states); | |
666 | ||
40d428d8 VZ |
667 | if (Post::has('action')) { |
668 | S::assert_xsrf_token(); | |
46504fb3 | 669 | } |
9e570fe0 | 670 | switch (Post::v('action')) { |
46504fb3 | 671 | case 'create': |
9e570fe0 | 672 | if (trim(Post::v('emailN')) != '') { |
06f4daf9 | 673 | Xdb::execute('INSERT IGNORE INTO email_watch (email, state, detection, last, uid, description) |
9e570fe0 | 674 | VALUES ({?}, {?}, CURDATE(), NOW(), {?}, {?})', |
675 | trim(Post::v('emailN')), Post::v('stateN'), S::i('uid'), Post::v('descriptionN')); | |
676 | }; | |
677 | break; | |
678 | ||
46504fb3 | 679 | case 'edit': |
06f4daf9 | 680 | Xdb::execute('UPDATE email_watch |
9e570fe0 | 681 | SET state = {?}, last = NOW(), uid = {?}, description = {?} |
682 | WHERE email = {?}', Post::v('stateN'), S::i('uid'), Post::v('descriptionN'), Post::v('emailN')); | |
683 | break; | |
684 | ||
46504fb3 | 685 | default: |
9e570fe0 | 686 | if ($action == 'delete' && !is_null($email)) { |
06f4daf9 | 687 | Xdb::execute('DELETE FROM email_watch WHERE email = {?}', $email); |
9e570fe0 | 688 | } |
689 | } | |
690 | if ($action != 'create' && $action != 'edit') { | |
691 | $action = 'list'; | |
692 | } | |
693 | $page->assign('action', $action); | |
694 | ||
695 | if ($action == 'list') { | |
34b566f4 SJ |
696 | $it = XDB::iterRow('SELECT w.email, w.detection, w.state, s.email AS forlife |
697 | FROM email_watch AS w | |
698 | INNER JOIN email_redirect_account AS r ON (w.email = r.redirect) | |
699 | INNER JOIN email_source_account AS s ON (s.uid = r.uid AND s.type = \'forlife\') | |
700 | ORDER BY w.state, w.email, s.email'); | |
9e570fe0 | 701 | |
702 | $table = array(); | |
703 | $props = array(); | |
704 | while (list($email, $date, $state, $forlife) = $it->next()) { | |
705 | if (count($props) == 0 || $props['mail'] != $email) { | |
706 | if (count($props) > 0) { | |
707 | $table[] = $props; | |
708 | } | |
709 | $props = array('mail' => $email, | |
710 | 'detection' => $date, | |
711 | 'state' => $state, | |
712 | 'users' => array($forlife)); | |
713 | } else { | |
714 | $props['users'][] = $forlife; | |
715 | } | |
716 | } | |
717 | if (count($props) > 0) { | |
718 | $table[] = $props; | |
719 | } | |
720 | $page->assign('table', $table); | |
721 | } elseif ($action == 'edit') { | |
34b566f4 SJ |
722 | $it = XDB::iterRow('SELECT w.detection, w.state, w.last, w.description, |
723 | a.hruid AS edit, s.email AS forlife | |
724 | FROM email_watch AS w | |
725 | INNER JOIN email_redirect_account AS r ON (w.email = r.redirect) | |
726 | INNER JOIN email_source_account AS s ON (s.uid = r.uid AND s.type = \'forlife\') | |
727 | INNER JOIN accounts AS a ON (w.uid = a.uid) | |
728 | WHERE w.email = {?} | |
729 | ORDER BY s.email', | |
730 | $email); | |
9e570fe0 | 731 | |
732 | $props = array(); | |
733 | while (list($detection, $state, $last, $description, $edit, $forlife) = $it->next()) { | |
734 | if (count($props) == 0) { | |
735 | $props = array('mail' => $email, | |
736 | 'detection' => $detection, | |
737 | 'state' => $state, | |
738 | 'last' => $last, | |
739 | 'description' => $description, | |
740 | 'edit' => $edit, | |
741 | 'users' => array($forlife)); | |
742 | } else { | |
743 | $props['users'][] = $forlife; | |
744 | } | |
745 | } | |
746 | $page->assign('doublon', $props); | |
747 | } | |
748 | } | |
d4b25d1a | 749 | |
26ba053e | 750 | function handler_lost($page, $action = 'list', $email = null) |
7727ffc7 | 751 | { |
752 | $page->changeTpl('emails/lost.tpl'); | |
eaf30d86 | 753 | |
d4b25d1a | 754 | $page->assign('lost_emails', |
73682f22 | 755 | XDB::iterator('SELECT a.uid, a.hruid, pd.promo |
34b566f4 SJ |
756 | FROM accounts AS a |
757 | INNER JOIN account_types AS at ON (a.type = at.type) | |
758 | LEFT JOIN email_redirect_account AS er ON (er.uid = a.uid AND er.flags = \'active\' AND er.broken_level < 3 | |
759 | AND er.type != \'imap\' AND er.type != \'homonym\') | |
760 | LEFT JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', ap.perms)) | |
761 | LEFT JOIN profile_display AS pd ON (ap.pid = pd.pid) | |
762 | WHERE a.state = \'active\' AND er.redirect IS NULL AND FIND_IN_SET(\'mail\', at.perms) | |
763 | GROUP BY a.uid | |
73682f22 | 764 | ORDER BY pd.promo, a.hruid')); |
7727ffc7 | 765 | } |
67e06366 | 766 | |
26ba053e | 767 | function handler_broken_addr($page) |
67e06366 SJ |
768 | { |
769 | require_once 'emails.inc.php'; | |
770 | $page->changeTpl('emails/broken_addr.tpl'); | |
771 | ||
772 | if (Env::has('sort_broken')) { | |
773 | S::assert_xsrf_token(); | |
774 | ||
775 | $list = trim(Env::v('list')); | |
776 | if ($list == '') { | |
777 | $page->trigError('La liste est vide.'); | |
778 | } else { | |
779 | $valid_emails = array(); | |
780 | $invalid_emails = array(); | |
781 | $broken_list = explode("\n", $list); | |
782 | sort($broken_list); | |
783 | foreach ($broken_list as $orig_email) { | |
35a22488 SJ |
784 | $orig_email = trim($orig_email); |
785 | if ($orig_email != '') { | |
786 | $email = valide_email($orig_email); | |
787 | if (empty($email) || $email == '@') { | |
788 | $invalid_emails[] = trim($orig_email) . ': invalid email'; | |
789 | } elseif (!in_array($email, $valid_emails)) { | |
a9fd3272 SJ |
790 | $nb = XDB::fetchOneCell('SELECT COUNT(*) |
791 | FROM email_redirect_account | |
792 | WHERE redirect = {?}', $email); | |
793 | if ($nb > 0) { | |
35a22488 SJ |
794 | $valid_emails[] = $email; |
795 | } else { | |
a9fd3272 | 796 | $invalid_emails[] = $orig_email . ': no such redirection'; |
35a22488 | 797 | } |
67e06366 SJ |
798 | } |
799 | } | |
800 | } | |
801 | ||
802 | $page->assign('valid_emails', $valid_emails); | |
803 | $page->assign('invalid_emails', $invalid_emails); | |
804 | } | |
805 | } | |
806 | ||
807 | if (Env::has('process_broken')) { | |
808 | S::assert_xsrf_token(); | |
809 | ||
810 | $list = trim(Env::v('list')); | |
811 | if ($list == '') { | |
812 | $page->trigError('La liste est vide.'); | |
813 | } else { | |
67e06366 SJ |
814 | $broken_user_list = array(); |
815 | $broken_list = explode("\n", $list); | |
816 | sort($broken_list); | |
67e06366 | 817 | |
a9fd3272 SJ |
818 | foreach ($broken_list as $email) { |
819 | if ($user = mark_broken_email($email, true)) { | |
820 | if ($user['nb_mails'] > 0) { | |
67e06366 | 821 | $mail = new PlMailer('emails/broken.mail.tpl'); |
a9fd3272 SJ |
822 | $mail->addTo('"' . $user['full_name'] . '" <' . $user['alias'] . '@' . Platal::globals()->mail->domain . '>'); |
823 | $mail->assign('user', $user); | |
67e06366 SJ |
824 | $mail->assign('email', $email); |
825 | $mail->send(); | |
826 | } | |
827 | ||
a9fd3272 SJ |
828 | if (!isset($broken_user_list[$user['alias']])) { |
829 | $broken_user_list[$user['alias']] = array($email); | |
67e06366 | 830 | } else { |
a9fd3272 | 831 | $broken_user_list[$user['alias']][] = $email; |
67e06366 SJ |
832 | } |
833 | } | |
834 | } | |
835 | ||
a9fd3272 SJ |
836 | XDB::execute('UPDATE email_redirect_account |
837 | SET broken_level = broken_level - 1 | |
838 | WHERE flags = \'active\' AND broken_level > 1 | |
839 | AND DATE_ADD(last, INTERVAL 1 MONTH) < CURDATE()'); | |
840 | XDB::execute('UPDATE email_redirect_account | |
841 | SET broken_level = 0 | |
842 | WHERE flags = \'active\' AND broken_level = 1 | |
843 | AND DATE_ADD(last, INTERVAL 1 YEAR) < CURDATE()'); | |
67e06366 SJ |
844 | |
845 | // Output the list of users with recently broken addresses, | |
846 | // along with the count of valid redirections. | |
35a22488 | 847 | require_once 'notifs.inc.php'; |
023c46fb | 848 | pl_cached_content_headers('text/x-csv', 1); |
67e06366 SJ |
849 | |
850 | $csv = fopen('php://output', 'w'); | |
7b58e5e4 | 851 | fputcsv($csv, array('nom', 'promo', 'alias', 'bounce', 'nbmails', 'url', 'corps', 'job', 'networking'), ';'); |
67e06366 SJ |
852 | foreach ($broken_user_list as $alias => $mails) { |
853 | $sel = Xdb::query( | |
a9fd3272 SJ |
854 | 'SELECT a.uid, count(DISTINCT(r.redirect)) AS nb_mails, |
855 | IFNULL(pd.public_name, a.full_name) AS fullname, | |
856 | IFNULL(pd.promo, 0) AS promo, IFNULL(pce.name, \'Aucun\') AS corps, | |
857 | IFNULL(pje.name, \'Aucun\') AS job, GROUP_CONCAT(pn.address SEPARATOR \', \') AS networking | |
858 | FROM email_source_account AS s | |
859 | INNER JOIN accounts AS a ON (s.uid = a.uid) | |
860 | LEFT JOIN email_redirect_account AS r ON (a.uid = r.uid AND r.broken_level = 0 AND r.flags = \'active\' AND | |
861 | (r.type = \'smtp\' OR r.type = \'googleapps\')) | |
862 | LEFT JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET(\'owner\', ap.perms)) | |
863 | LEFT JOIN profile_display AS pd ON (pd.pid = ap.pid) | |
864 | LEFT JOIN profile_corps AS pc ON (pc.pid = ap.pid) | |
865 | LEFT JOIN profile_corps_enum AS pce ON (pc.current_corpsid = pce.id) | |
866 | LEFT JOIN profile_job AS pj ON (pj.pid = ap.pid) | |
867 | LEFT JOIN profile_job_enum AS pje ON (pj.jobid = pje.id) | |
868 | LEFT JOIN profile_networking AS pn ON (pn.pid = ap.pid) | |
869 | WHERE s.email = {?} | |
870 | GROUP BY a.uid', $alias); | |
67e06366 SJ |
871 | |
872 | if ($x = $sel->fetchOneAssoc()) { | |
ae6cd633 | 873 | if ($x['nb_mails'] == 0) { |
e03a98e9 SJ |
874 | $user = User::getSilentWithUID($x['uid']); |
875 | $profile = $user->profile(); | |
876 | WatchProfileUpdate::register($profile, 'broken'); | |
ae6cd633 | 877 | } |
a06602ae | 878 | fputcsv($csv, array($x['fullname'], $x['promo'], $alias, |
6139d6cb | 879 | join(',', $mails), $x['nb_mails'], |
7b58e5e4 SJ |
880 | 'https://www.polytechnique.org/marketing/broken/' . $alias, |
881 | $x['corps'], $x['job'], $x['networking']), ';'); | |
67e06366 SJ |
882 | } |
883 | } | |
884 | fclose($csv); | |
885 | exit; | |
886 | } | |
887 | } | |
888 | } | |
81b5b746 | 889 | } |
890 | ||
a7de4ef7 | 891 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
81b5b746 | 892 | ?> |