4

all, I'm having a problem with my wordpress page while using encrypted $_GET parameters to obtain data. this is my function:

function encryptDecrypt($key, $string, $decrypt)
{
    if($decrypt)
    {
        $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "6");
        return $decrypted;
    }else{
        $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
        return $encrypted;
    }
}

I'm using the registered user's mail to encrypt it and to retrieve his data using $_GET parameter. The problem is that if i use the normal email address (not encrypted, which it will be quite useless and dangerous) the $_GET request works. If i use an encrypted email, I only get a 404 Error.

This is what I've tried so far:

$m=urlencode(encryptDecrypt('mail',$mail,false));    
$msg.="<br><a href='siteurl/pageurl/?m=".$m."'>Click here</a>";

Example of encrypted mail which is used in the URL to send data:

VOvk4Wh%2FpMzm21lQNrFnvBcwRWLw6ZVPOMe0VCi2t3g%3D

and, in the "retrieving" page:

urldecode($_GET['m']);

Example of encrypted mail which is used in the URL to retrieve data:

VOvk4Wh/pMzm21lQNrFnvBcwRWLw6ZVPOMe0VCi2t3g=

When i open the "receiving" page with that link i get the 404 Error

UPDATE+

I've solved the problem, which was the 'm' as $_GET parameter, which is a wordpress's default taxonomy... Thanks to you all for helping me. :)

4

As the OP found out, m is a reserved parameter name that should be use only by core (indicates month). Solution is to use some other parameter name (always use your own prefixes in all global contexts!).

  • Many of us discover this the hard way ;-) – birgire Jan 20 '18 at 17:34
0

first off; turn the wp_debug function on if you haven't already. (wp_config.php). This should give you some additional error data. Secondly; it looks like you are using urldecode, but not encoding your string. If you're including an email address be sure to urlencode your data as well.

  • i use urlencode to write the string on the a tag's href and then, on that page, i use urldecode to retrieve the original string... By the way, if I get a 404 Error the problem should be on the "link writing" function, or am I missing something? WP_DEBUG is already enabled – CapitanFindus Dec 3 '14 at 10:58
  • Hi sorry, I overlooked that. The solution is easier I think :) If the link you posted is the code you are really using then the problem lies with the quote '"'. <a href="siteurl/page/?m="<?php echo urlencode(encryptDecrypt('mail',$mail,false)); ?>"> you are closing the quotes when addding the php part. – john23klipp Dec 3 '14 at 11:05
  • try: <a href="siteurl/page/?m=<?php echo urlencode(encryptDecrypt('mail',$mail,false)); ?>"> – john23klipp Dec 3 '14 at 11:05
  • Isn't it the same thing as I've done so far? – CapitanFindus Dec 3 '14 at 11:34
  • In your code there is a closing double quote (") after ...?/m". This says that your url ends there. However, in your link there is more to come. Check the source code of the link in your browser. It will look messed up. – john23klipp Dec 3 '14 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.