Redirect with email on "?" strange code [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm doing a system to reset password and I need pass email on URL like this:
http://example.com/reset?email=email#domain.com&token=89s8ads9
I'm doing this:
return $this->redirect(array(
'controller'=> 'site',
'action'=> 'resetaSenha',
'?'=> array('email'=> 'email=email#domain.com', 'token'=> 89s8ads9)
)
);
But is returning this:
http://example.com/reset?email=email%40domain.com&token=89s8ads9

%40 is # urlencoded.
Something in your code is converting # to %40 for you. http://php.net/manual/en/function.urlencode.php
You can decode it with urlencode($_GET['email']); which will replace the %40 with an #

I did'nt realized that even on url with ?email=email%40domain, when we access from controller $this->request->query['email'], we obtain the email decoded in the right way email#domain.com.

Do a captcha check, and deny access to the e-mail sender after the session var is unset.

Related

Escaping regex in php [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have regexes stored in a txt file. How do I escape them in PHP? preg_quote doesn't help if I use the output in an array, throws fatal error. (The following each are on new lines in the txt file)
/[^a-z\/'"]eval\([^\)]+['"\s\);]+/i
/\$auth_pass\s*=.+;/i
/document\.write\((['"])<iframe .+<\/iframe>\1\);*/i
/preg_replace\s*\(.+[\/\#\|][i]*e[i]*['"].+\)/i
/<\?.+?exec\(.+?system\(.+?passthru\(.+fwrite\(.+/s
/RewriteRule [^ ]+ http\:\/\/(?!127\.).*/i
/<\?[\shp]*\#?error_reporting\(0\);.+?[a-z0-9\/\-\='"\.]{2000}.*?($|\?>)/i
/\<a [^\>]+\>\<span style="color\:\#F1EFE4;"\>(.+?)\<\/span\>\<\/a\>\<span style="color\:\#F1EFE4;"\>(.+?)\<\/span\>/i
/(<!\d)\$[\$\{]*[a-z\-\_0-9]+[\} \t]*(\[[^\]]+\][ \t]*)*\(.*?\)\;/i
/\#(\w+)\#.+?\#\/\1\#/is
/(\$[a-z_0-9]+[=\s\#]+)?create_function\([^,]+,[\s\$\.\[\]a-z_0-9]+[\s\)]+;*/i
/json2\.min\.js/i
/(RewriteCond \%\{HTTP_USER_AGENT\} .+\s+)+RewriteRule \^.*\$ http:\/\/(?!127\.).*/i
/<title>[^<]*hack[3e][rd]/i
I think you need to adjust your call to preg_quote(). Something like this:
Preg_match("|" . preg_quote($str, "|") . "|", $content->content)
See another post with a similar question:
PHP String to Regex

Encoding equals symbol to html equivalent php [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I attempted encoding a '=' symbol to its html equivalent through the use of:
htmlentities("This is my test and it = this");
The result is:
<p>This is my test and it = this</p>1
Notice how the equals sign is not encoded? I know there is a HTML equivalent.
What is an alternative function I can use to encode this string?
Thanks.
I know there is a HTML equivalent
The equals sign isn't encoded for HTML, there is no reason to do so.
You might be thinking of URL-encoding, which would be %3d:
urlencode("This is my test and it = this");
// => "This+is+my+test+and+it+%3D+this"
There's no need to encode the =; it's HTML-safe. If you really want to, though: =
echo str_replace('=', '=', htmlentities("This is my test and it = this"));
Demo

Checking validity url in php [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Нi guуs. I russian php noob.
I have the following code:
if($rr['site']) echo '<a target="_blank" href="http://'.$rr['site'].'" class="">'.$rr['site'].'</a>';
Need to make a valid of the user a url HTTP there or not. Otherwise it outputs - http://http://siteurl
Prompt me how to do it? pliz
Maybe, there is a solution - How do I remove http, https and slash from user input in php
but i need an example with my code.
I would be grateful for any help.
I would do the opposite. Instead of removing http:// or https:// and then adding it again, I would just check if the string starts with http:// or https://, and add http:// only if it doesn't.
Something like:
if($rr['site']) {
$url = preg_match('/^https?:\/\//', $rr['site']) ? $rr['site'] : 'http://'.$rr['site'];
echo '<a target="_blank" href="http://'.$url.'" class="">'.$url.'</a>';
}

url encoding issue. instead %50 its passing space..how to pass %50 through urlencoded url [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have tried to pass a variable trough url... its %50.
I am doing urlencoding to pass other languages through the url.
At that time %50 also been converted to a space or something else.
Can anyone help me to find out a way to send %50 as a variable through urlencoded link(url).
<?php
$string = '%50';
echo $encoded = urlencode($string);
// returns %2550
echo urldecode($encoded);
// returns %50
?>
So if you want to pass $string to a url you write something like:
http://yoursite.com/script.php?string=$encoded
To get your original string value you can just use $_GET in your script.php:
echo $_GET["string"];
// returns %50

How to convert to a link using Rrawurldecode()? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a host of files that generate link like this for hosted files:
http://endertec.com.br/hf/see-img.php?img=http://www.endertec.com.br/hf/do.php?imgf=Fav2.png
But when I see link like this on Facebook, it looks like this:
http://endertec.com.br/hf/see-img.php?img=http%3A%2F%2Fwww.endertec.com.br%2Fhf%2Fdo.php%3Fimgf%3Fav2.png
So I researched ways to convert it, and got the following code:
<?php
$str = 'http://www.endertec.com.br'.$_SERVER['REQUEST_URI'];
$src = str_replace('see-img.php?img=' , '' ,stristr($str , 'see-img.php?img='));
string rawurldecode ( string $src )
echo '<img src="'.$src.'"/>';
?>
But for some reason it does not work, does anyone know how it might work?
You need to store your rawurldecode in something.. try something like this:
$decoded_src = rawurldecode($src);
echo '<img src="'.$decoded_src.'" />';

Categories