Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require '/home/solidarity/kr/bbs/include/common.php';
- $user="solidarity";
- $host="localhost";
- $password="hyuz";
- $database="dev";
- $connection = mysql_connect($host,$user,$password)
- or die ("couldn't connect to server"); $db = mysql_select_db($database,$connection)
- or die ("Couldn't select database");
- $query .= "SELECT donor FROM bbs_users WHERE id=".$pun_user['id'];
- $result = mysql_query($query, $connection) or die
- ("Could not execute query : $query ." . mysql_error());
- $show = $_GET['show'];
- $ep = $_GET['ep'];
- $directory = '/home/solidarity/private/krdl/';
- $show2 = $show.'/';
- // local file that should be send to the client
- $local_file = $ep;
- $download = $directory.$show2.$local_file;
- $size = intval(sprintf("%u", filesize($download)));
- while($process=mysql_fetch_array($result)) {
- $donor=$process["donor"];
- if($donor=="1") {
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename='.basename($download));
- header('Content-Transfer-Encoding: binary');
- header('Cache-Control: private');
- header('Content-Length: ' . filesize($download));
- set_time_limit(300);
- // If it's a large file, readfile might not be able to do it in one go, so:
- $chunksize = 1 * (1024 * 1024); // how many bytes per chunk
- if ($size > $chunksize) {
- $handle = fopen($download, 'rb');
- $buffer = '';
- while (!feof($handle)) {
- $buffer = fread($handle, $chunksize);
- echo $buffer;
- ob_flush();
- flush();
- }
- fclose($handle);
- } else {
- readfile($download);
- }
- // Exit successfully. We could just let the script exit
- // normally at the bottom of the page, but then blank lines
- // after the close of the script code would potentially cause
- // problems after the file download.
- exit;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment