<?php

//////////////////////////////////////////////////
////// проверка размеров файлов и запись /////////
//////////////////////////////////////////////////

defined('_IN_JOHNCMS') or die('Error: restricted access');

echo '
<br/><br/>
<div class="profile-img card-artists music-name">
<center><h3>Faýl goşmak</h3><br/>
';

if($_POST['yukle']){
$singer = $_POST['singerid'];
$bolum = $_POST['cat'];
$fayl = $_FILES['file'];
$surat = $_FILES['foto'];
$ady = $_POST['name'];
$aydymchy = $_POST['artist'];
$sftp = $_POST['ftpfoto'];
$ftp = $_POST['ftpfile'];
$salgy = $_POST['linkfile'];


if($_POST['cat'] == 1){
$aydymroot = '../uploads/music/file';
$suratroot = '../uploads/music/img';
}

if($_POST['cat'] == 2){
$aydymroot = '../uploads/video/file';
$suratroot = '../uploads/video/img';
}
$sbukja = $suratroot.'/';
$bukja = $aydymroot.'/';

if(empty($singer)){
echo 'Aýdymçyny saýlamadyňyz! Eger aýdymçy ýok bolsa <a href="'.$home.'/yukleme/admin.php?act=addsinger">bu bölüm</a>den goşup bilersiňiz!';
require_once '../incfiles/end.php';
exit;
}
if(empty($bolum)){
echo 'Bölümi saýlamadyňyz!';
require_once '../incfiles/end.php';
exit;
}
if(empty($fayl)){
echo 'Ýüklemek üçin faýl saýlamadyňyz!';
require_once '../incfiles/end.php';
exit;
}
if(empty($ady)){
echo 'Aýdymyň ady girizilmedi! Meselem: Gaçma';
require_once '../incfiles/end.php';
exit;
}
if(empty($aydymchy)){
echo 'Aýdymçynyň ady girizilmedi! Meselem: Söhbet Jumaýew';
require_once '../incfiles/end.php';
exit;
}
if(empty($ftp)){
echo 'Faýlyň serwerdäki orny girizilmedi! Meselem: sohbet_j_gacma.mp3';
require_once '../incfiles/end.php';
exit;
}
if(empty($sftp)){
echo 'Suradyň serwerdäki orny girizilmedi! Meselem: bagysynyn-ady.jpg';
require_once '../incfiles/end.php';
exit;
}
if(empty($salgy)){
echo 'Faýla salgy girizilmedi girizilmedi! Meselem: Sohbet-Jumayew_ft_SAAP-Gacma';
require_once '../incfiles/end.php';
exit;
}

if(move_uploaded_file($_FILES["file"]["tmp_name"], $bukja.$ftp) == true){
@chmod($bukja.$ftp, 0777);

mysql_query("INSERT INTO `yuklemeler` SET
        `singerid` = '".$singer."',
        `user_id` = '" .$user_id. "',
        `cat` = '" .$bolum. "',
        `name` = '" .$ady. "',
        `singer` = '" .$aydymchy. "',
        `link` = '" .$salgy. "',
        `url` = '" .$ftp. "',
        `desc` = '',
        `time` = '" . time() . "';");
$sid = mysql_insert_id();

if($surat){

if ((move_uploaded_file($_FILES["foto"]["tmp_name"], $sbukja.$sftp)) == true) {
     @chmod($sbukja.$sftp, 0777);
mysql_query("INSERT INTO `skreen` SET
        `fid` = '".$sid."',
        `url` = '" .$sftp. "';");
echo 'Skrinşot ýüklenildi!';
}else{
echo 'Skrinşot ýükläp bolmady!';
}}


echo '<p>Aýdym üstünlikli jaýlanyldy!</p>';

}else{
echo 'Faýly serwere ýükläp bolmady!';
}

}else{

$gyzyl = '<b><font color="red">*</font></b>';
echo '
<form action="admin.php?act=upload" name="fileadd" method="post" enctype="multipart/form-data">
'.$gyzyl.' Aýdymçyny saýla <b><font color="red">(<a href="'.$home.'/yukleme/admin.php?act=addsinger">???</a>)</font></b>:<br/>
<select name="singerid">';

echo '<option value="" selected="selected">--Saýlaa--</option>';

$req = mysql_query("SELECT * FROM `singers` ORDER BY `id` DESC LIMIT 9999");
while ($res = mysql_fetch_array($req)) {
echo '<option value="'.$res['id'].'">'.$res['name'].'</option>';
}

echo '
</select><br/>
<br/>
'.$gyzyl.' Bölümi saýla: <br/>
<select name="cat"><option value="0">--Saýlaa--</option><option value="1">Aýdymlar</option><option value="2">Wideolar</option></select><br/>
<br/>
'.$gyzyl.' Faýl saýla:<br/><input type="file" name="file"/><br/>
<br/>
'.$gyzyl.' Aýdymyň ady:<br/><input type="text" name="name"/><br/>
<br/>
'.$gyzyl.' Aýdymçynyň ady:<br/><input type="text" name="artist"/><br/>
<br/>
'.$gyzyl.' Skrinşot:<br/><input type="file" name="foto"/><br/>
<br/>
'.$gyzyl.' Skrinşot FTP ady:<br/><input type="text" name="ftpfoto"/><br/>
<br/>
'.$gyzyl.' Faýlyň FTP ady:<br/><input type="text" name="ftpfile"/><br/>
<br/>
'.$gyzyl.' Faýlyň linki:<br/><input type="text" name="linkfile"/><br/>
<br/>
<input type="submit" name="yukle" value="Jaýla"/> - <a href="'.$home.'/yukleme/admin.php">Dolandyryş paneli</a>
</form>
';
}


echo '
	</center>
<br/>
</div>
';


?>