Welcome Guest, Not a member yet? Register   Sign In
Allowing all base64 encoding characters in URI
#1

[eluser]Gewa[/eluser]
Hi .

Actually I need to encode all external links on website to some string like



blablablabladasdas4124124125

then use mysite.com/redirect/goto/blablablabladasdas4124124125 link


then to decode it in goto controller and make redirect.


I saw the base64 is one solution but some characters, i guess = one cause not allowed error.

Any help please...


Or help me to fix to allow all alphabet of base64 encoding or other encoding function???


Please help
#2

[eluser]Xeoncross[/eluser]
Base 64 is the way to go - I use it to encode a $return_to variable so that after a login or something I can send the user back to wherever they were before I asked them to login.
Code:
//Construct current URL for functions that "return_to"
$return_to = base64_encode($this->uri->uri_string());

//Send back to the page
redirect(base64_decode($return_to));
#3

[eluser]Gewa[/eluser]
Yes I understand. that the base64 is the way to do it but for example it will couse

NOT ALLOWED CHARACTERS problem....
#4

[eluser]Xeoncross[/eluser]
Then allow those characters in the config.
#5

[eluser]Gewa[/eluser]
Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';

what to add to above chars to allow all chars from base64 alphabet?
#6

[eluser]pistolPete[/eluser]
The base64 alphabet is shown here: http://www.garykessler.net/library/base64.html

You need to add +/=.
#7

[eluser]Gewa[/eluser]
Thanks a lot!!!!
#8

[eluser]Gewa[/eluser]
After I added what you said

Code:
A PHP Error was encountered

Severity: Warning

Message: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 18

Filename: libraries/URI.php

Line Number: 189
An Error Was Encountered

The URI you submitted has disallowed characters.
#9

[eluser]pistolPete[/eluser]
Which CI version are you using?
How does your permitted_uri_chars now look exactly?
I just tried it using the following line, and it's working:
Code:
$config['permitted_uri_chars'] = '+=\a-z 0-9~%.:_-';
Maybe you appended the characters instead of prepending? Then the minus sign at the end is interpreted as a range operator in the regular expression.
#10

[eluser]Gewa[/eluser]
version is 1.7.1
What you gave worked. Thank you. Sometimes I am so dude in PHP...Smile))




Theme © iAndrew 2016 - Forum software by © MyBB