This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * @package Freemius |
||
4 | * @copyright Copyright (c) 2015, Freemius, Inc. |
||
5 | * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
||
6 | * @since 1.0.5 |
||
7 | */ |
||
8 | |||
9 | if ( ! defined( 'ABSPATH' ) ) { |
||
10 | exit; |
||
11 | } |
||
12 | |||
13 | /** |
||
14 | * Class FS_Plugin_License |
||
15 | */ |
||
16 | class FS_Plugin_License extends FS_Entity { |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
17 | |||
18 | #region Properties |
||
19 | |||
20 | /** |
||
21 | * @var number |
||
22 | */ |
||
23 | public $plugin_id; |
||
24 | /** |
||
25 | * @var number |
||
26 | */ |
||
27 | public $user_id; |
||
28 | /** |
||
29 | * @var number |
||
30 | */ |
||
31 | public $plan_id; |
||
32 | /** |
||
33 | * @var number |
||
34 | */ |
||
35 | public $pricing_id; |
||
36 | /** |
||
37 | * @var int|null |
||
38 | */ |
||
39 | public $quota; |
||
40 | /** |
||
41 | * @var int |
||
42 | */ |
||
43 | public $activated; |
||
44 | /** |
||
45 | * @var int |
||
46 | */ |
||
47 | public $activated_local; |
||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | public $expiration; |
||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | public $secret_key; |
||
56 | /** |
||
57 | * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same |
||
58 | * license. |
||
59 | */ |
||
60 | public $is_free_localhost; |
||
61 | /** |
||
62 | * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only |
||
63 | * block updates and support. |
||
64 | */ |
||
65 | public $is_block_features; |
||
66 | /** |
||
67 | * @var bool |
||
68 | */ |
||
69 | public $is_cancelled; |
||
70 | |||
71 | #endregion Properties |
||
72 | |||
73 | /** |
||
74 | * @param stdClass|bool $license |
||
75 | */ |
||
76 | function __construct( $license = false ) { |
||
0 ignored issues
–
show
|
|||
77 | parent::__construct( $license ); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Get entity type. |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | static function get_type() { |
||
0 ignored issues
–
show
|
|||
86 | return 'license'; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Check how many site activations left. |
||
91 | * |
||
92 | * @author Vova Feldman (@svovaf) |
||
93 | * @since 1.0.5 |
||
94 | * |
||
95 | * @return int |
||
96 | */ |
||
97 | function left() { |
||
0 ignored issues
–
show
|
|||
98 | if ( ! $this->is_active() || $this->is_expired() ) { |
||
99 | return 0; |
||
100 | } |
||
101 | |||
102 | if ( $this->is_unlimited() ) { |
||
103 | return 999; |
||
104 | } |
||
105 | |||
106 | return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) ); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Check if single site license. |
||
111 | * |
||
112 | * @author Vova Feldman (@svovaf) |
||
113 | * @since 1.1.8.1 |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | function is_single_site() { |
||
0 ignored issues
–
show
|
|||
118 | return ( is_numeric( $this->quota ) && 1 == $this->quota ); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @author Vova Feldman (@svovaf) |
||
123 | * @since 1.0.5 |
||
124 | * |
||
125 | * @return bool |
||
126 | */ |
||
127 | function is_expired() { |
||
0 ignored issues
–
show
|
|||
128 | return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME ); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Check if license is not expired. |
||
133 | * |
||
134 | * @author Vova Feldman (@svovaf) |
||
135 | * @since 1.2.1 |
||
136 | * |
||
137 | * @return bool |
||
138 | */ |
||
139 | function is_valid() { |
||
0 ignored issues
–
show
|
|||
140 | return ! $this->is_expired(); |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * @author Vova Feldman (@svovaf) |
||
145 | * @since 1.0.6 |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | function is_lifetime() { |
||
0 ignored issues
–
show
|
|||
150 | return is_null( $this->expiration ); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @author Vova Feldman (@svovaf) |
||
155 | * @since 1.2.0 |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | function is_unlimited() { |
||
0 ignored issues
–
show
|
|||
160 | return is_null( $this->quota ); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * Check if license is fully utilized. |
||
165 | * |
||
166 | * @author Vova Feldman (@svovaf) |
||
167 | * @since 1.0.6 |
||
168 | * |
||
169 | * @param bool|null $is_localhost |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | function is_utilized( $is_localhost = null ) { |
||
0 ignored issues
–
show
|
|||
174 | if ( is_null( $is_localhost ) ) { |
||
175 | $is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER; |
||
176 | } |
||
177 | |||
178 | if ( $this->is_unlimited() ) { |
||
179 | return false; |
||
180 | } |
||
181 | |||
182 | return ! ( $this->is_free_localhost && $is_localhost ) && |
||
183 | ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) ); |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * Check if license can be activated. |
||
188 | * |
||
189 | * @author Vova Feldman (@svovaf) |
||
190 | * @since 2.0.0 |
||
191 | * |
||
192 | * @param bool|null $is_localhost |
||
193 | * |
||
194 | * @return bool |
||
195 | */ |
||
196 | function can_activate( $is_localhost = null ) { |
||
0 ignored issues
–
show
|
|||
197 | return ! $this->is_utilized( $is_localhost ) && $this->is_features_enabled(); |
||
198 | } |
||
199 | |||
200 | /** |
||
201 | * Check if license can be activated on a given number of production and localhost sites. |
||
202 | * |
||
203 | * @author Vova Feldman (@svovaf) |
||
204 | * @since 2.0.0 |
||
205 | * |
||
206 | * @param int $production_count |
||
207 | * @param int $localhost_count |
||
208 | * |
||
209 | * @return bool |
||
210 | */ |
||
211 | function can_activate_bulk( $production_count, $localhost_count ) { |
||
0 ignored issues
–
show
|
|||
212 | if ( $this->is_unlimited() ) { |
||
213 | return true; |
||
214 | } |
||
215 | |||
216 | /** |
||
217 | * For simplicity, the logic will work as following: when given X sites to activate the license on, if it's |
||
218 | * possible to activate on ALL of them, do the activation. If it's not possible to activate on ALL of them, |
||
219 | * do NOT activate on any of them. |
||
220 | */ |
||
221 | return ( $this->quota >= $this->activated + $production_count + ( $this->is_free_localhost ? 0 : $this->activated_local + $localhost_count ) ); |
||
222 | } |
||
223 | |||
224 | /** |
||
225 | * @author Vova Feldman (@svovaf) |
||
226 | * @since 1.2.1 |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | function is_active() { |
||
0 ignored issues
–
show
|
|||
231 | return ( ! $this->is_cancelled ); |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * Check if license's plan features are enabled. |
||
236 | * |
||
237 | * - Either if plan not expired |
||
238 | * - If expired, based on the configuration to block features or not. |
||
239 | * |
||
240 | * @author Vova Feldman (@svovaf) |
||
241 | * @since 1.0.6 |
||
242 | * |
||
243 | * @return bool |
||
244 | */ |
||
245 | function is_features_enabled() { |
||
0 ignored issues
–
show
|
|||
246 | return $this->is_active() && ( ! $this->is_block_features || ! $this->is_expired() ); |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * Subscription considered to be new without any payments |
||
251 | * if the license expires in less than 24 hours |
||
252 | * from the license creation. |
||
253 | * |
||
254 | * @author Vova Feldman (@svovaf) |
||
255 | * @since 1.0.9 |
||
256 | * |
||
257 | * @return bool |
||
258 | */ |
||
259 | function is_first_payment_pending() { |
||
0 ignored issues
–
show
|
|||
260 | return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) ); |
||
261 | } |
||
262 | |||
263 | /** |
||
264 | * @return int |
||
265 | */ |
||
266 | function total_activations() { |
||
0 ignored issues
–
show
|
|||
267 | return ( $this->activated + $this->activated_local ); |
||
268 | } |
||
269 | } |
||
270 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.