All pastes #284501 Raw Edit

Someone

public php v1 · immutable
#284501 ·published 2006-12-19 02:47 UTC
rendered paste body
<style type="text/css"><!--.dir{font-family: Verdana; background-color: #303030;color: #FFFFFF;font-size: small;border: none;}  td{font-family: Verdana; background-color: #595959;color: #FFFFFF;font-size: small;border: none;}  table{font-family: Verdana; background-color: #000000; color: #FFFFFF;font-size: small;border: none;}--></style><body bgcolor=#999999 link="#FFFFFF" vlink="#FFFFFF"><font size=2 face="Verdana, Arial, Helvetica, sans-serif">ColdFyre's <b>MP3</b> Finder/lister V .2 - ColdFyre Creations(CFC) - <a href="http://cfyre.myip.org">http://cfyre.myip.org</a><br><?php echo "Script created:"; echo date("F d Y H:i:s.", filectime("/mp3/index.php"));echo "<br>Script modified:"; echo date("F d Y H:i:s.", filemtime("/mp3/index.php"));?><hr color=black><?phperror_reporting(e_none);$act = $_GET['act'];$dir = $_GET['dir'];//strip out bs shit in dir$dir = str_replace("..","",$dir);$dir = str_replace("//","/",$dir);if ($act == "view"){$mp3_file = "/www/htdocs/mp3/Techno&Trance/$dir";$ID3 = new ID3v1x($mp3_file);if($ID3->read_tag() == true) {//$ID3=str_replace("  echo "<p>ID3V1 Info:</p><table width=100%><tr><td>File : $mp3_file<br>";  echo "----------------------------------<br>";  echo "ID3v1 : $ID3->tag<br>";  echo "Title : $ID3->title<br>";  echo "Artist : $ID3->artist<br>";  echo "Album : $ID3->album<br>";  echo "Year : $ID3->year<br>";  echo "Comment : $ID3->comm<br>";  echo "Track : $ID3->track<br>";  echo "Genre : $ID3->genre<br>";  echo "----------------------------------<br></td></tr></table>";  $handle=fopen($mp3_file,"rb");  fseek($handle,0);  $c=0;  while ($header != 11111111) {  $header = fgets($handle,2);  $header = decbin(hexdec(bin2hex($header)));  $c++;  }  $c = $c-1;  echo "<p>Breakdown of first valid frame:</p><table width=100%><tr><td>Header found at <b>". ($c) ." </b>bytes into file<br>Analysis of first 4 bytes:<br><font color=blue>11111111</font> Byte $c "." (bits ". ((($c+1)*8) -8) ." - " .  ((($c+1)*8) -1).")<font color=blue><br>111</font>";  //bits 8-15  $block1 = fgets($handle,2);  $block1 = decbin(hexdec(bin2hex($block1)));  $mpegid = substr($block1,2,2);  echo "<font color=red>$mpegid</font>";  $layer = substr($block1,4,2);  echo "<font color=brown>$layer</font>";  $crc = substr($block1,6,1);  echo "<font color=green>$crc</font> Byte ". ($c+1) ." (bits ". ((($c+2)*8) -8) ." - " .  ((($c+2)*8) -1).")<br>";  //bits 16-23  $block2 = fgets($handle,2);  $block2 = decbin(hexdec(bin2hex($block2)));  $bitrate = substr($block2,0,4);  echo "<font color=purple>$bitrate</font>";  $sample = substr($block2,4,2);  echo "<font color=grey>$sample</font>";  $padding = substr($block2,5,1);  echo "<font color=pink>$padding</font>";  $priv = substr($block2,6,1);  echo "<font color=orange>$priv</font> Byte ". ($c+2) ." (bits ". ((($c+3)*8) -8) ." - " .  ((($c+3)*8) -1).")<br>";  //bits 24-31  $block3 = fgets($handle,3);  $block3 = decbin(hexdec(bin2hex($block3)));  $channel = substr($block3,0,2);  echo "<font color=white>$channel</font>";  $mode = substr($block3,2,2);  echo "<font color=magenta>$mode</font>";  $copyright = substr($block3,5,1);  echo "<font color=yellow>$copyright</font>";  $original = substr($block3,4,1);  echo "<font color=navy>$original</font>";  $emphasis = substr($block3,6,2);  echo "<font color=fuschia>$emphasis</font> Byte ". ($c+3) ." (bits ". ((($c+4)*8) -8) ." - " .  ((($c+4)*8)-1) .")<br></td></tr></table>";      fclose($handle);  if ($sample == "00") $sample = "44100";  if ($sample == "01") $sample = "48000";  if ($sample == "10") $sample = "32000";  if ($bitrate == "0001") $bitrate = "32";  if ($bitrate == "0010") $bitrate = "40";  if ($bitrate == "0011") $bitrate = "48";  if ($bitrate == "0100") $bitrate = "56";  if ($bitrate == "0101") $bitrate = "64";  if ($bitrate == "0110") $bitrate = "80";  if ($bitrate == "0111") $bitrate = "96";  if ($bitrate == "1000") $bitrate = "112";  if ($bitrate == "1001") $bitrate = "128";  if ($bitrate == "1010") $bitrate = "160";  if ($bitrate == "1011") $bitrate = "192";  if ($bitrate == "1100") $bitrate = "224";  if ($bitrate == "1101") $bitrate = "246";  if ($bitrate == "1110") $bitrate = "320";  if ($bitrate == "1111") $bitrate = "BAD";  if ($layer == "01") $layer = "I";  if ($layer == "10") $layer = "II";  if ($layer == "11") $layer = "III";  if ($mpegid == "00") $mpegid = "2.5";  if ($mpegid == "10") $mpegid = "2";  if ($mpegid == "11") $mpegid = "1";  if ($channel == "00") $channel = "Stereo";  if ($channel == "01") $channel = "Joint stereo";  if ($channel == "10") $channel = "Dual mono";  if ($channel == "11") $channel = "Mono";  if ($channel == "00") $channel = "Stereo";  if ($mode == "00") $mode = "Intensity stereo: off, MS Stereo:,off";  if ($mode == "01") $mode = "Intensity stereo: on, MS Stereo:off";  if ($mode == "10") $mode = "Intensity stereo: off, MS Stereo: on";  if ($mode == "11") $mode = "Intensity stereo: on, MS Stereo: on";  if ($emphasis == "00") $emphasis = "None";  if ($emphasis == "01") $emphasis = "50/15";  if ($emphasis == "11") $emphasis = "CCIT J.17";      	      echo "<p>Key:</p><table width=100%><tr><td><font color=blue>Frame synchronizer</font>";  echo "<br><font color=red>MPEG Version - $mpegid</font>";  echo "<br><font color=brown>Layer - $layer</font>";  echo "<br><font color=green>CRC bit - $crc</font>"; echo "<br><font color=purple>Bitrate - $bitrate kbps</font>";  echo "<br><font color=grey>Samplerate - $sample Hz</font>";  echo "<br><font color=pink>Padding - $padding</font>";   echo "<br><font color=orange>Private - $priv</font>";    echo "<br><font color=white>Channels - $channel</font>";  echo "<br><font color=magenta>Mode extension - $mode</font>";  echo "<br><font color=yellow>Copyright - $copyright</font>";   echo "<br><font color=navy>Original - $original</font>";     echo "<br><font color=fuschia>Emphasis - $emphasis</font></td></tr></table>";   echo "<hr>Bits marked as 0 are no/off whereas 1 is yes/on";}else {  echo "Error!";} return 0;}echo "<table width=100% ><tr><td bgcolor=#3984AC><b>Location = /$dir</td></tr></table>";if ($handle = opendir("/www/htdocs/mp3/Techno&Trance/$dir")) {    while (false !== ($file = readdir($handle))) {         //if (!stristr($file,"..")) {		$filearray[$x]=$file;			$x++;		    	//}	}}natsort($filearray);reset($filearray);closedir($handle); echo "<hr color=white><br><table>";//pull out dirs and remove non mp3$coun=0;echo "COUNT: ". count($filearray);while ($coun != count($filearray)) {		$file = $filearray[$coun];	$file_link = $file;	$dir_link = $dir;	$file=str_replace("%20"," ",$file);	$dir_link=str_replace("%20"," ",$dir);	$file=str_replace(" ","%20",$file);	$dir=str_replace(" ","%20",$dir);	$file_size=filesize("/www/htdocs/mp3/Techno&Trance/$dir_link/$file_link");	if ((!strstr($file,".mp3")) && (filesize("/www/htdocs/mp3/Techno&Trance/$dir_link/$file_link") != 4096)){ 		array_splice($filearray,$coun,1);		$coun--;		}	if (is_dir($file)) { $dirarray[$coun]=$file;}	if (!is_file($file) &&  (!is_dir($file)) && ($file_size == 4096)) { $dirarray[$coun]=$file;}	//if (is_file($file)) {					//}		$coun++;}sort($dirarray);reset($dirarray);$coun=0;while ($coun != count($dirarray)) {	$file = $dirarray[$coun];	$file_link = $file;	$file=str_replace("%20"," ",$file);	echo " <tr><td class=dir>[DIR]</b> <a href=http://67.161.42.100/mp3/Techno&Trance/?dir=$dir/$file_link>$file</a></td></tr>";	$coun++;}echo "";$coun=0;while ($coun <= count($filearray))	 {    $file = $filearray[$coun];	$file_link = $file;	$dir_link = $dir;	$file=str_replace("%20"," ",$file);	$dir_link=str_replace("%20"," ",$dir);	$file=str_replace(" ","%20",$file);	$dir=str_replace(" ","%20",$dir);	$file_size=filesize("/www/htdocs/mp3/Techno&Trance/$dir_link/$file_link");//    if (is_dir($file)) { echo " [DIR] <a href=http://mp3.cfyre.myip.org?dir=$dir/$file>$file_link</a><br>";}	//if (!is_file($file) &&  (!is_dir($file)) && ($file_size == 4096)) { echo " [DIR] <a href=http://mp3.cfyre.myip.org?dir=$dir/$file>$file_link</a><br>";}	if (is_link($file)) { echo " [SYM] <a href=http://mp3.cfyre.myip.org?dir=$dir/$file>$file_link</a><br>";}	if (is_file($file)) { echo "<tr><td>[FILE]$file_link</a></td><td>" . round(($file_size /1024/1024),2 )." MB</td><td><a href=http://67.161.42.100/mp3/Techno&Trance/?act=view&dir=$dir/$file>[DETAILS]</a></td></tr>";}	if (!is_file($file) &&  (!is_dir($file)) && ($file_size != 4096)) { echo " <tr><td>[FILE] $file_link</td><td>" . round(($file_size /1024/1024),2 )." MB</td><td><a href=http://67.161.42.100/mp3/Techno&Trance/?act=view&dir=$dir/$file>[DETAILS]</a></td></tr>";}	$coun++;}echo "</table>";$total=count($filearray) - count($dirarray);echo "<br><table padding=0 width=100% ><tr><td bgcolor=#3984AC><b>Files listed: $total Directories listed:" . (count($dirarray)  - 2)."</td></tr></table>";return 0;class ID3v1x {  var $file_name;  var $tag;  var $title;  var $artist;  var $album;  var $year;  var $comm;  var $track;  var $genre;  function ID3v1x($inputfile) {    $this->file_name = $inputfile;  }  function read_tag() {    $file = fopen($this->file_name, "rb");    if($file == false) {      return false;    }    else {      fseek($file, -128, SEEK_END);      $this->tag = fgets($file, 4);      if($this->tag == 'TAG') {        $this->title = fgets($file, 31);        $this->artist = fgets($file, 31);        $this->album = fgets($file, 31);        $this->year = fgets($file, 5);        $this->comm = fgets($file, 29);        $this->temp = fgets($file, 2);        $this->track = fgets($file, 2);        $this->track = hexdec(bin2hex($this->track));        $this->genre = fgets($file, 2);        $this->genre = hexdec(bin2hex($this->genre));        $genre_list = array("Blues","ClassicRock","Country","Dance","Disco","Funk","Grunge","HipHop","Jazz",          "Metal","NewAge","Oldies","Other","Pop","R&B","Rap","Reggae","Rock","Techno",          "Industrial","Alternative","Ska","DeathMetal","Pranks","Soundtrack","Euro-Techno",          "Ambient","TripHop","Vocal","Jazz-Funk","Fusion","Trance","Classical","Instrumental",          "Acid", "House", "Game", "SoundClip", "Gospel", "Noise", "Alt.Rock", "Bass", "Soul", "Punk",          "Space", "Meditative", "InstrumentalPop", "InstrumentalRock", "Ethnic", "Gothic", "Darkwave",          "Techno-Industrial", "Electronic", "Pop/Folk", "Eurodance", "Dream", "SouthernRock", "Comedy",          "Cult", "GangstaRap", "Top40", "ChristianRap", "Pop/Funk", "Jungle", "NativeAmerican", "Cabaret",          "NewWave", "Psychedelic", "Rave", "Showtunes", "Trailer", "Lo-fi", "Tribal", "AcidPunk",          "AcidJazz", "Polka", "Retro", "Musical", "Rock'n'Roll", "HardRock", "Folk", "Folk/Rock",          "NationalFolk","Swing", "FastFusion", "Bebob", "Latin", "Revival", "Celtic", "BlueGrass",          "AvantGarde", "GothicRock", "ProgressiveRock", "PsychedelicRock", "SymphonicRock",          "SlowRock", "BigBand", "Chorus", "EasyListening", "Acoustic", "Humour", "Speech", "Chanson",          "Opera", "ChamberMusic", "Sonata", "Symphony", "BootyBass", "Primus", "PornGroove", "Satire",          "SlowJam", "Club", "Tango", "Samba", "Folklore", "Ballad", "PowerBallad", "RhythmicSoul",          "Freestyle", "Duet", "PunkRock", "DrumSolo", "Euro-House", "DanceHall", "Goa", "Drum&Bass",          "Club-House", "Hardcore", "Terror", "Indie", "BritPop", "Negerpunk", "PolskPunk", "Beat",          "ChristianGangstaRap", "HeavyMetal", "BlackMetal", "Crossover", "ContemporaryChristian",          "ChristianRock", "Merengue", "Salsa", "ThrashMetal","Anime","JPop","SynthPop");        $this->genre = @$genre_list[$this->genre];        return true;      }      else {        $this->tag = 'No ID3 tag';        return true;      }    }    fclose($file);  }}?>