Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Общие вопросы » Нужна помощь в правке плагина?

Нужна помощь в правке плагина?


     26.11.2024    Общие вопросы, Модули    4

вопрос
Здравствуйте. Может кто то помочь в правке плагина?
Суть вопроса: Проблема в том что нужно сделать отдельную страницу с таймером, основанную на плагине (возможно) https://github.com/Ticcix/download_page.
Нужно чтоб таймер был на ссылку вставленную через доп. поле и использовал шаблон плагина ( то есть клик по ссылке открывается страница с таймером).
На сколько я помню там что-то правилось download.php
Есть исходник когда-то работающего download.php

<?php
/*
=====================================================
 DataLife Engine - by SoftNews Media Group 
-----------------------------------------------------
 http://dle-news.ru/
-----------------------------------------------------
 Copyright (c) 2004-2023 SoftNews Media Group
=====================================================
 This code is protected by copyright
=====================================================
 File: download.php
-----------------------------------------------------
 Use: Files download
=====================================================
*/

if( !defined( 'DATALIFEENGINE' ) ) {
	header( "HTTP/1.1 403 Forbidden" );
	header ( 'Location: ../' );
	die( "Hacking attempt!" );
}

function reset_url($url) {
	$url = (string)$url;
	
	$value = str_replace ( "http://", "", $url );
	$value = str_replace ( "https://", "", $value );
	$value = str_replace ( "www.", "", $value );
	$value = explode ( "/", $value );
	$value = reset ( $value );
	return $value;
}

if ( $config['allow_registration'] ) {
	include_once (DLEPlugins::Check(ENGINE_DIR . '/modules/sitelogin.php'));
}

if ( !$is_logged ) {
	$member_id['user_group'] = 5;
}

require_once (DLEPlugins::Check(ENGINE_DIR . '/classes/download.class.php'));

$id = intval( $_REQUEST['id'] );
$viewonline = isset($_REQUEST['viewonline']) ? intval( $_REQUEST['viewonline'] ) : 0;

$perm = true;
$onlineview_ext = array("pdf", "doc", "docx", "docm", "dotm", "dotx", "xlsx", "xlsb", "xls", "xlsm", "pptx", "ppsx", "ppt", "pps", "pptm", "potm", "ppam", "potx", "ppsm", "odt", "odx");
$full_link = $config['http_home_url'];

if (isset($_REQUEST['area']) AND $_REQUEST['area'] == "static") {
	
	$row = $db->super_query ( "SELECT * FROM " . PREFIX . "_static_files WHERE id ='{$id}'" );

	$row_news = $db->super_query ( "SELECT id, name FROM " . PREFIX . "_static WHERE id ='{$row['static_id']}'" );
	
	if ( $row_news['id'] ) {
		
		if( $config['allow_alt_url'] ) $full_link = $config['http_home_url'] . $row_news['name'] . ".html";
		else $full_link = $config['http_home_url'] . "index.php?do=static&page=" . $row_news['name'];
		
	} else {
		
		$perm = false;
		
	}
	
} else {
	
	$row = $db->super_query ( "SELECT * FROM " . PREFIX . "_files WHERE id ='{$id}'" );

	if ( $row['news_id'] AND !$viewonline ) {
		
		$row_news = $db->super_query ( "SELECT id, autor, date, category, alt_name, approve, access FROM " . PREFIX . "_post LEFT JOIN " . PREFIX . "_post_extras ON (" . PREFIX . "_post.id=" . PREFIX . "_post_extras.news_id) WHERE id ='{$row['news_id']}'" );
		
		if( $row_news['id'] ) {
			
			$row_news['date'] = strtotime( $row_news['date'] );
			
			if( $config['allow_alt_url'] ) {
				
				if( $config['seo_type'] == 1 OR $config['seo_type'] == 2  ) {
					
					if( $row_news['category'] and $config['seo_type'] == 2 ) {
						
						$full_link = $config['http_home_url'] . get_url( $row_news['category'] ) . "/" . $row_news['id'] . "-" . $row_news['alt_name'] . ".html";
					
					} else {
						
						$full_link = $config['http_home_url'] . $row_news['id'] . "-" . $row_news['alt_name'] . ".html";
					
					}
				
				} else {
					
					$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row_news['date'] ) . $row_news['alt_name'] . ".html";
				}
			
			} else {
				
				$full_link = $config['http_home_url'] . "index.php?newsid=" . $row_news['id'];
			
			}
			
			$options = news_permission( $row_news['access'] );
			if( isset($options[$member_id['user_group']]) AND $options[$member_id['user_group']] AND $options[$member_id['user_group']] != 3 ) $perm = true;
			if( isset($options[$member_id['user_group']]) AND $options[$member_id['user_group']] == 3 ) $perm = false;
	
			if ($config['no_date'] AND !$config['news_future'] AND !$user_group[$member_id['user_group']]['allow_all_edit']) {
		
				if( $row_news['date'] > $_TIME ) {
					$perm = false;		
				}
		
			}
			
			$cat_list = explode( ',', $row_news['category'] );
			
			if( count($cat_list) ) {
				
				$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
				$not_allow_cats = explode ( ',', $user_group[$member_id['user_group']]['not_allow_cats'] );
		
				foreach ( $cat_list as $element ) {
						
					if( $allow_list[0] != "all" AND !in_array( $element, $allow_list ) ) $perm = false;
					
					if( $not_allow_cats[0] != "" AND in_array( $element, $not_allow_cats ) ) $perm = false;
					
				}
				
			}
			
			if( !$row_news['approve'] AND $member_id['name'] != $row_news['autor'] AND !$user_group[$member_id['user_group']]['allow_all_edit'] ) $perm = false;
			
		} else $perm = false;

	} elseif ( !$row['news_id'] ) {
		$perm = false;
	}

}

