Location: PHPKode > projects > PHP Media Manager with IMDB > movie_scan.php
include 'config.php';

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<title>File scanner - movies</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />

$medialocations = explode("|", MOVIELOCATIONS);

//recurse many different file storage locations
while ($j < count ($medialocations)) {
$files = listdir($medialocations[$j]);

// recurse directories within those locations
while($i < count($files)) {
// split $files into path and file name strings
   $filename = basename($files[$i]);
   $pathname = dirname($files[$i]);
   $extension = getExtension($filename);
   // only add files of accepted extensions (config.php)

   if (in_array($extension, $scan_add_extensions))
	// check the script isn't attempting to insert duplicate. We assume that filename and path are indexed, else this might take longer. If so, I might need to find a more elegant way of doing this.
	mysql_query("select id from movie_scanresults where filename = '".addslashes($filename)."' and path = '".addslashes($pathname)."' limit 0,1");
	if (mysql_affected_rows() == 0)
	// This record is not a duplicate, so insert	 to the database
	mysql_query("insert into movie_scanresults (filename,path) values ('".addslashes($filename)."','".addslashes($pathname)."')");
//   echo "file:".$filename."  ----  ";
//   echo "path:".$pathname."<br />";

<h1>Scan complete</h1>
Return current item: PHP Media Manager with IMDB