Jump to content

Need a little help...


devWhiz

Recommended Posts

ok so I have a simple html form

 


<html>
<body>

<form action="urldecode.php" method="post">
<b>URL TO DECODE:</b> <input type="text" name="decode"/>
<input type="submit" value="DECODE"/>

</form>
</body>
</html>


 

Ok the string that would be entered and decoded in the text box is something like this

 

http://api.msappspace.com/proxy/relay.proxy?opensocial_url=http%3A//mob-dynamic-lb1.mobsters09.com/mob/increase_attribute%3Fuser_id%3D530450112%26attribute%3Dmax_health%26session_id%3Db5774838ed75d567c9105733c64fa0ec7e66a950%26auth_key%3Df4815c4135e034f3ad1b1d36a4b952a444e4c9e5%26nocache%3D1301137263349&opensocial_authtype=SIGNED&opensocial_app_url=http%3A//profile.myspace.com/index.cfm%3Ffuseaction%3Duser.viewprofile%26friendid%3D356357051&ts=1301137263350

 

now.. When I hit decode it goes to this script

 


<html>
<body>

<?php

$var = urldecode($_POST['decode']);
echo $var;

?>

</body>
</html>

 

now.. when I hit decode, how can I get the script to remove

 

http://api.msappspace.com/proxy/relay.proxy?opensocial_url= 

 

and

 

&opensocial_authtype=SIGNED&opensocial_app_url=http%3A//profile.myspace.com/index.cfm%3Ffuseaction%3Duser.viewprofile%26friendid%3D356357051&ts=1301137263350

 

so that is just echos out

 

http://mob-dynamic-lb1.mobsters09.com/mob/increase_attribute?user_id=530450112&attribute=max_health&session_id=b5774838ed75d567c9105733c64fa0ec7e66a950&auth_key=f4815c4135e034f3ad1b1d36a4b952a444e4c9e5&nocache=1301137263349

instead of 

http://api.msappspace.com/proxy/relay.proxy?opensocial_url=http://mob-dynamic-lb1.mobsters09.com/mob/increase_attribute?user_id=530450112&attribute=max_health&session_id=b5774838ed75d567c9105733c64fa0ec7e66a950&auth_key=f4815c4135e034f3ad1b1d36a4b952a444e4c9e5&nocache=1301137263349&opensocial_authtype=SIGNED&opensocial_app_url=http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=356357051&ts=1301137263350 

 

Any help is appreciated.. Thank you

 

Link to comment
https://forums.phpfreaks.com/topic/231770-need-a-little-help/
Share on other sites

<?php
$url = "http://api.msappspace.com/proxy/relay.proxy?opensocial_url=http%3A//mob-dynamic-lb1.mobsters09.com/mob/increase_attribute%3Fuser_id%3D530450112%26attribute%3Dmax_health%26session_id%3Db5774838ed75d567c9105733c64fa0ec7e66a950%26auth_key%3Df4815c4135e034f3ad1b1d36a4b952a444e4c9e5%26nocache%3D1301137263349&opensocial_authtype=SIGNED&opensocial_app_url=http%3A//profile.myspace.com/index.cfm%3Ffuseaction%3Duser.viewprofile%26friendid%3D356357051&ts=1301137263350";
$url = urldecode($url);
$parsed = parse_url($url);
$parsed = parse_url($parsed[query]);
$filtered = substr($parsed[query], 0, stripos($parsed[query], '&opensocial_authtype'));
$filtered_url = 'http:'.$parsed[path].'?'.$filtered;
echo $filtered_url.'<br>';
?>

 

This will do the job, taken my precious 10 minutes to make this logic..... ;) enjoy......

Link to comment
https://forums.phpfreaks.com/topic/231770-need-a-little-help/#findComment-1192478
Share on other sites

parse_url builds an array of data from its function and puts out similar to the below array.. so query is a parameter of that array automatically.

 

http://php.net/manual/en/function.parse-url.php

Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)

 

Link to comment
https://forums.phpfreaks.com/topic/231770-need-a-little-help/#findComment-1192500
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.