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
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
<?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:
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.
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.
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.
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
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: