<?php
#-----------------------------------------------------#
# Зц Sea mod Ganjara                                  #
# 	 Автор : Slayer  with   Ganjar                    #
#    ICQ :   566003         993770                    #
#    Вы не имеете права распространять данный скрипт. #
# 		По всем вопросам пишите в ICQ.                  #
#-----------------------------------------------------#

define('_IN_JOHNCMS', 1);
$zc=1;
$headmod = 'load';
$textl = 'Информация';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");
$time = time();
$setting = mysql_query('SELECT * FROM `zc_setting`;');

while($set = mysql_fetch_assoc($setting)){
$setup[$set['name']] = $set['value'];
}

$hackmess = $setup['hackmess'];

require 'moduls/ini.php';
require 'moduls/fun.php';

// Проверка переменных
$id = intval($_GET['id']);
is_num($_GET['eval'],'eval');

$d = mysql_fetch_row(mysql_query('SELECT TRIM(`open`) FROM `'.$setup['pref'].'files` WHERE `id` = '.$id.' LIMIT 1'));
if($setup['obm'] == 1 AND $d[0]==1) {$open=1; $endurl='&amp;open=1'; $endquery=' AND `open`=1';}else {$open=0; $endquery=' AND `open`=0';}

// Получаем инфу о файле
$file_info = mysql_fetch_assoc(mysql_query('SELECT * FROM `'.$setup['pref'].'files` WHERE `id` = '.$id.$endquery));
if(!is_file($file_info['path'])){
die('Файл не существует');
}
###############Готовим заголовок###################
$ex = explode('/',$file_info['infolder']);
foreach($ex as $k=>$v)
{
if($v!='' and $v!='.' and $v!='..' and $v!=$setup['path'])
{
$s = mysql_fetch_array(mysql_query("SELECT `id`,`name` FROM `".$setup['pref']."files` WHERE `path` LIKE '%".clean($v)."/' AND `size` = '0'"));
$s['name'] = str_replace('*','',$s['name']);
if($k >= sizeof($ex)-2) $put .= $s['name'];
else $put .= '<a href="index.php?id='.$s['id'].'">'.$s['name'].'</a>&raquo;';
}
}##############Заголовок##########################

echo '<div class="menu"> <a href="'.$setup['site_url'].'">'.$setup['site_url'].'</a>&raquo;<a href="index.php?'.$endurl.'">Загрузки</a>&raquo;'.$put.'</div>';

##############Всего комментириев
$all_komments = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `'.$setup['pref'].'komments` WHERE `file_id` = '.$id),0);

##############Система голосований##############
$ip=$_SERVER['REMOTE_ADDR'];
if(isset($_GET['eval']) and $setup['eval_change'] == 1)
{
$ips = explode("\n",$file_info['ips']);
if(in_array($ip ,$ips) === false)
{
$vote = 0;
if(empty($file_info['ips'])){
$ipp = $ip;
}
else{
$ipp = $file_info['ips']."\n".$ip;
}

if($_GET['eval']==0){
$str = 'UPDATE `'.$setup['pref'].'files` SET `no`=`no`+1,`ips`="'.$ipp.'" WHERE `id` = '.$file_info['id'];
}
elseif($_GET['eval']==1){
$str = 'UPDATE `'.$setup['pref'].'files` SET `yes`=`yes`+1,`ips`="'.$ipp.'" WHERE `id` = '.$file_info['id'];
}

mysql_query($str);
$vote = 1;
$file_info = mysql_fetch_assoc(mysql_query('SELECT * FROM `'.$setup['pref'].'files` WHERE `id` = '.$id));
}
else $vote = 2;
}
#######Получаем имя файла и обратный каталог#####
$filename = pathinfo($file_info['path']);
 $filename2 = str_replace('.'.$filename['extension'],'',$filename['basename']);
