Issues (234)

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/installation.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
 * Installation
4
 *
5
 * @package SimpleCalendar
6
 */
7
namespace SimpleCalendar;
8
9
use SimpleCalendar\Admin\Pages;
10
11
if ( ! defined( 'ABSPATH' ) ) {
12
	exit;
13
}
14
15
/**
16
 * Installation.
17
 *
18
 * Static class that deals with plugin activation and deactivation events.
19
 *
20
 * @since 3.0.0
21
 */
22
class Installation {
23
24
	/**
25
	 * What happens when the plugin is activated.
26
	 *
27
	 * @since 3.0.0
28
	 */
29
	public static function activate() {
30
31
		include_once 'functions/shared.php';
32
		include_once 'functions/admin.php';
33
34
		self::create_terms();
35
		self::create_options();
36
37
		do_action( 'simcal_activated' );
38
	}
39
40
	/**
41
	 * What happens when the plugin is deactivated.
42
	 *
43
	 * @since 3.0.0
44
	 */
45
	public static function deactivate() {
46
47
		flush_rewrite_rules();
48
49
		do_action( 'simcal_deactivated' );
50
	}
51
52
	/**
53
	 * Create default terms.
54
	 *
55
	 * @since 3.0.0
56
	 */
57
	public static function create_terms() {
58
59
		$taxonomies = array(
60
			'calendar_feed' => array(
61
				'google',
62
				'grouped-calendar',
63
			),
64
			'calendar_type' => array(
65
				'default-calendar'
66
			)
67
		);
68
69
		foreach ( $taxonomies as $taxonomy => $terms ) {
70
			foreach ( $terms as $term ) {
71
				if ( ! get_term_by( 'slug', sanitize_title( $term ), $taxonomy ) ) {
72
					wp_insert_term( $term, $taxonomy );
73
				}
74
			}
75
		}
76
77
	}
78
79
	/**
80
	 * Sets the default options.
81
	 *
82
	 * @since 3.0.0
83
	 */
84
	public static function create_options() {
85
86
		$default = '';
87
		$page    = 'settings';
88
		$settings_pages  = new Pages( $page );
89
		$plugin_settings = $settings_pages->get_settings();
90
91
		if ( $plugin_settings && is_array( $plugin_settings ) ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $plugin_settings of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
92
93
			foreach ( $plugin_settings as $id => $settings ) {
94
95
				$group = 'simple-calendar_' . $page . '_' . $id;
96
97
				if ( isset( $settings['sections'] ) ) {
98
99
					if ( $settings['sections'] && is_array( $settings['sections'] ) ) {
100
101
						foreach ( $settings['sections'] as $section_id => $section ) {
102
103
							if ( isset( $section['fields'] ) ) {
104
105
								if ( $section['fields'] && is_array( $section['fields'] ) ) {
106
107
									foreach ( $section['fields'] as $key => $field ) {
108
109
										if ( isset ( $field['type'] ) ) {
110
											// Maybe an associative array.
111
											if ( is_int( $key ) ) {
112
												$default[ $section_id ] = self::get_field_default_value( $field );
113
											} else {
114
												$default[ $section_id ][ $key ] = self::get_field_default_value( $field );
115
											}
116
										}
117
118
									} // Loop fields.
119
120
								} // Are fields non empty?
121
122
							} // Are there fields?
123
124
						} // Loop fields sections.
125
126
					} // Are sections non empty?
127
128
				} // Are there sections?
129
130
				add_option( $group, $default, '', true );
131
132
				// Reset before looping next settings page.
133
				$default = '';
134
			}
135
136
		}
137
	}
138
139
	/**
140
	 * Get field default value.
141
	 *
142
	 * Helper function to set the default value of a field.
143
	 *
144
	 * @since  3.0.0
145
	 *
146
	 * @param  $field
147
	 *
148
	 * @return mixed
149
	 */
150
	private static function get_field_default_value( $field ) {
151
152
		$saved_value   = isset( $field['value'] )   ? $field['value']   : '';
153
		$default_value = isset( $field['default'] ) ? $field['default'] : '';
154
155
		return ! empty( $saved_value ) ? $saved_value : $default_value;
156
	}
157
158
}
159