protect uploaded file from direct download,and anti-leeching

Tips submitted by PHPMaker users
Post Reply
analizer

protect uploaded file from direct download,and anti-leec

Post by analizer »

if you want to protect uploaded file from hotlinking, direct download or anti-leeching
and protect file from download manager software such as FLASHGET,INTERNET DOWNLOAD MANAGER etc.
user will unknown real upload path (hide real file path)

1.then you must google and download "Smart File Download" and get only "download.php" file

1.1 open it and edit below code

define('ALLOWED_REFERRER', 'abc.com');

// If set to nonempty value (Example: abc.com) will only allow downloads when referrer contains this text
// For block download manager software, and allow web browser only, Please set it with full path (Ex. abc.com/filelist.php)
because download manager software has referer text with domain only (not include path) such as "abc.com"

1.2 edit below code
// Download folder, i.e. folder where you keep all files for download.
// MUST end with slash (i.e. "/" )

define('BASE_DIR', 'uploads/');

// for avoid guess folder name , please set it with strong folder such as

define('BASE_DIR', '4uKu52_aWq43_cXy5Jp/');

// if you want to use phpmaker upload folder as you define, insert this code

<?php include "ewcfg6.php" ?>

and use

define('BASE_DIR', str_replace("\\", "/", ew_UploadPathEx(true,EW_UPLOAD_DEST_PATH)));

2.open "ewcfg6.php" and insert this code, then save it

define("KG_USE_SECURITY_DOWNLOAD", "1", TRUE); // use (=1) or not use (=0) security download for anti-leeching

2.1 you can toggle download style between

define("KG_USE_SECURITY_DOWNLOAD", "0", TRUE);

for normal style (show real file path) such as
h t t p://www.abc.com/uploads/xxx.pdf
or use

define("KG_USE_SECURITY_DOWNLOAD", "1", TRUE);

for protect mode (hide real file path) such as
h t t p://www.abc.com/download.php?f=xxx.pdf

3.open "phpfn6.php" file and find

function ew_UploadPathEx($PhyPath, $DestPath) {

3.1 in this function find this code

$Path = ew_IncludeTrailingDelimiter($Path, FALSE) . $DestPath;
}

3.2 insert this code below it, and save it

if (KG_USE_SECURITY_DOWNLOAD=="1" && !$PhyPath) { // If use security download and in view mode
return "download.php?f=";
} elseif (KG_USE_SECURITY_DOWNLOAD=="0" || $PhyPath) { // If not use security download or in upload mode
return ew_IncludeTrailingDelimiter($Path, $PhyPath);
}

  1. I Love PHPMAKER ;)

edersamaniego
User
Posts: 7

Post by edersamaniego »

I had two problems:
1 Files larger than 2gb not downloaded.
2 This code blocks download managers (eg DMF)


Post Reply