diff options
author | TheTroll <trolldev@gmail.com> | 2010-02-24 22:54:18 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-02-24 22:54:18 +0100 |
commit | 3d72b276b17a920a3f319afd2aec44d7bdf7a40e (patch) | |
tree | 460a30a3e2828032ffcfb5d4a85efe0725d8a246 /includes | |
parent | b28b92b318e55387fa24283195163bab32c8bf69 (diff) | |
download | istreamdev-3d72b276b17a920a3f319afd2aec44d7bdf7a40e.tar.gz istreamdev-3d72b276b17a920a3f319afd2aec44d7bdf7a40e.tar.bz2 |
Better management of audio/video media
Diffstat (limited to 'includes')
-rwxr-xr-x | includes/inc_audio.php | 120 | ||||
-rwxr-xr-x | includes/inc_files.php | 28 | ||||
-rwxr-xr-x | includes/inc_media.php | 153 | ||||
-rwxr-xr-x | includes/inc_mp3.php | 99 | ||||
-rwxr-xr-x | includes/inc_video.php | 103 | ||||
-rwxr-xr-x | includes/include.php | 2 |
6 files changed, 260 insertions, 245 deletions
diff --git a/includes/inc_audio.php b/includes/inc_audio.php new file mode 100755 index 0000000..458689f --- /dev/null +++ b/includes/inc_audio.php @@ -0,0 +1,120 @@ +<?php + +global $httppath; + +print "<body class=\"ipodlist\">\r\n"; +print "<div id=\"topbar\" class=\"transparent\">\r\n"; +print "<div id=\"leftnav\">\r\n"; +print " <a href=\"javascript:sendForm('getback')\">Back</a>\r\n"; +print "</div>\r\n"; +print "<div id=\"rightnav\">\r\n"; +print " <a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n"; + +print "<div id=\"title\">iStreamdev</div>\r\n"; +print "</div>\r\n"; +print "<div id=\"content\">\r\n"; +print " <ul>\r\n"; + +$dir_handle = @opendir($mediapath .$subdir); +if (!$dir_handle) + print "Unable to open $mediapath .$subdir"; +else while ($medianame = readdir($dir_handle)) +{ + // Add only mp3 files and dirs + if($medianame == "." || $medianame == ".." || $medianame == 'lost+found') + continue; + + $type = mediagettype($mediapath .$subdir .$medianame); + if (($type != 2) && ($type != 3)) + continue; + + $medianame_array[] = $medianame; +} + +if ($medianame_array[0]) +{ + // Alphabetical sorting + sort($medianame_array); + + exec('rm playlist/*.mp3'); + exec('ln -s ' .addcslashes(quotemeta($mediapath .$subdir), " ") .'*.mp3 playlist'); + + $count = count($medianame_array); + + for ($cnt=0; $cnt < $count; $cnt++) + { + // Dirs + if (mediagettype($mediapath .$subdir .$medianame_array[$cnt]) == 3) + { + print " <li>\r\n"; + print " <a class=\"noeffect\" href=\"javascript:sendForm('dir_{$medianame_array[$cnt]}');\">\r\n"; + print " <span class=\"name\">{$medianame_array[$cnt]}</span><span class=\"time\">></span>\r\n"; + print " </a>\r\n"; + print " </li>\r\n"; + print " <form name=\"dir_{$medianame_array[$cnt]}\" id=\"dir_{$medianame_array[$cnt]}\" method=\"post\" action=\"index.php\">\r\n"; + print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\"/>\r\n"; + print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; + print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}{$medianame_array[$cnt]}\" />\r\n"; + print " </form>\r\n"; + } + } + + $idx = 1; + for ($cnt=0; $cnt < $count; $cnt++) + { + // Audio + if (mediagettype($mediapath .$subdir .$medianame_array[$cnt]) == 2) + { + print " <li>\r\n"; + print " <a class=\"noeffect\" href=\"javascript:document.s{$idx}.Play();\">\r\n"; + print " <span class=\"number\">$idx</span><span class=\"stop\"></span><span class=\"name\">{$medianame_array[$cnt]}</span>\r\n"; + print " </a>\r\n"; + print " </li>\r\n"; + + $idx++; + } + } + + print("</div>"); + + print "<div style=\"position:absolute; left:0; top:0\">\r\n"; + $idx = 1; + for ($cnt=0; $cnt < $count; $cnt++) + { + // Audio files + if (mediagettype($mediapath .$subdir .$medianame_array[$cnt]) == 2) + { + print "<embed enablejavascript=\"true\" autoplay=\"false\" height=\"0\" name=\"s{$idx}\""; + print " src=\"{$httppath}playlist/{$medianame_array[$cnt]}\""; + print " width=\"0\" loop=\"true\" controller=\"false\""; + + $next=1; + for ($cnt2=$idx+1; $cnt2<$count; $cnt2++) + { + if (mediagettype($mediapath .$subdir .$medianame_array[$cnt2]) == 2) + { + print " qtnext{$next}=\"<{$httppath}playlist/{$medianame_array[$cnt2]}>\""; + $next++; + } + } + + print " />\r\n"; + + $idx++; + } + } + print("</div>"); +} +else + print "</div>\r\n"; + +$upsubdir = dirname($subdir); + +print " <form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\">\r\n"; +print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\" />\r\n"; +print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; +print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$upsubdir}\" />\r\n"; +print " </form>\r\n"; + +?> + diff --git a/includes/inc_files.php b/includes/inc_files.php index f593ba9..7a6f5a8 100755 --- a/includes/inc_files.php +++ b/includes/inc_files.php @@ -1,5 +1,7 @@ <?php +$audiotypes='mp3 aac'; + function mediagetinfostream($stream = "") { @@ -43,4 +45,30 @@ function mediagetinfostream($stream = "") return array($title, $info); } +function mediagettype($file) +{ + global $videotypes, $audiotypes; + + // Get file extension + $fileext = end(explode(".", $file)); + if (is_dir($file)) + return 3; + if ( preg_match("/" .$fileext ." /", $videotypes) || preg_match("/" .$fileext ." $/", $videotypes) ) + return 1; + else if ( preg_match("/" .$fileext ." /", $audiotypes) || preg_match("/" .$fileext ." $/", $audiotypes) ) + return 2; + else + return 0; +} + +function mediadirhasaudio($dir) +{ + global $audiotypes; + + $audioextarray = explode(' ', $audiotypes); + foreach ($audioextarray as $num => $audioext) + if (glob($dir .'*.' .$audioext)) + return 1; + return 0; +} diff --git a/includes/inc_media.php b/includes/inc_media.php index eaed547..e0f7cb9 100755 --- a/includes/inc_media.php +++ b/includes/inc_media.php @@ -1,156 +1,17 @@ <?php -global $videotypes; -$audiotypes='mp3 aac'; - -$subdir = $_REQUEST['subdir']; $mediapath = $_REQUEST['mediapath']; +$subdir = $_REQUEST['subdir']; /* Add last slash to dirs */ if ($mediapath[strlen($mediapath)-1] != '/') - $mediapath = $mediapath .'/'; + $mediapath = $mediapath .'/'; if ($subdir[strlen($subdir)-1] != '/') - $subdir = $subdir .'/'; + $subdir = $subdir .'/'; -print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n"; -print "<div id=\"topbar\" class=\"transparent\">\r\n"; -print "<div id=\"leftnav\">\r\n"; - -if ($subdir == '/') - print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n"; +// Use the right media type +if (mediadirhasaudio($mediapath .$subdir)) + include ('includes/inc_audio.php'); else -{ - print "<a href=\"javascript:sendForm('getback')\">Back</a></div>\r\n"; - print "<div id=\"rightnav\">\r\n"; - print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n"; -} - -print "<div id=\"title\">iStreamdev</div>\r\n"; -print "</div>\r\n"; - -print "<div id=\"content\">\r\n"; -print " <span class=\"graytitle\">Media</span>\r\n"; -print " <br>"; -print " <ul class=\"pageitem\">"; -print " <li class=\"textbox\"><span class=\"header\">Current path:</span><p>{$subdir}</p></li>"; - -// Option to play dir -$audioextarray = explode(' ', $audiotypes); -$playlist = 0; -foreach ($audioextarray as $num => $audioext) -{ - if (glob($mediapath .$subdir .'*.' .$audioext)) - $playlist = 1; -} - -if ($playlist) -{ - print " <li class=\"menu\">\r\n"; - print " <a class=\"noeffect\" href=\"javascript:sendForm('track_all');\">\r\n"; - print " <img src=\"images/pictos/playlist.png\" />\r\n"; - print " <span class=\"name\">Play current dir</span>\r\n"; - print " <span class=\"arrow\"></span>\r\n"; - print " </a>\r\n"; - print " </li>\r\n"; - print "<form name=\"track_all\" id=\"track_all\" method=\"post\" action=\"index.php\">"; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"playdir\"/>"; - print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />"; - print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />"; - print " <input name=\"play\" type=\"hidden\" id=\"play\" value= />"; - print "</form>"; -} - -$dir_handle = @opendir($mediapath .$subdir); -if (!$dir_handle) -{ - print "Unable to open $mediapath .$subdir"; -} -else while ($medianame = readdir($dir_handle)) -{ - if($medianame == "." || $medianame == ".." || $medianame == 'lost+found') - continue; - - $medianame_array[] = $medianame; -} - -if ($medianame_array[0]) -{ - // Alphabetical sorting - sort($medianame_array); - - $audiocnt=0; - - foreach($medianame_array as $value) - { - $medianame2=addslashes($value); - - // Directories - if (is_dir($mediapath .$subdir .$value)) - { - print "<li class=\"menu\">\r\n"; - print " <a class=\"noeffect\" href=\"javascript:sendForm('$medianame2');\">\r\n"; - print " <span class=\"name\">$value</span><span class=\"arrow\"></span>\r\n"; - print " </a>\r\n"; - print "</li>\r\n"; - print "<form name=\"$value\" id=\"$value\" method=\"post\" action=\"index.php\">"; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\"/>"; - print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />"; - print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}{$value}\" />\r\n"; - print "</form>\r\n"; - } - else - { - // Get file extension - $fileext = end(explode(".", $value)); - - // Check if it is supported - if ( preg_match("/" .$fileext ." /", $videotypes) || preg_match("/" .$fileext ." $/", $videotypes) ) - { - print "<li class=\"menu\">\r\n"; - print " <a class=\"noeffect\" href=\"javascript:sendForm('$medianame2');\">\r\n"; - print " <img src=\"images/pictos/video.png\" />\r\n"; - print " <span class=\"name\">$value</span><span class=\"arrow\"></span>\r\n"; - print " </a>\r\n"; - print "</li>\r\n"; - print "<form name=\"$value\" id=\"$value\" method=\"post\" action=\"index.php\">"; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"stream\"/>"; - print " <input name=\"type\" type=\"hidden\" id=\"type\" value=3 />"; - print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />"; - print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n"; - print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$mediapath}{$subdir}{$value}\" />"; - print "</form>\r\n"; - } - else if ( preg_match("/" .$fileext ." /", $audiotypes) || preg_match("/" .$fileext ."$/", $audiotypes) ) - { - $audiocnt++; - - print "<li class=\"menu\">\r\n"; - print " <a class=\"noeffect\" href=\"javascript:sendForm('track_{$audiocnt}');\">\r\n"; - print " <img src=\"images/pictos/audio.png\" />\r\n"; - print " <span class=\"name\">$value</span><span class=\"arrow\"></span>\r\n"; - print " </a>\r\n"; - print "</li>\r\n"; - print "<form name=\"track_{$audiocnt}\" id=\"track_{$audiocnt}\" method=\"post\" action=\"index.php\">"; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"playdir\"/>"; - print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />"; - print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />"; - print " <input name=\"play\" type=\"hidden\" id=\"play\" value={$audiocnt} />"; - print "</form>"; - } - } - } -} - -$upsubdir = dirname($subdir); - -print "<form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\">\r\n"; -print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\"/>\r\n"; -print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; -print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$upsubdir}\" />\r\n"; -print "</form>\r\n"; - -if ($dir_handle) - closedir($dir_handle); - -print "</ul></div>\r\n"; + include ('includes/inc_video.php'); ?> diff --git a/includes/inc_mp3.php b/includes/inc_mp3.php deleted file mode 100755 index 85553e6..0000000 --- a/includes/inc_mp3.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php - -$play =$_REQUEST['play']; -if ($play == "") - print "<body class=\"ipodlist\">\r\n"; -else - print "<body class=\"ipodlist\">\r\n"; - -print "<div id=\"topbar\" class=\"transparent\">\r\n"; -print "<div id=\"leftnav\">\r\n"; -print " <a href=\"javascript:sendForm('getback')\">Back</a>\r\n"; -print "</div>\r\n"; -print "<div id=\"rightnav\">\r\n"; -print " <a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n"; - -global $httppath; - -print "<div id=\"title\">iStreamdev</div>\r\n"; -print "</div>\r\n"; -print "<div id=\"content\">\r\n"; -print " <ul>\r\n"; - -$mediapath = $_REQUEST['mediapath']; -$subdir = $_REQUEST['subdir']; - -$dir_handle = @opendir($mediapath .$subdir); -if (!$dir_handle) - print "Unable to open $mediapath .$subdir"; -else while ($medianame = readdir($dir_handle)) -{ - // Add only mp3 files - - if(strstr($medianame, ".mp3") != ".mp3") - continue; - - $medianame_array[] = $medianame; -} - -if ($medianame_array[0]) -{ - // Alphabetical sorting - sort($medianame_array); - - exec('rm playlist/*.mp3'); - exec('ln -s ' .addcslashes(quotemeta($mediapath .$subdir), " ") .'*.mp3 playlist'); - - $cnt = 1; - foreach($medianame_array as $value) - { - $medianame2=addslashes($value); - - - print " <li>\r\n"; - print " <a class=\"noeffect\" href=\"javascript:document.s{$cnt}.Play();\">\r\n"; - print " <span class=\"number\">$cnt</span><span class=\"stop\"></span><span class=\"name\">{$value}</span>\r\n"; - print " </a>\r\n"; - print " </li>\r\n"; - - $cnt++; - } - - print "</div>\r\n"; - - print "<div style=\"position:absolute; left:0; top:0\">\r\n"; - - $count = count($medianame_array); - for ($cnt=0; $cnt < $count; $cnt++) - { - $idx=$cnt+1; - - print "<embed enablejavascript=\"true\" autoplay=\"false\" height=\"0\" name=\"s{$idx}\""; -// print " src=\"streammusic.php?mediapath={$mediapath}&subdir={$subdir}&file={$medianame_array[$cnt]}\""; - print " src=\"{$httppath}playlist/{$medianame_array[$cnt]}\""; - print " width=\"0\" loop=\"true\" controller=\"false\""; - - $next=1; - for ($cnt2=$cnt+1; $cnt2<$count; $cnt2++) - { -// print " qtnext{$next}=\"<streammusic.php?mediapath={$mediapath}&subdir={$subdir}&file={$medianame_array[$cnt2]}\""; - print " qtnext{$next}=\"<{$httppath}playlist/{$medianame_array[$cnt2]}>\""; - $next++; - } - - print " />\r\n"; - } - - print "</div>"; -} -else - print "</div>\r\n"; - -print " <form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\">"; -print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\" />"; -print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; -print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n"; -print " </form>\r\n"; - -?> - diff --git a/includes/inc_video.php b/includes/inc_video.php new file mode 100755 index 0000000..d933a04 --- /dev/null +++ b/includes/inc_video.php @@ -0,0 +1,103 @@ +<?php + +print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n"; +print "<div id=\"topbar\" class=\"transparent\">\r\n"; +print "<div id=\"leftnav\">\r\n"; + +if ($subdir == '/') + print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n"; +else +{ + print "<a href=\"javascript:sendForm('getback')\">Back</a></div>\r\n"; + print "<div id=\"rightnav\">\r\n"; + print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n"; +} + +print "<div id=\"title\">iStreamdev</div>\r\n"; +print "</div>\r\n"; + +print "<div id=\"content\">\r\n"; +print " <span class=\"graytitle\">Media</span>\r\n"; +print " <br>"; +print " <ul class=\"pageitem\">"; +print " <li class=\"textbox\"><span class=\"header\">Current path:</span><p>{$subdir}</p></li>"; + +$dir_handle = @opendir($mediapath .$subdir); +if (!$dir_handle) +{ + print "Unable to open $mediapath .$subdir"; +} +else while ($medianame = readdir($dir_handle)) +{ + if($medianame == "." || $medianame == ".." || $medianame == 'lost+found') + continue; + + $medianame_array[] = $medianame; +} + +if ($medianame_array[0]) +{ + // Alphabetical sorting + sort($medianame_array); + + $audiocnt=0; + + foreach($medianame_array as $value) + { + $medianame2=addslashes($value); + + switch (mediagettype($mediapath .$subdir .$value)) + { + // Dir + case 3: + { + print "<li class=\"menu\">\r\n"; + print " <a class=\"noeffect\" href=\"javascript:sendForm('$medianame2');\">\r\n"; + print " <span class=\"name\">$value</span><span class=\"arrow\"></span>\r\n"; + print " </a>\r\n"; + print "</li>\r\n"; + print "<form name=\"$value\" id=\"$value\" method=\"post\" action=\"index.php\">"; + print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\"/>"; + print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />"; + print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}{$value}\" />\r\n"; + print "</form>\r\n"; + break; + } + // Video + case 1: + { + print "<li class=\"menu\">\r\n"; + print " <a class=\"noeffect\" href=\"javascript:sendForm('$medianame2');\">\r\n"; + print " <img src=\"images/pictos/video.png\" />\r\n"; + print " <span class=\"name\">$value</span><span class=\"arrow\"></span>\r\n"; + print " </a>\r\n"; + print "</li>\r\n"; + print "<form name=\"$value\" id=\"$value\" method=\"post\" action=\"index.php\">"; + print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"stream\"/>"; + print " <input name=\"type\" type=\"hidden\" id=\"type\" value=3 />"; + print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />"; + print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n"; + print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$mediapath}{$subdir}{$value}\" />"; + print "</form>\r\n"; + break; + } + // Rest of files + default: + continue; + } + } +} + +$upsubdir = dirname($subdir); + +print "<form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\">\r\n"; +print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\"/>\r\n"; +print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; +print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$upsubdir}\" />\r\n"; +print "</form>\r\n"; + +if ($dir_handle) + closedir($dir_handle); + +print "</ul></div>\r\n"; +?> diff --git a/includes/include.php b/includes/include.php index f8819dd..a409f45 100755 --- a/includes/include.php +++ b/includes/include.php @@ -10,6 +10,8 @@ include ('includes/inc_vdr.php'); include ('includes/inc_files.php'); include ('includes/inc_streaminfo.php'); +$audiotypes='mp3 aac'; + function selectpage() { $action = $_REQUEST['action']; |