Jump to content

[SOLVED] Loading URL from XML


Graxeon

Recommended Posts

How can I get the URL in "Config/Media/Content/Video" from this XML file?

 

Here are my attempts, but I'm messing up a lot :/. I don't get an error message...the page just keeps trying to load.

 

<?php

if (isset($_GET['url'])) {

  $converter = array('blankspot' => 'blanks',
  'soccer' => '906',
  'blankspothere' => 'blank');
  $url = $_GET['url']; 

  if (isset($converter[$url])) {
  $url='/flv_player/data/playerConfigEmbed/'.$converter[$url] . '.xml';
  $sxml = simplexml_load_file($url);

  list($node) = $sxml->xpath('/config/media/content/video');
  header('Location: '.$node['url']);
           exit;
   }
}

?>

 

And an edit:

 

<?php
      $url='/flv_player/data/playerConfigEmbed/'.$converter[$url] . '.xml';
      $string = file_get_contents($url); 

      $sxml = new SimpleXmlElement($string);
      $node =  $sxml->config->media->content->video()->SD;
      header('Location: '.$node);
           exit;
   }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/
Share on other sites

I'm bad at this :/

 

So like this?

 

<?php
if (isset($_GET['url'])) {

  $converter = array('blankspot' => 'blanks',
  'soccer' => '906',
  'blankspothere' => 'blank');
  $url = $_GET['url']; 

  if (isset($converter[$url])) {
$xmlContent = '/flv_player/data/playerConfigEmbed/'.$converter[$url] . '.xml';
$xml = @simplexml_load_file ($xmlContent);

if ($xml):
   echo (string)$xml->media->content->video['SD'];
endif;
   }
}

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

?>

 

That should just print the URL from what I understand. But it doesn't...again it just keeps loading (and nothing is actually loading).

 

If I can get it to print then directing to it is easy.

are you sure '/flv_player/data/playerConfigEmbed/'.$converter[$url] . '.xml' is the correct URL .. have you tried echo'ing out $xmlContent to make sure your $converter[$url] is right?

 

your header() redirect, why is that there?  that's just going to redirect you right off that page (and possibly into an infinite loop if you script is on the homepage) .. lose that redirect, or put it in a condition.

The header redirect at the very bottom leads to the home page in case one of the inputs are not allowed. Example: file.php?url=soccer is allowed. file.php?url=1234 is not allowed so it redirects to the homepage.

 

Now, if "soccer" was entered then the file would take the contents (config/media/content/video SD) from http://www.sqweasel.com/flv_player/data/playerConfigEmbed/906.xml. Then, the script would direct the user to that content (in this case, http://www.sqweasel.com/files/70dd27861e3dea2d.flv, which is in the "video SD" tag).

 

So how would I go about doing this? I tried but can't seem to get the coding right.

You dont need an xml list to redirect for a file download

 

 
function redirect( $url ){
    if (! headers_sent( ) ){
   
        header( "Location: ".$url );
        exit( 0 );
    }
    echo "<script language=Javascript>document.location.href='".$url."';</script>";
    exit( 0 );
}

redirect("http://www.sqweasel.com/files/70dd27861e3dea2d.flv");

 

and in htaccess force the download

 

# instruct browser to download multimedia files
AddType application/octet-stream .avi
AddType application/octet-stream .mpg
AddType application/octet-stream .wmv
AddType application/octet-stream .mp4
AddType application/octet-stream .mov

Can't see why this shouldn't work:

 

<?php
if (isset($_GET['url'])) {
$converter = array(
	'blankspot' => 'blanks',
	'soccer' => '906',
	'blankspothere' => 'blank'
);
$url = $_GET['url'];

if (isset($converter[$url])) {
	$xml = @simplexml_load_file('/flv_player/data/playerConfigEmbed/' . $converter[$url] . '.xml');
	if ($xml) {
		echo (string) $xml->media->content->video['SD'];
		exit;
	}
}
}
header('Location: http://www.sqweasel.com/');
?>

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.