<?php
/******************

* Developed by vibehypes media: Mp3 Mixer

* Coded by Ayorinde Ayodeji
* Naijabamz.com | Naijabamz@gmail.com

******************/


echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv=\'Content-Type\' content=\'text/html; charset=ISO-8859-1;charset=windows-1252\' />

<meta name="keywords" content="mp3 tag editor,php mp3 tag editor,automatic mp3 tag editor" />

<meta name="description" content="Edit mp3 tags online." />

<title>Naijabamz - Online mp3 Tagger</title>

<link rel="stylesheet" href="style.css" />
</head>


<body>';

function friendly_size($size,$round=2)
{
$sizes=array(' Byts',' Kb',' Mb',' Gb',' Tb');
$total=count($sizes)-1;
for($i=0;$size>1024 && $i<$total;$i++){
$size/=1024;
}
return round($size,$round).$sizes[$i];
}
$default_mp3_directory =  "uploads/";
$sitename = "Loadedhitz.com.ng"; // default site title
$url = "http://LOADEDHITZ.COM.NG"; // no slash at end
if(isset($_GET['site']))
{
$sitename= strip_tags($_GET['site']);
}
if(isset($_GET['url']))
{
$url = strip_tags($_GET['url']);
}
$default_filename_prefix = '[Loadedhitz.Com.ng].mp3';
$default_songname_prefix = " | Loadedhitz.com.ng";
$default_comment = 'Mp3 Tag Editor by '.$sitename.'';
$default_artist = '';
$default_album = "@Loadedhitz.com.ng";
$default_year = date("Y");
$default_genre = "Loadedhitz.Com.ng";
?>
<table style="width: 2%;" class="logo"><tbody><tr><td valign="bottom"><a href="#"><img src="logo.png" alt="logo" title=""></a></td><td align="right"></td></tr></tbody></table>
<?php
if(isset($_POST['submit'])){
$mp3_filepath = isset($_POST['mp3_filepath']) ? $_POST['mp3_filepath'] : '';
$mp3_filename = isset($_POST['mp3_filename']) ? $_POST['mp3_filename'] : '';
$mp3_songname = isset($_POST['mp3_songname']) ? $_POST['mp3_songname'] : '';
$mp3_comment = isset($_POST['mp3_comment']) ? $_POST['mp3_comment'] : $default_comment;
$mp3_band = isset($_POST['mp3_band']) ? $_POST['mp3_band'] : '';
$mp3_publisher = isset($_POST['mp3_publisher']) ? $_POST['mp3_publisher'] : '';
$mp3_composer = isset($_POST['mp3_composer']) ? $_POST['mp3_composer'] : '';
$mp3_original_artist = isset($_POST['mp3_original_artist']) ? $_POST['mp3_original_artist'] : '';
$mp3_copyright = isset($_POST['mp3_copyright']) ? $_POST['mp3_copyright'] : '';
$mp3_encoded_by = isset($_POST['mp3_encoded_by']) ? $_POST['mp3_encoded_by'] : '';
$mp3_user_defined = isset($_POST['mp3_user_defined']) ? $_POST['mp3_user_defined'] : '';
$mp3_wxxx = isset($_POST['mp3_wxxx']) ? $_POST['mp3_wxxx'] : '';
$mp3_artist = isset($_POST['mp3_artist']) ? $_POST['mp3_artist'] : $default_artist;
$mp3_album = isset($_POST['mp3_album']) ? $_POST['mp3_album'] : $default_album;
$mp3_year = isset($_POST['mp3_year']) ? $_POST['mp3_year'] : $default_year;
$mp3_genre = isset($_POST['mp3_genre']) ? $_POST['mp3_genre'] : $default_genre;
$mp3_track = isset($_POST['track']) ? $_POST['track'] : '';

if(filter_var($mp3_filepath,FILTER_VALIDATE_URL)){
if($mp3_filename!="")
{
$mp3_filename = str_replace(DIRECTORY_SEPARATOR,"-X-",$mp3_filename);
if(strtolower(@end(@explode(".",basename($mp3_filepath))))!="mp3"){
exit("<br />URL must have a .mp3 extension !");
}
if(strtolower(@end(@explode(".",basename($mp3_filename))))!="mp3"){
exit("<br />Filename must have a .mp3 exntension !");
}
 $sname = $default_mp3_directory.$mp3_filename;
 if((file_exists($sname)) || (file_exists("voicetracks/".$mp3_filename)))
 {
 $extension = @end(@explode('.',$sname));
 $mp3_filename = str_replace(".".$extension,"_".rand(0,999).".".$extension,$mp3_filename);   
 } 
 $sname = $default_mp3_directory.$mp3_filename;
  $j_sname = $default_mp3_directory.$mp3_filename;
 if(isset($_POST['mp3_voice_track']) && $_POST['mp3_voice_track']=="on")
 {
 $sname = "voicetracks/".$mp3_filename;
 }

// Check if directories exist before copying
if (!is_dir($default_mp3_directory)) {
    if (!mkdir($default_mp3_directory, 0755, true)) {
        echo '<div class="rmenu">Failed to create uploads directory.</div>';
        exit;
    }
}

if(copy($mp3_filepath,$j_sname)){
if(isset($_POST['mp3_voice_track']) && $_POST['mp3_voice_track']=="on" && isset($_POST['mp3_voicetrack']) && $_POST['mp3_voicetrack']!='')
{
// Check if temp_joins directory exists
if (!is_dir("temp_joins")) {
    mkdir("temp_joins", 0755, true);
}

if(copy($_POST['mp3_voicetrack'],"temp_joins/".$mp3_filename))
{
include 'function.joinmp3.php';
$place = isset($_POST['mp3_voice_track_add']) ? $_POST['mp3_voice_track_add'] : 'first';
if($place=="first")
{
$FilenamesIn[] = "temp_joins/".$mp3_filename;
$FilenamesIn[] = $j_sname;
}
else
{
$FilenamesIn[] = $j_sname;
$FilenamesIn[] = "temp_joins/".$mp3_filename;
}

// Check if voicetracks directory exists
if (!is_dir("voicetracks")) {
    mkdir("voicetracks", 0755, true);
}

 if (CombineMultipleMP3sTo($sname, $FilenamesIn)) {
if(file_exists("temp_joins/".$mp3_filename)) unlink("temp_joins/".$mp3_filename);
if(file_exists($default_mp3_directory."/".$mp3_filename)) unlink($default_mp3_directory."/".$mp3_filename);
if(file_exists("voicetracks/".$mp3_filename)) rename("voicetracks/".$mp3_filename,$default_mp3_directory."/".$mp3_filename);
 }
 }
 else echo '<div class="rmenu">Unable to upload Voice Track</div><br />';
}
$sname = $default_mp3_directory."/".$mp3_filename;
$size = friendly_size(filesize($sname));        
$mp3_tagformat = 'UTF-8';

// Check if getID3 library exists
if (!file_exists('getid3/getid3.php')) {
    echo '<div class="rmenu"><b>Error:</b> getID3 library is missing!<br>
    Please download it from <a href="https://www.getid3.org/" target="_blank">https://www.getid3.org/</a><br>
    and extract the "getid3" folder to your script directory.</div>';
    exit;
}

require_once('getid3/getid3.php');
$mp3_handler = new getID3;
$mp3_handler->setOption(array('encoding'=>$mp3_tagformat));
require_once('getid3/write.php'); 
$mp3_writter = new getid3_writetags;
$mp3_writter->filename       = $sname;
$mp3_writter->tagformats     = array('id3v1', 'id3v2.3');
$mp3_writter->overwrite_tags = true;
$mp3_writter->tag_encoding   = $mp3_tagformat;
$mp3_writter->remove_other_tags = true;
$mp3_data['title'][]   = $mp3_songname;
$mp3_data['artist'][]  = $mp3_artist;
$mp3_data['album'][]   = $mp3_album;
$mp3_data['year'][]    = $mp3_year;
$mp3_data['genre'][]   = $mp3_genre;
$mp3_data['comment'][] = $mp3_comment;
$mp3_data['publisher'][] = $mp3_publisher;
$mp3_data['composer'][] = $mp3_composer;
$mp3_data['band'][] = $mp3_band;
$mp3_data['commercial_information'][] = $mp3_wxxx;
$mp3_data['url_user'][] = $mp3_user_defined;
$mp3_data['track'][] = $mp3_track;
$mp3_data['original_artist'][] = $mp3_original_artist;
$mp3_data['copyright_message'][] = $mp3_copyright;
$mp3_data['encoded_by'][] = $mp3_encoded_by;

$album_art = isset($_POST['album_art']) ? @end(@explode('/',$_POST['album_art'])) : '';
if(!empty($album_art) && isset($_POST['album_art']) && !empty($_POST['album_art'])) {
    $album_path = "temp_albumarts/".$album_art;
    $album_ext = strtolower(@end(@explode('.',$album_art)));
    
    // Check if temp_albumarts directory exists
    if (!is_dir("temp_albumarts")) {
        mkdir("temp_albumarts", 0755, true);
    }
    
    if(in_array($album_ext, array("png","jpeg","jpg","gif")) && (copy($_POST['album_art'], $album_path)))
    {
        // Set correct MIME type
        switch($album_ext) {
            case 'jpeg':
            case 'jpg':
                $mime_type = "image/jpeg";
                break;
            case 'png':
                $mime_type = "image/png";
                break;
            case 'gif':
                $mime_type = "image/gif";
                break;
            default:
                $mime_type = "image/jpeg";
        }
        
        // Only add album art if file is successfully copied and readable
        if(file_exists($album_path) && is_readable($album_path)) {
            $image_data = file_get_contents($album_path);
            if($image_data !== false) {
                $mp3_data['attached_picture'][0]['data'] = $image_data;
                $mp3_data['attached_picture'][0]['picturetypeid'] = 3; // Cover (front)
                $mp3_data['attached_picture'][0]['description'] = 'Cover';
                $mp3_data['attached_picture'][0]['mime'] = $mime_type;
            } else {
                echo '<div class="rmenu">Could not read album art file!</div>'; 
            }
        } else {
            echo '<div class="rmenu">Album art file not accessible!</div>'; 
        }
    }
    else
    {
        echo '<div class="rmenu">Incompatible image format or download failed!</div>'; 
    }
}

$mp3_writter->tag_data = $mp3_data;

if($mp3_writter->WriteTags()) {
$id3 = new getID3;
$info = $id3->analyze($sname);
echo '<div class="phdr"><b>MP3 Taged Notice</b></div><div class="gmenu">
<center><font color="green"><b>Tags Were Successfully Written.</b></font></center>
</div><div class="list1"><b>Copied:</b><br><div class="func">
<a href="'.$mp3_filepath.'">'.$mp3_filepath.'</a></div><p><b>To:</b></p><br><center>
<a class="fmenu" href="'.$sname.'"><b>Download Now<br>'.basename($sname).'</b></a>
<br>Size: <font color="blue">( '.$size.' )</font></center></div>
<div class="phdr"><b>Direct Download Url</b></div><div align="center" class="list2">
<input size="25" type="text" class="input" name="mp3_filename" value="'.$url.'/'.$sname.'"></div>
<div class="rmenu">
<font color="red"><b>Warning:</b></font> Download Link Is AVAILABLE 1 hour</div>
';
if(isset($_POST['mp3_info_view']) && $_POST['mp3_info_view']=="on")
{
echo '<div class="phdr"><b>Mp3 Tag Information</b>
</div>';
if(isset($_POST['album_art']) && !empty($_POST['album_art']))echo '<div class="list2"><center><img class="gmenu" src="cover.php?type='.$mime_type.'&p='.basename($sname).'&img='.$album_art.'" width="200" height="200" alt="art">
</center></div>';
echo '<div class="list1">Title: '.$info['id3v1']['title'].'</div>
<div class="list2">Artist: '.$info['id3v1']['artist'].'</div>

<div class="list1">Album: '.$info['id3v1']['album'].'</div>

<div class="list2">Comment: '.$info['id3v1']['comment'].'</div>
<div class="list1">Year: '.$info['id3v1']['year'].'</div>

<div class="list2">Duration: '.$info['playtime_string'].'</div>';
}
}
else{
echo"<br />Failed to write tags!<br>".implode("<br /><br />",$mp3_writter->errors);
}
}
else{echo '<div class="rmenu">Unable to copy file.</div>';}
}
else{echo '<div class="rmenu">Empty filename.</div>';}
}
else{echo '<div class="rmenu">Invalid FilePath.</div>';}
}
else{
?>



<style>
body { font-size: 100%; background: #DEDEDE; margin: 0 auto; text-align: center;}
.wrapper { background: #F5F5F5; padding: 50px 100px; margin-top: 50px;}
.help { font-size: 80%; font-style: italic; font-weight: normal; }
.label { font-weight: bold;}
input[type=text] { padding: 5px; width: 70%; border-radius: 3px; }
input[type=submit] { padding: 10px 40px; cursor: pointer; background-color: #3366CC; color: #FFF; font-weight: bold; border-radius: 20px;  }
input[type=submit]:hover{ background-color: #000; }
.error { padding: 30px 50px; color: #000; background-color: #FFFFCC; border: 3px solid #000;}
.successbox { padding: 30px 50px; color: #000; background-color: #ffffcc; border: 3px solid #FF00FF; font-weight: bold; }
.successbox p input[type=text] { padding: 3px; width: 100%; border-radius: 5px; }

.wrap {
padding: 4px;
border: 1px solid #000000;
font-size: 12px;
color: #420050;
</style>
</head>
<body>
<div class="">
<center class="wrap"<h2>WELCOME TO 9JABAMZ MUSIC UPLOAD PANEL</h2></center>
<?php if ( isset ( $link ) && ! empty ( $link ) ) { ?>
<div class="successbox">
File Uploaded Successfully
<p class="copy"><input type="text" value="<?php echo $shownUrl; ?>"></p>
</div>
<?php } else {  ?>
<?php if ( ! empty ( $error ) ) { ?>
<div class="error"><?php echo $error; ?></div>
<?php } ?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<div>
    <div class="list1"><b> &raquo; Mp3 url</b><br /><input size="50" type="text" class="input" name="mp3_filepath" value="" /></div>
<div class="list2"><b> &raquo; Album art/Cover</b><br /><input size="25" type="text" class="input" name="album_art"value="https://naijabamz.com/wp-content/uploads/2022/11/918BFEA8-49D6-47A7-A6D6-A812B09A8843.jpeg"/></div>
  <div class="list1"><b> &raquo; Filename</b><br /><input size="25" type="text" class="input" name="mp3_filename" value="<?php echo $default_filename_prefix ; ?>" /> </div>
  <div class="list2"><b> &raquo; Song name/title</b><br /><input size="25" type="text" class="input" name="mp3_songname" value="<?php echo $default_songname_prefix ; ?>" /></div>
  <div class="list2"><b> &raquo; Artist(s)</b><br /><input size="25" type="text" class="input" name="mp3_artist" value="<?php echo $default_artist ; ?>" /></div>
<div class="list1"><b> &raquo; Album</b><br /><input size="25" type="text" class="input" name="mp3_album" value="<?php echo $default_album ; ?>" /> </div>
<div class="list1"><b> &raquo; Released Year</b><br /><select class="input" name="mp3_year"><?php for($d=date('Y');$d>=2000;$d--) echo '<option value="'.$d.'">'.$d.'</option>'; ?> </select></div>

<div class="list2"><b> &raquo; Genre</b><br /><select name="mp3_genre" class="input">
<option value="<?php echo $default_genre ; ?>"><?php echo $default_genre ; ?></option>
<option value="Blues">Blues</option>
<option value="Classical">Classical</option>
<option value="Classic Rock">Classic Rock</option>
<option value="Country">Country</option>
<option value="Dance">Dance</option>
<option value="Drum Solo">Drum Solo</option>
<option value="Fusion">Fusion</option>
<option value="Gangstar">Gangstar</option>
<option value="Hip-Hop">Hip-Hop</option>
<option value="Instrumental Rock">Instrumental Rock</option>
<option value="Instrumental PoP">Instrumental PoP</option>
<option value="Jazz">Jazz</option>
<option value="Metal">Metal</option>
<option value="Oldies">Oldies</option>
<option value="PoP">PoP</option>
<option value="PoP-Folk">PoP-Folk</option>
<option value="Porn Groove">Porn Groove</option>
<option value="R&amp;B">R&amp;B</option>
<option value="Symphony">Symphony</option>
<option value="Slow Rock">Slow Rock</option>
<option value="Symphonic Rock">Symphonic Rock</option>
<option value="Sound Track">Sound Track</option>
<option value="Other">Other</option>
</select></div>
<div class="phdr"><input type="checkbox" name="mp3_voice_track" /><b>Add Voice Track</b> (Optional)</div>
<div class="list1"><b> &raquo; Voice Track Url</b> [<a href="http://fromtexttospeech.com/"><b>Make Track</b></a>]<br /><input size="25" type="text" class="input" name="mp3_voicetrack" value="https://naijabamz.com/wp-content/uploads/2021/08/More-Music-From-9jabamz.com-2.mp3" /><br />
Add Track On <input type="radio" name="mp3_voice_track_add" value="first" checked="yes" />First <input type="radio" name="mp3_voice_track_add" value="last" />Last</div>
<div class="gmenu"><input type="checkbox" name="mp3_info_view" checked="checked" />View Taged File Info?<br />
<center><input size="15" type="submit" name="submit" value="Edit Tags" /></center></div>
</form>

<?php } ?>
<?php
}
?>
<center><b><a href="/wp-contents/uploads">Click Here to View The Total Mp3 tagged Files</a><b></center>
</div><div class="wrap"><center>Powered By Leriqx | 9jabamz.com</center></div>
<div class="footer"><center><b> &copy; 2020-<?php echo date('Y'); ?> - 9jabamz<br />All Rights Reserved</b></center></div>
<p></p><center>Developed By: <a href="http://Naijabamz.com/"><b>Naijabamz Website</b><br /></a>
</body>
</html>