Jump to content


Photo

Get variables...


  • Please log in to reply
2 replies to this topic

#1 anbu_nin

anbu_nin
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 21 April 2006 - 02:20 PM

Hi everyone I'm new here, I'd like to ask if my php page got something like this in the url
http://www.something.com/something.php?var1=http%3A%2F%2Fmangataz.free.fr%2Fmanga%2Fnaruto.htm&var2=naruto&var3=http%3A%2F%2Fsomething.com%2Fsomething.php%3Fq%3Dnaruto%26var4%3Dhttp%253A%252F%252Fmangataz.free.fr%252Fmanga%252Fnaruto.htm%26imagesrc%3D
Now php understood variable 1 and 2 but couldn't understand variable 3. In variable 1 %3A is ":" and %2F is "/" but once we reach variable 3, we start having %3F which is "?" and %3D which is "=". And then %26 is "&" and %253A becomes ":" and %252F becomes "/" (basicly, since we have another "?", 25 is being added to these things, like %2F becomes %252F....)

Now is there anyway to let php understand the variables that come after var3? I usually use $HTTP_GET_VARS ir request to get variables.......

If there is no way, I thought I could take the entire unknown text as var3 and then replace each occurence of %26, %253A etc by the correct character and then I will be left with a variable, say
$var3 = "http://www.something.com/something.php?q=naruto&var4=......"
now how can I extract var4 or "q" out of var3. I hope I didnt confuse the hell out of you....I'm sorry if I did....

#2 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 22 April 2006 - 01:47 AM

it looks to me like a few things could be going on here, for one you should do a little name changing, don't put spaces in the names of your filenames for your server, and try not to use underscores. Just leave the names together, capital letters if needed, that confuses things, another thing is all of those variables you have listed there are strings. So they should be formatted as follows
var1 = "http%3A%2F%2Fmangataz.free.fr%2Fmanga%2Fnaruto.htm&";
var2 = "naruto&";
var3 = "http%3A%2F%2Fsomething.com%2Fsomething.php%3Fq%3Dnaruto%26";
var4 = "%3Dhttp%253A%252F%252Fmangataz.free.fr%252Fmanga%252Fnaruto.htm%26imagesrc%3D";
as you noticed you had them all bunched together unreadable, secondly you were missing quotation marks, third you didn't have the closing colons like this;. The last one isn't necessary but I do it out of habbit. Now your 4th variable didn't even have an equal symbol, reformat your text like this, make any necessary changes to the urls and your script should run like normal. The section you had before the first one wasn'te ven assigned to a variable. And if you are doing all this because of trying to make it Xhtml compliant by using ampersands, well you don't need to do that for text that is within the
<?php
?>
if it's inside that you don't have a need to replace every little symbol with an ampersand

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 22 April 2006 - 03:22 AM

Use the following code to decode this mess:
<?php
$w = 'http://www.something.com/something.php?var1=http%3A%2F%2Fmangataz.free.fr%2Fmanga%2Fnaruto.htm&var2=naruto&var3=http%3A%2F%2Fsomething.com%2Fsomething.php%3Fq%3Dnaruto%26var4%3Dhttp%253A%252F%252Fmangataz.free.fr%252Fmanga%252Fnaruto.htm%26imagesrc%3D';
echo urldecode(urldecode($w));
$z = parse_url(urldecode(urldecode($w)));
parse_str($z['query'],$x);
echo '<pre>' . print_r($z,true) . print_r($x,true) . '</pre>';
?>

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users