Jump to content

XML generated by PHP


Graxeon

Recommended Posts

I have an idea of how this could work...but I don't really know the exact coding for it:

 

 

A user requests something like "video.php?s=stickman&e=4"

 

s = show
e = episode

 

Now there are many combinations that can be made with that request. Examples:

 

video.php?s=nature&e=70

video.php?s=car&e=10

 

This is what would be run in video.php:

 

<?php
if $s=car
-then $i='http://domain.com/car.png'
-then $l='http://domain.com/car.html'
-then $t=14
-then run:
--Take $e and match it with the corresponding number (example: video.php?a=car&e=2 would correspond with $2)
--$1='http://domain.com/car1.flv'
--$2='http://domain.com/car2.flv'
--$3='http://domain.com/car3.flv'

or

if $s=nature
-then $i='http://domain.com/nature.png'
-then $l='http://domain.com/nature.html'
-then $t=91
-then run:
--Take $e and match it with the corresponding number (example: video.php?a=nature&e=1 would correspond with $1)
--$1='http://domain.com/nature1-1.flv';'http://domain.com/nature1-2.flv';'http://domain.com/nature1-3.flv'
--$2='http://domain.com/nature2-1.flv';'http://domain.com/nature2-2.flv'
--$3='http://domain.com/nature3-1.flv';'http://domain.com/nature3-2.flv';'http://domain.com/nature3-3.flv';'http://domain.com/nature3-4.flv'

or

if $s=stickman
-then $i='http://domain.com/stickman.png'
-then $l='http://domain.com/stickman.html'
-then $t=43
-then run:
--Take $e and match it with the corresponding number (example: video.php?a=stickman&e=3 would correspond with $3)
--$1='http://domain.com/stickman1.flv'
--$2='http://domain.com/stickman2.flv'
--$3='http://domain.com/stickman3.flv'

//etc, etc

 

Then take the values and generate an XML file. Let's say that the request was "video.php?s=nature&e=3":

 

echo all of this:

<?xml version="1.0" encoding="UTF-8"?>

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>

//The first track is a little different from the rest
<track>
<annotation>$s</annotation>
<location>$i</location>
<title>$t</title>
<info>$l</info>
</track>

<track>
<annotation>$s</annotation>
<location>$e$3-first URL</location>//note the difference in the other tracks for the "location" tag
<title>$t</title>
<info>$l</info>
</track>

<track>
<annotation>$s</annotation>
<location>$e$3-second URL</location>//note the difference in the other tracks for the "location" tag
<title>$t</title>
<info>$l</info>
</track>

<track>
<annotation>$s</annotation>
<location>$e$3-third URL</location>//note the difference in the other tracks for the "location" tag
<title>$t</title>
<info>$l</info>
</track>

<track>
<annotation>$s</annotation>
<location>$e$3-fourth URL</location>//note the difference in the other tracks for the "location" tag
<title>$t</title>
<info>$l</info>
</track>

//etc, etc until all of the different URLs were implemented (in this case there were 4 different URLs within the 
//$3 of $e in $nature)

</trackList>
</playlist>

 

The final generated product of "video.php?s=nature&e=3" would then look like this:

 

<?xml version="1.0" encoding="UTF-8"?>

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>

//The first track is a little different from the rest
<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature.png</location>
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature3-1.flv</location>//note the difference in the other tracks for the "location" tag
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature3-2.flv</location>//note the difference in the other tracks for the "location" tag
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature3-3.flv</location>//note the difference in the other tracks for the "location" tag
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature3-4.flv</location>//note the difference in the other tracks for the "location" tag
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

</trackList>
</playlist>

 

 

That's it, if you can help me out I would be very grateful :).

 

(I just need the basic skeleton of this)

 

 

Thank you :)

Link to comment
Share on other sites

Here is my attempt at starting this...a lot of things are wrong but at least you can see why I need help:

 

<?php
if ($s=="nature")
  $_GET['e'];
  $i="http://domain.com/nature.png";
  $l="http://domain.com/nature.html";
  $t="112";
  $1="1"
  $2="2"
  $1 = array("http://domain.com/nature1-1.flv",
  "http://domain.com/nature1-2.flv",
  "http://domain.com/nature1-3.flv",
  "http://domain.com/nature1-4.flv");
  $2 = array("http://domain.com/nature2-1.flv",
  "http://domain.com/nature2-2.flv",
  "http://domain.com/nature2-3.flv",
  "http://domain.com/nature2-4.flv");

  if ($_GET['e']==$1)
     foreach ($1 as $episode)
//I'm lost here. I don't know if I've done everything right so far and I don't know how to continue.

  echo "Have a nice weekend!"; 
elseif ($s=="Car")
  echo "Have a nice Sunday!"; 
else
  echo "Have a nice day!"; 

?>

Link to comment
Share on other sites

$car1 = http://domain.com/car1.flv;
$car2 = http://domain.com/car2.flv;
$car3 = http://domain.com/car3.flv;

$nature1 = array("http://domain.com/nature1-1.flv",
  "http://domain.com/nature1-2.flv",
  "http://domain.com/nature1-3.flv",
  "http://domain.com/nature1-4.flv");

$nature2 = array("http://domain.com/nature2-1.flv",
  "http://domain.com/nature2-2.flv",
  "http://domain.com/nature2-3.flv",
  "http://domain.com/nature2-4.flv");

$stickman1 = 'http://domain.com/stickman1.flv';
$stickman2 = 'http://domain.com/stickman2.flv';
$stickman3 = 'http://domain.com/stickman3.flv';

$annotation = $_GET['s'];
$var = $annotation . $_GET['e'];
$locations = $$var;


switch($annotation)
{
  case 'car':
    $image = 'http://domain.com/car.png';
    $info = 'http://domain.com/car.html';
    $title = 14;
    break;
  case 'nature':
    $image = "http://domain.com/nature.png";
    $info = "http://domain.com/nature.html";
    $title = 91;
    break;
  case 'stickman':
    $image = 'http://domain.com/stickman.png';
    $info = 'http://domain.com/stickman.html';
    $title = 43;
    break;
}

$xml = '<track>' . PHP_EOL;
$xml .= '<annotation>' . $annotation . '</annotation'> . PHP_EOL;
$xml .= '<location>' . $image . '</location>' . PHP_EOL;
$xml .= '<title>' . $title . '</title>' . PHP_EOL;
$xml .= '<info>' . $info . '</info>' . PHP_EOL;
$xml .= '</track>' . PHP_EOL;

foreach($locations as $location)
{
  $xml = '<track>' . PHP_EOL;
  $xml .= '<annotation>' . $annotation . '</annotation'> . PHP_EOL;
  $xml .= '<location>' . $location . '</location>' . PHP_EOL;
  $xml .= '<title>' . $title . '</title>' . PHP_EOL;
  $xml .= '<info>' . $info . '</info>' . PHP_EOL;
  $xml .= '</track>' . PHP_EOL;
}

 

This should get you going in the right direction. It hasn't been tested, so there may be a couple of errors in it, and I left out opening and closing XML stuff. But essentially, this should help.

Link to comment
Share on other sites

Alright, cool. But I am getting an error on line 45: Parse error: syntax error, unexpected '.'

 

I tried removing them but it didn't do anything :(. (oh...btw I added single quotes in the $car things)

 

<?php
$car1 = 'http://domain.com/car1.flv';
$car2 = 'http://domain.com/car2.flv';
$car3 = 'http://domain.com/car3.flv';

$nature1 = array("http://domain.com/nature1-1.flv",
  "http://domain.com/nature1-2.flv",
  "http://domain.com/nature1-3.flv",
  "http://domain.com/nature1-4.flv");

$nature2 = array("http://domain.com/nature2-1.flv",
  "http://domain.com/nature2-2.flv",
  "http://domain.com/nature2-3.flv",
  "http://domain.com/nature2-4.flv");

$stickman1 = 'http://domain.com/stickman1.flv';
$stickman2 = 'http://domain.com/stickman2.flv';
$stickman3 = 'http://domain.com/stickman3.flv';

$annotation = $_GET['s'];
$var = $annotation . $_GET['e'];
$locations = $$var;


switch($annotation)
{
  case 'car':
    $image = 'http://domain.com/car.png';
    $info = 'http://domain.com/car.html';
    $title = 14;
    break;
  case 'nature':
    $image = "http://domain.com/nature.png";
    $info = "http://domain.com/nature.html";
    $title = 91;
    break;
  case 'stickman':
    $image = 'http://domain.com/stickman.png';
    $info = 'http://domain.com/stickman.html';
    $title = 43;
    break;
}

$xml = '<track>' . PHP_EOL;
$xml .= '<annotation>' . $annotation . '</annotation'> . PHP_EOL;
$xml .= '<location>' . $image . '</location>' . PHP_EOL;
$xml .= '<title>' . $title . '</title>' . PHP_EOL;
$xml .= '<info>' . $info . '</info>' . PHP_EOL;
$xml .= '</track>' . PHP_EOL;

foreach($locations as $location)
{
  $xml = '<track>' . PHP_EOL;
  $xml .= '<annotation>' . $annotation . '</annotation'> . PHP_EOL;
  $xml .= '<location>' . $location . '</location>' . PHP_EOL;
  $xml .= '<title>' . $title . '</title>' . PHP_EOL;
  $xml .= '<info>' . $info . '</info>' . PHP_EOL;
  $xml .= '</track>' . PHP_EOL;
}
?>

Link to comment
Share on other sites

