Location: PHPKode > projects > Mummi (Multi-user MOD_MP3 Interface) > mummi.0.6/lib/audio-db.inc
<?

class AUDIO_DB extends MYSQL_DB{

	var $adb_id3v1_genres = array(
		0=>Blues,1=>'Classic Rock',2=>Country,3=>Dance,4=>Disco,5=>Funk,6=>Grunge,7=>'Hip-Hop',8=>Jazz,9=>Metal,
		10=>'New Age',11=>Oldies,12=>Other,13=>Pop,14=>'R&B',15=>Rap,16=>Reggae,17=>Rock,18=>Techno,19=>Industrial,
		20=>Alternative,21=>Ska,22=>'Death Metal',23=>Pranks,24=>Soundtrack,25=>'Euro-Techno',26=>Ambient,27=>'Trip-Hop',28=>Vocal,29=>'Jazz+Funk',
		30=>Fusion,31=>Trance,32=>Classical,33=>Instrumental,34=>Acid,35=>House,36=>Game,37=>'Sound Clip',38=>Gospel,39=>Noise,
		40=>AlternRock,41=>Bass,42=>Soul,43=>Punk,44=>Space,45=>Meditative,46=>'Instrumental Pop',47=>'Instrumental Rock',48=>Ethnic,49=>Gothic,
		50=>DarkWave,51=>'Techno-Industrial',52=>Electronic,53=>'Pop-Folk',54=>Eurodance,55=>Dream,56=>'Southern Rock',57=>Comedy,58=>Cult,59=>Gangsta,
		60=>'Top 40',61=>'Christian Rap',62=>'Pop/Funk',63=>Jungle,64=>'Native American',65=>Cabaret,66=>'New Wave',67=>Psychadelic,68=>Rave,69=>Showtunes,
		70=>Trailer,71=>'Lo-Fi',72=>Tribal,73=>'Acid Punk',74=>'Acid Jazz',75=>Polka,76=>Retro,77=>Musical,78=>'Rock & Roll',79=>'Hard Rock',
		80=>Folk,81=>'Folk/Rock',82=>'National Folk',83=>Swing,84=>'Fast Fusion',85=>Bebob,86=>Latin,87=>Revival,88=>Celtic,89=>Bluegrass,
		90=>'Avantgarde',91=>'Gothic Rock',92=>'Progressive Rock',93=>'Psychedelic Rock',94=>'Symphonic Rock',95=>'Slow Rock',96=>'Big Band',97=>'Chorus',98=>'Easy Listening',99=>'Acoustic',
		100=>Humour,101=>Speech,102=>Chanson,103=>Opera,104=>'Chamber Music',105=>Sonata,106=>Symphony,107=>'Booty Bass',108=>Primus,109=>'Porn Groove',
		110=>Satire,111=>'Slow Jam',112=>Club,113=>Tango,114=>Samba,115=>Folklore,116=>Ballad,117=>'Power Ballad',118=>'Rhythmic Soul',119=>Freestyle,
		120=>Duet,121=>'Punk Rock',122=>'Drum Solo',123=>Acapella,124=>'Euro-House',125=>'Dance Hall',126=>Goa,127=>'Drum & Bass',128=>'Club-House',129=>Hardcore,
		130=>Terror,131=>Indie,132=>BritPop,133=>Negerpunk,134=>'Polsk Punk',135=>Beat,136=>'Christian Gangsta Rap',137=>'Heavy Metal',138=>'Black Metal',139=>Crossover,
		140=>'Contemporary Christian',141=>'Christian Rock',142=>Merengue,143=>Salsa,144=>'Thrash Metal',145=>Anime,146=>JPop,147=>Synthpop);





	// Functions to check the database for various boolian conditions.

	// the md5 of the filename including the path.
	function chk_path_md5($path_md5){
		$query = "SELECT path_md5 FROM mp3_files WHERE path_md5 = '$path_md5'";
		if(!$this->num_rows($query))return false;
		else return true;
	}//eo function

	// The data_md5 is the md5 sum of the files content.
	// This is the best way to test for duplicate files with different filenames.
	function chk_data_md5($data_md5){
		$query = "SELECT data_md5 FROM $this->dbname WHERE data_md5 = '$data_md5'";
		if(!$this->num_rows($query))return false;
		else return true;
	}//eo function

	// Check the filename only, this doesn't include the path.
	function chk_file_name($file_name){
		$query = "SELECT file_name FROM $this->dbname WHERE file_name = '$file_name'";
		if(!$this->num_rows($query))return false;
		else return true;
	}//eo function

	// Check the path only, this does not include the filename.
	function chk_file_path($file_path){
		$query = "SELECT file_path FROM $this->dbname WHERE file_path = '$file_path'";
		if(!$this->num_rows($query))return false;
		else return true;
	}//eo function





