GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (1881)

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.

extensions/albums/functions.php (3 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
/**
4
 * Builds up a FooGallery album shortcode
5
 *
6
 * @param $album_id
7
 *
8
 * @return string
9
 */
10
function foogallery_build_album_shortcode( $album_id ) {
11
	return '[' . foogallery_album_shortcode_tag() . ' id="' . $album_id . '"]';
12
}
13
14
/**
15
 * Returns the album shortcode tag
16
 *
17
 * @return string
18
 */
19
function foogallery_album_shortcode_tag() {
20
	return apply_filters( 'foogallery_album_shortcode_tag', FOOGALLERY_CPT_ALBUM );
21
}
22
23
/**
24
 * Return all the album templates used within FooGallery
25
 *
26
 * @return array
27
 */
28
function foogallery_album_templates() {
29
	$album_templates[] = array(
30
		'slug'        => 'default',
31
		'name'        => __( 'Responsive Album Layout', 'foogallery' ),
32
		'fields'	  => array(
33
			array(
34
				'id'      => 'thumbnail_dimensions',
35
				'title'   => __( 'Thumbnail Size', 'foogallery' ),
36
				'desc'    => __( 'Choose the size of your gallery thumbnails.', 'foogallery' ),
37
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
38
				'type'    => 'thumb_size',
39
				'default' => array(
40
					'width' => get_option( 'thumbnail_size_w' ),
41
					'height' => get_option( 'thumbnail_size_h' ),
42
					'crop' => true,
43
				),
44
			),
45
			array(
46
				'id'      => 'title_bg',
47
				'title'   => __( 'Title Background Color', 'foogallery' ),
48
				'desc'    => __( 'The color of the title that overlays the album thumbnails', 'foogallery' ),
49
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
50
				'type'    => 'colorpicker',
51
				'default' => '#fff'
52
			),
53
			array(
54
				'id'      => 'title_font_color',
55
				'title'   => __( 'Title Text Color', 'foogallery' ),
56
				'desc'    => __( 'The color of the title text that overlays the album thumbnails', 'foogallery' ),
57
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
58
				'type'    => 'colorpicker',
59
				'default' => '#000000'
60
			),
61
			array(
62
				'id'      => 'alignment',
63
				'title'   => __( 'Alignment', 'foogallery' ),
64
				'desc'    => __( 'The horizontal alignment of the gallery thumbnails inside the album.', 'foogallery' ),
65
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
66
				'default' => 'alignment-left',
67
				'type'    => 'select',
68
				'choices' => array(
69
					'alignment-left' => __( 'Left', 'foogallery' ),
70
					'alignment-center' => __( 'Center', 'foogallery' ),
71
					'alignment-right' => __( 'Right', 'foogallery' ),
72
				)
73
			),
74
			array(
75
				'id'      => 'gallery_link',
76
				'title'   => __( 'Gallery Link', 'foogallery' ),
77
				'section' => __( 'URL Settings', 'foogallery' ),
78
				'default' => '',
79
				'type'    => 'radio',
80
				'spacer'  => '<span class="spacer"></span>',
81
				'choices' =>  array(
82
						'' =>  __('Default', 'foogallery'),
83
						'custom_url' => __('Custom URL', 'foogallery')
84
				),
85
				'desc'	  => __( 'You can choose to link each gallery to the default embedded gallery, or you can choose to link to the gallery custom URL (if set).', 'foogallery' ),
86
			),
87
			array(
88
				'id'      => 'gallery_link_format',
89
				'title'   => __( 'Gallery Link Format', 'foogallery' ),
90
				'desc'    => __( 'The format of the URL for each individual gallery in the album.', 'foogallery' ),
91
				'section' => __( 'URL Settings', 'foogallery' ),
92
				'type'    => 'radio',
93
				'choices' =>  array(
94
					'default' =>  __('Pretty, e.g. ', 'foogallery') . '<code>/page-with-album/' . foogallery_album_gallery_url_slug() . '/some-gallery</code>',
95
					'querystring' => __('Querystring e.g. ', 'foogallery') . '<code>/page-with-album?' . foogallery_album_gallery_url_slug() . '=some-gallery</code>'
96
				),
97
				'default' => foogallery_determine_best_link_format_default()
98
			),
99
			array(
100
				'id'	  => 'url_help',
101
				'title'	  => __( 'Please Note', 'foogallery' ),
102
				'section' => __( 'URL Settings', 'foogallery' ),
103
				'type'	  => 'help',
104
				'help'	  => true,
105
				'desc'	  => __( 'If you are getting 404\'s when clicking on the album galleries, then change to the querystring format. To force your rewrite rules to flush, simply deactivate and activate the albums extension again.', 'foogallery' ),
106
			),
107
			array(
108
				'id'      => 'album_hash',
109
				'title'   => __( 'Remember Scroll Position', 'foogallery' ),
110
				'desc'    => __( 'When a gallery is loaded in your album, the page is refreshed which means the scroll position will be lost .', 'foogallery' ),
111
				'section' => __( 'URL Settings', 'foogallery' ),
112
				'type'    => 'radio',
113
				'choices' =>  array(
114
					'none' =>  __('Don\'t Remember', 'foogallery'),
115
					'remember' => __('Remember Scroll Position', 'foogallery')
116
				),
117
				'default' => 'none'
118
			),
119
			array(
120
				'id'      => 'gallery_title_size',
121
				'title'   => __( 'Gallery Title Size', 'foogallery' ),
122
				'desc'    => __( 'The size of the title when displaying a gallery page.', 'foogallery' ),
123
				'section' => __( 'Gallery Settings', 'foogallery' ),
124
				'default' => 'h2',
125
				'type'    => 'select',
126
				'choices' => array(
127
					'h2' => __( 'H2', 'foogallery' ),
128
					'h3' => __( 'H3', 'foogallery' ),
129
					'h4' => __( 'H4', 'foogallery' ),
130
					'h5' => __( 'H5', 'foogallery' ),
131
					'h6' => __( 'H6', 'foogallery' ),
132
				)
133
			),
134
		)
135
	);
136
137
	$album_templates[] = array(
138
		'slug'        => 'stack',
139
		'name'        => __( 'All-In-One Stack Album', 'foogallery' ),
140
		'fields'	  => array(
141
			array(
142
				'id'      => 'lightbox',
143
				'title'   => __( 'Lightbox', 'foogallery' ),
144
				'desc'    => __( 'Choose which lightbox you want to use to display images.', 'foogallery' ),
145
				'type'    => 'lightbox',
146
			),
147
148
			array(
149
				'id'      => 'thumbnail_dimensions',
150
				'title'   => __( 'Thumbnail Size', 'foogallery' ),
151
				'desc'    => __( 'Choose the size of your image stack thumbnails.', 'foogallery' ),
152
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
153
				'type'    => 'thumb_size',
154
				'default' => array(
155
					'width' => get_option( 'thumbnail_size_w' ),
156
					'height' => get_option( 'thumbnail_size_h' ),
157
					'crop' => true,
158
				),
159
			),
160
161
			array(
162
				'id'      => 'random_angle',
163
				'title'   => __( 'Thumbnail Rotation', 'foogallery' ),
164
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
165
				'desc'    => __( 'Choose how thumbnails in each gallery are shown when clicking an image stack.', 'foogallery' ),
166
				'type'    => 'radio',
167
				'default' => 'false',
168
				'choices' =>  array(
169
					'false' => __( 'Normal', 'foogallery' ),
170
					'true' => __( 'Random Angles', 'foogallery' )
171
				)
172
			),
173
174
			array(
175
				'id'      => 'gutter',
176
				'title'   => __( 'Thumbnail Gutter', 'foogallery' ),
177
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
178
				'desc'    => __( 'The spacing between each image stack.', 'foogallery' ),
179
				'type'    => 'number',
180
				'default' => 50
181
			),
182
183
			array(
184
				'id'      => 'delay',
185
				'title'   => __( 'Expand Delay', 'foogallery' ),
186
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
187
				'desc'    => __( 'The delay between expanding each image on a image stack.', 'foogallery' ),
188
				'type'    => 'number',
189
				'default' => 0
190
			),
191
192
			array(
193
				'id'      => 'pile_angles',
194
				'title'   => __( 'Image Stack Angles', 'foogallery' ),
195
				'section' => __( 'Thumbnail Settings', 'foogallery' ),
196
				'desc'    => __( 'The angle of the images behind the thumbnail in each image stack.', 'foogallery' ),
197
				'type'    => 'radio',
198
				'default' => '1',
199
				'choices' =>  array(
200
					'1' => __( 'Low', 'foogallery' ),
201
					'2' => __( 'Normal', 'foogallery' ),
202
					'3' => __( 'More Than Normal', 'foogallery' ),
203
					'5' => __( 'High', 'foogallery' ),
204
				)
205
			)
206
		)
207
	);
208
209
	return apply_filters( 'foogallery_album_templates', $album_templates );
210
}
211
212
function foogallery_determine_best_link_format_default() {
213
	global $wp_rewrite;
214
	if ( '' === $wp_rewrite->permalink_structure ) {
215
		//we are using ?page_id
216
		return 'querystring';
217
	}
218
219
	//we are using permalinks
220
	return 'default';
221
}
222
223
/**
224
 * Returns the default album template
225
 *
226
 * @return string
227
 */
228
function foogallery_default_album_template() {
229
	return foogallery_get_setting( 'album_template' );
230
}
231
232
/**
233
 * Returns the gallery link url for an album
234
 *
235
 * @param $album FooGalleryAlbum
236
 * @param $gallery FooGallery
237
 *
238
 * @return string
239
 */
240
function foogallery_album_build_gallery_link( $album, $gallery ) {
241
	//first check if we want to use custom URL's
242
	$gallery_link = $album->get_meta( 'default_gallery_link', '' );
243
244
	if ( 'custom_url' === $gallery_link ) {
245
		//check if the gallery has a custom url, and if so, then use it
246
		$url = get_post_meta( $gallery->ID, 'custom_url', true );
247
	}
248
249
	if ( empty( $url ) ) {
250
		$slug   = foogallery_album_gallery_url_slug();
251
		$format = $album->get_meta( 'default_gallery_link_format', 'default' );
252
253
		if ( 'default' === $format && 'default' === foogallery_determine_best_link_format_default() ) {
254
			$url = untrailingslashit( trailingslashit( get_permalink() ) . $slug . '/' . $gallery->slug );
255
		} else {
256
			$url = add_query_arg( $slug, $gallery->slug );
257
		}
258
259
		$use_hash = $album->get_meta( 'default_album_hash', 'remember' );
260
261
		if ( 'remember' === $use_hash ) {
262
			//add the album hash if required
263
			$url .= '#' . $album->slug;
264
		}
265
	}
266
267
	return apply_filters( 'foogallery_album_build_gallery_link', $url );
268
}
269
270
/**
271
 * Returns the gallery slug used when generating gallery URL's
272
 *
273
 * @return string
274
 */
275
function foogallery_album_gallery_url_slug() {
276
	$slug = foogallery_get_setting( 'album_gallery_slug', 'gallery' );
0 ignored issues
show
'gallery' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
277
	return apply_filters( 'foogallery_album_gallery_url_slug', $slug );
278
}
279
280
/**
281
 * Returns the gallery link target for an album
282
 *
283
 * @param $album FooGalleryAlbum
284
 * @param $gallery FooGallery
285
 *
286
 * @return string
287
 */
288
function foogallery_album_build_gallery_link_target( $album, $gallery ) {
289
	//first check if we want to use custom URL's
290
	$gallery_link = $album->get_meta( 'default_gallery_link', '' );
291
292
	if ( 'custom_url' === $gallery_link ) {
293
		//check if the gallery has a custom target, and if so, then use it
294
		$target = get_post_meta( $gallery->ID, 'custom_target', true );
295
	}
296
297
	if ( empty( $target ) ) {
298
		$target = '_self';
299
	}
300
301
	return apply_filters( 'foogallery_album_build_gallery_link_target', $target );
302
}
303
304
function foogallery_album_get_current_gallery() {
305
	$slug = foogallery_album_gallery_url_slug();
306
307
	$gallery = get_query_var( $slug );
308
309
	if ( empty( $gallery ) ) {
310
		$gallery = safe_get_from_request( $slug );
311
	}
312
313
	return apply_filters( 'foogallery_album_get_current_gallery', $gallery );
314
}
315
316
function foogallery_album_remove_gallery_from_link() {
317
	$gallery = foogallery_album_get_current_gallery();
318
	$slug = foogallery_album_gallery_url_slug();
319
320
	$url = untrailingslashit( remove_query_arg( $slug ) );
321
322
	return str_replace( $slug . '/' . $gallery, '', $url);
323
}
324
325
/**
326
 * Get a foogallery album template setting for the current foogallery that is being output to the frontend
327
 * @param string	$key
328
 * @param string	$default
329
 *
330
 * @return bool
331
 */
332
function foogallery_album_template_setting( $key, $default = '' ) {
333
	global $current_foogallery_album;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
334
	global $current_foogallery_album_arguments;
335
	global $current_foogallery_album_template;
336
337
	$settings_key = "{$current_foogallery_album_template}_{$key}";
338
339
	if ( $current_foogallery_album_arguments && array_key_exists( $key, $current_foogallery_album_arguments ) ) {
340
		//try to get the value from the arguments
341
		$value = $current_foogallery_album_arguments[ $key ];
342
343
	} else if ( $current_foogallery_album->settings && array_key_exists( $settings_key, $current_foogallery_album->settings ) ) {
344
		//then get the value out of the saved gallery settings
345
		$value = $current_foogallery_album->settings[ $settings_key ];
346
	} else {
347
		//otherwise set it to the default
348
		$value = $default;
349
	}
350
351
	$value = apply_filters( 'foogallery_album_template_setting-' . $key, $value );
352
353
	return $value;
354
}
355
356
/**
357
 * uninstall all albums and setting for albums
358
 */
359
function foogallery_album_uninstall() {
360
	if ( !current_user_can( 'install_plugins' ) ) exit;
361
362
	//delete all albums posts
363
	global $wpdb;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
364
	$query = "SELECT p.ID FROM {$wpdb->posts} AS p WHERE p.post_type IN (%s)";
365
	$gallery_post_ids = $wpdb->get_col( $wpdb->prepare( $query, FOOGALLERY_CPT_ALBUM ) );
366
367
	if ( !empty( $gallery_post_ids ) ) {
368
		$deleted = 0;
369
		foreach ( $gallery_post_ids as $post_id ) {
370
			$del = wp_delete_post( $post_id );
371
			if ( false !== $del ) {
372
				++$deleted;
373
			}
374
		}
375
	}
376
}