Issues (3833)

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.

shortcodely-utilities.php (5 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
 * Utilities for use all over shortcodely plugin
4
 * Version 0.1
5
 *
6
 * @package Shortcodely
7
 */
8
function shortcodely_show_shortcode_widget_possibilities() {
9
	//function to show the widget possibilities
10
	global $_wp_sidebars_widgets;
11
12
	$sidebars_widgets = $_wp_sidebars_widgets;
13
	ksort( $sidebars_widgets ); // push inactive down the bottom of the list
14
	$text = '<ul>';
15
	foreach ( $sidebars_widgets as $sidebarid => $sidebar ) {
16
		if ( is_array( $sidebar ) ) {
17
			$text .= '<li><em>[do_widget_area ' . $sidebarid . ']</em><ul>';
18
			foreach ( $sidebar as $i => $w ) {
19
				$text .= '<li>';
20
				$text .= '[do_widget id="' . $w . '"]';
21
				$text .= '</li>';
22
			}
23
			$text .= '</ul></li>';
24
		}
25
	}
26
	$text .= '</ul>';
27
28
	return $text;
29
}
30
31
/*-----------------------------------*/
32
function shortcodely_get_widgets_sidebar( $wid ) {
33
	/* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
34
    take the first one that matches */
35
	global $_wp_sidebars_widgets;
36
37
	foreach ( $_wp_sidebars_widgets as $sidebarid => $sidebar ) {
38
		if ( is_array( $sidebar ) ) { // ignore the 'array version' sidebarid that isnt actually a sidebar
39
			foreach ( $sidebar as $i => $w ) {
40
				if ( $w == $wid ) {
41
					return    $sidebarid;
42
				}
43
			}
44
		}
45
	}
46
47
	return false; // widget id not in any sidebar
48
}
49
/*-----------------------------------*/
50
function shortcodely_get_sidebar_id( $name ) {
51
	/* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
52
    take the first one that matches */
53
	global $wp_registered_sidebars;
54
55
	foreach ( $wp_registered_sidebars as $i => $a ) {
56
		if ( (isset( $a['name'] )) and ($a['name'] === $name) ) {
57
			return $i;
58
		}
59
	}
60
61
	return false;
62
}
63
/*-----------------------------------*/
64
function shortcodely_get_sidebar_name( $id ) {
65
	/* dont need anymore ? or at least temporarily */
66
	/* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.  take the first one */
67
	global $wp_registered_sidebars;
68
	foreach ( $wp_registered_sidebars as $i => $a ) {
69
		if ( (isset( $a['id'] )) and ($a['id'] === $id) ) {
70
			if ( isset( $a['name'] ) ) {
71
				return $a['name'];
72
			} else {
73
				return $id;
74
			}
75
		}
76
	}
77
78
	return false;
79
}
80
/*-----------------------------------*/
81
function shortcodely_check_if_widget_debug() {
82
	global $said;
83
	// only do these debug if we are logged in and are the administrator
84
85
	if ( is_admin() ) {
86
		return false;
87
	}   // if running in backend, then do not do debug.  20151217
88
89
	if ( ( ! is_user_logged_in()) or ( ! current_user_can( 'administrator' )) ) {
90
		return false;
91
	}
92
93
	if ( isset( $_REQUEST['do_widget_debug'] ) ) {
94
		if ( empty( $said ) ) {
95
			$said = true;
96
		} else {
97
			return true;
98
		}
99
100
		$url_without_debug_query = esc_url( remove_query_arg( 'do_widget_debug' ) );
101
		$eek = '<a href="' . $url_without_debug_query . '">Remove debug</a>';
102
		echo '<br/>Note: Debug help is only shown to a logged-in Administrator.'
103
		. $eek
0 ignored issues
show
Expected next thing to be a escaping function, not '$eek'
Loading history...
104
		. '<br />';
105
		$text = shortcodely_show_shortcode_widget_possibilities();
106
		echo $text;
0 ignored issues
show
Expected next thing to be a escaping function, not '$text'
Loading history...
107
108
		return true;
109
	} else {
110
		return false;
111
	}
112
}
113
/*-----------------------------------*/
114
/**
115
 * @param string $type
116
 */
117
function shortcodely_show_widget_debug( $type, $name, $id, $sidebar ) {
0 ignored issues
show
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $sidebar is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
118
	global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount;
119
	// only do these debug if we are logged in and are the administrator
120
121
	$debug = shortcodely_check_if_widget_debug();
122
	$text = shortcodely_show_shortcode_widget_possibilities();
123
124
	if ( 'empty' == $type ) {
125
		if ( current_user_can( 'administrator' ) ) {
126
			$text = '<p>Problem with do_widget shortcode?  Try one of the following:</p>' . $text;
127
		}
128
	} elseif ( ('which one' == $type) and ($debug) ) {
129
		$text = '<p>Debug help is on: Is your widget in the widgets_for_shortcodes sidebar?</p>'
130
			. $text;
131
	}
132
133
	return $text;
134
}
135
/*-----------------------------------*/
136
function shortcodely_save_shortcodes_sidebar() {
137
	// when switching a theme, save the widgets we use for the shortcodes as they are getting overwritten
138
	$sidebars_widgets = wp_get_sidebars_widgets();
139
	if ( ! empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) {
140
		update_option( 'sidebars_widgets_for_shortcodes_saved', $sidebars_widgets['widgets_for_shortcodes'] );
141
	} else {  // our shortcodes sidebar is empty  but when to fix ?
142
	}
143
}
144
/*-----------------------------------*/
145
function shortcodely_restore_shortcodes_sidebar() {
146
	// when switching a theme, restore the widgets we use for the shortcodes as they are getting overwritten
147
	global $_wp_sidebars_widgets;
148
149
	$sidebars_widgets = wp_get_sidebars_widgets();
150
	if ( empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) {
151
		$sidebars_widgets['widgets_for_shortcodes'] = get_option( 'sidebars_widgets_for_shortcodes_saved' );
152
		update_option( 'sidebars_widgets', $sidebars_widgets );
153
	}
154
}
155
/*-----------------------------------*/
156
function shortcodely_upgrade_sidebar() {
157
	// added in 2014 February for compatibility.. keep for how long. till no sites running older versions.?
158
	$sidebars_widgets = wp_get_sidebars_widgets();
159
	if ( ! empty( $sidebars_widgets['Shortcodes'] ) and empty( $sidebars_widgets['widgets_for_shortcodes'] ) ) {  // we need to upgrade
160
		$sidebars_widgets['widgets_for_shortcodes'] = $sidebars_widgets['Shortcodes'];
161
		unset( $sidebars_widgets['Shortcodes'] );
162
		update_option( 'sidebars_widgets', $sidebars_widgets );
163
		add_action( 'admin_notices', 'widgets_shortcode_admin_notice' );
164
	}
165
}
166
167
function widgets_shortcode_admin_notice() {
168
	?>
169
	<div class="updated">
170
		<p>Please go to widgets page and check your "widgets for shortcodelys" sidebar.  It will hopefully have been corrected upgraded with your widgets and all should be fine.</p>
171
	</div>
172
	<?php
173
174
}
175
/*-----------------------------------*/
176
177
?>
178