Issues (896)

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.

class-sensei-shortcode-user-messages.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 2.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
/**
4
 *
5
 * Renders the [sensei_user_messages] shortcode. The current users messages.
6
 * If none exists nothing will be shown.
7
 *
8
 * This class is loaded int WP by the shortcode loader class.
9
 *
10
 * @class Sensei_Shortcode_Teachers
11
 *
12
 * @package Content
13
 * @subpackage Shortcode
14
 * @author Automattic
15
 *
16
 * @since 1.9.0
17
 */
18
class Sensei_Shortcode_User_Messages implements Sensei_Shortcode_Interface {
19
20
    /**
21
     * @var WP_Query
22
     * messages for the current user
23
     */
24
    protected $messages_query;
25
26
    /**
27
     * Setup the shortcode object
28
     *
29
     * @since 1.9.0
30
     * @param array $attributes
31
     * @param string $content
32
     * @param string $shortcode the shortcode that was called for this instance
33
     */
34
    public function __construct( $attributes, $content, $shortcode ){
35
36
        $this->setup_messages_query();
37
38
    }
39
40
    /**
41
     * create the messages query .
42
     *
43
     * @return mixed
44
     */
45
    public function setup_messages_query(){
46
47
        $user = wp_get_current_user();
48
49
        $args = array(
50
            'post_type' => 'sensei_message',
51
            'posts_per_page' => 500,
52
            'orderby' => 'date',
53
            'order' => 'DESC',
54
            'post_status' => 'publish',
55
            'meta_query' => array(
56
                array(
57
                    'key'     => '_sender',
58
                    'value'   => $user->user_login,
59
                    'compare' => '=',
60
                ),
61
            ),
62
        );
63
64
        $this->messages_query  = new WP_Query( $args );
65
    }
66
67
    /**
68
     * Rendering the shortcode this class is responsible for.
69
     *
70
     * @return string $content
71
     */
72
    public function render(){
73
74
        if( !is_user_logged_in() ){
75
76
            Sensei()->notices->add_notice( __('Please login to view your messages.','woothemes-sensei') , 'alert'  );
77
78
        } elseif( 0 == $this->messages_query->post_count ){
79
80
            Sensei()->notices->add_notice( __( 'You do not have any messages.', 'woothemes-sensei') , 'alert'  );
81
        }
82
83
        $messages_disabled_in_settings =  ! ( ! isset( Sensei()->settings->settings['messages_disable'] )
84
                                            || ! Sensei()->settings->settings['messages_disable'] ) ;
85
86
        // don't show anything if messages are disable
87
        if( $messages_disabled_in_settings ){
88
            return '';
89
        }
90
91
        //set the wp_query to the current messages query
92
        global $wp_query;
93
        $wp_query = $this->messages_query;
94
95
        ob_start();
96
        Sensei()->notices->maybe_print_notices();
97
        Sensei_Templates::get_part('loop', 'message');
98
        $messages_html = ob_get_clean();
99
100
        // set back the global query
101
        wp_reset_query();
102
103
        return $messages_html;
104
105
    }// end render
106
107
}// end class