Mp3 Directory Listing

Discussion in 'PHP' started by albaniax, Jan 4, 2009.

  1. #1
    I'm looking for a way, to list the MP3 files from another site, in mine.

    All the Mp3 songs are in 1 directory, with public access.

    I found a directory script, but with it I can only list the directories of my site.

    Is there another one, which can also list files from another site?
    Or can I modify the php script, so it allows also other site listings?

    Greets
    Albaniax
     
    albaniax, Jan 4, 2009 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    What's the site? A simple RegEx would do this just fine...
     
    Danltn, Jan 4, 2009 IP
  3. as7apcool

    as7apcool Peon

    Messages:
    168
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
  4. albaniax

    albaniax Banned

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    http://therandamusic.com/Hitet%20E%20Reja/

    For this one I want to make a directory in my site, where I can modify then the template etc.

    The problem is, I cannot code PHP..I just understand a little bit the code. Everything else like HTML/CSS/Webdesign is no problem.

    This is an example of an directory listing script:PHP directory listing.txt
     
    albaniax, Jan 4, 2009 IP
  5. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #5
    <?php
    
    $url = 'http://therandamusic.com/Hitet%20E%20Reja/';
    
    $page = file_get_contents($url) or die('Could not open page.');
    preg_match_all('/<li><a href="(?<url>[^"]*?)">(?<name>.*?).mp3<\/a><\/li>/i', $page, $matches, PREG_SET_ORDER); 
    
    foreach($matches as $match)
    	echo '<a href="' . $url . trim($match['url']) . '">' . trim($match['name']) . '</a><br />' . PHP_EOL;
    PHP:
     
    Danltn, Jan 4, 2009 IP
  6. albaniax

    albaniax Banned

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I get this:

    Something wrong in the code?

    I put the code you gave me in a .php file, end it with ?> and upload it to my server.
     
    albaniax, Jan 4, 2009 IP
  7. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #7
    Nah - the code is valid, what version of PHP do you have?

    And the ending ?> is not required.
     
    Danltn, Jan 4, 2009 IP
  8. albaniax

    albaniax Banned

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I have PHP Version 4.3.10 !

    Should I upgrade? Everything else is working..

    /** By the way, do you also have experience with MYSQL? You could soon do something for me ;) Of course I will pay for it..
    //** Tried it also on another server, same error.
     
    albaniax, Jan 4, 2009 IP
  9. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #9
    It is a good practice to add the ?> and i believe it is needed in your version so just add it ?>
     
    atlantaazfinest, Jan 5, 2009 IP
  10. albaniax

    albaniax Banned

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Again it is not working, I tried this also before. Hm.. is it that hard to list a directory of another site?

    All the directory scripts that I found, doesn't allow to add a URL of another site. And I don't know how to change the code, so that it allows it.
     
    albaniax, Jan 5, 2009 IP
  11. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #11
    Incorrect on both fronts, it is not recommended. If you're outputting directly from the PHP script it is irrelevant.

    If you are NOT outputting from the PHP script (which IMO is how PHP should be written, mvc-style. ) then you should strictly NEVER use the ending ?>.

    There is a good reason for this. :)

    And you definitely need to upgrade, PHP 4.3 was released in 2002. It's now 2009! I would strongly recommend moving hosts if they refuse to upgrade.

    The code works fine on my machine (PHP 5.2.8) so I'll assume it's your server error.

    Try putting this at the top and informing me of any errors.
    error_reporting(E_ALL);
    PHP:
    that occur. - Could be simply your regular expression is too old to handle name subpatterns, in which just remove the ?<url> and ?<name> parts.

    And yes, I also have plenty of experience with MySQL - contact me for paid work.

    Dan
     
    Danltn, Jan 5, 2009 IP
  12. ez-designs

    ez-designs Well-Known Member

    Messages:
    230
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #12
    I would highly recommend updating as they have already released v5.2.8
     
    ez-designs, Jan 5, 2009 IP
  13. albaniax

    albaniax Banned

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I tried this now on a different server, which has PHP v5.2.8.

    After adding 'error_reporting(E_ALL);', this is what I get:

     
    albaniax, Jan 6, 2009 IP