Jump to content

[SOLVED] Grab contents in this file:


Graxeon

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;
   }
}

 

 

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.