$ext = strtolower($filename['extension']);
$dir = $file_info['infolder'];
$filename = $filename['basename'];
$back = mysql_fetch_assoc(mysql_query("SELECT `id` FROM `".$setup['pref']."files` WHERE `path` = '".clean($dir)."' AND `size`=0"));
###############Красивый размер###################
if($file_info['size'] < 1024){
$file_info['size'] = $file_info['size'].'b';
}
elseif($file_info['size'] < 1048576 and $file_info['size'] >= 1024){
$file_info['size'] = round($file_info['size']/1024, 2).'Kb';
}
else{
$file_info['size'] = round($file_info['size']/1024/1024, 2).'Mb';
}
$d2 = mysql_fetch_row(mysql_query('SELECT TRIM(`infolder`) FROM `'.$setup['pref'].'files` WHERE `id` = '.$id.' LIMIT 1'));
$path_info = mysql_fetch_array(mysql_query('SELECT `pas` FROM `'.$setup['pref'].'files` WHERE `path` LIKE "'.$d2[0].'%" AND `size` = 0;'));
###############Вывод###################
echo '<div class="phdr">'.($ext =='jar'? '<img src="ic.php?lf='.$file_info['path'].'" alt=""/>':'').($open==1 ? $file_info['name'].$file_info['tname']:$filename).($rights >= 4 ? '|<a href="apanel.php?action=refile&amp;id='.$file_info['id'].'&amp;del=1"><font color="red"> Удалить</font></a>':'').'</div>';

if($open) {
$res = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = '.$file_info['user_id']));
echo '<div class="gmenu">';
echo '<b>Добавил:</b> '.show_user($res, 1, '', '', '', '').'</div>';}
echo '<div class="gmenu">';
echo '<b>Размер:</b> '.$file_info['size'].'<br/>';

###############Недавнее скачивание###################
if($file_info['timeload'])
	{
		$file_info['timeload'] = date('d.m.Y (H:i)', $file_info['timeload']);
		print '<b>Недавнее скачивание:</b>'.$file_info['timeload'].'<br/>';
	}
###############Время добавления######################
$file_info['timeupload'] = date('d.m.Y (H:i)', $file_info['timeupload']);
print '<b>Время добавления:</b>'.$file_info['timeupload'].'<br/></div>';
###############Особый размер для картинок############
$image = '';
$ext = strtolower($ext);
echo '<div class="list1">';
if ($ext == 'gif' or $ext == 'jpg' or $ext == 'jpeg' or $ext == 'jpe' or $ext == 'png') $image = 1;
if ($image == 1)
	{
		$arr = array('130x130','120x160','132x176','176x220','240x320');
		//Добавлено просмотр изображения
echo '
		<img src="im.php?bab=1&amp;id='.$id.'&amp;W=80&amp;H=80" alt="Screen"/></div><div class="gmenu"><b>Размер:</b><br/>';
	foreach($arr as $v)
		{
			list ($W,$H) = explode('x',$v);
			echo '<a href="im.php?id='.$id.'&amp;H='.$H.'&amp;W='.$W.'">'.$v.'</a><br/>';
			}

	}




$image = '';
$ext = strtolower($ext);
if ($ext == 'gif' or $ext == 'jpg' or $ext == 'jpeg' or $ext == 'jpe' or $ext == 'png') $image = 1;
if ($image == 1)
	{

		echo '


		<b>Особый размер:</b>
		<form action="im.php" method="GET">
		<input type="hidden" name="id" value="'.$id.'"/>
	   <input type="text" name="W" maxlength="3" size="3"/>x<input type="text" name="H" maxlength="3" size="3"/> px.
	   	   <input type="submit" value="Ok"/>
	   </form>';

	}