<?php
$car1 = 'http://domain.com/car1.flv';
$car2 = 'http://domain.com/car2.flv';
$car3 = 'http://domain.com/car3.flv';

$nature1 = array("http://domain.com/nature1-1.flv",
  "http://domain.com/nature1-2.flv",
  "http://domain.com/nature1-3.flv",
  "http://domain.com/nature1-4.flv");

$nature2 = array("http://domain.com/nature2-1.flv",
  "http://domain.com/nature2-2.flv",
  "http://domain.com/nature2-3.flv",
  "http://domain.com/nature2-4.flv");

$stickman1 = 'http://domain.com/stickman1.flv';
$stickman2 = 'http://domain.com/stickman2.flv';
$stickman3 = 'http://domain.com/stickman3.flv';

$annotation = $_GET['s'];
$var = $annotation . $_GET['e'];
$locations = $$var;


switch($annotation)
{
  case 'car':
    $image = 'http://domain.com/car.png';
    $info = 'http://domain.com/car.html';
    $title = 14;
    break;
  case 'nature':
    $image = "http://domain.com/nature.png";
    $info = "http://domain.com/nature.html";
    $title = 91;
    break;
  case 'stickman':
    $image = 'http://domain.com/stickman.png';
    $info = 'http://domain.com/stickman.html';
    $title = 43;
    break;
}

$xml = '<track>' . PHP_EOL;
$xml .= '<annotation>' . $annotation . '</annotation>' . PHP_EOL;
$xml .= '<location>' . $image . '</location>' . PHP_EOL;
$xml .= '<title>' . $title . '</title>' . PHP_EOL;
$xml .= '<info>' . $info . '</info>' . PHP_EOL;
$xml .= '</track>' . PHP_EOL;

foreach($locations as $location)
{
  $xml = '<track>' . PHP_EOL;
  $xml .= '<annotation>' . $annotation . '</annotation>' . PHP_EOL;
  $xml .= '<location>' . $location . '</location>' . PHP_EOL;
  $xml .= '<title>' . $title . '</title>' . PHP_EOL;
  $xml .= '<info>' . $info . '</info>' . PHP_EOL;
  $xml .= '</track>' . PHP_EOL;
}
?>

 

You had a single quote in the wrong place and this stupid editor just will not allow me to post the code properly... When I view the line inside the foreach for "annotation", the single quote is inside the annotation closing tag... No matter how I try and post it here, it puts it back inside.

 

Link to comment
Share on other sites

There aren't any errors but it doesn't do anything :/

 

http://fr33.ulmb.com/gr/grall4.php?s=car&e=1

 

Oh hey...I also have some questions with the script that you edited:

 

In the "switch" part it has cases for car/nature/stickman under the "s" input. However...how do those have anything to do with car1/car2/car3/nature1/nature2/stickman1/stickman2/stickman3?

 

Also, what is "PHP_EOL"?

Link to comment
Share on other sites

Lol...I forgot about echoing xD.

 

Well I added "echo $xml" at the end of the script but all I get is:

 

<track>
<annotation>nature</annotation>
<location>http://domain.com/nature1-4.flv</location>
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

 

Umm...I don't understand how to get all of the stuff to come out correctly.

 

Why is nature1-4.flv the only that shows? I need everything that is within an array to show up in individual tracks.

 

So if I requested http://fr33.ulmb.com/gr/grall4.php?s=nature&e=1, I would get:

 

<?xml version="1.0" encoding="UTF-8"?>

<playlist version="1" xmlns="http://xspf.org/ns/0/">
   <trackList>

//The first track is a little different from the rest
<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature.png</location>
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature1-1.flv</location>//note the difference in the other tracks for the "location" tag
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature1-2.flv</location>//note the difference in the other tracks for the "location" tag
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature1-3.flv</location>//note the difference in the other tracks for the "location" tag
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

<track>
<annotation>Nature</annotation>
<location>http://domain.com/nature1-4.flv</location>//note the difference in the other tracks for the "location" tag
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

   </trackList>
</playlist>

Link to comment
Share on other sites

Patience mate. Not all of us are on the same time zone as you.

 

First, there were a couple errors in the code - as I mentioned I didn't test it. It was just supposed to point you in the right direction, though it looks like it was maybe above what you were expecting. Anyways, this code will do what you want:

 

<?php
$car1 = array('http://domain.com/car1.flv');
$car2 = array('http://domain.com/car2.flv');
$car3 = array('http://domain.com/car3.flv');

$nature1 = array("http://domain.com/nature1-1.flv",
  "http://domain.com/nature1-2.flv",
  "http://domain.com/nature1-3.flv",
  "http://domain.com/nature1-4.flv");

$nature2 = array("http://domain.com/nature2-1.flv",
  "http://domain.com/nature2-2.flv",
  "http://domain.com/nature2-3.flv",
  "http://domain.com/nature2-4.flv");

