groucho75 / alo-easymail

ALO EasyMail Newsletter, a newsletter plugin for WordPress.
http://wordpress.org/plugins/alo-easymail/
GNU General Public License v2.0
12 stars 19 forks source link

Newsletter confirmation e-mail activation not working. #7

Open grafxflow opened 9 years ago

grafxflow commented 9 years ago

I had an issue with the confirmation e-mail activation url not working.

h**p://www.website.com/newsletter/?lang=en&ac=activate&em1=test&em2=email.net&uk=randomcode

I have managed to sort it by changing the code in all-easymail-subscr-page.php...

// Email
$em1 = ( isset($_REQUEST['em1']) ) ? $_REQUEST['em1'] : '';
$em2 = ( isset($_REQUEST['em2']) ) ? $_REQUEST['em2'] : '';
$concat_email = $em1 . "@" . $em2; 
$email  = ( is_email($concat_email) ) ? $concat_email : false;

$unikey = ( isset($_REQUEST['uk']) ) ? preg_replace( '/[^a-zA-Z0-9]/i', '', $_REQUEST['uk'])  : false;
$action = ( isset($_REQUEST['ac']) && in_array( $_REQUEST['ac'], $allowed_actions) ) ? $_REQUEST['ac'] : false;

to

$parsed = parse_url(parse_url($_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI], PHP_URL_QUERY));
parse_str($parsed['path'], $get_array);

// Email
$em1 = ( isset($get_array['em1']) ) ? $get_array['em1'] : '';
$em2 = ( isset($get_array['em2']) ) ? $get_array['em2'] : '';
$concat_email = $em1 . "@" . $em2; 
$email  = ( is_email($concat_email) ) ? $concat_email : false;
$unikey = ( isset($get_array['uk']) ) ? preg_replace( '/[^a-zA-Z0-9]/i', '', $get_array['uk'])  : false;
$action = ( isset($get_array['ac']) && in_array( $get_array['ac'], $allowed_actions) ) ? $get_array['ac'] : false;

Is anybody else having this issue? or has another fix?

grafxflow commented 9 years ago

Worth doing a 'Pull request'? with the amended version.

groucho75 commented 9 years ago

Hi grafxflow, thanks a lot. As you like, you can do a pull request, or I'll add this code in plugin master.

grafxflow commented 9 years ago

Okay have done a 'Pull request', but I would still like to know if anybody else is having the same problem.

groucho75 commented 9 years ago

I understand. Anyway, I see that my original old code is not very good... your proposal is of course much better, but we should use get_query_var to retrieve appended vars, so I think I have to update some more pieces of code to be a bit more compliant to guidelines.

https://codex.wordpress.org/Function_Reference/get_query_var

grafxflow commented 9 years ago

Cool. Thanks for the update.

grafxflow commented 9 years ago

The activate page has stopped working from the update. I think the url is the issue.

My url has the following structure:

http://{blog_url}/newsletter/?lang=en&ac=activate&em1=email_account&em2=domain.ltd&uk={uniquekey}

There maybe an issue with it not working outside the home url i.e. http://{blog_url}/ NOT http://{blog_url}/newsletter/

I have had to change the code temporarily to see if there is a way around the url issue.