Issues (103)

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/functions-templating.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
 * BetterOptin Metabox
4
 *
5
 * @package   BetterOptin/Metabox
6
 * @author    ThemeAvenue <[email protected]>
7
 * @license   GPL-2.0+
8
 * @link      http://themeavenue.net
9
 * @copyright 2015 ThemeAvenue
10
 */
11
12
// If this file is called directly, abort.
13
if ( ! defined( 'WPINC' ) ) {
14
	die;
15
}
16
17
/**
18
 * Retrieve the popup templates list.
19
 *
20
 * @since  1.0.0
21
 * @return array List of available templates with the associated screenshot
22
 */
23
function wpbo_get_templates_list() {
24
25
	/* Set the default templates directory */
26
	$directory = array(
27
		'path' => WPBO_PATH . 'templates',
28
		'url'  => WPBO_URL . 'templates'
29
	);
30
31
	/* Allow for extra directories */
32
	$dirs = apply_filters( 'wpbo_templates_dirs', array( $directory ) );
33
	$list = array();
34
35
	foreach( $dirs as $key => $dir ) {
36
37
		$exceptions = array( '.', '..' );
38
39
		if( !isset( $_GET['test_template'] ) )
40
			$exceptions[] = 'template-test.php';
41
42
		/* Get file paths with trailing slashes */
43
		$path = trailingslashit( $dir['path'] );
44
		$url  = trailingslashit( $dir['url'] );
45
46
		/* Scan the content */
47
		$templates = scandir( $path );
48
49
		foreach( $templates as $key => $template ) {
50
51
			$images = array( 'png', 'jpg', 'jpeg', 'gif' ); // Allowed images types
52
53
			/* Don't process the '.' and '..' */
54
			if( in_array( $template, $exceptions ) )
55
				continue;
56
57
			/* Get file extension */
58
			$ext = pathinfo( $path . $template, PATHINFO_EXTENSION );
59
60
			/* Only check the php files */
61
			if( 'php' != $ext )
62
				continue;
63
64
			/* Get template base name */
65
			$tpl = str_replace( ".$ext", '', $template );
66
67
			foreach( $images as $k => $type ) {
68
69
				$imgfile = $tpl . '.' . $type;
70
71
				if( file_exists( $path . $imgfile ) ) {
72
73
					/**
74
					 * @todo need to get image URL
75
					 */
76
					$img = $url . $imgfile;
77
					break;
78
79
				}
80
81
			}
82
83
			/* Add new template to the list */
84
			$list[$tpl] = $img;
0 ignored issues
show
The variable $img does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
85
86
		}
87
	}
88
89
	return $list;
90
91
}
92
93
add_action( 'plugins_loaded', 'wpbo_save_templates' );
94
/**
95
 * Save Customized Templates.
96
 *
97
 * @since  1.0.0
98
 */
99
function wpbo_save_templates() {
100
101
	if ( ! isset( $_GET['wpbo_popup'] ) || ! isset( $_POST['wpbo_nonce'] ) ) {
102
		return;
103
	}
104
105
	$post_id = intval( $_GET['wpbo_popup'] );
106
107
	if ( 'wpbo-popup' != get_post_type( $post_id ) ) {
108
		return;
109
	}
110
111
	if ( ! wp_verify_nonce( $_POST['wpbo_nonce'], 'wpbo_customize_template' ) ) {
112
		return;
113
	}
114
115 View Code Duplication
	if ( isset( $_POST['taed-outerhtml'] ) ) {
116
		update_post_meta( $post_id, '_wpbo_template_editor', htmlentities( $_POST['taed-outerhtml'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) );
117
	}
118
119 View Code Duplication
	if ( isset( $_POST['taed-outerhtmlclean'] ) ) {
120
		update_post_meta( $post_id, '_wpbo_template_display', htmlentities( $_POST['taed-outerhtmlclean'], ENT_COMPAT | ENT_HTML401, 'UTF-8' ) );
121
	}
122
123
	/* Read-only redirect */
124
	wp_redirect( add_query_arg( array( 'post_type'  => 'wpbo-popup',
125
	                                   'page'       => 'wpbo-customizer',
126
	                                   'wpbo_popup' => $post_id,
127
	                                   'message'    => 'updated'
128
	), admin_url( 'edit.php' ) ) );
129
130
	exit;
131
132
}
133
134
135
add_action( 'init', 'wpbo_reset_template' );
136
/**
137
 * Reset to default template.
138
 *
139
 * Deletes all customizations from database which
140
 * will result in using the default template file.
141
 *
142
 * @since  1.0.0
143
 */
144
function wpbo_reset_template() {
145
146
	if ( isset( $_GET['wpbo_reset'] ) && isset( $_GET['wpbo_popup'] ) && wp_verify_nonce( $_GET['wpbo_reset'], 'reset_template' ) ) {
147
148
		delete_post_meta( $_GET['wpbo_popup'], '_wpbo_template_editor' );
149
		delete_post_meta( $_GET['wpbo_popup'], '_wpbo_template_display' );
150
151
		wp_redirect( add_query_arg( array(
152
			'wpbo_popup' => $_GET['wpbo_popup'],
153
			'post_type'  => 'wpbo-popup',
154
			'page'       => 'wpbo-customizer'
155
		), admin_url( 'edit.php' ) ) );
156
157
		exit;
158
159
	}
160
161
}