<?php 


/* ---------- 


Avtor: Nizomiddin

e-mail: programm011@gmail.com
telegram: https://t.me/programm011


--------------- */



define('_IN_JOHNCMS', 1);
$textl = 'Musiqa import qilish';
require_once ('../incfiles/core.php');
require_once ('../incfiles/head.php');
include 'function.php';
    echo '<div class="phdr">Musiqa import qilish</div>';if (!$user_id) {echo '<div class="rmenu">Faqat sayt foydalanuvchilari bu xizmatdan foydalanishi mumkin!</div>';	require('../incfiles/end.php');	exit();	}
    
    
	if(isset($_POST['submit'])) 
	{
	    
	    $url = isset($_POST['url'][$i]) ? str_replace('./', '_', trim($_POST['url'])) : false;if ($url) { if (mb_substr($url, 0, 7) !== 'http://'){ echo '<div class="rmenu"> Manzil xato kiritildi! Tekshirib qaytadan urinib ko`ring</div> <div class="menu"><a href="import.php">Ortga</a></div>'; require('../incfiles/end.php');  exit(); }  else $url = str_replace('http://', '', $url); }   if (empty($url)) { echo '<div class="rmenu"> Manzil kiritilmadi! Tekshirib qaytadan urinib ko`ring</div> <div class="menu"><a href="import.php">Ortga</a></div>'; require('../incfiles/end.php');  exit();} $typ = pathinfo($url, PATHINFO_EXTENSION); if($typ!="mp3") { echo '<div class="rmenu"> Taqiqlangan format! Tekshirib qaytadan urinib ko`ring</div> <div class="menu"><a href="import.php">Ortga</a></div>'; require('../incfiles/end.php');  exit();}	if(empty($_POST['ijrochi']) || mb_strlen($_POST['ijrochi']) > 60) { echo '<div class="rmenu"> Ijrochi kiritilmadi, yoki 60 tadan ko`p belgi ishlatdingiz!</div> <div class="menu"><a href="import.php">Ortga</a></div>'; require('../incfiles/end.php');  exit();}if(empty($_POST['albom']) || mb_strlen($_POST['albom']) > 30) { echo '<div class="rmenu"> Albom kiritilmadi, yoki 30 tadan ko`p belgi ishlatdingiz!</div> <div class="menu"><a href="import.php">Ortga</a></div>'; require('../incfiles/end.php');  exit();}if(empty($_POST['izoh']) || mb_strlen($_POST['izoh']) > 100) { echo '<div class="rmenu"> Izoh kiritilmadi, yoki 100 tadan ko`p belgi ishlatdingiz!</div> <div class="menu"><a href="import.php">Ortga</a></div>'; require('../incfiles/end.php');  exit();}if(empty($_POST['nomi']) || mb_strlen($_POST['nomi']) > 60) { echo '<div class="rmenu"> Nomi kiritilmadi, yoki 60 tadan ko`p belgi ishlatdingiz!</div> <div class="menu"><a href="import.php">Ortga</a></div>'; require('../incfiles/end.php');  exit();} 
			$file_path = 'files/'.clean($_POST['ijrochi']).'_'.clean($_POST['nomi']).'.mp3'; $file_path2 = 'files/'.clean($_POST['ijrochi']).'_'.clean($_POST['nomi']).'_cache.mp3';
	        copy('http://' . $url, $file_path); if (copy('http://' . $url, $file_path2))  { $sfile = $file_path2; if(!empty($_FILES["covermusic"]["name"])){ if(($_FILES["covermusic"]["size"] / 1024) < 1024 || $_FILES["covermusic"]["type"] == "audio/mp3"){$covermusic = 'files/'.clean($_POST['ijrochi']).'_'.clean($_POST['nomi']).'_covermusicfile.mp3';move_uploaded_file($_FILES["covermusic"]["tmp_name"],$covermusic); require_once('getid3/getid3.php');    $getID3 = new getID3;    $znu_test = $getID3->analyze($file_path);     $znu_test2 = $getID3->analyze($covermusic); $bit = ceil($znu_test['bitrate']/1000); $bit2 = ceil($znu_test2['bitrate']/1000);  if($bit==$bit2 + 1 || $bit==$bit2 - 1 || $bit==$bit2 || $bit==$bit2 + 2 || $bit==$bit2 - 2 || $bit==$bit2 - 3 || $bit==$bit2 + 3 || $bit==$bit2 - 4 || $bit==$bit2 + 4){   if($_POST['cover'] == 1){  $FilenamesIn[] = $covermusic;   $FilenamesIn[] = $file_path;  $FilenamesIn[] = $covermusic;         }   if($_POST['cover'] == 2){  $FilenamesIn[] = $covermusic;  $FilenamesIn[] = $file_path;  }  if($_POST['cover'] == 3){       $FilenamesIn[] = $file_path;  $FilenamesIn[] = $covermusic;         }     if (CombineMultipleMP3sTo($sfile, $FilenamesIn)) {     unlink($file_path);     rename($sfile,$file_path);      unlink($file_path2);   unlink($covermusic);  }   else {  echo '<div class="menu"> <font color="red">Xatolik yuz berdi!</font></div><div class="menu"><a href="index.php">Ortga</a></div>'; require('../incfiles/end.php'); exit(); }
	         }else { unlink($file_path); unlink($file_path2); unlink($covermusic); echo '<div class="menu"> <font color="red">Yuklangan mp3 fayl va jingle  sifati bir xil emas! Tekshirib qaytadan urinib ko`ring!</font></div><div class="menu"><a href="index.php">Ortga</a></div>'; require('../incfiles/end.php'); exit(); } }   else {echo '<div class="menu"> <font color="red">Xato! Yuklagan cover musiqangiz og`irligi 1MB dan kam va mp3 formatda bo`lishi kerak. Faylingizni tekshirib qaytadan urinib ko`ring.</font></div><div class="menu"><a href="index.php">Ortga</a></div>'; require('../incfiles/end.php'); exit(); } }  @chmod($file_path, 0777); if((filesize($file_path) / (1024*1024)) < 12){ if (!file_exists($file_path)) echo $file_path . " bu fayl avvaldan mavjud. "; else { require 'MP3Tool.class.php'; $mp3 = new MP3Tool(); 
	        if(($_FILES["coverfile"]["size"] / 1024) < 100 || $_FILES["coverfile"]["type"] == "image/jpg"){$cover = 'cover_images/'.clean($_POST['ijrochi']).'_'.clean($_POST['nomi']).'_coverfile.jpg';move_uploaded_file($_FILES["coverfile"]["tmp_name"],$cover);}else {echo '<div class="menu"> <font color="red">Xato! Yuklagan cover rasmingiz og`irligi 100kb dan kam va jpg formatda bo`lishi kerak. Rasmni tekshirib qaytadan urinib ko`ring.</font></div><div class="menu"><a href="index.php">Ortga</a></div>'; require('../incfiles/end.php'); exit(); }  $tags = array('album' => $_POST['albom'], 'year' => $_POST['yil'], 'comment' => $_POST['izoh'],'artist' => $_POST['ijrochi'],'title' => $_POST['nomi']); $mp3->Write($file_path, $tags,$cover); $info = $mp3->GetMp3Info($file_path); $bitrate = ceil($info['bitrate']/1000); $duration = $info['duration']; $sam = $info['samplerate']; $albom = $info['album']; $izoh = $info['comment']; $yil = $info['year']; $file_size = filesize($file_path); if(mysql_query("INSERT INTO `znu_music` SET  `time` = '".time()."', `ijrochi` = '".mysql_real_escape_string($_POST['ijrochi'])."', `nomi` = '".mysql_real_escape_string($_POST['nomi'])."', `albom` = '".mysql_real_escape_string($albom)."', `izoh` = '".mysql_real_escape_string($izoh)."', `path` = '".$file_path."', `coverpath` = '".$cover."', `bitrate` = '".$bitrate."', `sam` = '".$sam."', `duration` = '".$duration."',  `user_id` = '".$user_id."',  `size` = '".$file_size."';"))  { echo '<div class="menu"> <font color="green">Fayl import qilindi! Faylingiz 30 daqiqadan keyin o`chadi.</font></div><div class="menu"><a href="index.php">Ortga</a></div>'; require('../incfiles/end.php'); exit(); } else { unlink($file_path); unlink($cover); echo '<div class="rmenu">Fayl import qilinmadi! :( Xatolik haqida sayt ma`muriyatiga xabar bering!</div> <div class="menu"><a href="import.php">Qaytadan</a></div>'; require('../incfiles/end.php');exit(); } }}else echo '<div class="rmenu">Fayl maksimal hajmdan oshib ketdi!</div>'; } else echo '<div class="rmenu">Faylni import qilishda xatolik yuz berdi! :(</div>'; } // end if 
		 else {	
                 echo '<div class="menu">
				 <form method="post"  enctype="multipart/form-data">
                 <b>Ijrochi: </b> (Maks: 60 belgi.)<br /><input type="text" name="ijrochi"  placeholder="Tom Boxer"/><br />
                 <b>Nomi:</b> (Maks: 60 belgi.)<br /><input type="text" name="nomi"  placeholder="Give Me A Kiss [site.net]"/><br />
                 <b>Albom:</b> (Maks: 30 belgi.)<br /><input type="text" name="albom"  placeholder="Site.Net"/><br />
                 <b>Izoh:</b> (Maks: 100 belgi.)<br /><input type="text" name="izoh"  placeholder="Mening super saytim!"/><br />
                 <b>Cover musiqa(Jingle)tanlang:</b> (Ruhsat etilgan maksimal hamjmi: 1MB.)<br /><input name="covermusic" type="file"/> 
                 <select name="cover">
                   <option value="1">Boshiga va oxiriga</option>
                   <option value="2">Boshiga </option>
                   <option value="3">Oxiriga</option>
                 </select>
                 <br>
                 <b>Cover rasm tanlang:</b> (Rasm faqat jpg formatda va 100kb dan oshmasligi kerak.)<br /><input name="coverfile" type="file"/><br>
                 <b>URL:</b> <br /><input type="text" name="url"  placeholder="http://site.net/music.mp3"/><br />
                 <input type="submit" name="submit" value="Yukla!" />
		         </form></div>';
		      }
 
    
 require('../incfiles/end.php');
 auto_clean_cache(); 

?>