Issues (83)

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/MslsOutput.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
 * MslsOutput
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
use lloc\Msls\Map\HrefLang;
11
12
/**
13
 * Output in the frontend
14
 * @package Msls
15
 */
16
class MslsOutput extends MslsMain {
17
18
	/**
19
	 * Holds the format for the output
20
	 * @var array $tags
21
	 */
22
	protected $tags;
23
24
	/**
25
	 * Creates and gets the output as an array
26
	 *
27
	 * @param int $display
28
	 * @param bool $filter
29
	 * @param bool $exists
30
	 *
31
	 * @return array
32
	 * @uses MslsLink
33
	 * @uses MslsOptions
34
	 */
35
	public function get( $display, $filter = false, $exists = false ) {
36
		$arr = [];
37
38
		$blogs = $this->collection->get_filtered( $filter );
39
		if ( $blogs ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $blogs of type lloc\Msls\MslsBlog[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
40
			$mydata = MslsOptions::create();
41
			$link   = MslsLink::create( $display );
42
43
			foreach ( $blogs as $blog ) {
44
				$language = $blog->get_language();
45
46
				$link->src = $this->options->get_flag_url( $language );
47
				$link->alt = $language;
48
49
				$is_current_blog = $this->collection->is_current_blog( $blog );
50
				if ( $is_current_blog ) {
51
					$url       = $mydata->get_current_link();
52
					$link->txt = $blog->get_description();
53
				} else {
54
					switch_to_blog( $blog->userblog_id );
55
56
					if ( $this->is_requirements_not_fulfilled( $mydata, $exists, $language ) ) {
57
						restore_current_blog();
58
						continue;
59
					} else {
60
						$url       = $mydata->get_permalink( $language );
61
						$link->txt = $blog->get_description();
62
					}
63
64
					restore_current_blog();
65
				}
66
67
				if ( has_filter( 'msls_output_get' ) ) {
68
					/**
69
					 * Returns HTML-link for an item of the output-arr
70
					 *
71
					 * @param string $url
72
					 * @param MslsLink $link
73
					 * @param bool $is_current_blog
74
					 *
75
					 * @since 0.9.8
76
					 *
77
					 */
78
					$arr[] = ( string ) apply_filters( 'msls_output_get', $url, $link, $is_current_blog );
79
				} else {
80
					$arr[] = sprintf(
81
						'<a href="%s" title="%s"%s>%s</a>',
82
						$url,
83
						$link->txt,
84
						$is_current_blog ? ' class="current_language"' : '',
85
						$link
86
					);
87
				}
88
			}
89
		}
90
91
		return $arr;
92
	}
93
94
	/**
95
	 * Get alternate links for the head section
96
	 *
97
	 * @return string
98
	 */
99
	public function get_alternate_links() {
100
		$blogs    = MslsBlogCollection::instance();
101
		$hreflang = new HrefLang( $blogs );
102
		$options  = MslsOptions::create();
103
104
		$arr     = [];
105
		$default = '';
106
107
		foreach ( $blogs->get_objects() as $blog ) {
108
			$url = apply_filters( 'mlsl_output_get_alternate_links', $blog->get_url( $options ), $blog );
109
110
			if ( is_null( $url ) ) {
111
				continue;
112
			}
113
114
			$description = $blog->get_description();
115
116
			$format = '<link rel="alternate" hreflang="%s" href="%s" title="%s" />';
117
			if ( '' === $default ) {
118
				$default = sprintf( $format, 'x-default', $url, esc_attr( $description ) );
119
			}
120
121
			$arr[] = sprintf( $format, $hreflang->get( $blog->get_language() ), $url, esc_attr( $description ) );
122
		}
123
124
		return 1 === count( $arr ) ? $default : implode( PHP_EOL, $arr );
125
	}
126
127
	/**
128
	 * Returns a string when the object will be treated like a string
129
	 * @return string
130
	 */
131
	public function __toString() {
132
		$display = (int) $this->options->display;
133
		$filter  = false;
134
		$exists  = isset( $this->options->only_with_translation );
135
136
		$arr = $this->get( $display, $filter, $exists );
137
		if ( empty( $arr ) ) {
138
			return apply_filters( 'msls_output_no_translation_found', '' );
139
		}
140
141
		$tags = $this->get_tags();
142
143
		return $tags['before_output'] . $tags['before_item'] .
144
		       implode( $tags['after_item'] . $tags['before_item'], $arr ) .
145
		       $tags['after_item'] . $tags['after_output'];
146
	}
147
148
	/**
149
	 * Gets tags for the output
150
	 * @return array
151
	 */
152
	public function get_tags() {
153
		if ( empty( $this->tags ) ) {
154
			$this->tags = [
155
				'before_item'   => $this->options->before_item,
156
				'after_item'    => $this->options->after_item,
157
				'before_output' => $this->options->before_output,
158
				'after_output'  => $this->options->after_output,
159
			];
160
161
			/**
162
			 * Returns tags array for the output
163
			 *
164
			 * @param array $tags
165
			 *
166
			 * @since 1.0
167
			 *
168
			 */
169
			$this->tags = ( array ) apply_filters( 'msls_output_get_tags', $this->tags );
170
		}
171
172
		return $this->tags;
173
	}
174
175
	/**
176
	 * Sets tags for the output
177
	 *
178
	 * @param array $arr
179
	 *
180
	 * @return MslsOutput
181
	 */
182
	public function set_tags( array $arr = [] ) {
183
		$this->tags = wp_parse_args( $this->get_tags(), $arr );
184
185
		return $this;
186
	}
187
188
	/**
189
	 * Returns true if the requirements not fulfilled
190
	 *
191
	 * @param MslsOptions|null $thing
192
	 * @param boolean $exists
193
	 * @param string $language
194
	 *
195
	 * @return boolean
196
	 */
197
	public function is_requirements_not_fulfilled( $thing, $exists, $language ) {
198
		if ( is_null( $thing ) ) {
199
			return $exists;
200
		}
201
202
		return MslsOptions::class != get_class( $thing ) && ! $thing->has_value( $language ) && $exists;
203
	}
204
205
}
206