|
|
|
|
|
|
| |
I have a bunch of videos of various formats and images that I show on a web page. To make things easy on myself I wrote this to scan the folder where the videos sit and to display them in a way that makes sense. So this script reads the file list into an array and then sorts it by time (based on weeks in the year). Then I show the links arranged by folders for each week of the year. That folder is link and when clicked it shows/hides the videos for that week.
Enjoy
Bastien
| <html>
<title>Bastien's Video List</title>
<head>
<script language='javascript'>
function show_list(d)
{
var sInline = 'inline';
if (document.getElementById(d).style.display == 'inline'){ sInline='none'; }
document.getElementById(d).style.display = sInline;
}//end func
</script>
</head>
<body>
<?php
//preview video scripts
//read in the dir files and display them as links
//onclicking the link reloads the page with the video
//organize the vids by date...
if(isset($_GET['v']))
{
show_video();
}else{
show_list2();
}//endif
?>
</body>
</html>
<?php
function show_video()
{
$file = '';
$type = '';
$file = @$_GET['v'];
$type = stristr($file,".");
//check for file
if (!file_exists("./vids/$file"))
{
//file doesn't exist
confirm("File can't be found. Please try choosing it again from the list.");
show_list();
die();
}//end if
echo "<center>";
//check file type
if (($type == ".mov")||($type == ".qt")||($type == ".mp4"))
{
//if quicktime (.mov, .qt)
?>
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="256" width="320">
<param name="src" value="<?php echo "./vids/$file" ?>">
<param name="autoplay" value="true">
<param name="controller" value="true">
<embed height="256" width="320" src="<?php echo "./vids/$file" ?>" pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime" controller="true" autoplay="true">
</object>
<?php
}elseif (($type == ".wmv")||($type == ".mpeg")||($type == ".avi")||($type == ".wav")){
//if windows (.wmv,.mpeg,.avi,.wav)
?>
<OBJECT ID="Player" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<PARAM name="autoStart" value="True">
<PARAM name="fileName" value="<?php echo "./vids/$file" ?>">
</OBJECT>
<?php
}elseif($type == ".gif" || $type ==".jpeg" || $type == ".jpg")
{
echo "<img src='./vids/$file'>";
}//end if
echo "<br><br><br><a href='vids.php'>Back to list</a></center>";
}//end function
function show_list2()
{
//organize vids by data
//read into array
//sort array
//show folders in collapsed tables
//onclick folder/date to 'show folder contents'
echo "<center><h2>I take no responsibility if you ARE OFFENDED by these videos.<br /> YOU CHOOSE TO CLICK THE LINK!</h2></center>";
echo "<table width=75% cellpadding=5 cellspacing=0 align=center><tr valign=top><td>";
$dir = './vids/';
$aVids = array();
//get data into array
//open the main video dir
if ($handle = opendir($dir))
{
//loop thru the files in the dir
while (false !== ($file = readdir($handle)))
{
//check to make sure the file is not a directory
if ($file != "." && $file != "..")
{
//reset the new var to empty string
$new = '';
//clear the stats cache of file data
clearstatcache();
//get the file name and find out if its a new file
if (file_exists($dir.$file))
{
//check to see if the video is 'new' and needs the new tag
if ((time() - filemtime($dir.$file)) < 345600)
{
$new = "\n\t\t <span style=\"font-weight:bold; color:red; font-size:smaller;\">New!</span>";
}
//add the video to the array
$aVids[] = array('file'=>$file, 'dtime'=>filemtime($dir.$file), 'week'=>date("W",filemtime($dir.$file)), 'new'=> $new);
}//end if
}//end if
}//loop
}//end if
// Turn array into a list of columns
foreach ($aVids as $key => $row) {
$file[$key] = $row['file'];
$week[$key] = $row['week'];
$new[$key] = $row['new'];
}
// sort the arays
array_multisort($week,SORT_DESC,$aVids);
$old_week = 0;
$display = 10;
$nCount = 0;
//start table
// echo "<table border=1>\n<tr valign='top'><td>\n";
for($x=0; $x < count($aVids); $x++)
{
if (($old_week != $aVids[$x]['week']) && ($old_week != 0))
{
//close previous table
echo "\n\t</table></div>\n";
//multiple columns
$nCount++;
if ( $nCount % $display == 0 )
{
echo "</td><td>";
}
echo "\n<img src='folder.gif' /><a href='#' onclick='show_list(" . $aVids[$x]['week'] . ");'> Week " . $aVids[$x]['week'] . "</a><br />\n";
//start new hidden span
echo "\n\t<div id='" . $aVids[$x]['week'] . "' style='display:none;'>\n\t<table border=1>";
$old_week = $aVids[$x]['week'];
}elseif ($old_week == 0){
//first run thru
echo "\n<img src='folder.gif' /><a href='#' onclick='show_list(" . $aVids[$x]['week'] . ");'> Week " . $aVids[$x]['week'] . "</a><br />\n";
//start new hidden span
echo "\n\t<div id='" . $aVids[$x]['week'] . "' style='display:none;'>\n\t<table border=1>";
$old_week = $aVids[$x]['week'];
}
//show the individual elements
echo "\n\t\t<tr><td> <a href='" . $_SERVER['PHP_SELF'] . "?v=". $aVids[$x]['file'] . "'>". $aVids[$x]['file'] ."</a>";
if ($aVids[$x]['new']!=''){ echo "(" .$aVids[$x]['new']. ")</td></tr>"; }
}//next
echo "\n</td></tr></table>";
}
?> | | |
|
| The toll booth Categories : PHP, Java Script, Filesystem | | | A simple configuration file editor to ease you life in setting up php applications. Reads variables from a given file automatically and displays current value. New value will be written to file after submit. Categories : PHP, Filesystem, Regexps, Java Script | | | Complete NotePad application for Websites (Like Yahoo Notepad) Categories : PHP, Web Applications, Filesystem, Java Script, Complete Programs | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Introduction to Language Files Categories : PHP, Filesystem, Beginner Guides | | | Create HTML forms dynamicly using Javascript & PHP Categories : PHP, PHP Classes, Java Script | | | Linked comboboxes with php-mysql & javascript Categories : PHP, Java Script, Databases, MySQL | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | MD5 secured login Categories : PHP, Java Script, Authentication, Security | | | php jump urls...the best way Categories : PHP, URLs, Filesystem | | | Simple way to replace a variable value in a .conf (.ini) file using a
webbrowser - the first stage of a complete universal configuration editor Categories : PHP, Regexps, Code Editors, Filesystem | | | Display list of files within current and subdirectories (recursively) showing
each file as an anchored link and each directory as a category header. Categories : Filesystem, Directories, Arrays, PHP | | | File Explorer, browse, upload, download and edit your web site files with only a browser and a HTTP connection. Categories : Complete Programs, Content Management, Filesystem, PHP | | | Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | Zephyr: AJAX Based Framework for PHP5 Developers Categories : PHP, AJAX, Frameworks, Java Script, Web Applications | |
|
|
|