###############Инфа о jar###########################
elseif($ext == 'jar'){
include 'jar_info.php';
echo '<li><b>Разработчик:'.$poz.'</b></li>';
echo '<li><b>Версия:'.$ver.'</b></li>';



}
###############Инфа о mp3###########################
elseif($ext == 'mp3' or $ext == 'wav' ){
if(!$open){
if ( 
    !$h_ua || 
    strpos($h_ua, 'windows') !== false    || 
    strpos($h_ua, 'linux') !== false    || 
    strpos($h_ua, 'bsd') !== false        || 
    strpos($h_ua, 'x11') !== false        || 
    strpos($h_ua, 'unix') !== false        || 
    strpos($h_ua, 'macintosh') !== false    || 
    strpos($h_ua, 'macos') !== false) 
    {
echo'<b>Прослушка:</b> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 " width="96" height="20" id="own_flashplayer" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<embed src="own_flashplayer_plc.swf?file='.$file_info['path']. '&amp;sta rtplay=false" quality="high" bgcolor="#ffffff" width="96" height="20" name="own_flashplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object><br/>'; }  
}

//include 'moduls/classAudioFile.php';
//$AF = new AudioFile;
//$AF->loadFile($file_info['path']);
//$AF->printSampleInfo();

}


// Видео (ffmpeg)
elseif(($ext == '3gp' || $ext == 'avi' || $ext == 'mp4') && extension_loaded('ffmpeg')){
$mov = new ffmpeg_movie($file_info['path']);


// 80x80
print '<img src="ffmpeg.php?id='.$id.'&amp;W=80&amp;H=80" alt="prev"/>

<li>Koдeк: '.$mov->getVideoCodec().'</li>
<li>Paзpeшeниe: '.$mov->GetFrameWidth().' x '.$mov->GetFrameHeight().'</li>
';



}
if(!$open){
if(($ext == 'avi' || $ext == 'flv' || $ext =='swf' || $ext =='mp4') AND ( 
    !$h_ua || 
    strpos($h_ua, 'windows') !== false    || 
    strpos($h_ua, 'linux') !== false    || 
    strpos($h_ua, 'bsd') !== false        || 
    strpos($h_ua, 'x11') !== false        || 
    strpos($h_ua, 'unix') !== false        || 
    strpos($h_ua, 'macintosh') !== false    || 
    strpos($h_ua, 'macos') !== false))
{
echo '<object type="application/x-shockwave-flash" data="uflvplayer_500x375.swf" height="188" width="250">
<param name="bgcolor" value="#DFE6EF" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="uflvplayer_500x375.swf" />
<param name="FlashVars" value="way='.$file_info['path'].'&amp;swf=uflvplayer_500x375.swf&amp;w=400&amp;h=300&amp;pic=ffmpeg.php?id='.$file_info['id'].'&amp;autoplay=0&amp;tools=1&amp;skin=white&amp;volume=70&amp;q=&amp;comment=" /></object>
';
	
}}
elseif($ext == 'thm' || $ext == 'nth'){
echo '<img src="theme.php?id='.$id.'" alt="prev"/>';
}

if(!$open){
##############Скиншот##############

if(is_file($setup['spath'].'/'.$filename.'.gif')){
echo '<strong>Скриншот:</strong><br/><img style="margin: 1px;" src="'.$setup['spath'].'/'.$filename.'.gif" alt="screen"/><br/>';
}
if(is_file($setup['spath'].'/'.$filename.'.jpg')){echo '<strong>Скриншот:</strong><br/><img style="margin: 1px;" src="'.$setup['spath'].'/'.$filename.'.jpg" alt="screen"/><br/>';
}
if(is_file($setup['spath'].'/'.$filename.'.jpeg')){echo '<strong>Скриншот:</strong><br/><img style="margin: 1px;" src="'.$setup['spath'].'/'.$filename.'.jpeg" alt="screen"/><br/>';
}


if(is_file($setup['spath'].'/'.$filename2.'.gif')){
echo '<strong>Скриншот:</strong><br/><img style="margin: 1px;" src="'.$setup['spath'].'/'.$filename2.'.gif" alt="screen"/><br/>';
}
if(is_file($setup['spath'].'/'.$filename2.'.jpg')){echo '<strong>Скриншот:</strong><br/><img style="margin: 1px;" src="'.$setup['spath'].'/'.$filename2.'.jpg" alt="screen"/><br/>';
}
if(is_file($setup['spath'].'/'.$filename2.'.jpeg')){echo '<strong>Скриншот:</strong><br/><img style="margin: 1px;" src="'.$setup['spath'].'/'.$filename2.'.jpeg" alt="screen"/><br/>';
}
}
else 
{
if(is_file($file_info['path'].'.gif')) 
echo '<img style="margin: 1px;" src="im.php?id='.$file_info['id'].'&amp;W=128&amp;H=128&amp;bab=2'.$endurl.'" alt="screen"/><br/>';
}
###############Описание#############################
 if ($ext == 'txt') {
    $rtext=file_get_contents($file_info['path']);
    $rtext = htmlspecialchars($rtext);    
    $rtext=substr($rtext,0,500);
    $rtext=iconv("windows-1251", "UTF-8", "$rtext");
    if(strlen($rtext)>15) $rtext=substr($rtext,0,strrpos($rtext, ' '));
  echo '<b>Описание:</b><br/>'.$rtext.'...<br/>';

  }