$stickman1 = 'http://domain.com/stickman1.flv';
$stickman2 = 'http://domain.com/stickman2.flv';
$stickman3 = 'http://domain.com/stickman3.flv';

$annotation = $_GET['s'];
$var = $annotation . $_GET['e'];
$locations = $$var;

switch($annotation)
{
  case 'car':
    $image = 'http://domain.com/car.png';
    $info = 'http://domain.com/car.html';
    $title = 14;
    break;
  case 'nature':
    $image = "http://domain.com/nature.png";
    $info = "http://domain.com/nature.html";
    $title = 91;
    break;
  case 'stickman':
    $image = 'http://domain.com/stickman.png';
    $info = 'http://domain.com/stickman.html';
    $title = 43;
    break;
}

$xml = '<track>' . PHP_EOL;
$xml .= '<annotation>' . $annotation . '</annotation>' . PHP_EOL;
$xml .= '<location>' . $image . '</location>' . PHP_EOL;
$xml .= '<title>' . $title . '</title>' . PHP_EOL;
$xml .= '<info>' . $info . '</info>' . PHP_EOL;
$xml .= '</track>' . PHP_EOL;

foreach($locations as $location)
{
  $xml .= '<track>' . PHP_EOL;
  $xml .= '<annotation>' . $annotation . '</annotation>' . PHP_EOL;
  $xml .= '<location>' . $location . '</location>' . PHP_EOL;
  $xml .= '<title>' . $title . '</title>' . PHP_EOL;
  $xml .= '<info>' . $info . '</info>' . PHP_EOL;
  $xml .= '</track>' . PHP_EOL;
}
echo $xml;
?>

 

The reason that you were only getting the last element of the XML was the result of a type. In the foreach loop, the first $xml was set to equal (=), instead of dot-equal (.=). This meant that the track was getting overwritten each time.

 

As for your other questions:

In the "switch" part it has cases for car/nature/stickman under the "s" input. However...how do those have anything to do with car1/car2/car3/nature1/nature2/stickman1/stickman2/stickman3?

 

Look at this code:

$annotation = $_GET['s'];
$var = $annotation . $_GET['e'];
$locations = $$var;

 

* In the first line, $annotation is set to whatever 's' is in your URL. So if s equals 'stickman', then $annotation also equals 'stickman'.

* In the second line, $var is equal to a text string of the combination of 's' and 'e' from your URL. So if 's' equals 'stickman', and 'e' equals '1', then $var will be equal to a text string of 'stickman1'.

* now look back at all the arrays that I set at the start of the script. They are called $car1, $car2, $stickman1, $stickman 2 etc. So what we want is to get the correct one there. In the third line, there are two $ signs before var. $var is equal to 'stickman1', so $$var is equal to $stickman1. Since we set $stickman1 earlier in the script, now $locations is equal to $stickman1. In this way, the $locations variable will always be set by whatever is in your URL for 's' and 'e'.

 

Also, what is "PHP_EOL"?

 

It means 'end of line'. It just forces a line break in your source code, making your source code easier to read. It's not necessary, but I find it's very handy when outputting XML, as it keeps it in an easy to read list, rather than all over the place.

In the second

 

 

Link to comment
Share on other sites

Sorry about that...I've been getting on the computer at random times today >.<

 

Thank you very much for the code and the explanation :). Everything works perfectly.

 

 

However I have a little system setup that uses this XML generator. My problem is that this XML generator is not being recognized as a XML file.

 

My "system" involves JavaScript, PHP, HTML, XML, and the JW FLV Player (but I think the problem is probably in the JS-PHP interaction).

 

Here is how a normal "somefile.xml" file would look like:

 

<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<annotation>nature</annotation>
<location>http://domain.com/nature.png</location>
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>
<track>
<annotation>nature</annotation>
<location>http://domain.com/nature2-1.flv</location>

<title>91</title>
<info>http://domain.com/nature.html</info>
</track>
</trackList>
</playlist>
<track>
<annotation>nature</annotation>
<location>http://domain.com/nature2-2.flv</location>
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>

</trackList>
</playlist>
<track>
<annotation>nature</annotation>
<location>http://domain.com/nature2-3.flv</location>
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>
</trackList>
</playlist>
<track>
<annotation>nature</annotation>

<location>http://domain.com/nature2-4.flv</location>
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>
</trackList>
</playlist>

 

When you run that XML file through the JW FLV Player it works perfectly. And that's what the script that you wrote produces.

 

However, I have a modified system of how the JW FLV Player receives the XML file.

 

Here is what is displayed (this is my full HTML code so there are some extra things in, however the stuff in "body" shows the system) :

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

  <head>

    <title>Umm</title>

    <style type="text/css">
      div.playercontainer
      {
        position:                    absolute;
        top:                            82px;
        left:                           0px;
        z-index:                            0;
      }

      .drop_down, .loading_drop_down, .no_drop_down
      {
        display:                         none;
      }
    </style>

    <script type="text/javascript" src="jquery-1.2.6.min.js"></script>

    <script type="text/javascript" src="drop_down.js"></script>
    <script type="text/javascript" src="swfobject2.js"></script>

    <script language="JavaScript">
      pic1 = new Image(16, 16); 
      pic1.src="loader.gif";
    </script>

    <!-- just for testing -->
    <script type="text/javascript">
      function loadPlaylist(playlist)
      {
        newPlaylist = true;
        player.sendEvent('LOAD', playlist)
      };
    </script>

    <script language="JavaScript" type="text/javascript">
      var player             =  null;
      var playlist           =  null;
      var original_playlist  =  null;
      var newPlaylist        =  true;
      var multiple           = false;
      var multipleLocations  =    [];
      var currentML          =    -1;
      var currentItem        =    -1;


      function playerReady(obj)
      {
        player = gid(obj.id);
        player.addModelListener('STATE',          'stateMonitor');
        player.addViewListener('ITEM',            'itemMonitor');
        player.addControllerListener('PLAYLIST',  'playlistMonitor');
      };


      function stateMonitor(obj)
      {
        if(obj.newstate == 'COMPLETED')
        {
          if(multiple == true)
          {
            currentML++;
gid('dump2').innerHTML = 'currentML: ' + currentML + '    multipleLocations Length: ' + multipleLocations.length + '    mulitipleLocations[\'location' + currentML + '\']: ' + multipleLocations['location' + currentML];

            if(currentML > multipleLocations.length)
            {
              // reset multiple flag
              multiple = false;
            }
            else
            {
              // reload the playlist with location + currentML as the location
              playlist[currentItem]['file'] = multipleLocations['location' + currentML];
              playlist[currentItem]['description'] = multipleLocations['subtitle' + currentML];
              player.sendEvent('LOAD', playlist);
              player.sendEvent('PLAY', 'true');
            }
          }

          if((multiple == false) && (currentItem + 1 < playlist.length))
          {
            // advance to the next track
            setTimeout("player.sendEvent('ITEM', currentItem + 1)", 100);
          }
        }
      };


      function itemMonitor(obj)
      {
gid('dump1').innerHTML = 'Current Item: ' + obj.index + '    Track: ' + (obj.index+1) + '    File: ' + playlist[obj.index]['file'];

        if(currentItem != obj.index)
        {
          // reset multiple locations counter
          currentML = 0;
          count = 0;

          //...reload the original playlist here so a selection of another track will play the original location
//alert('Load Original Playlist');
          newPlaylist = false;
          player.sendEvent('LOAD', original_playlist);

          // check track for multiple locations
          for(j in playlist[obj.index])
          {
            if(j.match('location') == 'location')
            {
              // store in multipleLocations object
              multipleLocations[j] = playlist[obj.index][j];
              // reset multiple locations flag
              multiple = true;
              count++;
            }
            else if(j.match('subtitle') == 'subtitle')
            {
              // store in multipleLocations object
              multipleLocations[j] = playlist[obj.index][j];
            }
          }
          multipleLocations['length'] = count;
        }
        currentItem = obj.index;
      };


      function playlistMonitor(obj)
      {
        // load the playlist once
        if(newPlaylist)
        {
          playlist           = player.getPlaylist();
          original_playlist  = player.getPlaylist();
          newPlaylist        = false;
          multiple           = false;
          multipleLocations  =    [];
          currentML          =    -1;
          currentItem        =    -1;

gid('dump1').innerHTML = '';
gid('dump2').innerHTML = '';

          setTimeout("player.sendEvent('ITEM', 0)", 100);
          setTimeout("player.sendEvent('PLAY', 'true')", 200);
        }
      };

      function loadFile(file)
      {
        var type;
        newPlaylist = true;

        switch(file.substr(file.length - 4))
        {
          case '.flv': case '.mp4': case '.mov':
            type = 'video';
            break;
          case '.mp3':
            type = 'sound';
            break;
        }
//alert('File: ' + file + '\nType: ' + type);
        player.sendEvent('LOAD', {file:file, type:type});
      };


      function gid(name)
      {
        return document.getElementById(name);
      };

  
      function gid(name)
      {
        return document.getElementById(name);
      };
    </script>

    <script language="JavaScript" type="text/javascript">
      var flashvars =
      {
        'file':                 'ac_flv_website.xml',
        'playlist':             'left',
        'playlistsize':         '150',
        'shuffle':              'false',
        'repeat':               'false',
	'stretching':           'exactfit',
        'plugins':              'drelated-1',
        'drelated.dxmlpath':    'related_clips.xml',
        'drelated.dposition':   'top',
        'drelated.dskin':       'grayskin.swf',
        'drelated.dtarget':     '_self',
        'backcolor':            '#000000',
	'frontcolor':           '#FFFFFF',
	'lightcolor':           '#FFFFFF',
	'volume':               '100',
        'autostart':            'true'
      };

      var params =
      {
        'allowfullscreen':      'true',
        'allowscriptaccess':    'always',
        'bgcolor':              '#FFFFFF'
      };

      var attributes =
      {
        'id':                   'playerId',
        'name':                 'playerId'
      };
      
      swfobject.embedSWF('player3.swf', 'player', '630', '272', '9.0.124', false, flashvars, params, attributes);
    </script>

    <script type="text/javascript">
      var message = "Function Disabled!";

      function clickIE()
      {
        if (document.all)
        {
          alert(message);
          return false;
        }
      };

      function clickNS(e)
      {
        if(document.layers || (document.getElementById && !document.all))
        {
          if(e.which == 2 || e.which == 3)
          {
            alert(message);
            return false;
          }
        }
      };

      if(document.layers)
      {
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown = clickNS;
      }
      else
      {
        document.onmouseup = clickNS;
        document.oncontextmenu = clickIE;
      }
      document.oncontextmenu = new Function("return false");
    </script>

  </head>
  
