Issues (17)

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.

src/RecSelMeter.php (1 issue)

Severity

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 Chay22\RecSelMeter;
4
5
use Chay22\RecSelMeter\Parser;
6
use Chay22\RecSelMeter\Config;
7
8
class RecSelMeter
9
{
10
	/**
11
	 * Data of current store
12
	 *
13
	 * @var array $store
14
	 */
15
	protected $store;
16
17
	/**
18
	 * Set of configuration
19
	 * 
20
	 * @var object $config
21
	 */
22
	protected $config;
23
24
	/**
25
	 * Score of current store
26
	 *
27
	 * @var int $score
28
	 */
29
	protected $score = 0;
30
31
	/**
32
	 * @param   string  $url  URL of the store
33
	 */
34 1
	function __construct($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...
35
	{
36 1
		$store = new Parser($url);
37 1
		$this->store = $store->fetch();
38
39 1
		$this->config = new Config;
40 1
	}
41
42
	/**
43
	 * Return object of Config
44
	 * 
45
	 * @return object
46
	 */
47
	public function config()
48
	{
49
		return $this->config;
50
	}
51
52
	/**
53
	 * Return score of current store
54
	 * 
55
	 * @return int
56
	 */
57 1
	public function calculate()
58
	{
59 1
		$this->sold();
60 1
		$this->rank();
61 1
		$this->feedback();
62 1
		$this->storeActive();
63 1
		$this->cod();
64 1
		$this->accountAge();
65 1
		$this->imageCount();
66
67 1
		return $this->score;
68
	}
69
70
	/**
71
	 * Calculate amount of item of store sold
72
	 * 
73
	 * @return void
74
	 */
75 1
	protected function sold()
76
	{
77 1
		foreach ($this->config->data()['sold'] as $key => $value) {
78 1
			if ($this->store['sold'] >= $key) {
79 1
				$this->score += $value;
80 1
			}
81 1
		}
82 1
	}
83
84
	/**
85
	 * Add the score point based of seller rank
86
	 * 
87
	 * @return void
88
	 */
89 1
	protected function rank()
90
	{
91 1
		foreach ($this->config->data()['rank'] as $key => $value) {
92 1
			if (stripos($this->store['rank'], $key) !== false) {
93 1
				$this->score += $value;
94 1
			}
95 1
		}
96 1
	}
97
98
	/**
99
	 * Add the score point based of amount of seller feedback
100
	 * and its feedback percent
101
	 * 
102
	 * @return void
103
	 */
104 1
	protected function feedback()
105
	{
106 1
		if ($this->store['feedback_percent'] == 0) {
107 1
			return;
108
		}
109
		$feedback = $this->store['feedback'] * $this->config->data()['feedback'];
110
		$feedbackPercent = ($this->store['feedback_percent'] / $this->config->data()['feedbackPercent']);
111
		$score = round($feedback / $feedbackPercent);
112
		$this->score += $score;
113
	}
114
115
	/**
116
	 * Add score point based of time from store published time
117
	 * and latest bump (sundul) attempt
118
	 * 
119
	 * @return void
120
	 */
121 1
	protected function storeActive()
122
	{
123 1
		$storePublished = new \DateTime($this->store['published_at']);
124 1
		$storeBumped = new \DateTime($this->store['last_bump']);
125 1
		$interval = $storePublished->diff($storeBumped);
126 1
		$interval = $interval->days;
127
		
128 1
		foreach ($this->config->data()['storeActive'] as $key => $value) {
129 1
			if ($interval <= $key) {
130
				$this->score += $value;
131
			}
132 1
		}
133 1
	}
134
135
	/**
136
	 * Add a score based of seller provides COD or no
137
	 * 
138
	 * @return void
139
	 */
140 1
	protected function cod()
141
	{
142 1
		if ($this->store['cod'] !== false) {
143
			$this->score += $this->config->data()['cod'];
144
		}	
145 1
	}
146
147
	/**
148
	 * Add a score based of seller account age
149
	 * 
150
	 * @return void
151
	 */
152 1
	protected function accountAge()
153
	{
154 1
		$joinDate = new \DateTime($this->store['join_date']);
155 1
		$currentDate = new \DateTime();
156 1
		$interval = $joinDate->diff($currentDate);
157 1
		$interval = $interval->y;
158 1
		$this->score += ($interval * $this->config->data()['accountAge']);
159 1
	}
160
161
	/**
162
	 * Add a score based of amount of image seller provides
163
	 * 
164
	 * @return void
165
	 */
166 1
	protected function imageCount()
167
	{
168 1
		$this->score += $this->store['image_count'] * $this->config->data()['imageCount'];
169 1
	}
170
}
171