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 (423)

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.

myth/Modules.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 namespace Myth;
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 95 and the first side effect is on line 40.

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
/**
3
 * Sprint
4
 *
5
 * A set of power tools to enhance the CodeIgniter framework and provide consistent workflow.
6
 *
7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
8
 * of this software and associated documentation files (the "Software"), to deal
9
 * in the Software without restriction, including without limitation the rights
10
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
 * copies of the Software, and to permit persons to whom the Software is
12
 * furnished to do so, subject to the following conditions:
13
 *
14
 * The above copyright notice and this permission notice shall be included in
15
 * all copies or substantial portions of the Software.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
 * THE SOFTWARE.
24
 *
25
 * @package     Sprint
26
 * @author      Lonnie Ezell
27
 * @copyright   Copyright 2014-2015, New Myth Media, LLC (http://newmythmedia.com)
28
 * @license     http://opensource.org/licenses/MIT  (MIT)
29
 * @link        http://sprintphp.com
30
 * @since       Version 1.0
31
 */
32
33
/**
34
 * Since registerglobals doesn't exist after 5.4, you cannot get access to the CFG object
35
 * when running from the CLI. So, grab the config file and get our module location manually
36
 * here, then discard when we're done. It's a bit hacky, but since modules have to be
37
 * available within the Router class, before get_instance() is available we'll have to
38
 * live with it for now.
39
 */
40
include APPPATH . 'config/config.php';
41
42
if ( isset( $config ) )
43
{
44
	if ( is_array( $config['modules_locations'] ) )
45
	{
46
		Modules::$locations = $config['modules_locations'];
47
	}
48
	else
49
	{
50
		Modules::$locations = array( APPPATH . 'modules/' => '../modules/' );
51
	}
52
53
	unset( $config );
54
}
55
56
57
/**
58
 * This file has been copied from the original location and revised to work with CodeIgniter 3,
59
 * as well as add additional capabilities to, by Lonnie Ezell.
60
 */
61
62
/**
63
 * Modular Extensions - HMVC
64
 *
65
 * Adapted from the CodeIgniter Core Classes
66
 * @link    http://codeigniter.com
67
 *
68
 * Description:
69
 * This library provides functions to load and instantiate controllers
70
 * and module controllers allowing use of modules and the HMVC design pattern.
71
 *
72
 * Install this file as application/third_party/MX/Modules.php
73
 *
74
 * @copyright    Copyright (c) 2011 Wiredesignz
75
 * @version    5.4
76
 *
77
 * Permission is hereby granted, free of charge, to any person obtaining a copy
78
 * of this software and associated documentation files (the "Software"), to deal
79
 * in the Software without restriction, including without limitation the rights
80
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
81
 * copies of the Software, and to permit persons to whom the Software is
82
 * furnished to do so, subject to the following conditions:
83
 *
84
 * The above copyright notice and this permission notice shall be included in
85
 * all copies or substantial portions of the Software.
86
 *
87
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
93
 * THE SOFTWARE.
94
 **/