<script type="text/javascript">
function showContent(vThis)
{
// http://www.javascriptjunkie.com
// alert(vSibling.className + " " + vDef_Key);
vParent = vThis.parentNode;
vSibling = vParent.nextSibling;
while (vSibling.nodeType==3) { // Fix for Mozilla/FireFox Empty Space becomes a TextNode or Something
vSibling = vSibling.nextSibling;
};
if(vSibling.style.display == "none")
{
vThis.src="collapse.gif";
vThis.alt = "Hide Div";
vSibling.style.display = "block";
} else {
vSibling.style.display = "none";
vThis.src="expand.gif";
vThis.alt = "Show Div";
}
return;
}

function showContent2(vThis)
{
// http://www.javascriptjunkie.com
// alert(vSibling.className + " " + vDef_Key);
vParent = vThis.parentNode;
vSibling = vParent.nextSibling;
while (vSibling.nodeType==3) { // Fix for Mozilla/FireFox Empty Space becomes a TextNode or Something
vSibling = vSibling.nextSibling;
};
if(vSibling.style.display == "none")
{
vThis.src="collapse.gif";
vThis.alt = "Hide Div";
vSibling.style.display = "block";
} else {
vSibling.style.display = "none";
vThis.src="expand.gif";
vThis.alt = "Show Div";
}
return;
}
</script>
<!-- THIS IS WHERE THE SYSTEM STARTS -->
  <body onload="drop_down_list_level_1(document.form.level_1.options[document.form.level_1.selectedIndex].value);"
        bgcolor="black"
	TEXT="#FFFFFF">

    <form name="form">
      <table width="0" border="0">
        <tr>
          <td width="0">
            <select onchange="drop_down_list_level_1(this.options[this.selectedIndex].value);" name="level_1">
              <option value='website.xml'>Start Here</option>
		  
		  <option value=''>--------</option>
		  
              <option value=''>Videos</option>
		  <option value='de'>-Comedy</option>
		  <option value='dm'>-Old</option>
		  
		  <option value=''>--------</option>
            </select>

          </td>
        </tr>
        <tr>
          <td>
            <div id="level_2_drop_down" class="drop_down">
              <select onchange="drop_down_list_level_2(this.options[this.selectedIndex].value);" name="level_2">

                <option value="">Level 2...</option>
              </select>
            </div>
            <span id="loading_level_2_drop_down" class="loading_drop_down">
              <img src="loader.gif" width="16" height="16" align="absmiddle">
               Loading...
            </span>
            <div id="no_level_2_drop_down" class="no_drop_down">
              This Category has no further Levels.
            </div>

          </td>
        </tr>
        <tr>
          <td>
            <div id="level_3_drop_down" class="drop_down">
              <select onchange="loadPlaylist(this.options[this.selectedIndex].value);" name="level_3">

                <option value="">Playlist...</option>
              </select>
            </div>
            <span id="loading_level_3_drop_down" class="loading_drop_down">
              <img src="loader.gif" width="16" height="16" align="absmiddle">
               Loading...
            </span>
            <div id="no_level_3_drop_down" class="no_drop_down">
              This Category has no Levels.
            </div>

          </td>
        </tr>
      </table>
    </form>
<!-- THIS IS WHERE (pretty much) THE SYSTEM ENDS -->

<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<center>	
<b><img src="expand.gif" border="0" style="cursor:w-resize;" onclick="showContent(this);" />Chatbox</b>

<div style="display:none;">
[chatbox here]
</div>

<b>|| Rules<img src="expand.gif" border="0" style="cursor:w-resize;" onclick="showContent2(this);" /></b>

