problemen met functie filemtime
Dit script moet een directory met MP3's lezen en daar een XML (type media:) van maken.
Op zich lukt dat, maar krijg er nog wat foutmeldingen bij, die denk ik uit de functie filemtime komen.
PHP script:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
* This is a sample file that reads through a directory, filters the mp3/jpg/flv
* files and builds a playlist from it. After looking through this file, you'll
* probably 'get the idea' and'll be able to setup your own directory.
*
*/
// set this to a creator name
$creator = "Myself";
// search for mp3 files. set this to '.flv' or '.jpg' for other files
$filter = ".mp3";
// path to the directory you want to scan seen from $url (see line below)
// "./" = current directory
$directory = "/media/music";
// URL to files (progstreaming_test added, as the root is one directory deeper (sub directory) from 2rsweb.nl
$url =$_SERVER['HTTP_HOST'] . "/progstreaming_test";
/////////////////////////// no user configuration variables below this \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// read through the directory and filter files to an array
@$d = dir(".." . $directory);
if ($d)
{
while($entry = $d->read())
{
$ps = strpos(strtolower($entry), $filter);
if (!($ps === false))
{
$items[$entry]['mtime'] = filemtime($entry . "/");
echo $items[$entry];
}
}
$d->close();
arsort($entry);
}
// the playlist is built in an xspf format
// first, we'll add the opening tags...
echo "<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss/\" xmlns:jwplayer=\"http://developer.longtailvideo.com/trac/\">\n";
echo "<channel>\n";
echo " <title>PHP Generated Playlist for progstreaming.com</title>\n";
// ...then we loop through the array...
foreach($items as $key => $value)
{
$title = substr($key, 0, strlen($key) - 4);
echo " <item>\n";
echo " <title>" . $title . "</title>\n";
echo " <jwplayer:author>" . $creator . "</jwplayer:author>\n";
echo " <media:content url=\"" . $url . $directory . '/' . $key . "\" />\n";
echo " </item>\n";
}
// ...and last we add the closing tags
echo "</channel>\n";
echo "</rss>\n";
/*
* That's it! You can feed this playlist to the SWF by setting this as it's 'file'
* parameter in your HTML page.
*/
?>
/*
* This is a sample file that reads through a directory, filters the mp3/jpg/flv
* files and builds a playlist from it. After looking through this file, you'll
* probably 'get the idea' and'll be able to setup your own directory.
*
*/
// set this to a creator name
$creator = "Myself";
// search for mp3 files. set this to '.flv' or '.jpg' for other files
$filter = ".mp3";
// path to the directory you want to scan seen from $url (see line below)
// "./" = current directory
$directory = "/media/music";
// URL to files (progstreaming_test added, as the root is one directory deeper (sub directory) from 2rsweb.nl
$url =$_SERVER['HTTP_HOST'] . "/progstreaming_test";
/////////////////////////// no user configuration variables below this \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// read through the directory and filter files to an array
@$d = dir(".." . $directory);
if ($d)
{
while($entry = $d->read())
{
$ps = strpos(strtolower($entry), $filter);
if (!($ps === false))
{
$items[$entry]['mtime'] = filemtime($entry . "/");
echo $items[$entry];
}
}
$d->close();
arsort($entry);
}
// the playlist is built in an xspf format
// first, we'll add the opening tags...
echo "<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss/\" xmlns:jwplayer=\"http://developer.longtailvideo.com/trac/\">\n";
echo "<channel>\n";
echo " <title>PHP Generated Playlist for progstreaming.com</title>\n";
// ...then we loop through the array...
foreach($items as $key => $value)
{
$title = substr($key, 0, strlen($key) - 4);
echo " <item>\n";
echo " <title>" . $title . "</title>\n";
echo " <jwplayer:author>" . $creator . "</jwplayer:author>\n";
echo " <media:content url=\"" . $url . $directory . '/' . $key . "\" />\n";
echo " </item>\n";
}
// ...and last we add the closing tags
echo "</channel>\n";
echo "</rss>\n";
/*
* That's it! You can feed this playlist to the SWF by setting this as it's 'file'
* parameter in your HTML page.
*/
?>
Output:
Warning: filemtime(): stat failed for 01 - Chosen.mp3/ in /customers/8/9/c/2rsweb.nl/httpd.www/progstreaming_test/dir_list/index.php on line 34
Array
Warning: filemtime(): stat failed for 02 - Waiting For The Flood.mp3/ in /customers/8/9/c/2rsweb.nl/httpd.www/progstreaming_test/dir_list/index.php on line 34
Array
Warning: filemtime(): stat failed for 03 - The Butterfly Man.mp3/ in /customers/8/9/c/2rsweb.nl/httpd.www/progstreaming_test/dir_list/index.php on line 34
Array
Warning: filemtime(): stat failed for 04 - Ghost In The Firewall.mp3/ in /customers/8/9/c/2rsweb.nl/httpd.www/progstreaming_test/dir_list/index.php on line 34
Array
Warning: filemtime(): stat failed for 05 - Climbing The Net.mp3/ in /customers/8/9/c/2rsweb.nl/httpd.www/progstreaming_test/dir_list/index.php on line 34
Array
Warning: filemtime(): stat failed for 06 - Moviedrome.mp3/ in /customers/8/9/c/2rsweb.nl/httpd.www/progstreaming_test/dir_list/index.php on line 34
Array
Warning: filemtime(): stat failed for 07 - Friday's Dream.mp3/ in /customers/8/9/c/2rsweb.nl/httpd.www/progstreaming_test/dir_list/index.php on line 34
Array
Warning: arsort() expects parameter 1 to be array, boolean given in /customers/8/9/c/2rsweb.nl/httpd.www/progstreaming_test/dir_list/index.php on line 39
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:jwplayer="http://developer.longtailvideo.com/trac/">
<channel>
<title>PHP Generated Playlist for progstreaming.com</title>
<item>
<title>01 - Chosen</title>
<jwplayer:author>Myself</jwplayer:author>
<media:content url="2rsweb.nl/progstreaming_test/media/music/01 - Chosen.mp3" />
</item>
<item>
<title>02 - Waiting For The Flood</title>
<jwplayer:author>Myself</jwplayer:author>
<media:content url="2rsweb.nl/progstreaming_test/media/music/02 - Waiting For The Flood.mp3" />
</item>
<item>
<title>03 - The Butterfly Man</title>
<jwplayer:author>Myself</jwplayer:author>
<media:content url="2rsweb.nl/progstreaming_test/media/music/03 - The Butterfly Man.mp3" />
</item>
<item>
<title>04 - Ghost In The Firewall</title>
<jwplayer:author>Myself</jwplayer:author>
<media:content url="2rsweb.nl/progstreaming_test/media/music/04 - Ghost In The Firewall.mp3" />
</item>
<item>
<title>05 - Climbing The Net</title>
<jwplayer:author>Myself</jwplayer:author>
<media:content url="2rsweb.nl/progstreaming_test/media/music/05 - Climbing The Net.mp3" />
</item>
<item>
<title>06 - Moviedrome</title>
<jwplayer:author>Myself</jwplayer:author>
<media:content url="2rsweb.nl/progstreaming_test/media/music/06 - Moviedrome.mp3" />
</item>
<item>
<title>07 - Friday's Dream</title>
<jwplayer:author>Myself</jwplayer:author>
<media:content url="2rsweb.nl/progstreaming_test/media/music/07 - Friday's Dream.mp3" />
</item>
</channel>
</rss>
Ik hoop dat jullie de reden weten. E.e.a. draait bij provider One.com (linux).
/root
/root/file
/root/php/script // deze wil dus /root/file/ aanroepen wat dus ../../file is
de ../ omhoog gaan geeft dan een probleem. Vreemd genoeg ligt dat ook nog eens aan je php installatie. Daarnaast willen spaties soms ook nog wel eens moeilijk doen in zulke paden. Misschien eens je bestanden hernoemen en alle spaties wegfilteren?
Toevoeging op 29/01/2012 19:01:07:
Het vreemde is dat hetzelfde script zonder foutmeldingen werkt op mijn PC (met usbwebserver).
Het enige verschil dat ik zie is, dat ik bij de provider de document root een subdirectory hoger ligt dan op mijn PC.
Het rare is dat je ook een paar keer Array voorbij ziet komen.
Weer zat om over na te denken.