95
class Modules {
96
	public static $routes, $registry, $locations;
97
98
	//--------------------------------------------------------------------
99
100
	/**
101
	 * Load a module file
102
	 *
103
	 * @param $file
104
	 * @param $path
105
	 * @param string $type
106
	 * @param bool $result
107
	 *
108
	 * @return bool
109
	 */
110
	public static function load_file( $file, $path, $type = 'other', $result = TRUE )
111
	{
112
113
		$file     = str_replace( '.php', '', $file );
114
		$location = $path . $file . '.php';
115
116
		if ( $type === 'other' )
117
		{
118
			if ( class_exists( $file, FALSE ) )
119
			{
120
				log_message( 'debug', "File already loaded: {$location}" );
121
122
				return $result;
123
			}
124
			include_once $location;
125
		}
126
		else
127
		{
128
129
			/* load config or language array */
130
			include $location;
131
132
			if ( ! isset( $$type ) OR ! is_array( $$type ) )
133
			{
134
				show_error( "{$location} does not contain a valid {$type} array" );
135
			}
136
137
			$result = $$type;
138
		}
139
		log_message( 'debug', "File loaded: {$location}" );
140
141
		return $result;
142
	}
143
144
	//--------------------------------------------------------------------
145
146
	/**
147
	 * Find a file
148
	 *
149
	 * Scans for files located within modules directories.
150
	 * Also scans application directories for models, plugins and views.
151
	 * Generates fatal error if file not found.
152
	 *
153
	 * @param   string $file The name of the file to find.
154
	 * @param   string $module The name of the module or modules to look in for the file.
155
	 * @param   string $base The path within the module to look for the file.
156
	 *
157
	 * @return  array           [ {full_path_to_file}, {file} ] or FALSE
158
	 */
159
	public static function find( $file, $module, $base )
160
	{
161
		if (! is_string($module) || ! is_string($file) || ! is_string($base))
162
		{
163
			throw new \InvalidArgumentException('Argument must be a string for Modules::find()');
164
		}
165
166
		// Find the actual file name. It will always be the last element.
167
		$segments = explode( '/', $file );
168
		$file     = array_pop( $segments );
169
		$file_ext = ( pathinfo( $file, PATHINFO_EXTENSION ) ) ? $file : $file . '.php';
170
171
		// Put the pieces back to get the path.
172
		$path = implode( '/', $segments ) . '/';
173
		$base = rtrim( $base, '/' ) . '/';
174
175
		// Look in any possible module locations based on the string segments.
176
		$modules = array();
177
		if ( ! empty( $module ) )
178
		{
179
			$modules[ $module ] = $path;
180
		}
181
182
		// Collect the modules from the segments
183
		if ( ! empty( $segments ) )
184
		{
185
			$modules[ array_shift( $segments ) ] = ltrim( implode( '/', $segments ) . '/', '/' );
186
		}
187
188
		foreach ( self::$locations as $location )
189
		{
190
191
			foreach ( $modules as $module => $subpath )
192
			{
193
				// Combine the elements to make an actual path to the file
194
				$fullpath = str_replace( '//', '/', "{$location}{$module}/{$base}{$subpath}" );
195
196
				// If it starts with a '/' assume it's a full path already
197 View Code Duplication
				if ( substr( $path, 0, 1 ) == '/' && strlen( $path ) > 1 )
198
				{
199
					$fullpath = $path;
200
				}
201
202
				// Libraries are a special consideration since they are
203
				// frequently ucfirst.
204
				if ( $base == 'libraries/' AND is_file( $fullpath . ucfirst( $file_ext ) ) )
205
				{
206
					return array( $fullpath, ucfirst( $file ) );
207
				}
208
209
				if ( is_file( $fullpath . $file_ext ) )
210
				{
211
					return array( $fullpath, $file );
212
				}
213
			}
214
		}
215
216
		return array( FALSE, $file );
217
	}
218
219
	//--------------------------------------------------------------------
220
221
	/**
222
	 * Returns a list of all modules in the system.
223
	 *
224
	 * @return  array                   A list of all modules in the system.
225
	 */
226
	public static function listModules()
227
	{
228
		if ( ! function_exists( 'directory_map' ) )
229
		{
230
			require BASEPATH . 'helpers/directory_helper.php';
231
		}
232
233
		$map = array();
234
235
		foreach ( self::$locations as $folder )
236
		{
237
238
			$dirs = directory_map( $folder, 1 );
239
			if ( ! is_array( $dirs ) )
240
			{
241
				$dirs = array();
242
			}
243
244
			$map = array_merge( $map, $dirs );
245
		}
246
247
		// Clean out any html or php files
248
		if ( $count = count( $map ) )
249
		{
250
			for ( $i = 0; $i < $count; $i ++ )
251
			{
252
				if ( strpos( $map[ $i ], '.html' ) !== FALSE || strpos( $map[ $i ], '.php' ) !== FALSE )
253
				{
254
					unset( $map[ $i ] );
255
				}
256
			}
257
		}
258
259
		// CI 3 added trailing slashes to the folder names,
260
		// so clean that up.
261
		if (is_array($map))
262
		{
263
			array_walk($map, function(&$item, $key) {
264
				$item = trim($item, '/ ');
265
			});
266
		}
267
268
		return $map;
269
	}
270
271
	//--------------------------------------------------------------------
272
273
	/**
274
	 * Determines whether a controller exists for a module.
275
	 *
276
	 * @param   string $controller The name of the controller to look for (without the .php)
277
	 * @param   string $module The name of module to look in.
278
	 *
279
	 * @return boolean
280
	 */
281
	public static function controllerExists($controller, $module )
282
	{
283
		if (! is_string($module) || ! is_string($controller))
284
		{
285
			throw new \InvalidArgumentException('Argument must be a string for Modules::controllerExists()');
286
		}
287
288
		// Look in all module paths
289
		foreach ( self::$locations as $folder )
290
		{
291
			if ( is_file( "{$folder}{$module}/controllers/{$controller}.php" ) )
292
			{
293
				return TRUE;
294
			}
295
		}
296
297
		return FALSE;
298
	}
299
300
	//--------------------------------------------------------------------
301
302
	/**
303
	 * Finds the path to a module's file.
304
	 *
305
	 * @param   string $module The name of the module to find.
306
	 * @param   string $folder The folder within the module to search for the file (ie. controllers).
307
	 * @param   string $file The name of the file to search for.
308
	 *
309
	 * @return  string          The full path to the file, or false if the file was not found
310
	 */
311
	public static function filePath( $module, $folder, $file )
312
	{
313 View Code Duplication
		if (! is_string($module) || ! is_string($folder) || ! is_string($file))
314
		{
315
			throw new \InvalidArgumentException('Argument must be a string for Modules::filePath()');
316
		}
317
318
		foreach ( self::$locations as $location )
319
		{
320
			$test_file = "{$location}{$module}/{$folder}/{$file}";
321
322
			if ( is_file( $test_file ) )
323
			{
324
				return $test_file;
325
			}
326
		}
327
328
		return FALSE;
329
	}
330
331
	//--------------------------------------------------------------------
332
333
	/**
334
	 * Returns the path to the module and it's specified folder.
335
	 *
336
	 * @param $module string The name of the module (must match the folder name)
337
	 * @param $folder string The folder name to search for. (Optional)
338
	 *
339
	 * @return string The path, relative to the front controller, or false if the folder was not found
340
	 */
341
	public static function path( $module, $folder = null )
342
	{
343 View Code Duplication
		if (! is_string($module) || (! is_string($folder) && !is_null($folder) ) )
344
		{
345
			throw new \InvalidArgumentException('Argument must be a string for Modules::path()');
346
		}
347
348
		foreach ( self::$locations as $module_folder )
349
		{
350
			if ( is_dir( $module_folder . $module ) )
351
			{
352
				if ( ! empty( $folder ) && is_dir( "{$module_folder}{$module}/{$folder}" ) )
353
				{
354
					return "{$module_folder}{$module}/{$folder}/";
355
				}
356
357
				return $module_folder . $module . '/';
358
			}
359
		}
360
361
		return null;
362
	}
363
364
	//--------------------------------------------------------------------
365
366
	/**
367
	 * Returns an associative array of files within one or more modules.
368
	 *
369
	 * @param $module_name string If not NULL, will return only files from that module.
370
	 * @param $module_folder string If not NULL, will return only files within that folder of each module (ie 'views')
371
	 * @param $exclude_core boolean Whether we should ignore all core modules.
372
	 *
373
	 * @return array An associative array, like: array('module_name' => array('folder' => array('file1', 'file2')))
374
	 */
375
	public static function files( $module_name = NULL, $module_folder = NULL )
376
	{
377
		if ( ! function_exists( 'directory_map' ) )
378
		{
379
			require BASEPATH . 'helpers/directory_helper.php';
380
		}
381
382
		$files = array();
383
384
		foreach ( self::$locations as $path )
385
		{
386
387
			// Only map the whole modules directory if $module_name isn't passed
388
			if ( empty( $module_name ) )
389
			{
390
				$modules = directory_map( $path );
391
			}
392
			// Only map the $module_name directory if it exists
393
			elseif ( is_dir( $path . $module_name ) )
394
			{
395
				$path                    = $path . $module_name;
396
				$modules[ $module_name ] = directory_map( $path );
397
			}
398
399
			// If the element is not an array, it's a file, so ignore it.
400
			// Otherwise it is assumed to be a module.
401
			if ( empty( $modules ) || ! is_array( $modules ) )
402
			{
403
				continue;
404
			}
405
406
			foreach ( $modules as $mod_name => $values )
407
			{
408
				if ( is_array( $values ) )
409
				{
410
					// Add just the specified folder for this module
411
					if ( ! empty( $module_folder ) && isset( $values[ $module_folder .'/' ] ) && count( $values[ $module_folder .'/' ] ) )
412
					{
413
						$files[ $mod_name ] = array(
414
							$module_folder .'/' => $values[ $module_folder .'/' ],
415
						);
416
					}
417
					// Add the entire module
418
					elseif ( empty( $module_folder ) )
419
					{
420
						$files[ $mod_name ] = $values;
421
					}
422
				}
423
			}
424
		}
425
426
		return count( $files ) ? $files : null;
427
	}
428
429
	//--------------------------------------------------------------------
430
431
	/**
432
	 * Parse module routes.
433
	 *
434
	 * @param $module
435
	 * @param $uri
436
	 *
437
	 * @return array
438
	 */
439
	public static function parse_routes( $module, $uri )
440
	{
441
442
		/* load the route file */
443
		if ( ! isset( self::$routes[ $module ] ) )
444
		{
445
			if ( list( $path ) = self::find( 'routes', $module, 'config/' ) AND $path )
446
			{
447
				self::$routes[ $module ] = self::load_file( 'routes', $path, 'route' );
448
			}
449
		}
450
451
		if ( ! isset( self::$routes[ $module ] ) )
452
		{
453
			return;
454
		}
455
456
		/* parse module routes */
457
		foreach ( self::$routes[ $module ] as $key => $val )
458
		{
459
460
			$key = str_replace( array( ':any', ':num' ), array( '.+', '[0-9]+' ), $key );
461
462
			if ( preg_match( '#^' . $key . '$#', $uri ) )
463
			{
464 View Code Duplication
				if ( strpos( $val, '$' ) !== FALSE AND strpos( $key, '(' ) !== FALSE )
465
				{
466
					$val = preg_replace( '#^' . $key . '$#', $val, $uri );
467
				}
468
469
				return explode( '/', $module . '/' . $val );
470
			}
471
		}
472
	}
473
474
	//--------------------------------------------------------------------
475
476
	//--------------------------------------------------------------------
477
	// Autoloader
478
	//--------------------------------------------------------------------
479
480
	/**
481
	 * Library base class autoload.
482
	 *
483
	 * @param $class
484
	 */
485
	public static function autoload( $class )
486
	{
487
488
		/* don't autoload CI_ prefixed classes or those using the config subclass_prefix */
489
		if ( strstr( $class, 'CI_' ) OR strstr( $class, config_item( 'subclass_prefix' ) ) )
490
		{
491
			return;
492
		}
493
494
		/* autoload core classes */
495 View Code Duplication
		if ( is_file( $location = APPPATH . 'core/' . $class . '.php' ) )
496
		{
497
			include_once $location;
498
499
			return;
500
		}
501
502
		/* autoload library classes */
503 View Code Duplication
		if ( is_file( $location = APPPATH . 'libraries/' . $class . '.php' ) )
504
		{
505
			include_once $location;
506
507
			return;
508
		}
509
	}
510
511
	//--------------------------------------------------------------------
512
513
}
514