<div style="display:none;">
No linking to ANY website.<br>
No videos, pictures, music, or other links.<br>
PG rated language.<br>
Breaking the rules once yields a permanent ban.<br>
</div>
</center>

    <div id="playercontainer" class="playercontainer">
<p id="player" class="player">
      Get the <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target=_blank>Adobe Flash Player</a> to see this video.
  <br><br>
  Internet Explorer cannot run this script, get <a href="http://www.mozilla.com/en-US/firefox/" target=_blank>Firefox</a> to view this page.
</p>
    </div>

  </body>

</html>

 

So that HTML file has 3 dropdown lists that change depending on what your selection is. I forgot what type of dropdown list this is called but it's very similar to one of those "State-City-County" type of dropdown lists. All of the stuff within the "<option value='XXXXX'>" tags (that don't have an extention like "file.xml") call for a JS file that looks like this:

 

function populate(form)
{
  form.options.length = 0;
  form.options[0] = new Option("Select a category","");
  form.options[1] = new Option("Directly linked files work", "comedy.xml");
  form.options[2] = new Option("PHP generated XML files dont work", "http://facs.110mb.com/grall4.php?s=nature&e=2");
  form.options[3] = new Option("Other similar JS files can be linked to go to one of the other 2 dropdown lists", "JSFileNameHere-NoExtentionNeeded");
};

 

 

If you have questions...ask away...I know it's a bit confusing xD. I'll put up an example page if you need an example of my problem.

Link to comment
Share on other sites

You didn't really ask a question, so I'm not fully sure what the problem is here, but it seems that you need an xml file, and have a php file. You can use fopen, fwrite and fclose to create a file with the name ____.xml, and use that in your player. The only difference is that instead of echoing the variable of $xml that the script I gave you creates, you just output $xml to an xml file. This is probably your easiest bet.

Link to comment
Share on other sites

Oh...yeah sorry my question was in the JS file code:

 

function populate(form)
{
  form.options.length = 0;
  form.options[0] = new Option("Select a category","");
  form.options[1] = new Option("Directly linked files work", "comedy.xml");
  form.options[2] = new Option("PHP generated XML files dont work", "http://facs.110mb.com/grall4.php?s=nature&e=2");
  form.options[3] = new Option("Other similar JS files can be linked to go to one of the other 2 dropdown lists", "JSFileNameHere-NoExtentionNeeded");
};

 

Umm...can you give me a page that shows how to output $xml to an actual XML file? That sounds like it should work considering that XML files work with that JS file.

 

 

Oh...I have 1 problem though. How would I get the right things to output to the XML file?

 

Example:

 

function populate(form)
{
  form.options.length = 0;
  form.options[0] = new Option("Select a category","");
  form.options[1] = new Option("This is the file that your script outputs stuff to", "playlist.xml");
};

 

But in playlist.xml all that would be in it was a script that calls for whatever was inputted in the PHP file. How would this be accomplished? (redirecting from the PHP file might work but that might still cause the same problem since it doesn't have a ".xml" extention...idk would have to try it out first)

Link to comment
Share on other sites

Honestly, I have no idea what you are talking about! I don't know the system at hand, so your talk is confusing me. I'm also not sure why you would need/use javascript to populate a dropdown, when you can just hard code it, or use php to generate the options.

 

But as for how to output your xml into an xml file, well you just take the $xml variable I gave you earlier, and instead of echoing it, you use this:

 

$handle = fopen('file.xml', 'w'); // using w deletes all data and starts a new file. If the file doesn't exist, this function will attempt to create it, though your server settings may prevent that
fwrite($handle, $xml); // this writes the data in the $xml variable to the file
fclose($handle); // this finishes off the file

 

After doing this, you will have a file named file.xml that contains the contents of the $xml variable that was created in the file I gave you earlier.

Link to comment
Share on other sites

Yeah...nvm about the system xD. This works :)

 

I have 2 questions though:

 

1. How can I change it so that each $title goes from number 1 to whatever each "category's" (car,stickman, and nature) total episodes number is?

 

For example, I need the output to be this:

 

<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<annotation>nature</annotation>
<location>http://domain.com/nature.png</location>
<title>91</title>
<info>http://domain.com/nature.html</info>
</track>
<track>
<annotation>nature</annotation>
<location>http://domain.com/nature2-1.flv</location>

<title>1</title>
<info>http://domain.com/nature.html</info>
</track>
<track>
<annotation>nature</annotation>
<location>http://domain.com/nature2-2.flv</location>
<title>2</title>
<info>http://domain.com/nature.html</info>
</track>
<track>
<annotation>nature</annotation>

<location>http://domain.com/nature2-3.flv</location>
<title>3</title>
<info>http://domain.com/nature.html</info>
</track>
<track>
<annotation>nature</annotation>
<location>http://domain.com/nature2-4.flv</location>
<title>4</title>
<info>http://domain.com/nature.html</info>
</track>