	// Function to insert the mod_mp3 table.
	function insert_mod_mp3_main($name="", $filename="", $signature="", $artist="",$album="",$comment="",$track="", $year="", $genre=""){

		if(empty($name))$name = end(explode("/", $filename));

		$file_name = addslashes("$name");
		$file_name = addslashes("$filename");
		$file_name = addslashes("$signature");
		$file_name = addslashes("$artist");
		$file_name = addslashes("$album");
		$file_name = addslashes("$comment");
		$file_name = addslashes("$track");
		$file_name = addslashes("$year");
		$file_name = addslashes("$genre");


		$query ="INSERT INTO mod_mp3_main ".
				"VALUES(NULL, '$name', '$filename', '$signature', '$artist', '$album', '$comment', '$track', '$year', '$genre')";
		//echo "$query<br>\n";
		if($this->affected_rows($query)) return true;
		else return false;
	}

	// Function to insert the mod_mp3 table.
	function insert_mod_mp3_tokens($signature="", $genre=""){
		$file_name = addslashes("$signature");
		$file_name = addslashes("$genre");
		$query ="INSERT INTO mod_mp3_tokens ".
				"VALUES(NULL, '$genre', '$signature')";
		//echo "$query<br>\n";
		if($this->affected_rows($query)) return true;
		else return false;
	}




	// simple function to insert the main audio_files table.
	function insert_audio_files($file_path="", $file_name="", $file_size="", $path_md5="",$data_md5="",$file_owner="",$file_type="", $id3_v11="", $id3_v22="", $id3_v23="", $id3_v24="", $created="", $modified=""){
		$file_name = addslashes("$file_name");
		$file_path = addslashes("$file_path");
		$query = "INSERT INTO audio_files VALUES(NULL, '$file_path', '$file_name', '$file_size', '$path_md5','$data_md5','$file_owner', '$file_type', '$id3_v11', '$id3_v22', '$id3_v23', '$id3_v24', '$created', '$modified')";
		if($this->affected_rows($query)) return true;
		else return false;
	}

	// simple function to update the main audio_files table.
	function update_audio_files($id="", $file_path="", $file_name="", $file_size="", $path_md5="",$data_md5="",$file_owner="",$file_type="", $id3_v11="", $id3_v22="", $id3_v23="", $id3_v24="", $created="", $modified=""){
		$query = "UPDATE audio_files SET file_path='$file_path', file_name='$file_name', file_size='$file_size', path_md5='$path_md5', data_md5='$data_md5', file_owner='$file_owner', file_type='$file_type', id3_v11='$id3_v11', id3_v22='$id3_v22', id3_v23='$id3_v23', id3_v24='$id3_v24', created='$created', modified='$modified' WHERE id='$id'";
		if($this->affected_rows($query)) return true;
		else return false;
	}



	function insert_id3v23($path_md5="", $id3v2_major="",$id3v2_minor="",$id3v2_SIZE="",$COMM="",$IPLS="",$LINK="",$MCDI="",$PCNT="",$POPM="",$TALB="",$TCOM="",$TCON="",$TCOP="",$TENC="",$TIT1="",$TIT2="",$TIT3="",$TLEN="",$TMED="",$TOPE="",$TPE1="",$TPE2="",$TPE3="",$TRCK="",$TYER="",$USLT="",$WOAR="",$WXXX=""){

		$TIT1 = addslashes(ltrim($TIT1));
		$TIT2 = addslashes(ltrim($TIT2));
		$TIT3 = addslashes(ltrim($TIT3));
		$TPE1 = addslashes(ltrim($TPE1));
		$TPE2 = addslashes(ltrim($TPE2));
		$TPE3 = addslashes(ltrim($TPE3));
		$TALB = addslashes(ltrim($TALB));
		$IPLS = addslashes(ltrim($IPLS));
		$COMM = addslashes(ltrim($COMM));
		$TYER = addslashes(ltrim($TYER));
		$TRCK = addslashes(ltrim($TRCK));
		$TCOP = addslashes(ltrim($TCOP));
		$TENC = addslashes(ltrim($TENC));
		$TCOM = addslashes(ltrim($TCOM));
		$TOPE = addslashes(ltrim($TOPE));
		$PCNT = addslashes(ltrim($PCNT));
		$POPM = addslashes(ltrim($POPM));
		$TLEN = addslashes(ltrim($TLEN));
		$TMED = addslashes(ltrim($TMED));
		$MCDI = addslashes(ltrim($MCDI));
		$LINK = addslashes(ltrim($LINK));
		$TCON = addslashes(ltrim($TCON));
		$USLT = addslashes(ltrim($USLT));
		$WXXX = addslashes(ltrim($WXXX));
		$WOAR = addslashes(ltrim($WOAR));


		$query = "INSERT INTO id3v23 VALUES( 'NULL', '$path_md5', '$id3v2_major', '$id3v2_minor', '$id3v2_size', '$COMM', '$IPLS', '$LINK', '$MCDI', '$PCNT', '$POPM', '$TALB', '$TCOM', '$TCON', '$TCOP', '$TENC', '$TIT1', '$TIT2', '$TIT3', '$TLEN', '$TMED', '$TOPE', '$TPE1', '$TPE2', '$TPE3', '$TRCK', '$TYER', '$USLT', '$WOAR', '$WXXX')";
		//echo "<b><i>id3v23 query</i></b> = $query<br><Br>\n";
		if($this->affected_rows($query)){
			//echo "<b><i>worked</i></b><br><br>\n";
			return true;
		}
		else return false;
	}

	function update_id3v23($id="", $path_md5="", $id3v2_major="",$id3v2_minor="",$id3v2_SIZE="",$COMM="",$IPLS="",$LINK="",$MCDI="",$PCNT="",$POPM="",$TALB="",$TCOM="",$TCON="",$TCOP="",$TENC="",$TIT1="",$TIT2="",$TIT3="",$TLEN="",$TMED="",$TOPE="",$TPE1="",$TPE2="",$TPE3="",$TRCK="",$TYER="",$USLT="",$WOAR="",$WXXX=""){
		$query = "UPDATE id3v23 SET path_md5='$path_md5', id3v2_major='$id3v2_major', id3v2_minor='$id3v2_minor', id3v2_SIZE='$id3v2_size', COMM='$COMM',IPLS='$IPLS', LINK='$LINK', MCDI='$MCDI', PCNT='$PCNT', POPM='$POPM', TALB='$TALB', TCOM='$TCOM', TCON='$TCON', TCOP='$TCOP', TENC='$TENC', TIT1='$TIT1', TIT2='$TIT2', TIT3='$TIT3', TLEN='$TLEN', TMED='$TMED', TOPE='$TOPE', TPE1='$TPE1', TPE2='$TPE2', TPE3='$TPE3', TRCK='$TRCK', TYER='$TYER', USLT='$USLT', WOAR='$WOAR', WXXX='$WXXX' WHERE id='$id'";
		if($this->affected_rows($query)) return true;
		else return false;
	}


	function insert_mp3_files($path_md5="",$mp3_version="",$mp3_layer="",$mp3_crc="",$mp3_bitrate="",$mp3_frequency="",$mp3_padding="",$mp3_private="",$mp3_channelmode="",$mp3_copyright="",$mp3_original="",$mp3_emphasis="",$mp3_frameSIZE="",$mp3_frames="",$mp3_seconds="",$mp3_header="",$mp3_fps=""){
		$query = "INSERT INTO mp3_files VALUES(NULL, '$path_md5','$mp3_version','$mp3_layer','$mp3_crc','$mp3_bitrate','$mp3_frequency','$mp3_padding','$mp3_private','$mp3_channelmode','$mp3_copyright','$mp3_original','$mp3_emphasis','$mp3_framesize','$mp3_frames','$mp3_seconds','$mp3_header','$mp3_fps')";
		//echo "<b><i>mp3 files query</i></b> = $query<br><Br>\n";
		if($this->affected_rows($query)) return true;
		else return false;
	}

	// ;)
	function update_mp3_files($id="", $path_md5="",$mp3_version="",$mp3_layer="",$mp3_crc="",$mp3_bitrate="",$mp3_frequency="",$mp3_padding="",$mp3_private="",$mp3_channelmode="",$mp3_copyright="",$mp3_original="",$mp3_emphasis="",$mp3_frameSIZE="",$mp3_frames="",$mp3_seconds="",$mp3_header="",$mp3_fps=""){
		$query = "UPDATE mp3_files SET path_md5='$path_md5',mp3_version='$mp3_version',mp3_layer='$mp3_layer',mp3_crc='$mp3_crc',mp3_bitrate='$mp3_bitrate',mp3_frequency='$mp3_frequency',mp3_padding='$mp3_padding',mp3_private='$mp3_private',mp3_channelmode='$mp3_channelmode',mp3_copyright='$mp3_copyright',mp3_original='$mp3_original',mp3_emphasis='$mp3_emphasis',mp3_frameSIZE='$mp3_framesize',mp3_frames='$mp3_frames',mp3_seconds='$mp3_seconds',mp3_header='$mp3_header',mp3_fps='$mp3_fps' WHERE id='$id'";
		if($this->affected_rows($query)) return true;
		else return false;
	}

	function insert_id3v11($path_md5="",$title="",$artist="",$album="",$comment="",$year="",$track="0",$genre="255"){
		$title = addslashes("$title");
		$artist = addslashes("$artist");
		$album = addslashes("$album");
		$comment = addslashes("$comment");

		$query = "INSERT INTO id3v11 VALUES(NULL, '$path_md5','$title' ,'$artist','$album','$comment','$year','$track','$genre')";
		//echo "<b><i>id3v11 query</i></b> = $query<br><Br>\n";
		if($this->affected_rows($query)) return true;
		else return false;
	}

	function update_id3v11($id="", $path_md5="",$title="",$artist="",$album="",$comment="",$year="",$track="",$genre=""){
		$query = "UPDATE id3v11 SET path_md5='$path_md5',title='$title',artist='$artist',album='$album',comment='$comment',year='$year',track='$track',genre='$genre' WHERE id='$id'";
		if($this->affected_rows($query)) return true;
		else return false;
	}





//	// Get the title of an mp3 by passing the path string.
//	function pull_filepath_to_id($filepath){
//		$query = "SELECT id FROM audio_files WHERE file_path = '$filepath'";
//		$query_data = $this->fetch_numeric($query);
//		return $query_data[0][0];
//	}//eo function



	// Get the title of an mp3 by passing the path string.
	function pull_id3v11_id($md5path){
		$query = "SELECT id FROM id3v11 WHERE path_md5 = '$md5path'";
		$query_data = $this->fetch_numeric($query);
		return $query_data[0][0];
	}//eo function


	// Get the title of an mp3 by passing the path string.
	function pull_audio_id($md5path){
		$query = "SELECT id FROM audio_files WHERE path_md5 = '$md5path'";
		$query_data = $this->fetch_numeric($query);
		return $query_data[0][0];
	}//eo function



	// convert the md5 into a path.
	function pull_md5path_to_filepath($path_md5){
		$query ="SELECT file_path,file_name ".
				"FROM audio_files ".
				"WHERE path_md5='$path_md5'";
		if(!$query_data = $this->fetch_assoc($query))return false;
		$query_data = $query_data[0];
		$filepath = $query_data[file_path]."/".$query_data[file_name];
		//echo "$filepath<br>\n";
		return $filepath;
	}//eo function


	// Get the title of an mp3 by passing the md5 string.
	function pull_audio_title($path_md5){
		$query ="SELECT * ".
				"FROM audio_files,id3v11 ".
				"WHERE path_md5='$path_md5'";
		$result_array = $this->fetch_assoc($query);
		if(is_array($result_array)){
			while($qd = mysql_fetch_array($result)){
				$title = $qd[title];
				if(!$title) $title = $qd[filename];
				$sh = $qd["seconds"];
			}
		}else return false;
		return array($title,$sh);
	}






function pull_plst_info($path_md5){
	$query ="SELECT file_name,file_size,file_type,id3_v11,id3_v22,id3_v23,id3_v24 ".
			"FROM audio_files ".
			"WHERE path_md5='$path_md5'";
	//echo "query = $query<br><br>\n";
	if(!$query_array = $this->fetch_numeric($query))return false;
	while(list($k,$v) = each($query_array)){
		if($v[0])$return_array[filename] = $v[0];
		if($v[1])$return_array[filesize] = $v[1];
		if($v[2]){
			$return_array[file_type] = $v[2];
			switch($v[2]){
				case "mp3":
					//query mp3 array.
					$mp3_query ="SELECT mp3_seconds,mp3_bitrate ".
								"FROM mp3_files ".
								"WHERE path_md5='$path_md5'";
					$mp3_data = $this->fetch_numeric($mp3_query);
					$return_array[seconds] = $mp3_data[0][0];
					$return_array[bitrate] = $mp3_data[0][1];
				break;
				case "ogg":
					//query ogg array for seconds.
					$ogg_query ="SELECT ogg_seconds,ogg_bitrate ".
								"FROM ogg_files ".
								"WHERE path_md5='$path_md5'";
					$ogg_data = $this->fetch_numeric($ogg_query);
					$return_array[seconds] = $ogg_data[0][0];
					$return_array[bitrate] = $ogg_data[0][0];
				break;
			}//eo switch
		}
		if($v[3]){	//id3v11
			$return_array[id3v1] = true;
			$id3v11_query = "SELECT title,artist,album,genre ".
							"FROM id3v11 ".
							"WHERE path_md5='$path_md5'";
			$id3v11a = $this->fetch_assoc($id3v11_query);
			$return_array[id3v1_title] = $id3v11a[0][title];
			$return_array[id3v1_artist] = $id3v11a[0][artist];
			$return_array[id3v1_album] = $id3v11a[0][album];
			$return_array[id3v1_genre_id] = $id3v11a[0][genre];
			$return_array[id3v1_genre] = $this->adb_id3v1_genres[$return_array[id3v1_genre_id]];
		}
		if($v[4]){
			$return_array[id3v2] = true;
			$id3v22_query = "SELECT TT2,TP1,TAL ".
							"FROM id3v22 ".
							"WHERE path_md5='$path_md5'";
			$id3v22a = $this->fetch_assoc($id3v22_query);
			$return_array[id3v2_title] = $id3v22a[0][TT2];
			$return_array[id3v2_artist] = $id3v22a[0][TP1];
			$return_array[id3v2_album] = $id3v22a[0][TAL];
		}
		elseif($v[5]){
			$return_array[id3v2] = true;
			$id3v23_query = "SELECT TIT2,TPE1,TALB ".
							"FROM id3v23 ".
							"WHERE path_md5='$path_md5'";
			$id3v23a = $this->fetch_assoc($id3v23_query);
			$return_array[id3v2_title] = $id3v23a[0][TIT2];
			$return_array[id3v2_artist] = $id3v23a[0][TPE1];
			$return_array[id3v2_album] = $id3v23a[0][TALB];
		}
		elseif($v[6]){
			$return_array[id3v2] = true;
			$id3v24_query = "SELECT TIT2,TPE1,TALB ".
							"FROM id3v24 ".
							"WHERE path_md5='$path_md5'";
			$id3v24a = $this->fetch_assoc($id3v24_query);
			$return_array[id3v2_title] = $id3v24a[0][TIT2];
			$return_array[id3v2_artist] = $id3v24a[0][TPE1];
			$return_array[id3v2_album] = $id3v24a[0][TALB];
		}
	}//eo while
	return $return_array;
}//eo function



// new function to split up arrays
function array_chunk ($a, $s, $p=false) {
 $r = Array();
 $ak = @array_keys($a);
 $i = 0;
 $sc = 0;
 for ($x=0;$x<count($ak);$x++) {
  if ($i == $s){$i = 0;$sc++;}
  $k = ($p) ? $ak[$x] : $i;
  $r[$sc][$k] = $a[$ak[$x]];
  $i++;
 }
 return $r;
}





function search_audio($uid, $q){

	$query ="SELECT file_name,path_md5,file_size,file_type,id3_v11,id3_v22,id3_v23,id3_v24 ".
			"FROM audio_files ".
			"WHERE file_owner='$uid'";

	if(!$query_array = $this->fetch_numeric($query))return false;

	$cc=0;
	while(list($k,$v) = each($query_array)){
		if($v[0]){$return_array[$cc][name] = $v[0];}
		if($v[1]){$return_array[$cc][path_md5] = $v[1];}
		if($v[2]){$return_array[$cc][file_size] = $v[2];}
		if($v[3]){$return_array[$cc][file_type] = $v[3];
			switch($v[3]){
				case "mp3":
					$query ="SELECT mp3_bitrate,mp3_frequency,mp3_seconds ".
							"FROM mp3_files ".
							"WHERE path_md5='$v[1]'";
					//echo "query = $query<br><br>\n";
					$query_array1 = $this->fetch_numeric($query);
					$return_array[$cc][mp3_bitrate] = $query_array1[0][0];
					$return_array[$cc][mp3_frequency] = $query_array1[0][1];
					$return_array[$cc][mp3_seconds] = $query_array1[0][2];
				break;
				case "ogg":
					$query ="SELECT ogg_bitrate,ogg_frequency,ogg_seconds ".
							"FROM ogg_files ".
							"WHERE path_md5='$v[1]'";
					//echo "query = $query<br><br>\n";
					$query_array1 = $this->fetch_numeric($query);
					$return_array[$cc][ogg_bitrate] = $query_array1[0][0];
					$return_array[$cc][ogg_frequency] = $query_array1[0][1];
					$return_array[$cc][ogg_seconds] = $query_array1[0][2];
				break;
			}//eo switch
		}
		if($v[4]){
			$return_array[$cc][id3v1] = true;
			$id3v11_query = "SELECT title,artist,album,comment,genre ".
							"FROM id3v11 ".
							"WHERE path_md5='$v[1]'";
			$id3v11a = $this->fetch_assoc($id3v11_query);
			$return_array[$cc][id3v1_title] = $id3v11a[0][title];
			$return_array[$cc][id3v1_artist] = $id3v11a[0][artist];
			$return_array[$cc][id3v1_album] = $id3v11a[0][album];
			$return_array[$cc][id3v1_comment] = $id3v11a[0][comment];
			$return_array[$cc][id3v1_genre] = $id3v11a[0][genre];
		}
		if($v[5]){
			$return_array[$cc][id3v2] = true;
			$id3v22_query = "SELECT TT2,TP1,TAL,COM ".
							"FROM id3v22 ".
							"WHERE path_md5='$v[1]'";
			$id3v22a = $this->fetch_assoc($id3v22_query);
			$return_array[$cc][id3v2_title] = $id3v22a[0][TT2];
			$return_array[$cc][id3v2_artist] = $id3v22a[0][TP1];
			$return_array[$cc][id3v2_album] = $id3v22a[0][TAL];
			$return_array[$cc][id3v2_comment] = $id3v22a[0][COM];
		}

		if($v[6]){
			$return_array[$cc][id3v2] = true;
			$id3v23_query = "SELECT TIT2,TPE1,TALB,COMM ".
							"FROM id3v23 ".
							"WHERE path_md5='$v[1]'";
			$id3v23a = $this->fetch_assoc($id3v23_query);
			$return_array[$cc][id3v2_title] = $id3v23a[0][TIT2];
			$return_array[$cc][id3v2_artist] = $id3v23a[0][TPE1];
			$return_array[$cc][id3v2_album] = $id3v23a[0][TALB];
			$return_array[$cc][id3v2_comment] = $id3v23a[0][COMM];
		}

		if($v[7]){
			$return_array[$cc][id3v2] = true;
			$id3v24_query = "SELECT TIT2,TPE1,TALB,COMM ".
							"FROM id3v24 ".
							"WHERE path_md5='$v[1]'";
			$id3v24a = $this->fetch_assoc($id3v24_query);
			$return_array[$cc][id3v2_title] = $id3v24a[0][TIT2];
			$return_array[$cc][id3v2_artist] = $id3v24a[0][TPE1];
			$return_array[$cc][id3v2_album] = $id3v24a[0][TALB];
			$return_array[$cc][id3v2_comment] = $id3v24a[0][COMM];
		}
		++$cc;
	}//eo while

	// search the arrays for a match.
	$rr=0;
	while(list($zx,$xz) = each($return_array)){
		//echo "$zx = ".serialize($xz)."<br><br><br>\n";
		while(list($vb,$bv) = each($xz)){
			//echo "<FONT COLOR=\"purple\">$vb = $bv</FONT><br>\n";
			if(eregi($q, $bv)){
				//echo "<FONT COLOR=\"red\">'$bv'</FONT> does contains <FONT COLOR=\"red\">'$q'!</FONT><br><br>\n";
				$real_return_array[$rr] = $xz;
				$rr++;
				break;
			}
		}//eo while
	}//eo while
	//echo serialize($real_return_array)."<br><br><br>\n";

	// this is used to return the number is entries that will be returned
	// to the search page.  Page numbering will be based on this number.
	$GLOBALS[real_return_array_count] = $rr;
	return $real_return_array;

}//eo function







