<?php
define('_IN_JOHNCMS', 1);
$headmod = 'video';
require_once '../incfiles/core.php';
require_once 'functions.php';

$name = $_GET['id'];
$file1 = mysql_query("SELECT * FROM `yuklemeler` WHERE `cat` = '2' AND `link` = '" . $name . "'");
$file = mysql_fetch_array($file1);

$textl = ''.$file['name'].' - '.$file['singer'].'';

require_once '../incfiles/head.php';


function size_file($size){
    $size = round($size / 1024, 2);
    if($size > 1024000){
        $size = round($size / 1024000, 2).' GB';
    }elseif($size > 1024){
        $size = round($size / 1024, 2).' MB';
        }else{ $size = $size.' KB';  }
    return $size;
}

if($_GET['like'] == 1){
if($_SESSION['like'] !== $file['id']){
$lik = mysql_result(mysql_query("SELECT `like` FROM `yuklemeler` WHERE `id` = '" . $file['id'] . "';"), 0);
$likk = $lik+1;
mysql_query("UPDATE `yuklemeler` SET `like` = '".$likk."' WHERE `id` = '".$file['id']."'");
}
header('location: /videos/'.$file['link'].'');
$_SESSION['like'] = $file['id'];
}


$siz = $file['size'];
$filtime = date("d.m.Y", $file['time']);

if ($_SESSION['file'] !== $file['id']){
  $o_mow = mysql_result(mysql_query("SELECT `view` FROM `yuklemeler` WHERE `id` = '" . $file['id'] . "';"), 0);
  $i_mow = (int) $o_mow;
  $r_mow = $i_mow + 1;
  @mysql_query("UPDATE `yuklemeler` SET `view` = '" . $r_mow . "' WHERE `id` = '" . $file['id'] . "';");
}
$_SESSION['file'] = $file['id'];

$downs = mysql_result(mysql_query("SELECT `down` FROM `yuklemeler` WHERE `id` = '" . $file['id'] . "';"), 0);
$views = mysql_result(mysql_query("SELECT `view` FROM `yuklemeler` WHERE `id` = '" . $file['id'] . "';"), 0);
$likes = mysql_result(mysql_query("SELECT `like` FROM `yuklemeler` WHERE `id` = '" . $file['id'] . "';"), 0);
$furl = '../uploads/video/file/'.$file['url'];


echo '



<main class="mt-5 pt-5 px-2 p-xl-5">
    <section class="text-center row info container">
        <aside class="col-12 p-2  mx-auto">
            <video controls="" width="100%">
                <source src="'.$home.'/uploads/video/file/'.$file['url'].'">
            </video>
        </aside>
        <aside class="col-12 mx-auto row mt-5 p-2 p-lg-3 d-flex align-items-center align-self-center artist-info">
            <div class="col-12 py-4 justify-content-center">
                <div class="w-100">
                    <div class="col-12 py-4 justify-content-center">
                        <span class="artist-title">
                            <img src="'.$home.'/dist/img/play-button.svg" width="20"> '.$file['singer'].' - '.$file['name'].'
                        </span>
                    </div>

                    <div class="row col-12 mx-auto py-3 ">

                        <div class="col-3 border-right">
                            <span class="artist-icons d-flex flex-column p-2">
                                <img src="'.$home.'/dist/img/download.svg" width="25" class="mx-auto">
                                <span class="pt-1"> '.$downs.' </span>
                            </span>
                        </div>

                        <div class="col-3 border-right">
                            <span class="artist-icons d-flex flex-column p-2">
                                <img src="'.$home.'/dist/img/eye.svg" width="26" class="mx-auto">
                                <span class="pt-1"> '.$views.' </span>
                            </span>
                        </div>

                        <div class="col-3 border-right">
                            <span class="artist-icons d-flex flex-column p-2">
                                <img src="'.$home.'/dist/img/like.svg" width="24" class="mx-auto">
                                <span class="pt-1"> '.$likes.' </span>
                            </span>
                        </div>
                        <div class="col-3">
                            <span class="artist-icons d-flex flex-column p-2">
                                <img src="'.$home.'/dist/img/file.svg" width="24" class="mx-auto">
                                <span class="pt-1"> '.size_file(filesize($furl)).' </span>
                            </span>
                        </div>

                    </div>
                    <div class="row col-12 py-3 justify-content-center align-items-center">
                        <a href="'.$home.'/yukle/'.$file['link'].'" class="btn-load-music">ÝÜKLE
                        </a>
                        <a href="'.$home.'/videos/'.$file['link'].'?like=1" class="btn-like ml-4">
                            <img src="'.$home.'/dist/img/like.svg" width="24" class="mx-auto">
                        </a>
                    </div>

                </div>
            </div>

        </aside>
    </section>
</main>
';

require_once '../incfiles/end.php';
?>