Exemplo n.º 1
0
 /**
  * @param type $dir
  * @param type $match  search type name extentions, can be an array or csv list
  * @param type $cache caching extention, select one of sqlite3, mysql, dbm
  * @param array $opt database options,
  */
 public static function scan_files($dir, $match, $cache = 'sqlite3', $opt = array('table' => 'getid3_cache', 'hide' => true))
 {
     $Start = self::getTime();
     switch ($cache) {
         // load the caching module
         case 'sqlite3':
             if (!class_exists('getID3_cached_sqlite3')) {
                 require_once dirname(__FILE__) . '/extension.cache.sqlite3.php';
             }
             $id3 = new GetId3_Extension_Cache_Sqlite3($opt['table'], $opt['hide']);
             break;
         case 'mysql':
             if (!class_exists('getID3_cached_mysql')) {
                 require_once dirname(__FILE__) . '/extension.cache.mysql.php';
             }
             $id3 = new GetId3_Extension_Cache_Mysql($opt['host'], $opt['database'], $opt['username'], $opt['password'], $opt['table']);
             break;
             // I'll leave this for some one else
             //case 'dbm':
             //	if (!class_exists('getID3_cached_dbm')) {
             //		require_once(dirname(__FILE__)).'/extension.cache.dbm.php';
             //	}
             //	die(' This has not be implemented, sorry for the inconvenience');
             //	break;
         // I'll leave this for some one else
         //case 'dbm':
         //	if (!class_exists('getID3_cached_dbm')) {
         //		require_once(dirname(__FILE__)).'/extension.cache.dbm.php';
         //	}
         //	die(' This has not be implemented, sorry for the inconvenience');
         //	break;
         default:
             die(' You have selected an Invalid cache type, only "sqlite3" and "mysql" are valid' . "\n");
             break;
     }
     $count = array('dir' => 0, 'file' => 0);
     $dirs = self::getDirs($dir);
     if ($dirs !== null) {
         foreach ($dirs as $d) {
             echo ' Scanning: ' . $d . "\n";
             $search = self::type_brace($d, $match);
             if ($search !== null) {
                 $files = self::file_check($search);
                 if ($files !== null) {
                     foreach ($files as $f) {
                         echo ' * Analyzing ' . $f . ' ' . "\n";
                         $id3->analyze($f);
                         ++$count['file'];
                     }
                     ++$count['dir'];
                 } else {
                     echo 'Failed to get files ' . "\n";
                 }
             } else {
                 echo 'Failed to create match string ' . "\n";
             }
         }
         echo '**************************************' . "\n";
         echo '* Finished Scanning your directories ' . "\n*\n";
         echo '* Directories ' . $count['dir'] . "\n";
         echo '* Files ' . $count['file'] . "\n";
         $End = self::getTime();
         $t = number_format(($End - $Start) / 60, 2);
         echo '* Time taken to scan ' . $dir . ' ' . $t . ' min ' . "\n";
         echo '**************************************' . "\n";
     } else {
         echo ' failed to get directories ' . "\n";
     }
 }
Exemplo n.º 2
0
<?php

/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <*****@*****.**>               //
//  available at http://getid3.sourceforge.net                 //
//            or http://www.getid3.org                         //
/////////////////////////////////////////////////////////////////
//                                                             //
// /demo/demo.cache.mysql.php - part of getID3()               //
// Sample script demonstrating the use of the DBM caching      //
// extension for getID3()                                      //
// See readme.txt for more details                             //
//                                                            ///
/////////////////////////////////////////////////////////////////
die('Due to a security issue, this demo has been disabled. It can be enabled by removing line ' . __LINE__ . ' in ' . $_SERVER['PHP_SELF']);
require_once '../getid3/getid3.php';
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'extension.cache.mysql.php', __FILE__, true);
$getID3 = new GetId3_Extension_Cache_Mysql('localhost', 'database', 'username', 'password');
$r = $getID3->analyze('/path/to/files/filename.mp3');
echo '<pre>';
var_dump($r);
echo '</pre>';
// uncomment to clear cache
//$getID3->clear_cache();