	function pull_audio_stats($uid){

		//"SELECT count(file_name),SUM(file_size),SUM(id3_v11),SUM(id3_v22),SUM(id3_v23),SUM(id3_v24) "
		$af_query = "SELECT * FROM audio_files WHERE file_owner='$uid'";
		//echo "query = $af_query<br><br>\n";

		if(!$stat_array = $this->fetch_numeric($af_query))return false;

		//echo "<br>\n";
		//echo serialize($stat_array)."<br>\n";





		while(list($k,$v) = each($stat_array)){
//

			switch($v[7]){
				case "mp3":
					$mp3_query = "SELECT * FROM mp3_files WHERE path_md5='$v[4]'";
					$mp3_array = $this->fetch_assoc($mp3_query);
					//echo serialize($mp3_array)."<br><br>\n";
					switch($mp3_array[0]["mp3_version"]){
						case 1: $return_array[mp3_mpeg1_c] += 1; break;
						case 2: $return_array[mp3_mpeg2_c] += 1; break;
						case 3: $return_array[mp3_mpeg25_c] += 1; break;
					}//eo switch

					switch($mp3_array[0]["mp3_layer"]){
						case 1: $return_array[mp3_layer1_c] += 1; break;
						case 2: $return_array[mp3_layer2_c] += 1; break;
						case 3: $return_array[mp3_layer3_c] += 1; break;
					}//eo switch
					if($mp3_array[0]["mp3_crc"]) $return_array[mp3_crc_c] += 1;
					if($mp3_array[0]["mp3_padding"]) $return_array[mp3_pad_c] += 1;
					if($mp3_array[0]["mp3_private"]) $return_array[mp3_priv_c] += 1;
					if($mp3_array[0]["mp3_copyright"]) $return_array[mp3_copyright_c] += 1;
					if($mp3_array[0]["mp3_original"]) $return_array[mp3_orig_c] += 1;

					switch($mp3_array[0]["mp3_emphasis"]){
						case 1:	$return_array[mp3_empccit_c] += 1; break;
						case 2:	$return_array[mp3_emp50_c] += 1; break;
						case 3:	$return_array[mp3_emp_c] += 1; break;
					}//eo switch

					//echo "channel mode = ".serialize($mp3_array[0][mp3_channelmode])."<br>\n";
					switch($mp3_array[0]["mp3_channelmode"]){
						case 1: $return_array[mp3_mono_c] += 1; break;
						case 2: $return_array[mp3_dchan_c] += 1; break;
						case 3: $return_array[mp3_jstereo_c] += 1; break;
						case 4: $return_array[mp3_stereo_c] += 1; break;
					}//eo switch

					$tseconds += $mp3_array[0][mp3_seconds];
					//echo "tseconds = $tseconds<br>\n";

					$tsize += $v[3];
					//echo "tsize = $tsize<br><br>\n";
//
//
//					$second_a = ($tseconds%60);
//					$minute_a = (($tseconds/60)%60);
//					$hour_a = ((floor($tseconds/60)/60)%24);
//					$day_a = floor(floor(floor($tseconds/60)/60)/24);
//					$second_a = strlen($second_a) == 1 ? "0$second_a" : $second_a;
//					$minute_a = strlen($minute_a) == 1 ? "0$minute_a" : $minute_a;
//					$hour_a = strlen($hour_a) == 1 ? "0$hour_a" : $hour_a;
//					$day_a = strlen($day_a) == 1 ? "0$day_a" : $day_a;
//					$length = "$day_a:$hour_a:$minute_a:$second_a";
//					$Gb_a = floor($tsize / 1000000000);
//					$Mb_a = floor(floor($tsize / 1000000) / 100);
//
//					$return_array[length] = $length;
//					$return_array[tseconds] = $tseconds;
//					$return_array[Gb_a] = $Gb_a;
//					$return_array[Mb_a] = $Mb_a;




				break;
				case "ogg":
					$mp3_query = "SELECT * FROM ogg_files WHERE path_md5='$v[4]'";
					$ogg_array = $this->fetch_assoc($mp3_query);
					echo "ogg array = ".serialize($ogg_array)."<br>\n";
				break;
			}//eo switch
			if($v[8]){
				$return_array[id3v11] += $v[8];
				$id3v11_query = "SELECT * FROM id3v11 WHERE path_md5='$v[4]'";
				//echo "id3v11 query = $id3v11_query<br>\n";
				$id3v11_array = $this->fetch_assoc($id3v11_query);
				//echo serialize($id3v11_array)."<br>\n";
				// RECORD THE ID3V1 DATA.
				if($id3v11_array[0]["genre"] <= count($this->adb_id3v1_genres))	$return_array[id3v11_genres_c] += 1;
				if($id3v11_array[0]["title"]) $return_array[id3v11_title_c] += 1;
				if($id3v11_array[0]["artist"])	$return_array[id3v11_artist_c] += 1;
				if($id3v11_array[0]["album"]) $return_array[id3v11_album_c] += 1;
			}
			if($v[9]){
				$return_array[id3v22] += $v[9];
				$id3v22_query = "SELECT * FROM id3v22 WHERE path_md5='$v[4]'";
				$id3v22_array = $this->fetch_assoc($id3v22_query);
				//echo serialize($id3v22_array)."<br>\n";
				// RECORD THE ID3V22 DATA.
				if($id3v22_array[0]["TCO"] != '255') $return_array[id3v22_genres_c] += 1;
				if($id3v22_array[0]["TT2"]) $return_array[id3v22_title_c] += 1;
				if($id3v22_array[0]["TP1"]) $return_array[id3v22_artist_c] += 1;
				if($id3v22_array[0]["TAL"]) $return_array[id3v22_album_c] += 1;
			}
			if($v[10]){
				$return_array[id3v23] += $v[10];
				$id3v23_query = "SELECT * FROM id3v23 WHERE path_md5='$v[4]'";
				$id3v23_array = $this->fetch_assoc($id3v23_query);
				//echo serialize($id3v23_array)."<br>\n";
				// RECORD THE ID3V23 DATA.
				if($id3v23_array[0]["TCON"] != '255') $return_array[id3v23_genres_c] += 1;
				if($id3v23_array[0]["TIT2"]) $return_array[id3v23_title_c] += 1;
				if($id3v23_array[0]["TPE1"]) $return_array[id3v23_artist_c] += 1;
				if($id3v23_array[0]["TALB"]) $return_array[id3v23_album_c] += 1;
			}
			if($v[11]){
				$return_array[id3v24] += $v[11];
				$id3v24_query = "SELECT * FROM id3v24 WHERE path_md5='$v[4]'";
				$id3v24_array = $this->fetch_assoc($id3v24_query);
				//echo serialize($id3v24_array)."<br>\n";
				// RECORD THE ID3V24 DATA.
				if($id3v24_array[0]["TCON"] != '255') $return_array[id3v24_genres_c] += 1;
				if($id3v24_array[0]["TIT2"]) $return_array[id3v24_title_c] += 1;
				if($id3v24_array[0]["TPE1"]) $return_array[id3v24_artist_c] += 1;
				if($id3v24_array[0]["TALB"]) $return_array[id3v24_album_c] += 1;
			}
		}//eo while
		return $return_array;
	}//eo stats function