if(!empty($file_info['about'])){
$file_info['about'] = str_replace("\n", '<br/>', $file_info['about']);
echo '<b>Описание:</b><br/>'.$file_info['about'].'<br/>';
}
if(is_file($setup['opath'].'/'.$filename.'.txt'))
{
include('kodirovka.php');
$a=file_get_contents($setup['opath'].'/'.$filename.'.txt');
$a=charset_x_win("$a"); 
$a=iconv("windows-1251", "UTF-8", "$a");
$f = str_replace("\n",'<br/>', $a);
echo '<b>Описание:</b><br/>'.$f.'<br/>';
}
if(is_file($setup['opath'].'/'.$filename2.'.txt'))
{
include('kodirovka.php');
$a=file_get_contents($setup['opath'].'/'.$filename2.'.txt');
$a=charset_x_win("$a"); 
$a=iconv("windows-1251", "UTF-8", "$a");
$f = str_replace("\n",'<br/>', $a);
echo '<b>Описание:</b><br/>'.$f.'<br/>';
}
echo '</div>';
###############Голосование###########################
if($setup['eval_change'] == 1)
{
	$i = @round(($file_info['yes'])/($file_info['yes']+$file_info['no'])*100,0);
	echo '<div class="gmenu">
	<b>Рейтинг файла : <font color="green">'.$file_info['yes'].'</font>/<font color="red">'.$file_info['no'].'</font></b><br/>
	<img src="rate.php?i='.$i.'" alt=""/>';
	if ($vote==0) echo '( <a href="view.php?id='.$id.'&amp;eval=1"><b>+</b></a>/<a href="view.php?id='.$id.'&amp;eval=0"><b>-</b></a>)</div>';
	if ($vote==1) echo '<br/>Спасибо,ваш голос учтен!</div>';
	if ($vote==2) echo '<br/>Вы уже голосовали за этот файл.</div>';
}
echo'<div class="list1">';
###############Нарезка###########################

if($setup['cut_change'] == 1 AND !$open)
{
	if ($ext == 'mp3') print '<li><a href="cut.php?id='.$id.'"><b>Нарезка</b></a></li>
  <li><a href="cut1.php?id='.$id.'&amp;s=10&amp;p=17&amp;way=time"><b>Прослушать отрывок [7c.]</b></a></li>';
} 
###############Просмотр архива####################

if($setup['zip_change'] == 1)
{
if($ext == 'zip'){
print '<li><a href="zip.php?id='.$id.'"><strong>Просмотр архива</strong></a></li>';
}
}



##############txt##############
if($ext == 'txt'){
 echo'<li><a href="read.php?id='.$id.'&amp;id2='.$back['id'].'">Читать</a></li>';
print '<li><a href="txt_zip.php?id='.$id.'">Скачать [ZIP]</a></li>
<li><a href="txt_jar.php?id='.$id.'">Скачать [JAR]</a></li>';
}




