query($sql); echo " * Clearing playlist table...".PHP_EOL; Playlist::deleteAll(); echo " * Clearing files table...".PHP_EOL; $result = StoredFile::deleteAll(); if (PEAR::isError($result)) { echo $result->getMessage().PHP_EOL; } } global $CC_CONFIG; require_once('Zend/Loader/Autoloader.php'); $autoloader = Zend_Loader_Autoloader::getInstance(); try { $opts = new Zend_Console_Getopt( array( 'help|h' => 'Displays usage information.', 'clean|c' => 'Removes all audio file metadata from the database that does not have a matching file in the filesystem.', 'empty|e' => 'Removes all files and playlists from Airtime.' ) ); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { exit($e->getMessage() .PHP_EOL. $e->getUsageMessage()); } if (isset($opts->h)) { echo PHP_EOL; echo $opts->getUsageMessage(); echo "Storage directory: ". realpath($CC_CONFIG["storageDir"]).PHP_EOL.PHP_EOL; exit; } // Need to check that we are superuser before running this. if (exec("whoami") != "root") { echo PHP_EOL."You must be root to use this script.".PHP_EOL.PHP_EOL; exit(1); } $CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE); $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); if (isset($opts->e)) { echo PHP_EOL; airtime_empty_db($CC_DBC); echo "Done.".PHP_EOL.PHP_EOL; } elseif (isset($opts->c)) { $count = airtime_clean_files($CC_CONFIG['storageDir']); if ($count == 0) { echo PHP_EOL."All file metadata in the database is linked to a real file. Nothing to be done.".PHP_EOL.PHP_EOL; } else { echo PHP_EOL."Total rows removed: $count".PHP_EOL; } } else { echo PHP_EOL; echo $opts->getUsageMessage(); echo "Storage directory: ". realpath($CC_CONFIG["storageDir"]).PHP_EOL.PHP_EOL; }