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/Pagination.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 49 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
 * Pagination Class
42
 *
43
 * @package		CodeIgniter
44
 * @subpackage	Libraries
45
 * @category	Pagination
46
 * @author		EllisLab Dev Team
47
 * @link		http://codeigniter.com/user_guide/libraries/pagination.html
48
 */
49
class CI_Pagination {
50
51
	/**
52
	 * Base URL
53
	 *
54
	 * The page that we're linking to
55
	 *
56
	 * @var	string
57
	 */
58
	protected $base_url		= '';
59
60
	/**
61
	 * Prefix
62
	 *
63
	 * @var	string
64
	 */
65
	protected $prefix = '';
66
67
	/**
68
	 * Suffix
69
	 *
70
	 * @var	string
71
	 */
72
	protected $suffix = '';
73
74
	/**
75
	 * Total number of items
76
	 *
77
	 * @var	int
78
	 */
79
	protected $total_rows = 0;
80
81
	/**
82
	 * Number of links to show
83
	 *
84
	 * Relates to "digit" type links shown before/after
85
	 * the currently viewed page.
86
	 *
87
	 * @var	int
88
	 */
89
	protected $num_links = 2;
90
91
	/**
92
	 * Items per page
93
	 *
94
	 * @var	int
95
	 */
96
	public $per_page = 10;
97
98
	/**
99
	 * Current page
100
	 *
101
	 * @var	int
102
	 */
103
	public $cur_page = 0;
104
105
	/**
106
	 * Use page numbers flag
107
	 *
108
	 * Whether to use actual page numbers instead of an offset
109
	 *
110
	 * @var	bool
111
	 */
112
	protected $use_page_numbers = FALSE;
113
114
	/**
115
	 * First link
116
	 *
117
	 * @var	string
118
	 */
119
	protected $first_link = '&lsaquo; First';
120
121
	/**
122
	 * Next link
123
	 *
124
	 * @var	string
125
	 */
126
	protected $next_link = '&gt;';
127
128
	/**
129
	 * Previous link
130
	 *
131
	 * @var	string
132
	 */
133
	protected $prev_link = '&lt;';
134
135
	/**
136
	 * Last link
137
	 *
138
	 * @var	string
139
	 */
140
	protected $last_link = 'Last &rsaquo;';
141
142
	/**
143
	 * URI Segment
144
	 *
145
	 * @var	int
146
	 */
147
	protected $uri_segment = 0;
148
149
	/**
150
	 * Full tag open
151
	 *
152
	 * @var	string
153
	 */
154
	protected $full_tag_open = '';
155
156
	/**
157
	 * Full tag close
158
	 *
159
	 * @var	string
160
	 */
161
	protected $full_tag_close = '';
162
163
	/**
164
	 * First tag open
165
	 *
166
	 * @var	string
167
	 */
168
	protected $first_tag_open = '';
169
170
	/**
171
	 * First tag close
172
	 *
173
	 * @var	string
174
	 */
175
	protected $first_tag_close = '';
176
177
	/**
178
	 * Last tag open
179
	 *
180
	 * @var	string
181
	 */
182
	protected $last_tag_open = '';
183
184
	/**
185
	 * Last tag close
186
	 *
187
	 * @var	string
188
	 */
189
	protected $last_tag_close = '';
190
191
	/**
192
	 * First URL
193
	 *
194
	 * An alternative URL for the first page
195
	 *
196
	 * @var	string
197
	 */
198
	protected $first_url = '';
199
200
	/**
201
	 * Current tag open
202
	 *
203
	 * @var	string
204
	 */
205
	protected $cur_tag_open = '<strong>';
206
207
	/**
208
	 * Current tag close
209
	 *
210
	 * @var	string
211
	 */
212
	protected $cur_tag_close = '</strong>';
213
214
	/**
215
	 * Next tag open
216
	 *
217
	 * @var	string
218
	 */
219
	protected $next_tag_open = '';
220
221
	/**
222
	 * Next tag close
223
	 *
224
	 * @var	string
225
	 */
226
	protected $next_tag_close = '';
227
228
	/**
229
	 * Previous tag open
230
	 *
231
	 * @var	string
232
	 */
233
	protected $prev_tag_open = '';
234
235
	/**
236
	 * Previous tag close
237
	 *
238
	 * @var	string
239
	 */
240
	protected $prev_tag_close = '';
241
242
	/**
243
	 * Number tag open
244
	 *
245
	 * @var	string
246
	 */
247
	protected $num_tag_open = '';
248
249
	/**
250
	 * Number tag close
251
	 *
252
	 * @var	string
253
	 */
254
	protected $num_tag_close = '';
255
256
	/**
257
	 * Page query string flag
258
	 *
259
	 * @var	bool
260
	 */
261
	protected $page_query_string = FALSE;
262
263
	/**
264
	 * Query string segment
265
	 *
266
	 * @var	string
267
	 */
268
	protected $query_string_segment = 'per_page';
269
270
	/**
271
	 * Display pages flag
272
	 *
273
	 * @var	bool
274
	 */
275
	protected $display_pages = TRUE;
276
277
	/**
278
	 * Attributes
279
	 *
280
	 * @var	string
281
	 */
282
	protected $_attributes = '';
283
284
	/**
285
	 * Link types
286
	 *
287
	 * "rel" attribute
288
	 *
289
	 * @see	CI_Pagination::_attr_rel()
290
	 * @var	array
291
	 */
292
	protected $_link_types = array();
293
294
	/**
295
	 * Reuse query string flag
296
	 *
297
	 * @var	bool
298
	 */
299
	protected $reuse_query_string = FALSE;
300
301
	/**
302
	 * Use global URL suffix flag
303
	 *
304
	 * @var	bool
305
	 */
306
	protected $use_global_url_suffix = FALSE;
307
308
	/**
309
	 * Data page attribute
310
	 *
311
	 * @var	string
312
	 */
313
	protected $data_page_attr = 'data-ci-pagination-page';
314
315
	/**
316
	 * CI Singleton
317
	 *
318
	 * @var	object
319
	 */
320
	protected $CI;
321
322
	// --------------------------------------------------------------------
323
324
	/**
325
	 * Constructor
326
	 *
327
	 * @param	array	$params	Initialization parameters
328
	 * @return	void
329
	 */
330
	public function __construct($params = array())
331
	{
332
		$this->CI =& get_instance();
333
		$this->CI->load->language('pagination');
334
		foreach (array('first_link', 'next_link', 'prev_link', 'last_link') as $key)
335
		{
336
			if (($val = $this->CI->lang->line('pagination_'.$key)) !== FALSE)
337
			{
338
				$this->$key = $val;
339
			}
340
		}
341
342
		$this->initialize($params);
343
		log_message('info', 'Pagination Class Initialized');
344
	}
345
346
	// --------------------------------------------------------------------
347
348
	/**
349
	 * Initialize Preferences
350
	 *
351
	 * @param	array	$params	Initialization parameters
352
	 * @return	CI_Pagination
353
	 */
354
	public function initialize(array $params = array())
355
	{
356
		isset($params['attributes']) OR $params['attributes'] = array();
357
		if (is_array($params['attributes']))
358
		{
359
			$this->_parse_attributes($params['attributes']);
360
			unset($params['attributes']);
361
		}
362
363
		// Deprecated legacy support for the anchor_class option
364
		// Should be removed in CI 3.1+
365
		if (isset($params['anchor_class']))
366
		{
367
			empty($params['anchor_class']) OR $attributes['class'] = $params['anchor_class'];
368
			unset($params['anchor_class']);
369
		}
370
371
		foreach ($params as $key => $val)
372
		{
373
			if (property_exists($this, $key))
374
			{
375
				$this->$key = $val;
376
			}
377
		}
378
379
		if ($this->CI->config->item('enable_query_strings') === TRUE)
380
		{
381
			$this->page_query_string = TRUE;
382
		}
383
384
		if ($this->use_global_url_suffix === TRUE)
385
		{
386
			$this->suffix = $this->CI->config->item('url_suffix');
387
		}
388
389
		return $this;
390
	}
391
392
	// --------------------------------------------------------------------
393
394
	/**
395
	 * Generate the pagination links
396
	 *
397
	 * @return	string
398
	 */
399
	public function create_links()
400
	{
401
		// If our item count or per-page total is zero there is no need to continue.
402
		// Note: DO NOT change the operator to === here!
403
		if ($this->total_rows == 0 OR $this->per_page == 0)
404
		{
405
			return '';
406
		}
407
408
		// Calculate the total number of pages
409
		$num_pages = (int) ceil($this->total_rows / $this->per_page);
410
411
		// Is there only one page? Hm... nothing more to do here then.
412
		if ($num_pages === 1)
413
		{
414
			return '';
415
		}
416
417
		// Check the user defined number of links.
418
		$this->num_links = (int) $this->num_links;
419
420
		if ($this->num_links < 0)
421
		{
422
			show_error('Your number of links must be a non-negative number.');
423
		}
424
425
		// Keep any existing query string items.
426
		// Note: Has nothing to do with any other query string option.
427
		if ($this->reuse_query_string === TRUE)
428
		{
429
			$get = $this->CI->input->get();
430
431
			// Unset the controll, method, old-school routing options
432
			unset($get['c'], $get['m'], $get[$this->query_string_segment]);
433
		}
434
		else
435
		{
436
			$get = array();
437
		}
438
439
		// Put together our base and first URLs.
440
		// Note: DO NOT append to the properties as that would break successive calls
441
		$base_url = trim($this->base_url);
442
		$first_url = $this->first_url;
443
444
		$query_string = '';
445
		$query_string_sep = (strpos($base_url, '?') === FALSE) ? '?' : '&amp;';
446
447
		// Are we using query strings?
448
		if ($this->page_query_string === TRUE)
449
		{
450
			// If a custom first_url hasn't been specified, we'll create one from
451
			// the base_url, but without the page item.
452
			if ($first_url === '')
453
			{
454
				$first_url = $base_url;
455
456
				// If we saved any GET items earlier, make sure they're appended.
457
				if ( ! empty($get))
458
				{
459
					$first_url .= $query_string_sep.http_build_query($get);
460
				}
461
			}
462
463
			// Add the page segment to the end of the query string, where the
464
			// page number will be appended.
465
			$base_url .= $query_string_sep.http_build_query(array_merge($get, array($this->query_string_segment => '')));
466
		}
467
		else
468
		{
469
			// Standard segment mode.
470
			// Generate our saved query string to append later after the page number.
471
			if ( ! empty($get))
472
			{
473
				$query_string = $query_string_sep.http_build_query($get);
474
				$this->suffix .= $query_string;
475
			}
476
477
			// Does the base_url have the query string in it?
478
			// If we're supposed to save it, remove it so we can append it later.
479
			if ($this->reuse_query_string === TRUE && ($base_query_pos = strpos($base_url, '?')) !== FALSE)
480
			{
481
				$base_url = substr($base_url, 0, $base_query_pos);
482
			}
483
484
			if ($first_url === '')
485
			{
486
				$first_url = $base_url.$query_string;
487
			}
488
489
			$base_url = rtrim($base_url, '/').'/';
490
		}
491
492
		// Determine the current page number.
493
		$base_page = ($this->use_page_numbers) ? 1 : 0;
494
495
		// Are we using query strings?
496
		if ($this->page_query_string === TRUE)
497
		{
498
			$this->cur_page = $this->CI->input->get($this->query_string_segment);
499
		}
500
		else
501
		{
502
			// Default to the last segment number if one hasn't been defined.
503
			if ($this->uri_segment === 0)
504
			{
505
				$this->uri_segment = count($this->CI->uri->segment_array());
506
			}
507
508
			$this->cur_page = $this->CI->uri->segment($this->uri_segment);
509
510
			// Remove any specified prefix/suffix from the segment.
511
			if ($this->prefix !== '' OR $this->suffix !== '')
512
			{
513
				$this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $this->cur_page);
514
			}
515
		}
516
517
		// If something isn't quite right, back to the default base page.
518
		if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
519
		{
520
			$this->cur_page = $base_page;
521
		}
522
		else
523
		{
524
			// Make sure we're using integers for comparisons later.
525
			$this->cur_page = (int) $this->cur_page;
526
		}
527
528
		// Is the page number beyond the result range?
529
		// If so, we show the last page.
530
		if ($this->use_page_numbers)
531
		{
532
			if ($this->cur_page > $num_pages)
533
			{
534
				$this->cur_page = $num_pages;
535
			}
536
		}
537
		elseif ($this->cur_page > $this->total_rows)
538
		{
539
			$this->cur_page = ($num_pages - 1) * $this->per_page;
540
		}
541
542
		$uri_page_number = $this->cur_page;
543
544
		// If we're using offset instead of page numbers, convert it
545
		// to a page number, so we can generate the surrounding number links.
546
		if ( ! $this->use_page_numbers)
547
		{
548
			$this->cur_page = (int) floor(($this->cur_page/$this->per_page) + 1);
549
		}
550
551
		// Calculate the start and end numbers. These determine
552
		// which number to start and end the digit links with.
553
		$start	= (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
554
		$end	= (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
555
556
		// And here we go...
557
		$output = '';
558
559
		// Render the "First" link.
560
		if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1 + ! $this->num_links))
561
		{
562
			// Take the general parameters, and squeeze this pagination-page attr in for JS frameworks.
563
			$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, 1);
564
565
			$output .= $this->first_tag_open.'<a href="'.$first_url.'"'.$attributes.$this->_attr_rel('start').'>'
566
				.$this->first_link.'</a>'.$this->first_tag_close;
567
		}
568
569
		// Render the "Previous" link.
570
		if ($this->prev_link !== FALSE && $this->cur_page !== 1)
571
		{
572
			$i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page;
573
574
			$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, ($this->cur_page - 1));
575
576
			if ($i === $base_page)
577
			{
578
				// First page
579
				$output .= $this->prev_tag_open.'<a href="'.$first_url.'"'.$attributes.$this->_attr_rel('prev').'>'
580
					.$this->prev_link.'</a>'.$this->prev_tag_close;
581
			}
582
			else
583
			{
584
				$append = $this->prefix.$i.$this->suffix;
585
				$output .= $this->prev_tag_open.'<a href="'.$base_url.$append.'"'.$attributes.$this->_attr_rel('prev').'>'
586
					.$this->prev_link.'</a>'.$this->prev_tag_close;
587
			}
588
589
		}
590
591
		// Render the pages
592
		if ($this->display_pages !== FALSE)
593
		{
594
			// Write the digit links
595
			for ($loop = $start - 1; $loop <= $end; $loop++)
596
			{
597
				$i = ($this->use_page_numbers) ? $loop : ($loop * $this->per_page) - $this->per_page;
598
599
				$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, $loop);
600
601
				if ($i >= $base_page)
602
				{
603
					if ($this->cur_page === $loop)
604
					{
605
						// Current page
606
						$output .= $this->cur_tag_open.$loop.$this->cur_tag_close;
607
					}
608
					elseif ($i === $base_page)
609
					{
610
						// First page
611
						$output .= $this->num_tag_open.'<a href="'.$first_url.'"'.$attributes.$this->_attr_rel('start').'>'
612
							.$loop.'</a>'.$this->num_tag_close;
613
					}
614
					else
615
					{
616
						$append = $this->prefix.$i.$this->suffix;
617
						$output .= $this->num_tag_open.'<a href="'.$base_url.$append.'"'.$attributes.'>'
618
							.$loop.'</a>'.$this->num_tag_close;
619
					}
620
				}
621
			}
622
		}
623
624
		// Render the "next" link
625
		if ($this->next_link !== FALSE && $this->cur_page < $num_pages)
626
		{
627
			$i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page;
628
629
			$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, $this->cur_page + 1);
630
631
			$output .= $this->next_tag_open.'<a href="'.$base_url.$this->prefix.$i.$this->suffix.'"'.$attributes
632
				.$this->_attr_rel('next').'>'.$this->next_link.'</a>'.$this->next_tag_close;
633
		}
634
635
		// Render the "Last" link
636
		if ($this->last_link !== FALSE && ($this->cur_page + $this->num_links + ! $this->num_links) < $num_pages)
637
		{
638
			$i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page;
639
640
			$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, $num_pages);
641
642
			$output .= $this->last_tag_open.'<a href="'.$base_url.$this->prefix.$i.$this->suffix.'"'.$attributes.'>'
643
				.$this->last_link.'</a>'.$this->last_tag_close;
644
		}
645
646
		// Kill double slashes. Note: Sometimes we can end up with a double slash
647
		// in the penultimate link so we'll kill all double slashes.
648
		$output = preg_replace('#([^:"])//+#', '\\1/', $output);
649
650
		// Add the wrapper HTML if exists
651
		return $this->full_tag_open.$output.$this->full_tag_close;
652
	}
653
654
	// --------------------------------------------------------------------
655
656
	/**
657
	 * Parse attributes
658
	 *
659
	 * @param	array	$attributes
660
	 * @return	void
661
	 */
662
	protected function _parse_attributes($attributes)
663
	{
664
		isset($attributes['rel']) OR $attributes['rel'] = TRUE;
665
		$this->_link_types = ($attributes['rel'])
666
			? array('start' => 'start', 'prev' => 'prev', 'next' => 'next')
667
			: array();
668
		unset($attributes['rel']);
669
670
		$this->_attributes = '';
671
		foreach ($attributes as $key => $value)
672
		{
673
			$this->_attributes .= ' '.$key.'="'.$value.'"';
674
		}
675
	}
676
677
	// --------------------------------------------------------------------
678
679
	/**
680
	 * Add "rel" attribute
681
	 *
682
	 * @link	http://www.w3.org/TR/html5/links.html#linkTypes
683
	 * @param	string	$type
684
	 * @return	string
685
	 */
686
	protected function _attr_rel($type)
687
	{
688
		if (isset($this->_link_types[$type]))
689
		{
690
			unset($this->_link_types[$type]);
691
			return ' rel="'.$type.'"';
692
		}
693
694
		return '';
695
	}
696
697
}
698