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.

system/libraries/User_agent.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 51 and the first side effect is on line 38.

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
 * CodeIgniter
4
 *
5
 * An open source application development framework for PHP
6
 *
7
 * This content is released under the MIT License (MIT)
8
 *
9
 * Copyright (c) 2014 - 2015, British Columbia Institute of Technology
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
12
 * of this software and associated documentation files (the "Software"), to deal
13
 * in the Software without restriction, including without limitation the rights
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
 * copies of the Software, and to permit persons to whom the Software is
16
 * furnished to do so, subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be included in
19
 * all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
 * THE SOFTWARE.
28
 *
29
 * @package	CodeIgniter
30
 * @author	EllisLab Dev Team
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
32
 * @copyright	Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
33
 * @license	http://opensource.org/licenses/MIT	MIT License
34
 * @link	http://codeigniter.com
35
 * @since	Version 1.0.0
36
 * @filesource
37
 */
38
defined('BASEPATH') OR exit('No direct script access allowed');
39
40
/**
41
 * User Agent Class
42
 *
43
 * Identifies the platform, browser, robot, or mobile device of the browsing agent
44
 *
45
 * @package		CodeIgniter
46
 * @subpackage	Libraries
47
 * @category	User Agent
48
 * @author		EllisLab Dev Team
49
 * @link		http://codeigniter.com/user_guide/libraries/user_agent.html
50
 */
51
class CI_User_agent {
52
53
	/**
54
	 * Current user-agent
55
	 *
56
	 * @var string
57
	 */
58
	public $agent = NULL;
59
60
	/**
61
	 * Flag for if the user-agent belongs to a browser
62
	 *
63
	 * @var bool
64
	 */
65
	public $is_browser = FALSE;
66
67
	/**
68
	 * Flag for if the user-agent is a robot
69
	 *
70
	 * @var bool
71
	 */
72
	public $is_robot = FALSE;
73
74
	/**
75
	 * Flag for if the user-agent is a mobile browser
76
	 *
77
	 * @var bool
78
	 */
79
	public $is_mobile = FALSE;
80
81
	/**
82
	 * Languages accepted by the current user agent
83
	 *
84
	 * @var array
85
	 */
86
	public $languages = array();
87
88
	/**
89
	 * Character sets accepted by the current user agent
90
	 *
91
	 * @var array
92
	 */
93
	public $charsets = array();
94
95
	/**
96
	 * List of platforms to compare against current user agent
97
	 *
98
	 * @var array
99
	 */
100
	public $platforms = array();
101
102
	/**
103
	 * List of browsers to compare against current user agent
104
	 *
105
	 * @var array
106
	 */
107
	public $browsers = array();
108
109
	/**
110
	 * List of mobile browsers to compare against current user agent
111
	 *
112
	 * @var array
113
	 */
114
	public $mobiles = array();
115
116
	/**
117
	 * List of robots to compare against current user agent
118
	 *
119
	 * @var array
120
	 */
121
	public $robots = array();
122
123
	/**
124
	 * Current user-agent platform
125
	 *
126
	 * @var string
127
	 */
128
	public $platform = '';
129
130
	/**
131
	 * Current user-agent browser
132
	 *
133
	 * @var string
134
	 */
135
	public $browser = '';
136
137
	/**
138
	 * Current user-agent version
139
	 *
140
	 * @var string
141
	 */
142
	public $version = '';
143
144
	/**
145
	 * Current user-agent mobile name
146
	 *
147
	 * @var string
148
	 */
149
	public $mobile = '';
150
151
	/**
152
	 * Current user-agent robot name
153
	 *
154
	 * @var string
155
	 */
156
	public $robot = '';
157
158
	/**
159
	 * HTTP Referer
160
	 *
161
	 * @var	mixed
162
	 */
163
	public $referer;
164
165
	// --------------------------------------------------------------------
166
167
	/**
168
	 * Constructor
169
	 *
170
	 * Sets the User Agent and runs the compilation routine
171
	 *
172
	 * @return	void
173
	 */
174
	public function __construct()
175
	{
176
		if (isset($_SERVER['HTTP_USER_AGENT']))
177
		{
178
			$this->agent = trim($_SERVER['HTTP_USER_AGENT']);
179
		}
180
181
		if ($this->agent !== NULL && $this->_load_agent_file())
182
		{
183
			$this->_compile_data();
184
		}
185
186
		log_message('info', 'User Agent Class Initialized');
187
	}
188
189
	// --------------------------------------------------------------------
190
191
	/**
192
	 * Compile the User Agent Data
193
	 *
194
	 * @return	bool
195
	 */
196
	protected function _load_agent_file()
197
	{
198
		if (($found = file_exists(APPPATH.'config/user_agents.php')))
199
		{
200
			include(APPPATH.'config/user_agents.php');
201
		}
202
203
		if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
204
		{
205
			include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
206
			$found = TRUE;
207
		}
208
209
		if ($found !== TRUE)
210
		{
211
			return FALSE;
212
		}
213
214
		$return = FALSE;
215
216
		if (isset($platforms))
217
		{
218
			$this->platforms = $platforms;
219
			unset($platforms);
220
			$return = TRUE;
221
		}
222
223
		if (isset($browsers))
224
		{
225
			$this->browsers = $browsers;
226
			unset($browsers);
227
			$return = TRUE;
228
		}
229
230
		if (isset($mobiles))
231
		{
232
			$this->mobiles = $mobiles;
233
			unset($mobiles);
234
			$return = TRUE;
235
		}
236
237
		if (isset($robots))
238
		{
239
			$this->robots = $robots;
240
			unset($robots);
241
			$return = TRUE;
242
		}
243
244
		return $return;
245
	}
246
247
	// --------------------------------------------------------------------
248
249
	/**
250
	 * Compile the User Agent Data
251
	 *
252
	 * @return	bool
253
	 */
254
	protected function _compile_data()
255
	{
256
		$this->_set_platform();
257
258
		foreach (array('_set_robot', '_set_browser', '_set_mobile') as $function)
259
		{
260
			if ($this->$function() === TRUE)
261
			{
262
				break;
263
			}
264
		}
265
	}
266
267
	// --------------------------------------------------------------------
268
269
	/**
270
	 * Set the Platform
271
	 *
272
	 * @return	bool
273
	 */
274 View Code Duplication
	protected function _set_platform()
275
	{
276
		if (is_array($this->platforms) && count($this->platforms) > 0)
277
		{
278
			foreach ($this->platforms as $key => $val)
279
			{
280
				if (preg_match('|'.preg_quote($key).'|i', $this->agent))
281
				{
282
					$this->platform = $val;
283
					return TRUE;
284
				}
285
			}
286
		}
287
288
		$this->platform = 'Unknown Platform';
289
		return FALSE;
290
	}
291
292
	// --------------------------------------------------------------------
293
294
	/**
295
	 * Set the Browser
296
	 *
297
	 * @return	bool
298
	 */
299
	protected function _set_browser()
300
	{
301
		if (is_array($this->browsers) && count($this->browsers) > 0)
302
		{
303
			foreach ($this->browsers as $key => $val)
304
			{
305
				if (preg_match('|'.$key.'.*?([0-9\.]+)|i', $this->agent, $match))
306
				{
307
					$this->is_browser = TRUE;
308
					$this->version = $match[1];
309
					$this->browser = $val;
310
					$this->_set_mobile();
311
					return TRUE;
312
				}
313
			}
314
		}
315
316
		return FALSE;
317
	}
318
319
	// --------------------------------------------------------------------
320
321
	/**
322
	 * Set the Robot
323
	 *
324
	 * @return	bool
325
	 */
326 View Code Duplication
	protected function _set_robot()
327
	{
328
		if (is_array($this->robots) && count($this->robots) > 0)
329
		{
330
			foreach ($this->robots as $key => $val)
331
			{
332
				if (preg_match('|'.preg_quote($key).'|i', $this->agent))
333
				{
334
					$this->is_robot = TRUE;
335
					$this->robot = $val;
336
					$this->_set_mobile();
337
					return TRUE;
338
				}
339
			}
340
		}
341
342
		return FALSE;
343
	}
344
345
	// --------------------------------------------------------------------
346
347
	/**
348
	 * Set the Mobile Device
349
	 *
350
	 * @return	bool
351
	 */
352
	protected function _set_mobile()
353
	{
354
		if (is_array($this->mobiles) && count($this->mobiles) > 0)
355
		{
356
			foreach ($this->mobiles as $key => $val)
357
			{
358
				if (FALSE !== (stripos($this->agent, $key)))
359
				{
360
					$this->is_mobile = TRUE;
361
					$this->mobile = $val;
362
					return TRUE;
363
				}
364
			}
365
		}
366
367
		return FALSE;
368
	}
369
370
	// --------------------------------------------------------------------
371
372
	/**
373
	 * Set the accepted languages
374
	 *
375
	 * @return	void
376
	 */
377 View Code Duplication
	protected function _set_languages()
378
	{
379
		if ((count($this->languages) === 0) && ! empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
380
		{
381
			$this->languages = explode(',', preg_replace('/(;\s?q=[0-9\.]+)|\s/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE']))));
382
		}
383
384
		if (count($this->languages) === 0)
385
		{
386
			$this->languages = array('Undefined');
387
		}
388
	}
389
390
	// --------------------------------------------------------------------
391
392
	/**
393
	 * Set the accepted character sets
394
	 *
395
	 * @return	void
396
	 */
397 View Code Duplication
	protected function _set_charsets()
398
	{
399
		if ((count($this->charsets) === 0) && ! empty($_SERVER['HTTP_ACCEPT_CHARSET']))
400
		{
401
			$this->charsets = explode(',', preg_replace('/(;\s?q=.+)|\s/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET']))));
402
		}
403
404
		if (count($this->charsets) === 0)
405
		{
406
			$this->charsets = array('Undefined');
407
		}
408
	}
409
410
	// --------------------------------------------------------------------
411
412
	/**
413
	 * Is Browser
414
	 *
415
	 * @param	string	$key
416
	 * @return	bool
417
	 */
418
	public function is_browser($key = NULL)
419
	{
420
		if ( ! $this->is_browser)
421
		{
422
			return FALSE;
423
		}
424
425
		// No need to be specific, it's a browser
426
		if ($key === NULL)
427
		{
428
			return TRUE;
429
		}
430
431
		// Check for a specific browser
432
		return (isset($this->browsers[$key]) && $this->browser === $this->browsers[$key]);
433
	}
434
435
	// --------------------------------------------------------------------
436
437
	/**
438
	 * Is Robot
439
	 *
440
	 * @param	string	$key
441
	 * @return	bool
442
	 */
443
	public function is_robot($key = NULL)
444
	{
445
		if ( ! $this->is_robot)
446
		{
447
			return FALSE;
448
		}
449
450
		// No need to be specific, it's a robot
451
		if ($key === NULL)
452
		{
453
			return TRUE;
454
		}
455
456
		// Check for a specific robot
457
		return (isset($this->robots[$key]) && $this->robot === $this->robots[$key]);
458
	}
459
460
	// --------------------------------------------------------------------
461
462
	/**
463
	 * Is Mobile
464
	 *
465
	 * @param	string	$key
466
	 * @return	bool
467
	 */
468
	public function is_mobile($key = NULL)
469
	{
470
		if ( ! $this->is_mobile)
471
		{
472
			return FALSE;
473
		}
474
475
		// No need to be specific, it's a mobile
476
		if ($key === NULL)
477
		{
478
			return TRUE;
479
		}
480
481
		// Check for a specific robot
482
		return (isset($this->mobiles[$key]) && $this->mobile === $this->mobiles[$key]);
483
	}
484
485
	// --------------------------------------------------------------------
486
487
	/**
488
	 * Is this a referral from another site?
489
	 *
490
	 * @return	bool
491
	 */
492
	public function is_referral()
