Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit ( 0 );
- ob_start();
- header('Content-Type: text/html; charset=utf-8');
- // check folder
- if(!isset($_GET['p'])){
- $path = './';
- }else{
- $path = $_GET['p'];
- }
- // check for extensions
- if(isset($_GET['exts'])){
- $exts = $_GET['exts'];
- }else{
- $exts = "mp3";
- }
- function mk_file($filename) {
- if(!is_file($filename)) {
- fclose(fopen($filename,"x"));
- return true;
- } else return false;
- }
- if(!file_exists("./musiclist.php")){
- echo<<<EOL
- <style>
- body{
- background:#5E7CB0;
- }
- #music{
- background:#5E7CB0;
- }
- tr:nth-child(even) {
- background: #C4CEDF
- }
- tr:nth-child(odd) {
- background: #C8dEEF
- }
- </style>
- <body>
- <center>
- EOL;
- }
- $load_file = false;
- if(file_exists("./musiclist-$exts.php")){
- $load_file = true;
- $file = "musiclist-$exts.php";
- }
- if($load_file == true){
- echo "<div id='loaded'>";
- echo file_get_contents($file);
- echo "</div></center>
- </body>";
- die;
- }
- function saveit($data,$exts){
- if(!file_exists("./musiclist-$exts.php")){
- mk_file("./musiclist-$exts.php");
- }
- $data = ob_get_contents();
- file_put_contents("./musiclist-$exts.php", $data, FILE_APPEND | LOCK_EX);
- }
- require_once('./getid3/getid3.php');
- $getID3 = new getID3;
- $dir = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
- $files = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST);
- foreach ($files as $file=>$mykey) {
- if(is_dir($file)) {
- $directory = $file;
- $mydir = new RecursiveIteratorIterator(
- new RecursiveRegexIterator(
- new RecursiveDirectoryIterator($directory,RecursiveDirectoryIterator::FOLLOW_SYMLINKS),
- '#(?<!/)\.'.$exts.'$|^[^\.]*$#i')
- ,true);
- foreach ($mydir as $myfile=>$mykey){
- $result[] = $myfile.'<br />';
- $filetypes = array("$exts");
- $filetype = pathinfo($myfile, PATHINFO_EXTENSION);
- if (in_array(strtolower($filetype), $filetypes)){?>
- <div><h3><?php echo count($result);?>
- <span><?php echo substr(PHP_EOL . $directory . PHP_EOL . PHP_EOL,4);?></span></h3></div>
- <?php
- if(in_array(strtolower($filetype), array("mp3"))){
- echo '<table border="1" cellspacing="0" cellpadding="3" id="music">';
- echo '<tr><th>Filename</th><th>Artist</th><th>Title</th><th>Bitrate</th><th>Playtime</th></tr>';
- }
- if (!empty($mydir)) {
- foreach ($mydir as $d) {
- if (strpos($d->getFilename(), ".$exts") !== FALSE) {
- if (strpos($d->getFilename(), ".mp3") == FALSE) {?>
- <div><tr><td><a href="<?php echo $d;?>"><?php echo basename($d->getPath() . DIRECTORY_SEPARATOR . $d->getFilename() . PHP_EOL);?></a></td><td>
- <? }
- if(strpos($d->getFilename(), ".mp3") !== FALSE){
- $ThisFileInfo = $getID3->analyze($d);
- getid3_lib::CopyTagsToComments($ThisFileInfo);
- echo '<td>'.htmlentities($ThisFileInfo['filenamepath']).'</td>';
- echo '<td>'.htmlentities(!empty($ThisFileInfo['comments_html']['artist']) ? implode('<br>', $ThisFileInfo['comments_html']['artist']): chr(160)).'</td>';
- echo '<td>'.htmlentities(!empty($ThisFileInfo['comments_html']['title']) ? implode('<br>', $ThisFileInfo['comments_html']['title']) : chr(160)).'</td>';
- echo '<td align="right">'.htmlentities(!empty($ThisFileInfo['audio']['bitrate'])?round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : chr(160)).'</td>';
- echo '<td align="right">'.htmlentities(!empty($ThisFileInfo['playtime_string'])?$ThisFileInfo['playtime_string'] : chr(160)).'</td>';
- }?></td></tr></div>
- <?php }
- }
- }
- if(strpos($d->getFilename(), ".mp3") !== FALSE){
- echo '</table>';
- }
- }
- $size=ob_get_length();
- if ($size > 0.0000){
- $content = ob_get_contents();
- saveit($content,$exts);
- ob_clean();
- }
- }
- }
- }
- header("location: http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
- ?>
- </center>
- </body>
- <?
- ob_end_flush();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement