Overview
Comment:Move POST unsubscribe to index.php as POST does not always handle redirects
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | emails
Files: files | file ages | folders
SHA3-256: d2eaaa7d7b94abea35dd7cb5a9426642d0a58e41a2fc250aa570d77d3c1f8be1
User & Date: bohwaz on 2022-05-30 21:46:33
Other Links: branch diff | manifest | tags
Context
2022-05-31
01:43
Add handle bounce script check-in: a3a07e4318 user: bohwaz tags: emails
2022-05-30
21:46
Move POST unsubscribe to index.php as POST does not always handle redirects check-in: d2eaaa7d7b user: bohwaz tags: emails
21:38
Add script for emails for a factory setup check-in: 8846d1d03f user: bohwaz tags: emails
Changes

Modified src/www/admin/optout.php from [e8a71eafcd] to [541d80a80f].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$email = Emails::getEmailFromOptout($code);
$verify = null;

if (!$email) {
	throw new UserException('Adresse email introuvable.');
}

// RFC 8058
if (!empty($_POST['Unsubscribe']) && $_POST['Unsubscribe'] == 'Yes') {
	$email->setOptout();
	$email->save();
	http_response_code(200);
	echo 'Unsubscribe successful';
	exit;
}

if (!empty($_GET['v'])) {
	if ($email->verify($_GET['v'])) {
		$email->save();
		$verify = true;
	}
	else {
		$verify = false;







<
<
<
<
<
<
<
<
<







15
16
17
18
19
20
21









22
23
24
25
26
27
28
$email = Emails::getEmailFromOptout($code);
$verify = null;

if (!$email) {
	throw new UserException('Adresse email introuvable.');
}










if (!empty($_GET['v'])) {
	if ($email->verify($_GET['v'])) {
		$email->save();
		$verify = true;
	}
	else {
		$verify = false;

Modified src/www/index.php from [1e78903487] to [0b19b27e48].

1
2
3
4

5
6
7
8
9
10
11
















12
13
14
15
<?php

namespace Garradin;


use Garradin\Web\Web;

require __DIR__ . '/_inc.php';

// Handle __un__subscribe URL
if (!empty($_GET['un'])) {
	$params = array_intersect_key($_GET, ['un' => null, 'v' => null]);
















	Utils::redirect('!optout.php?' . http_build_query($params));
}

Web::dispatchURI();




>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




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
<?php

namespace Garradin;

use Garradin\Users\Emails;
use Garradin\Web\Web;

require __DIR__ . '/_inc.php';

// Handle __un__subscribe URL
if (!empty($_GET['un'])) {
	$params = array_intersect_key($_GET, ['un' => null, 'v' => null]);

	// RFC 8058
	if (!empty($_POST['Unsubscribe']) && $_POST['Unsubscribe'] == 'Yes') {
		$email = Emails::getEmailFromOptout($params['un']);

		if (!$email) {
			throw new UserException('Adresse email introuvable.');
		}

		$email->setOptout();
		$email->save();
		http_response_code(200);
		echo 'Unsubscribe successful';
		exit;
	}

	Utils::redirect('!optout.php?' . http_build_query($params));
}

Web::dispatchURI();