Created
June 18, 2011 08:56
-
-
Save geekgonecrazy/1032936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Download and hit counter script. | |
//@Author: Aaron Ogle | |
$file = $_GET['f']; | |
if(ini_get('zlib.output_compression')) | |
ini_set('zlib.output_compression', 'off'); | |
// Prevent downloading any file | |
$file = str_replace(array("/", ".."), "", $file); | |
//set allowable extensions | |
$ext_filter = array("jar"); | |
//get file extension | |
$file_extension = strtolower(substr(strrchr($file,"."),1)); | |
if (!in_array($file_extension, $ext_filter)) { | |
exit('File Type Invalid'); | |
} else if (!file_exists($file)) { | |
exit('File Does Not Exist'); | |
} | |
//Set count +1 | |
$count = @file_get_contents("count.txt"); | |
$count++; | |
@file_put_contents('count.txt', $count); | |
@file_put_contents('hosts.html', gethostbyaddr($_SERVER['REMOTE_ADDR']) . '<br />', FILE_APPEND); | |
//do download | |
header("Pragma: public"); | |
header("Expires: 0"); | |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
header("Cache-Control: private",false); | |
header("Content-type: application/force-download"); | |
header("Content-Disposition: attachment; filename=\"".basename($file)."\";" ); | |
header("Content-Transfer-Encoding: binary"); | |
header("Content-Length: ".filesize($file)); | |
readfile("$file"); | |
exit(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not reliable, file doesn't always download. Probably easier to just parse the log file.