	function pull_music_stats(){

		$af_query = "SELECT count(afs.file_name),SUM(afs.file_size),SUM(afs.id3_v11),SUM(afs.id3_v22),SUM(afs.id3_v23),SUM(afs.id3_v24),SUM(mfs.mp3_seconds),SUM(ofs.ogg_seconds) ".
					"audio_files AS afs, ".
					"mp3_files AS mfs".
					"ogg_files AS ofs".
					"WHERE audio_files.file_owner='$uid'";

		$query ="SELECT count(file_name),SUM(file_size),SUM(id3_v11),SUM(id3_v22),SUM(id3_v23),SUM(id3_v24) ".
				"FROM audio_files ".
				"WHERE file_owner='".$GLOBALS[result_array][user_name]."'";

		//$af_query = "SELECT * FROM audio_files WHERE file_owner='$uid'";
		//echo "query = $af_query<br><br>\n";

	}






	function insert_tmp_movefile($user_name, $move_array, $table="tmp_movefile"){
		$move_array = OVERSEER::encipher($move_array,$GLOBALS[secret_key]);
		$time = md5($GLOBALS[current_utime]);
		$query = "INSERT INTO $table VALUES('$time', '$user_name', '$move_array')";
		if(!$this->affected_rows($query))return false;
		else return true;
	}


