CodeIgniter Forums
Allowing all base64 encoding characters in URI - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Allowing all base64 encoding characters in URI (/showthread.php?tid=15913)

Pages: 1 2


Allowing all base64 encoding characters in URI - El Forum - 02-18-2009

[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


Allowing all base64 encoding characters in URI - El Forum - 02-18-2009

[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));



Allowing all base64 encoding characters in URI - El Forum - 02-19-2009

[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....


Allowing all base64 encoding characters in URI - El Forum - 02-19-2009

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


Allowing all base64 encoding characters in URI - El Forum - 02-20-2009

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


Allowing all base64 encoding characters in URI - El Forum - 02-20-2009

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

You need to add +/=.


Allowing all base64 encoding characters in URI - El Forum - 02-20-2009

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


Allowing all base64 encoding characters in URI - El Forum - 02-20-2009

[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.



Allowing all base64 encoding characters in URI - El Forum - 02-20-2009

[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.


Allowing all base64 encoding characters in URI - El Forum - 02-20-2009

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