Jump to content

Recommended Posts

Well I tried this but it didn't work :(

 

<?php
$allowed_url = array("umm", //test start
"blankspothere");

$passed_url = $_GET['url']; 

foreach ($allowed_url as $allowed) {
    if(stristr($allowed, $passed_url) !== false) {
      $url='http://www.domain.com/content.php?a=uhh&?b='.$allowed;
      $string = file_get_contents($url); 

      $sxml = new SimpleXmlElement($string);
      $node =  $sxml->user[0]->attributes()->thepage;
      header('Location: '.$node);
        exit;
   }
}

header("Location: http://www.google.com/");

?>

 

I got "Fatal error: Call to a member function attributes() on a non-object on line 13"

Well you would need to look more into the SimpleXML setup, I do not htink you are using it wrong, hence the error.

 

For a preg_match function to do this, this would work.

 

<?php
$string = '<user type="cool" thepage="http%3A%2F%2Fgoogle.com" />';

preg_match("~thepage=\"(.+?)\"~si", $string, $matches);

echo urldecode($matches[1]);
?>

 

As far as which is better, I do not know. I have a hunch that the preg_match is quicker due to it does not have to create an object of all the xml elements since you simple want a static element etc.

Cool, the one you made works perfectly.

 

However...the XML file thing is on a separate file. I can't seem to get this to work, could you help me out? :

 

 

<?php
$allowed_url = array("umm", //test start
"blankspothere");

$passed_url = $_GET['url']; 

foreach ($allowed_url as $allowed) {
    if(stristr($allowed, $passed_url) !== false) {
         $string = 'http://www.domain.com/content.php?a=uhh&?b='.$allowed;

         preg_match("~thepage=\"(.+?)\"~si", $string, $matches);

         header('Location: '.urldecode($matches[1]));
             exit;
   }
}

header("Location: http://www.google.com/");

?>

foreach ($allowed_url as $allowed) {
    if(stristr($allowed, $passed_url) !== false) {
         $string = file_get_contents('http://www.domain.com/content.php?a=uhh&?b='.$allowed);

         preg_match("~thepage=\"(.+?)\"~si", $string, $matches);
       
         header('Location: '.urldecode($matches[1]));
             exit;
   }
}

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.