Issues (4296)

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.

includes/class-give-cron.php (4 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
 * Cron
4
 *
5
 * @package     Give
6
 * @subpackage  Classes/Give_Cron
7
 * @copyright   Copyright (c) 2016, WordImpress
8
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
9
 * @since       1.3.2
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
18
/**
19
 * Give_Cron Class
20
 *
21
 * This class handles scheduled events.
22
 *
23
 * @since 1.3.2
24
 */
25
class Give_Cron {
0 ignored issues
show
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
26
27
	/**
28
	 * Instance.
29
	 *
30
	 * @since  1.8.13
31
	 * @access private
32
	 * @var
33
	 */
34
	private static $instance;
35
36
	/**
37
	 * Singleton pattern.
38
	 *
39
	 * @since  1.8.13
40
	 * @access private
41
	 */
42
	private function __construct() {
43
	}
44
45 3
46
	/**
47 3
	 * Get instance.
48 3
	 *
49 3
	 * @since  1.8.13
50 3
	 * @access public
51
	 * @return static
52 3
	 */
53 View Code Duplication
	public static function get_instance() {
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...
54
		if ( null === static::$instance ) {
55
			self::$instance = new static();
56
			self::$instance->setup();
57
		}
58
59
		return self::$instance;
60
	}
61
62 3
63 3
	/**
64 3
	 * Setup
65 3
	 *
66
	 * @since 1.8.13
67
	 */
68
	private function setup() {
69
		add_filter( 'cron_schedules', array( self::$instance, '__add_schedules' ) );
70
		add_action( 'wp', array( self::$instance, '__schedule_events' ) );
71
	}
72
73
	/**
74 3
	 * Registers new cron schedules
75 3
	 *
76 3
	 * @since  1.3.2
77 3
	 * @access public
78 3
	 *
79
	 * @param  array $schedules An array of non-default cron schedules.
80
	 *
81
	 * @return array            An array of non-default cron schedules.
82
	 */
83
	public function __add_schedules( $schedules = array() ) {
0 ignored issues
show
Method name "Give_Cron::__add_schedules" is invalid; only PHP magic methods should be prefixed with a double underscore
Loading history...
84
		// Adds once weekly to the existing schedules.
85
		$schedules['weekly'] = array(
86
			'interval' => 604800,
87 3
			'display'  => __( 'Once Weekly', 'give' ),
88 3
		);
89 3
90 3
		return $schedules;
91 3
	}
92
93
	/**
94
	 * Schedules our events
95
	 *
96
	 * @since  1.3.2
97
	 * @access public
98
	 *
99
	 * @return void
100
	 */
101
	public function __schedule_events() {
0 ignored issues
show
Method name "Give_Cron::__schedule_events" is invalid; only PHP magic methods should be prefixed with a double underscore
Loading history...
102
		$this->weekly_events();
103
		$this->daily_events();
104
	}
105
106
	/**
107
	 * Schedule weekly events
108
	 *
109
	 * @since  1.3.2
110
	 * @access private
111
	 *
112
	 * @return void
113
	 */
114
	private function weekly_events() {
115
		if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) {
116
			wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' );
117
		}
118
	}
119
120
	/**
121
	 * Schedule daily events
122
	 *
123
	 * @since  1.3.2
124
	 * @access private
125
	 *
126
	 * @return void
127
	 */
128
	private function daily_events() {
129
		if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) {
130
			wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' );
131
		}
132
	}
133
134
	/**
135
	 * get cron job action name
136
	 *
137
	 * @since  1.8.13
138
	 * @access public
139
	 *
140
	 * @param string $type
141
	 *
142
	 * @return string
143
	 */
144
	public static function get_cron_action( $type = 'weekly' ) {
145
		switch ( $type ) {
146
			case 'daily':
147
				$cron_action = 'give_daily_scheduled_events';
148
				break;
149
150
			default:
151
				$cron_action = 'give_weekly_scheduled_events';
152
				break;
153
		}
154
155
		return $cron_action;
156
	}
157
158
	/**
159
	 * Add action to cron action
160
	 *
161
	 * @since  1.8.13
162
	 * @access private
163
	 *
164
	 * @param        $action
165
	 * @param string $type
166
	 */
167
	private static function add_event( $action, $type = 'weekly' ) {
168
		$cron_event = self::get_cron_action( $type );
169
		add_action( $cron_event, $action );
170
	}
171
172
	/**
173
	 * Add weekly event
174
	 *
175
	 * @since  1.8.13
176
	 * @access public
177
	 *
178
	 * @param $action
179
	 */
180
	public static function add_weekly_event( $action ) {
181
		self::add_event( $action, 'weekly' );
182
	}
183
184
	/**
185
	 * Add daily event
186
	 *
187
	 * @since  1.8.13
188
	 * @access public
189
	 *
190
	 * @param $action
191
	 */
192
	public static function add_daily_event( $action ) {
193
		self::add_event( $action, 'daily' );
194
	}
195
}
196
197
// Initiate class.
198
Give_Cron::get_instance();