###############Меню закачек#######################

echo '<li><a href="load.php?id='.$id.'"><strong>Скачать ['.ucfirst($ext).']</strong></a></li>';
if($ext == 'jar' and $setup['jad_change'] == 1){
echo '<li><a href="jad.php?id='.$id.'"><strong>Скачать [Jad]</strong></a></li>';
}
$all = mysql_fetch_row(mysql_query('SELECT COUNT(`id`) FROM `'.$setup['pref'].'files` WHERE `file_id` = '.$id));
$all = $all[0];
if($all>0) {
echo '</div><div class="list1"><b>Прикрепленные файлы:</b>';
    ###############Получаем список файлов###
  $query = mysql_query('SELECT `id` FROM `'.$setup['pref'].'files` WHERE `file_id` = '.$id.' ORDER BY `timeupload`');

  while($list_sw = mysql_fetch_array($query)){
  $array_id[] = $list_sw['id'];
  }
  $n=0;
    while($i<$all)
    {
    if(!isset($array_id[$n])) {$n++; continue; }
    $razdel = mysql_fetch_array(mysql_query('SELECT * FROM `'.$setup['pref'].'files` WHERE `id` = '.$array_id[$n].' AND `file_id` = '.$id));
    ###############Красивый размер###################
if($razdel['size'] < 1024){
$razdel['size'] = $razdel['size'].'b';
}
elseif($razdel['size'] < 1048576 and $razdel['size'] >= 1024){
$razdel['size'] = round($razdel['size']/1024, 2).'Kb';
}
else{
$razdel['size'] = round($razdel['size']/1024/1024, 2).'Mb';
}
    
    echo '<li>
    <a href="load.php?id='.$razdel['id'].'">'.$razdel['name'].'</a> ('.$razdel['size'].')'.($razdel['about']? '<br/>'.$razdel['about']:'').'</li>';
    $i++;
    $n++;
    }  
echo '</div><div class="list1">';
}    
###############Комментарии#######################
if($setup['komments_change'] == 1){
echo '<li><a href="komm.php?id='.$id.'"><strong>Комментарии ['.$all_komments.']</strong></a></li>';
}
###############Картинка текстом#######################
$pyt=$file_info[path];
if($ext==png or $ext==jpg )
{
$h_ua = str_replace('windows ce', '', strtolower($_SERVER['HTTP_USER_AGENT'])); 
if ( 
    !$h_ua || 
    strpos($h_ua, 'windows') !== false    || 
    strpos($h_ua, 'linux') !== false    || 
    strpos($h_ua, 'bsd') !== false        || 
    strpos($h_ua, 'x11') !== false        || 
    strpos($h_ua, 'unix') !== false        || 
    strpos($h_ua, 'macintosh') !== false    || 
    strpos($h_ua, 'macos') !== false) 
{ 
echo('<a href="tekst.php?pic='.$pyt.'"><strong>Скачать картинку как текст [txt]</strong></a><br/>');
}}

echo'</div>';
if ($path_info['pas']==0) {
//<tr><td width="10%" align=left style="background: #DFE6EF;"><b>Скачано:</b></td><td style="background: #DFE6EF;"> '.$file_info['loads'].' раз(а)</td></tr>
echo'<div class="gmenu"><font color="#999999"><b>Скачали:</b>'.$file_info['loads'].' раз(а) </font><br/>';

if(!$open AND $setup['adr']==1) echo '<input class="enter" size="20" type="text" value="'.$setup['site_url'].dirname($_SERVER['PHP_SELF']).'/'.$file_info['path'].'"/>';

}

echo '</div><div class="bmenu">';

echo' 
<li><a href="index.php?id='.$back['id'].$endurl.'">Назад</a></li>
<li><a href="index.php?'.$endurl.'">Загрузки</a></li>
<li><a href="'.$setup['site_url'].'">На главную</a></li>';
echo '</div>';
require_once ("moduls/foot.php");
?>