Issues (1752)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

func/download.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @package		fwolflib
4
 * @subpackage	func
5
 * @copyright	Copyright 2007-2012, Fwolf
6
 * @author		Fwolf <[email protected]>
7
 * @since		2007-04-29
8
 */
9
10
11
require_once(dirname(__FILE__) . '/../fwolflib.php');
12
require_once(FWOLFLIB . 'func/env.php');
13
require_once(FWOLFLIB . 'func/filesystem.php');
14
15
16
/**
17
 * Download content as a file
18
 *
19
 * @deprecated      Use Fwlib\Util\HttpUtil::download()
20
 * @param	string	$content	Content to download
21
 * @param	string	$filename	Download file name, send to client, not path on server.
22
 * @param	string	$mime		Mime type of file
23
 * @return	boolean
24
 */
25
function Download ($content, $filename = '', $mime = 'application/force-download') {
26
	list($usec, $sec) = explode(" ", microtime());
27
	$usec = substr(strval($usec), 2, 3);
28
	$tmpfilename = $sec . $usec;
29
30
	if (empty($filename)) {
31
		// Use timestamp as filename if not provide
32
		$filename = $tmpfilename;
33
	}
34
35
	if (NixOs()) {
0 ignored issues
show
Deprecated Code introduced by
The function NixOs() has been deprecated with message: Use Fwlib\Util\Env::isNixOs()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
36
		$filepath = '/tmp/';
37
	} else {
38
		$s_tmp = '';
39
		if (!empty($_ENV["TEMP"]))
40
			$s_tmp = $_ENV["TEMP"];
41
		if (empty($s_tmp) && !empty($_ENV["TMP"]))
42
			$s_tmp = $_ENV["TMP"];
43
		// Default, this should never accur
44
		if (empty($s_tmp))
45
			$s_tmp = 'c:/windows/temp/';
46
		// And check again
47
		if (!is_dir($s_tmp) || !is_writable($s_tmp))
48
			die('No temp dir to store file content which need to downloaded.');
49
50
		$filepath = $s_tmp;
51
	}
52
	// Add the ending '/' to tmp path
53
	if ('/' != substr($filepath, -1))
54
		$filepath .= '/';
55
	// Then got full path of tmp file
56
	$tmpfilename = $filepath . $tmpfilename;
57
58
	file_put_contents($tmpfilename, $content);
59
	$result = DownloadFile($tmpfilename, $filename, $mime);
0 ignored issues
show
Deprecated Code introduced by
The function DownloadFile() has been deprecated with message: Use Fwlib\Util\HttpUtil::downloadFile()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
60
61
	unlink($tmpfilename);
62
	return $result;
63
} // end of func Download
64
65
66
/**
67
 * Download a file
68
 *
69
 * @deprecated      Use Fwlib\Util\HttpUtil::downloadFile()
70
 * @param	string	$filepath	Full path to download file.
71
 * @param	string	$filename	Download file name, send to client, not path on server.
72
 * @param	string	$mime		Mime type of file
73
 * @return	boolean
74
 */
75
function DownloadFile ($filepath, $filename = '', $mime = 'application/force-download') {
76
	// Check and fix parameters
77
	if (!is_file($filepath) || !is_readable($filepath))
78
		return false;
79
	// If no client filename given, use original name
80
	if (empty($filename))
81
		$filename = BaseName1($filepath);
0 ignored issues
show
Deprecated Code introduced by
The function BaseName1() has been deprecated with message: Use native basename()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
82
83
	// Begin writing headers
84
	header("Cache-Control:");
85
	header("Cache-Control: public");
86
87
	//Use the switch-generated Content-Type
88
	header("Content-Type: $mime");
89
90
	// workaround for IE filename bug with multiple periods / multiple dots in filename
91
	// that adds square brackets to filename - eg. setup.abc.exe becomes setup[1].abc.exe
92
	if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
93
		// count is reference (&count) in str_replace, so can't use it.
94
		$filename = preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1);
95
		//$iefilename = preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1);
96
97
	header("Content-Disposition: attachment; filename=\"$filename\"");
98
	//header("Content-Range: $from-$to fsize");  加上压缩包头信息不正确
99
	//header("Content-Length: $content_size");   加上压缩包头信息不正确
100
101
	header("Accept-Ranges: bytes");
102
103
	// Read temp file & output
104
	$size = filesize($filepath);
105
	$size_downloaded = 0;	// Avoid infinite loop
106
	$size_step = 1024 * 8;	// Control download speed
107
108
	$fp = fopen($filepath, "rb");
109
	//fseek($fp,$range);
110
	// Start buffered download
111
	//reset time limit for big files
112
	set_time_limit(0);
113
	while(!feof($fp) && ($size > $size_downloaded)) {
114
		print(fread($fp, $size_step));
115
		$size_downloaded += $size_step;
116
		//flush();   这个是多余的函数,加上会使压缩包下载不完整
117
		//ob_flush();  这个也是多余的函数,加上会使压缩包下载不完整
118
	}
119
120
	fclose($fp);
121
	//unlink($ft_name);
122
	return true;
123
} // end of func DownloadFile
124
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
125