Blame view

js/_tiny_mce/plugins/ajaxfilemanager/ajax_download.php 1.21 KB
42868d70   andryeyev   Создал GIT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  <?php
  	/**
  	 * delete selected files
  	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
  	 * @link www.phpletter.com
  	 * @since 22/April/2007
  	 *
  	 */
  
  	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
  	if(!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path']))
  	{
  			$path = $_GET['path'];
  			//check if the file size
  			$fileSize = @filesize($path);
  			if($fileSize > getMemoryLimit())
  			{//larger then the php memory limit, redirect to the file
  				header('Location: ' . $path);
  				exit;				 
  			}else 
  			{//open it up and send out with php
  			  header("Cache-Control: ");// leave blank to avoid IE errors
  			  header("Pragma: ");// leave blank to avoid IE errors
  			  Header( "Content-type: ".@filetype($path)."\n");
  			  header("Content-Transfer-Encoding: binary\n"); 
  			  header("Content-Disposition: attachment; filename=\"" .  basename($path). "\"\n");
  			  header("Content-length:".$fileSize);
  			 	$fp = @fopen($path);
  			 	if($fp)
  			 	{
  			 		while($data = @fread($fp, 1000))
  			 		{
  			 			echo $data;	
  			 		}
  			 		fclose($fp);
  			 	}
  			 	
  			  			
  			}
  	}else 
  	{
  		die(ERR_DOWNLOAD_FILE_NOT_FOUND);
  	}
  ?>