if ( !$row['name'] OR !$row['onserver']) {
	header( "HTTP/1.1 403 Forbidden" );
	die ( "Access denied" );
}

if ( !$perm ) {
	header( "HTTP/1.1 403 Forbidden" );
	die ( "You don't have access to download this file" );
}

$file_name = pathinfo($row['onserver']);

if ($viewonline == 1 AND in_array($file_name['extension'], $onlineview_ext) ) {
	
    $config['files_antileech'] = false;
	$user_group[$member_id['user_group']]['files_max_speed'] = 0;
	$user_group[$member_id['user_group']]['allow_files'] = true;
	
}

if ( !$user_group[$member_id['user_group']]['allow_files'] ) {
	header( "HTTP/1.1 403 Forbidden" );
	die ( "Access denied" );
}

if ($config['files_antileech']) {
	
	$_SERVER['HTTP_REFERER'] = reset_url ( $_SERVER['HTTP_REFERER'] );
	$_SERVER['HTTP_HOST'] = reset_url ( $_SERVER['HTTP_HOST'] );

	if ($_SERVER['HTTP_HOST'] != $_SERVER['HTTP_REFERER']) {
		header( "HTTP/1.1 403 Forbidden" );
		header( "Location: " . $full_link );
		die ( "Access denied!!!<br /><br />Please visit <a href=\"{$config['http_home_url']}\">{$config['http_home_url']}</a>" );
	}

}

$file = new download ( 'files/'.$row['onserver'], $row['name'], $row['driver'] );
$timer = 10;    //Оставшееся время до загрузки
$offline_time = 1;    //Время жизни ссылки
//////////////////////////////////////////////////////////////////////////


 $image = pathinfo(ROOT_DIR . '/uploads/files/' . $row['onserver']);
		$fi = $image['extension'];
		$file_image = "{$fi}.png";
if( !$_GET['hash'] OR !$_SESSION['download_timer'] OR $_GET['hash'] != md5( $id . $row['onserver'] . $_SESSION['download_timer'] ) OR $_SESSION['download_timer'] > time() OR $_SESSION['download_timer'] + $offline_time*60 < time() )
{
    $_SESSION['download_timer'] = time() + $timer;

    $cat_info = get_vars( "category" );
    if( ! is_array( $cat_info ) ) {
        $cat_info = array ();
        $db->query( "SELECT * FROM " . PREFIX . "_category ORDER BY posi ASC" );
        while ( $row = $db->get_row() ) $cat_info[$row['id']] = array_map("stripslashes",$row);
        set_vars( "category", $cat_info );
        $db->free();
    }
  

  
    $tpl = file_get_contents( ROOT_DIR . "/templates/{$config['skin']}/downpage.tpl" );

    $tpl = str_ireplace( "{category}", $cat_info[$row_news['category']]['name'], $tpl );
    $tpl = str_ireplace( "{category-link}", $config['http_home_url'] . get_url( intval($row_news['category'] )) . "/", $tpl );
    $tpl = str_ireplace( "{author}", "" . $row['author'] . "", $tpl );
    $tpl = str_ireplace( "{title}", stripslashes( $row_news['title'] ), $tpl );   
    $tpl = str_ireplace( "{full_link}", $full_link, $tpl );  
    $tpl = str_ireplace( "{filename}", stripslashes( $row['name'] ), $tpl );
    $tpl = str_ireplace( "{size}", formatsize( @filesize( ROOT_DIR . '/uploads/files/' . $row['onserver'] ) ), $tpl );
    $tpl = str_ireplace( "{date}", date( "d.m.Y, H:i", $row['date'] ), $tpl );
    $tpl = str_ireplace( "{count}", $row['dcount'], $tpl );
    $tpl = str_ireplace( "{timer}", $timer, $tpl );
    $tpl = str_ireplace( "{downlink}", "index.php?do=download&id=$id&hash=" . md5( $id . $row['onserver'] . $_SESSION['download_timer'] ), $tpl );
    $tpl = str_ireplace( "{charset}", $config['charset'], $tpl );
    $tpl = str_ireplace( "{file_image}", $file_image, $tpl);
    $tpl = str_ireplace( "/templates/", $config['http_home_url'] . 'templates/' . $config['skin'], $tpl );
  
    echo $tpl;
    die();
}else $_SESSION['download_timer'] = time();
if (isset($_REQUEST['area']) AND $_REQUEST['area'] == "static") {
	
	if ($config['files_count'] AND !$file->range) {
		$db->query ( "UPDATE " . PREFIX . "_static_files SET dcount=dcount+1 WHERE id ='$id'" );
	}

} else {
	
	if ($config['files_count'] AND !$file->range) {
		$db->query ( "UPDATE " . PREFIX . "_files SET dcount=dcount+1 WHERE id ='$id'" );
	}

}

$db->close();
session_write_close();

$file->download_file();

die();

Ответа пока нет


Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх