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/validate.php (5 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
 * Functions about validate some data.
4
 * @package		fwolflib
5
 * @subpackage	func
6
 * @copyright	Copyright 2006-2010, Fwolf
7
 * @author		Fwolf <[email protected]>
8
 * @since		2006-07-09
9
 */
10
11
12
require_once(dirname(__FILE__) . '/../fwolflib.php');
13
require_once(FWOLFLIB . 'func/env.php');
14
15
16
/**
17
 * Validate an email address.
18
 *
19
 * Provide email address (raw input)
20
 * Returns true if the email address has the email
21
 * address format and the domain exists.
22
 *
23
 * @deprecated      Use Fwlib\Validator\Constraint\Email
24
 * @link http://www.linuxjournal.com/article/9585
25
 * @param	string	$email
26
 * @return	boolean
27
 */
28
function ValidateEmail($email)
29
{
30
	$is_valid = true;
31
	$at_index = strrpos($email, '@');
32
	if (is_bool($at_index) && !$at_index)
33
	{
34
		$is_valid = false;
35
	}
36
	else
37
	{
38
		$domain = substr($email, $at_index + 1);
39
		$local = substr($email, 0, $at_index);
40
		$local_len = strlen($local);
41
		$domain_len = strlen($domain);
42
		if ($local_len < 1 || $local_len > 64)
43
		{
44
			// local part length exceeded
45
			$is_valid = false;
46
		}
47
		elseif ($domain_len < 1 || $domain_len > 255)
48
		{
49
			// domain part length exceeded
50
			$is_valid = false;
51
		}
52
		elseif ($local[0] == '.' || $local[$local_len-1] == '.')
53
		{
54
			// local part starts or ends with '.'
55
			$is_valid = false;
56
		}
57
		elseif (preg_match('/\\.\\./', $local))
58
		{
59
			// local part has two consecutive dots
60
			$is_valid = false;
61
		}
62
		elseif (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
63
		{
64
			// character not valid in domain part
65
			$is_valid = false;
66
		}
67
		elseif (preg_match('/\\.\\./', $domain))
68
		{
69
			// domain part has two consecutive dots
70
			$is_valid = false;
71
		}
72 View Code Duplication
		elseif (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
			str_replace("\\\\", "", $local)))
74
		{
75
			// character not valid in local part unless
76
			// local part is quoted
77
			if (!preg_match('/^"(\\\\"|[^"])+"$/',
78
				str_replace("\\\\", "", $local)))
79
			{
80
				$is_valid = false;
81
			}
82
		}
83
84
		// :NOTICE: Some network provider will return fake A record if
85
		// a dns query return fail, usually disp some ads.
86
		// So we only check MX record.
87
		if ($is_valid && 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...
88
			if (false == checkdnsrr($domain, "MX"))
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
89
				$is_valid = false;
90
	}
91
	return $is_valid;
92
}
93
94
95
/**
96
 * If a string is valid ip address.
97
 *
98
 * @deprecated      Use Fwlib\Util\Validator::ipv4()
99
 * @param	string	$ip
100
 * @return	boolean
101
 */
102 View Code Duplication
function ValidateIp($ip)
0 ignored issues
show
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
103
{
104
	 if (!strcmp(long2ip(sprintf("%u", ip2long($ip))), $ip))
105
		return true;
106
	 else
107
		return false;
108
} // end of function ValidateIp
109
110
111
/**
112
 * 老版本的检查ip函数, obsolete, leave here as reference.
113
 * @param	$str	string
114
 * @return	boolean
115
 */
116
function ValidateIpOld($str)
117
{
118
	 $ip = explode(".", $str);
119
	 if (count($ip)<4 || count($ip)>4) return false;
120
	 foreach($ip as $ip_addr) {
121
		  if ( !is_numeric($ip_addr) ) return false;
122
		  if ( $ip_addr<0 || $ip_addr>255 ) return false;
123
	 }
124
	 return true;
125
} // end of function ValidateIpOld
126
127
//如果简单的判断格式a.b.c.d而不考虑abcd的值的话:
128
//return (preg_match("/^([0-9]{1,3}\.){3}[0-9]{1,3}$/is", $str));
129
//不过如果需要真的ip的时候就不好玩了
130
?>
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...
131