Issues (663)

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.

pay/alipay/alipay_service.php (18 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
 * 类名 alipay_service
4
 * 功能  支付宝外部服务接口控制
5
 * 版本  0.6
6
 * 日期  2006-6-10
7
 * 作者   http://www.buybay.org
8
  * 联系   Email: [email protected]  Homepage:http://www.buybay.org
9
 * 版权   Copyright2006 Buybay NetTech
10
 */
11
12 View Code Duplication
class alipay_service {
0 ignored issues
show
This class 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...
13
14
	var $gateway = "http://www.alipay3.net/cooperate/gateway.do?";         //支付接口
15
	var $parameter;       //全部需要传递的参数
16
	var $security_code;  	//安全校验码
17
	var $mysign;             //签名
18
19
	//构造支付宝外部服务接口控制
20
	function alipay_service($parameter,$security_code,$sign_type = "MD5",$transport= "https") {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
21
		$this->parameter      = $this->para_filter($parameter);
22
		$this->security_code  = $security_code;
23
		$this->sign_type      = $sign_type;
0 ignored issues
show
The property sign_type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
		$this->mysign         = '';
25
		$this->transport      = $transport;
0 ignored issues
show
The property transport does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
		if($parameter['_input_charset'] == "")
27
		$this->parameter['_input_charset']='utf-8';
28
		if($this->transport == "https") {
29
			$this->gateway = "https://www.alipay.com/cooperate/gateway.do?";
30
		} else $this->gateway = "httsp://www.alipay.com/cooperate/gateway.do?";
31
		$sort_array = array();
0 ignored issues
show
$sort_array is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
32
		$arg = "";
33
		$sort_array = $this->arg_sort($this->parameter);
34
		while (list ($key, $val) = each ($sort_array)) {
35
			$arg.=$key."=".$this->charset_encode($val,$this->parameter['_input_charset'])."&";
36
		}
37
		$prestr = substr($arg,0,count($arg)-2);  //去掉最后一个问号
38
		$this->mysign = $this->sign($prestr.$this->security_code);
39
	}
40
41
42
	function create_url() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
43
		$url = $this->gateway;
44
		$sort_array = array();
0 ignored issues
show
$sort_array is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
45
		$arg = "";
46
		$sort_array = $this->arg_sort($this->parameter);
47
		while (list ($key, $val) = each ($sort_array)) {
48
			$arg.=$key."=".urlencode($this->charset_encode($val,$this->parameter['_input_charset']))."&";
49
		}
50
		$url.= $arg."sign=" .$this->mysign ."&sign_type=".$this->sign_type;
51
		
52
		return $url;
53
54
	}
55
56
	function signParams() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
57
		$url = $this->gateway;
0 ignored issues
show
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
58
		$sort_array = array();
0 ignored issues
show
$sort_array is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
59
		$arg = "";
60
		$sort_array = $this->arg_sort($this->parameter);
61
		while (list ($key, $val) = each ($sort_array)) {
62
			$arg.=$key."=".urlencode($this->charset_encode($val,$this->parameter['_input_charset']))."&";
63
		}
64
		return $this->mysign;
65
	}
66
67
	function arg_sort($array) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
68
		ksort($array);
69
		reset($array);
70
		return $array;
71
72
	}
73
74
	function sign($prestr) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
75
		$mysign = "";
0 ignored issues
show
$mysign is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
76
		if($this->sign_type == 'MD5') {
77
			$mysign = md5($prestr);
78
		}elseif($this->sign_type =='DSA') {
79
			//DSA 签名方法待后续开发
80
			die("DSA 签名方法待后续开发,请先使用MD5签名方式");
81
		}else {
82
			die("支付宝暂不支持".$this->sign_type."类型的签名方式");
83
		}
84
		return $mysign;
85
86
	}
87
	function para_filter($parameter) { //除去数组中的空值和签名模式
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
88
		$para = array();
89
		while (list ($key, $val) = each ($parameter)) {
90
			if($key == "sign" || $key == "sign_type" || $val == "")continue;
91
			else	$para[$key] = $parameter[$key];
92
93
		}
94
		return $para;
95
	}
96
	//实现多种字符编码方式
97
	function charset_encode($input,$_output_charset ,$_input_charset ="utf-8" ) {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
98
		$output = "";
0 ignored issues
show
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
99
		if(!isset($_output_charset) )$_output_charset  = $this->parameter['_input_charset '];
100
		if($_input_charset == $_output_charset || $input ==null) {
101
			$output = $input;
102
		} elseif (function_exists("mb_convert_encoding")){
103
			$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
104
		} elseif(function_exists("iconv")) {
105
			$output = iconv($_input_charset,$_output_charset,$input);
106
		} else die("sorry, you have no libs support for charset change.");
107
		return $output;
108
	}
109
	
110
111
}
112
113
114
?>
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...
115