Issues (21)

Security Analysis    no request data  

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.

lib/DictsUtils.php (1 issue)

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
namespace Ridibooks\Platform\Common;
4
5
/**
6
 * sqlDicts 통해서 얻어진 배열에 대해 자주 사용하는 함수들
7
 */
8
class DictsUtils
9
{
10
	/**
11
	 * Dicts 에서 특정 key를 가진 값들을 모두 얻기
12
	 *
13
	 * $dicts = $db->sqlDicts('select * from tb_book');
14
	 * $b_ids = DictsUtils::extractValuesByKey($dicts, 'id');
15
	 *
16
	 * @param $dicts
17
	 * @param $key
18
	 * @return array
19
	 */
20
	public static function extractValuesByKey($dicts, $key)
21
	{
22
		$return = [];
23
		foreach ($dicts as $dict) {
24
			$return[] = $dict[$key];
25
		}
26
		return $return;
27
	}
28
29
	/**
30
	 * Dicts 에서 특정 key 를 기준으로 재배치(key 기준으로 하나밖에 없을떄)
31
	 *
32
	 * $dicts = $db->sqlDicts('select * from cpdp_books');
33
	 * $cpdp_books_by_bid = DictsUtils::alignByKey($dicts, 'b_id');
34
	 * $cpdp_books_111011110 = $tb_book_property_by_bid['111011110'];
35
	 *
36
	 * $cpdp_books_111011110 => ['id' => '123123', 'b_id'=>'111011110', 'title' => '바람과 함께 사라지다']
37
	 *
38
	 * @param $dicts
39
	 * @param $key
40
	 * @return array
41
	 */
42
	public static function alignByKey($dicts, $key)
43
	{
44
		$return = [];
45
		foreach ($dicts as $dict) {
46
			$return[$dict[$key]] = $dict;
47
		}
48
		return $return;
49
	}
50
51
	/**
52
	 * Dicts 에서 특정 key 를 기준으로 재배치(key 기준으로 여러개 있을떄)
53
	 *
54
	 * $dicts = $db->sqlDicts('select * from tb_book_property');
55
	 * $tb_book_propertys_by_bid = DictsUtils::alignListByKey($dicts, 'b_id');
56
	 * $tb_book_propertys_111011110 = $tb_book_propertys_by_bid['111011110'];
57
	 *
58
	 * $tb_book_propertys_111011110 => [
59
	 *      ['b_id'=>'111011110', 'key' => 'num_pages', 'vaule' => 123123],
60
	 *      ['b_id'=>'111011110', 'key' => 'type', 'vaule' => 'pdf'],
61
	 * ]
62
	 *
63
	 * @param $dicts
64
	 * @param $key
65
	 * @return array
66
	 */
67
	public static function alignListByKey($dicts, $key)
68
	{
69
		$return = [];
70
		foreach ($dicts as $dict) {
71
			$return[$dict[$key]][] = $dict;
72
		}
73
		return $return;
74
	}
75
76
	/**
77
	 * Dicts 와 Dicts 끼리 join 할때 (SQL 에서 join 하지 않고 PHP에서 join)
78
	 *
79
	 * $dictA = $db->sqlDicts('select t_id, amount point from tb_point');
80
	 * $dictB = $db->sqlDicts('select t_id, amount cash from tb_cash');
81
	 * $dictNew = DictsUtils::join($dictA, $dictB);
82
	 *
83
	 * $dictNew => [
84
	 *      [t_id => '111', 'point' => 123, 'cash' => 456],
85
	 *      [t_id => '112', 'point' => 124, 'cash' => 457],
86
	 * ]
87
	 *
88
	 * @param $left_dicts
89
	 * @param $right_dicts
90
	 * @param int $left_dicts_column_index_to_join
91
	 * @param int $right_dicts_column_index_to_join
92
	 * @return mixed
93
	 */
94 View Code Duplication
	public static function join(
0 ignored issues
show
This method 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...
95
		$left_dicts,
96
		$right_dicts,
97
		$left_dicts_column_index_to_join = 0,
98
		$right_dicts_column_index_to_join = 0
99
	) {
100
		if (count($left_dicts) == 0) {
101
			return $right_dicts;
102
		}
103
		if (count($right_dicts) == 0) {
104
			return $left_dicts;
105
		}
106
107
		$left_keys = array_keys($left_dicts[0]);
108
		$left_key_to_join = $left_keys[$left_dicts_column_index_to_join];
109
		$right_keys = array_keys($right_dicts[0]);
110
		$right_key_to_join = $right_keys[$right_dicts_column_index_to_join];
111
112
		foreach ($left_dicts as $lk => $lv) {
113
			foreach ($right_dicts as $rk => $rv) {
114
				if ($lv[$left_key_to_join] != $rv[$right_key_to_join]) {
115
					continue;
116
				}
117
				$left_dicts[$lk] = array_merge($lv, $rv);
118
			}
119
		}
120
121
		$keys = [];
122
		foreach ($left_dicts as $dict) {
123
			$keys = array_unique(array_merge($keys, array_keys($dict)));
124
		}
125
126
		foreach ($left_dicts as $dictKey => $dict) {
127
			foreach ($keys as $key) {
128
				if (!isset($left_dicts[$dictKey][$key])) {
129
					$left_dicts[$dictKey][$key] = null;
130
				}
131
			}
132
		}
133
134
		return $left_dicts;
135
	}
136
137
	public static function convertDictsToHtmlTable($dicts)
138
	{
139
		$th = '';
140
		$tr = '';
141
		foreach ($dicts as $index => $dict) {
142
			$td = '';
143
			foreach ($dict as $key => $value) {
144
				if ($index == 0) {
145
					$th = $th . "<th align='left'>" . $key . "</th>\n";
146
				}
147
				$td = $td . "<td align='left'>" . $value . "</td>\n";
148
			}
149
			$tr = $tr . "<tr>" . $td . "</tr>\n";
150
		}
151
152
		$html_table = "
153
		<table cellspacing='0' cellpadding='0' style='width: 100%; border-collapse: collapse; color: #333; font-size: 13px; line-height: 1.7em; border-top:1px solid #848484;'>"
154
			. "<thead>" . "<tr>" . $th . "</tr>" . "</thead>"
155
			. "<tbody>" . $tr . "</tbody>" . "</table>";
156
157
		return $html_table;
158
	}
159
}
160