etc all the way to the total number of episodes that each category has (in this case, 91)

</trackList>
</playlist>

 

Currently it's just putting "91" in every single $title.

 

My second question:

 

Wouldn't the output get messed up if say this happened?:

 

User A - has a fast internet

User B - has American Offline (slow internet)

User B requests "video.php?s=nature&e=2" and has to wait a minute for the page to load.

User A requests "video.php?s=car&e=1" a few seconds after user B. User A's request is loaded up automatically.

 

Wouldn't this change the output of User B since they're both using the same "file.xml" to output their stuff to? Or is each input request -totally- isolated from other requests regardless of any "multi-user" use. Because if you get like 50+ users on at the same time...it might cause problems (I think).

Link to comment
Share on other sites

Oh...also...

 

I want to add this line:

 

<meta rel='type'>video</meta>

 

I do this:

 

$xml .= '<meta rel='type'>video</meta>' . PHP_EOL;

 

but of course the single quotes near type cause a problem because single quotes are used for the opening & closing tags for $xml.

 

How can I fix this?

 

P.S. The single quotes on type -have- to be single quotes in the final output.

Link to comment
Share on other sites

Grr...nevermind about the "1-91" for $title question.

 

I won't be using it.

 

All that's left to answer is the one about User A and User B xD

 

Edit:

 

Ok...this is my last question:

 

I have some videos that have more than 1 part that play right after the first one finishes (and second, third, etc if there are more than 2 parts).

 

So I need this:

 

//This first track has 1 video split into 2 separate files
<track>
<title></title>
<location>http://domain.com/video1p1.flv</location>
<meta rel='location1'>http://domain.com/video1p2.flv</meta>
<annotation></annotation>
<info></info>
</track>

//This second track has 5 parts to it. Notice how the "location#" part is not the same as the actual part of the videos (location1 goes with p2, location2 goes with p3, etc). Also note that there can be an infinite number of "location#s".
<track>
<title></title>
<location>http://domain.com/video2p1.flv</location>
<meta rel='location1'>http://domain.com/video2p2.flv</meta>
<meta rel='location2'>http://domain.com/video2p3.flv</meta>
<meta rel='location3'>http://domain.com/video2p4.flv</meta>
<meta rel='location4'>http://domain.com/video2p5.flv</meta>
<annotation></annotation>
<info></info>
</track>

//This third track has just 1 video file in it
<track>
<title></title>
<location>http://domain.com/video3.flv</location>
<annotation></annotation>
<info></info>
</track>

 

So essentially it incorporates everything that we have currently but just adding 1 extra feature. There is an infinite number of combinations of tracks (some could have 1 location#, some not at all, some have a lot of location#s, etc).

Link to comment
Share on other sites

Give each user a unique xml file name (append a timestamp to the filename or something), and load that file for the user. This way they won't be using the same xml file, and overwriting each other. You will have to create a function that cleans out old files every so often though.

 

 

Link to comment
Share on other sites

Give each user a unique xml file name (append a timestamp to the filename or something), and load that file for the user. This way they won't be using the same xml file, and overwriting each other. You will have to create a function that cleans out old files every so often though.

 

I'm sorry...you lost me :(. Do you mean making one of those things that change the source for every user? Like how video hosts such as MegaVideo and YouTube always change the source file of their videos? If so...wouldn't that require major coding...which would probably require a team of experts to accomplish? Lol xD. I might just make a bunch of these scripts so that there is less of a chance of this happening. And if it does happen...the user should just refresh the page and try again (yes, I do know that that might drive off some users...but there doesn't seem to be any way to fix this besides creating an XML file per episode # for every show...which would take too long and be a pain in the rear end xD).

 

 

Also...do you know of a way of adding that 1 extra feature that I talked about in my last post?

 

 

Thank you very much for your help so far :)

Link to comment
Share on other sites

no no, I didn't mean that at all. What you have to do is in this code:

 

$handle = fopen('file.xml', 'w');

 

instead of 'file.xml' make it

 

$filename = $time . 'file.xml';
$handle = fopen($filename. 'file.xml', 'w');

 

This will give each person a unique xml file that they will be working with, rather than all sharing the same XML file. The filename is stored in $filename.

Link to comment
Share on other sites

Ok, I got that to work.

 

Is there a way of automatically deleting these files after a certain amount of time? Because I don't want it to get too big xD.

 

I thought about use sleep() but that just delays everything else from being executed and I need to redirect the person at the end (so if I redirect before the sleep...it won't work [or will it? o.o]. But if I sleep() before the redirect then it deletes the file before the person gets redirected). That or just delete ####file.xml right after ####file.xml finishes loading (my host doesn't allow automatic "refreshes" so a direct thing would be better).

 

 

Do you know of how to add that extra feature that I mentioned a few posts up (the one about location#s)?

Link to comment
Share on other sites

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.