	function insert_tmp_syncfile($user_name, $sync_array, $table="tmp_syncfile"){
		$sync_array = OVERSEER::encipher($sync_array,$GLOBALS[secret_key]);
		$time = md5($GLOBALS[current_utime]);
		$query = "INSERT INTO $table VALUES('$time', '$user_name', '$sync_array')";
		//echo "insert sync query = $query<br>\n<br>";
		if(!$this->affected_rows($query))return false;
		else return true;
	}

	function insert_tmp_playlist($user_name, $plst_array, $table="tmp_playlist"){
		$plst_array = OVERSEER::encipher($plst_array,$GLOBALS[secret_key]);
		$time = md5($GLOBALS[current_utime]);
		$query = "INSERT INTO $table VALUES('$time', '$user_name', '$plst_array')";
		//echo "insert plst query = $query<br>\n<br>";
		if(!$this->affected_rows($query))return false;
		else return true;
	}

	function insert_user_playlist($user_name, $plst_name="new playlist", $plst_mood="", $plst_array, $table="user_playlist"){
		$plst_count = count($plst_array);
		$plst_array = OVERSEER::encipher($plst_array,$GLOBALS[secret_key]);
		$time = $GLOBALS[current_utime];
		$ss_time = md5($GLOBALS[current_utime]);
		$query = "INSERT INTO $table VALUES('$ss_time', '$plst_name', '$time', '$time', '$user_name', '$plst_mood', '$plst_count', '', '$plst_array')";
		if(!$this->affected_rows($query))return false;
		else return true;
	}

	function update_user_playlist($id="", $plst_name="", $plst_mood="", $plst_array="", $plst_visible="", $table="user_playlist"){
		//echo serialize($plst_array)."<br>\n";
		$plst_count = count($plst_array);
		$plst_array = OVERSEER::encipher($plst_array,$GLOBALS[secret_key]);
		$time = $GLOBALS[current_utime];
		$query ="UPDATE user_playlist ".
						"SET plst_name='$plst_name',".
						"modified='$time',".
						"plst_mood='$plst_mood',".
						"plst_count='$plst_count',".
						"plst_visible='$plst_visible',".
						"plst_array='$plst_array' ".
						"WHERE id='$id' ";
		//echo "update plst query = $query<br>\n<br>";
		if(!$this->affected_rows($query))return false;
		else return true;
	}


















}//eo class

?>
Return current item: Mummi (Multi-user MOD_MP3 Interface)