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.

includes/class-sensei-course-results.php (2 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
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 12 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
 * All functionality pertaining to the course results pages in Sensei.
6
 *
7
 * @package Views
8
 * @author Automattic
9
 *
10
 * @since 1.4.0
11
 */
12
class Sensei_Course_Results {
13
14
    /**
15
     * @var string
16
     */
17
    public  $courses_url_base;
18
19
	/**
20
	 * Constructor.
21
	 * @since  1.4.0
22
	 */
23
	public function __construct () {
24
25
		// Setup learner profile URL base
26
		$this->courses_url_base = apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url slug', 'woothemes-sensei' ) );
27
28
		// Setup permalink structure for course results
29
		add_action( 'init', array( $this, 'setup_permastruct' ) );
30
		add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 );
31
32
		// Load course results
33
		add_action( 'sensei_course_results_content_inside_before', array( $this, 'deprecate_course_result_info_hook' ), 10 );
34
35
		// Add class to body tag
36
		add_filter( 'body_class', array( $this, 'body_class' ), 10, 1 );
37
38
	} // End __construct()
39
40
	/**
41
	 * Setup permalink structure for course results
42
	 * @since  1.4.0
43
	 * @return void
44
	 */
45
	public function setup_permastruct() {
46
		add_rewrite_rule( '^' . $this->courses_url_base . '/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top' );
47
		add_rewrite_tag( '%course_results%', '([^&]+)' );
48
	}
49
50
	/**
51
	 * Adding page title for course results page
52
	 * @param  string $title Original title
53
	 * @param  string $sep   Seeparator string
54
	 * @return string        Modified title
55
	 */
56
	public function page_title( $title, $sep = null ) {
57
		global $wp_query;
58
		if( isset( $wp_query->query_vars['course_results'] ) ) {
59
			$course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' );
60
			$title = __( 'Course Results: ', 'woothemes-sensei' ) . $course->post_title . ' ' . $sep . ' ';
61
		}
62
		return $title;
63
	}
64
65
	/**
66
	 * Get permalink for course results based on course ID
67
	 * @since  1.4.0
68
	 * @param  integer $course_id ID of course
69
	 * @return string             The course results page permalink
70
	 */
71
	public function get_permalink( $course_id = 0 ) {
72
73
		$permalink = '';
74
75
		if( $course_id > 0 ) {
76
77
			$course = get_post( $course_id );
78
79 View Code Duplication
			if ( get_option('permalink_structure') ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
80
				$permalink = trailingslashit( get_home_url() ) . $this->courses_url_base . '/' . $course->post_name . '/results/';
81
			} else {
82
				$permalink = trailingslashit( get_home_url() ) . '?course_results=' . $course->post_name;
83
			}
84
		}
85
86
		return $permalink;
87
	}
88
89
	/**
90
	 * Load content for course results
91
	 * @since  1.4.0
92
	 * @return void
93
	 */
94
	public function content() {
95
		global $wp_query,  $current_user;
96
97
		if( isset( $wp_query->query_vars['course_results'] ) ) {
98
            Sensei_Templates::get_template( 'course-results/course-info.php' );
99
		}
100
101
	}
102
103
	/**
104
	 * Load course results info
105
	 * @since  1.4.0
106
	 * @return void
107
	 */
108
	public function course_info() {
109
110
		global $course;
111
112
		Sensei_Utils::sensei_user_course_status_message( $course->ID, get_current_user_id());
113
114
		sensei_do_deprecated_action( 'sensei_course_results_lessons','1.9.','sensei_course_results_content_inside_after', $course );
115
116
        sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID );
117
118
	}
119
120
	/**
121
	 * Load template for displaying course lessons
122
     *
123
	 * @since  1.4.0
124
	 * @return void
125
	 */
126
	public function course_lessons() {
127
128
		global $course;
129
        _deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' );
130
131
	}
132
133
	/**
134
	 * Adding class to body tag
135
	 * @param  array $classes Existing classes
136
	 * @return array          Modified classes
137
	 */
138
	public function body_class( $classes ) {
139
		global $wp_query;
140
		if( isset( $wp_query->query_vars['course_results'] ) ) {
141
			$classes[] = 'course-results';
142
		}
143
		return $classes;
144
	}
145
146
    /**
147
     * Deprecate the sensei_course_results_content hook
148
     *
149
     * @deprecated since 1.9.0
150
     */
151
    public static function deprecate_sensei_course_results_content_hook(){
152
153
        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before');
154
155
    }
156
157
    /**
158
     * Fire the sensei frontend message hook
159
     *
160
     * @since 1.9.0
161
     */
162
    public static function fire_sensei_message_hook(){
163
164
        do_action( 'sensei_frontend_messages' );
165
166
    }
167
168
    /**
169
     * Deprecate the course_results info hook
170
     *
171
     * @since 1.9.0
172
     */
173
    public static function deprecate_course_result_info_hook(){
174
175
        sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' );
176
177
    }
178
179
    /**
180
     * Deprecate the sensei_course_results_top hook
181
     *
182
     * @deprecate since 1.9.0
183
     */
184
    public static function deprecate_course_results_top_hook(){
185
186
        global $course;
187
        sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID );
188
189
    }
190
191
    /**
192
     * Fire the course image hook
193
     *
194
     * @since 1.8.0
195
     */
196
    public static function fire_course_image_hook(){
197
198
        global $course;
199
        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
200
201
    }
202
203
} // End Class
204
205
/**
206
 * Class WooThemes_Sensei_Course_Results
207
 * @ignore only for backward compatibility
208
 * @since 1.9.0
209
 */
210
class WooThemes_Sensei_Course_Results extends Sensei_Course_Results{}
211