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

// mod Gemorroj

include 'moduls/ini.php';
include 'moduls/connect.php';
include 'moduls/func.php';
###############Проверка переменных###############

$id = intval($_GET['id']);
$time=time();
$setting = mysql_query('SELECT * FROM `zc_setting`;');

while($set = mysql_fetch_assoc($setting)){
$setup[$set['name']] = $set['value'];
}
###############Получаем инфу о файле###########
$open = mysql_fetch_row(mysql_query('SELECT TRIM(`open`) FROM `'.$setup['pref'].'files` WHERE `id` = '.$id.' LIMIT 1'));
$d = mysql_fetch_row(mysql_query('SELECT TRIM(`path`) FROM `'.$setup['pref'].'files` WHERE `id` = '.$id.' LIMIT 1'));
$d2 = mysql_fetch_row(mysql_query('SELECT TRIM(`infolder`) FROM `'.$setup['pref'].'files` WHERE `id` = '.$id.' LIMIT 1'));
click_change();
if($open[0]!=1){
$path_info = mysql_fetch_array(mysql_query('SELECT `pas` FROM `'.$setup['pref'].'files` WHERE `path` LIKE "'.$d2[0].'%" AND `size` = 0;'));

		if ($path_info['pas']==1) //если закрыто по смс
	{
    $vhod=NULL;
    $smspas = mysql_fetch_row(mysql_query('SELECT (`time`) FROM `'.$setup['pref'].'smspas`  WHERE `pas` = '.$_COOKIE[ "smspas" ]));  //смотрим пас
    	if ($smspas[0] AND $smspas[0]>=$time) {            //если пароль верный,и срок действия не вышел.
      $vhod=1;
    }
    else header('Location: pay.php?id='.$id);
	}
	elseif ($path_info['pas']==2) //если закрыто по кликам
	{
      $vhod=NULL;
    $clickpas = mysql_fetch_row(mysql_query('SELECT (`time`) FROM `'.$setup['pref'].'clickpas`  WHERE `pas` = '.$_COOKIE[ "clickpas" ]));  //смотрим пас
    	if ($clickpas[0] AND $clickpas[0]>=$time) {            //если пароль верный,и срок действия не вышел.
      $vhod=1;
	}
	else header('Location: click.php?id='.$id.'&action=1');
  }
	else $vhod=1;

if(file_exists($d[0]) AND $vhod==1){
mysql_query('UPDATE `'.$setup['pref'].'files` SET `loads`=`loads`+1, `timeload`='.$time.' WHERE `id`='.$id);
$tex2=$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/'.$d[0];
$tex2=str_replace('\/','/',$tex2);
header('Location: http://'.$tex2,true,301);
}
else{
print $hackmess;
}
}
else
 {
 $razdel = mysql_fetch_array(mysql_query('SELECT * FROM `'.$setup['pref'].'files` WHERE `id` = '.$id.' AND open=1'));
 mysql_query('UPDATE `'.$setup['pref'].'files` SET `loads`=`loads`+1, `timeload`='.$time.' WHERE `id`='.$id);
$filename=$razdel['name'].$razdel['tname'];
 if ($razdel['path']) {
header("Content-Disposition: form-data; filename=".$filename);
header("Content-Type: application/download\n");
header("Content-Transfer-Encoding: binary");
    header('Content-Length: ' . (filesize($razdel['path'])));
    header('Connection: close');
echo file_get_contents($razdel['path']);
}else {
    die("Ошибка закачки, файл отсутствует на сервере.");
  }
exit;
 }
?>