493
	{
494
		if ( ! isset($this->referer))
495
		{
496
			if (empty($_SERVER['HTTP_REFERER']))
497
			{
498
				$this->referer = FALSE;
499
			}
500
			else
501
			{
502
				$referer_host = @parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
503
				$own_host = parse_url(config_item('base_url'), PHP_URL_HOST);
504
505
				$this->referer = ($referer_host && $referer_host !== $own_host);
506
			}
507
		}
508
509
		return $this->referer;
510
	}
511
512
	// --------------------------------------------------------------------
513
514
	/**
515
	 * Agent String
516
	 *
517
	 * @return	string
518
	 */
519
	public function agent_string()
520
	{
521
		return $this->agent;
522
	}
523
524
	// --------------------------------------------------------------------
525
526
	/**
527
	 * Get Platform
528
	 *
529
	 * @return	string
530
	 */
531
	public function platform()
532
	{
533
		return $this->platform;
534
	}
535
536
	// --------------------------------------------------------------------
537
538
	/**
539
	 * Get Browser Name
540
	 *
541
	 * @return	string
542
	 */
543
	public function browser()
544
	{
545
		return $this->browser;
546
	}
547
548
	// --------------------------------------------------------------------
549
550
	/**
551
	 * Get the Browser Version
552
	 *
553
	 * @return	string
554
	 */
555
	public function version()
556
	{
557
		return $this->version;
558
	}
559
560
	// --------------------------------------------------------------------
561
562
	/**
563
	 * Get The Robot Name
564
	 *
565
	 * @return	string
566
	 */
567
	public function robot()
568
	{
569
		return $this->robot;
570
	}
571
	// --------------------------------------------------------------------
572
573
	/**
574
	 * Get the Mobile Device
575
	 *
576
	 * @return	string
577
	 */
578
	public function mobile()
579
	{
580
		return $this->mobile;
581
	}
582
583
	// --------------------------------------------------------------------
584
585
	/**
586
	 * Get the referrer
587
	 *
588
	 * @return	bool
589
	 */
590
	public function referrer()
591
	{
592
		return empty($_SERVER['HTTP_REFERER']) ? '' : trim($_SERVER['HTTP_REFERER']);
593
	}
594
595
	// --------------------------------------------------------------------
596
597
	/**
598
	 * Get the accepted languages
599
	 *
600
	 * @return	array
601
	 */
602
	public function languages()
603
	{
604
		if (count($this->languages) === 0)
605
		{
606
			$this->_set_languages();
607
		}
608
609
		return $this->languages;
610
	}
611
612
	// --------------------------------------------------------------------
613
614
	/**
615
	 * Get the accepted Character Sets
616
	 *
617
	 * @return	array
618
	 */
619
	public function charsets()
620
	{
621
		if (count($this->charsets) === 0)
622
		{
623
			$this->_set_charsets();
624
		}
625
626
		return $this->charsets;
627
	}
628
629
	// --------------------------------------------------------------------
630
631
	/**
632
	 * Test for a particular language
633
	 *
634
	 * @param	string	$lang
635
	 * @return	bool
636
	 */
637
	public function accept_lang($lang = 'en')
638
	{
639
		return in_array(strtolower($lang), $this->languages(), TRUE);
640
	}
641
642
	// --------------------------------------------------------------------
643
644
	/**
645
	 * Test for a particular character set
646
	 *
647
	 * @param	string	$charset
648
	 * @return	bool
649
	 */
650
	public function accept_charset($charset = 'utf-8')
651
	{
652
		return in_array(strtolower($charset), $this->charsets(), TRUE);
653
	}
654
655
	// --------------------------------------------------------------------
656
657
	/**
658
	 * Parse a custom user-agent string
659
	 *
660
	 * @param	string	$string
661
	 * @return	void
662
	 */
663
	public function parse($string)
664
	{
665
		// Reset values
666
		$this->is_browser = FALSE;
667
		$this->is_robot = FALSE;
668
		$this->is_mobile = FALSE;
669
		$this->browser = '';
670
		$this->version = '';
671
		$this->mobile = '';
672
		$this->robot = '';
673
674
		// Set the new user-agent string and parse it, unless empty
675
		$this->agent = $string;
676
677
		if ( ! empty($string))
678
		{
679
			$this->_compile_data();
680
		}
681
	}
682
683
}
684