Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Help with php script!


ghost's Avatar
0 0

im trying to code a script that will load some url adresses from a file, all these adresses are index's, then open the url and read all the files and print the name, this is embadded in a webpage with content, but all it does is load a blank page with no wrrors…

  $file = fopen("/warez/music/links.txt", "r");
  while(!feof($file))
  {
    $url = fgets($file);
    $dir = fopen($url);
  
    while (($track = readdir($dir)) !== false)
    {
      echo "Track: " . $track . "<br />";
    }
    fclose($dir);
  }
  fclose($file);
?>```

thaks for any help

ghost's Avatar
0 0

i will give you some help tomorrow hopefully (Y)


ghost's Avatar
0 0

keiran420 wrote: im trying to code a script that will load some url adresses from a file, all these adresses are index's, then open the url and read all the files and print the name, this is embadded in a webpage with content, but all it does is load a blank page with no wrrors…

  $file = fopen("/warez/music/links.txt", "r");
  while(!feof($file))
  {
    $url = fgets($file);
    $dir = fopen($url);
  
    while (($track = readdir($dir)) !== false)
    {
      echo "Track: " . $track . "<br />";
    }
    fclose($dir);
  }
  fclose($file);
?>```

thaks for any help

ok try this.. it might work might not.

<?php
  $file = fopen("/warez/music/links.txt", "r");
  while(!feof($file))
  {
    $url = fgets($file);
    $dir = fopen($url);
    $track = readdir($dir);
    while ($track !== false)
    {
      echo "Track: " . $track . "<br />";
    }
    fclose($dir);
  }
  fclose($file);
?>

ghost's Avatar
0 0

oh yes Arto is right, you would want to have:

fopen($url, "r");

that should be the only error.


ghost's Avatar
0 0

Cheers, but it looks like my code is crappyer yet…

i keep getting this now: The connection was reset

and here is the code up to the first 2 lines of one of the directorys im trying to links tracks from

<html>
 <head>
  <title>Index of /mp3</title>
 </head>
 <body>
<h1>Index of /mp3</h1>
<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a>                    <a href="?C=M;O=A">Last modified</a>      <a href="?C=S;O=A">Size</a>  <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/">Parent Directory</a>                             -   

<img src="/icons/sound2.gif" alt="[SND]"> <a href="764hero_impossible-waste.mp3">764hero_impossible-w..></a> 23-Mar-2004 13:10  3.5M  
<img src="/icons/sound2.gif" alt="[SND]"> <a href="764hero_loaded-painted-red.mp3">764hero_loaded-paint..></a> 23-Mar-2004 13:10  5.6M ```

will i have to edit my code to filter all the crap away? i dunno

thanks for the help though :)

ghost's Avatar
0 0

just use this code

<?php
$pages="warez/music/links.txt";
$list = file ($pages);
foreach ($list as $track) {
 echo "Track: " .$track ."<br />";
}
?>

ghost's Avatar
0 0

adlez wrote: just use this code

<?php
$pages="warez/music/links.txt";
$list = file ($pages);
foreach ($list as $track) {
 echo "Track: " .$track ."<br />";
}
?>

Also you can use this which is like…..

<?php
$pages="warez/music/links.txt";
$list = file ($pages);
foreach ($list as $track) {
 echo "Track: {.$track} <br />";
}
?>

its easier to understand and include the variable, some like some dont