Completed
Push — master ( d6ef10...270242 )
by Angus
03:27
created
public/index.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -210,10 +210,10 @@
 block discarded – undo
210 210
 {
211 211
 	// Ensure there's a trailing slash
212 212
 	$system_path = strtr(
213
-		               rtrim($system_path, '/\\'),
214
-		               '/\\',
215
-		               DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
216
-	               ).DIRECTORY_SEPARATOR;
213
+					   rtrim($system_path, '/\\'),
214
+					   '/\\',
215
+					   DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
216
+				   ).DIRECTORY_SEPARATOR;
217 217
 }
218 218
 
219 219
 // Is the system path correct?
Please login to merge, or discard this patch.
application/models/Auth_Model.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,9 +77,9 @@
 block discarded – undo
77 77
 	public function verification_check(string $verificationCode) {
78 78
 		//user is trying to validate their email for signup, check if verification code is still valid/exists
79 79
 		$query = $this->db->select('email, verification_code_time')
80
-		                  ->from('auth_signup_verification')
81
-		                  ->where(array('verification_code' => $verificationCode))
82
-		                  ->get();
80
+						  ->from('auth_signup_verification')
81
+						  ->where(array('verification_code' => $verificationCode))
82
+						  ->get();
83 83
 
84 84
 		$return = FALSE;
85 85
 		if($query->num_rows() > 0) {
Please login to merge, or discard this patch.
application/models/User_Model.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 		$this->load->database();
41 41
 
42 42
 		$query = $this->db->select('*')
43
-		                  ->from('auth_users')
44
-		                  ->where('username', $username)
45
-		                  ->get();
43
+						  ->from('auth_users')
44
+						  ->where('username', $username)
45
+						  ->get();
46 46
 
47 47
 		return (bool) $query->num_rows();
48 48
 	}
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 			$this->load->database();
65 65
 
66 66
 			$query = $this->db->select('email')
67
-			                  ->from('auth_users')
68
-			                  ->where('username', $identity)
69
-			                  ->get();
67
+							  ->from('auth_users')
68
+							  ->where('username', $identity)
69
+							  ->get();
70 70
 
71 71
 			if($query->num_rows() > 0) {
72 72
 				//username exists, grab email
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 		$user = NULL;
85 85
 
86 86
 		$query = $this->db->select('*')
87
-		                  ->from('auth_users')
88
-		                  ->where('username', $username)
89
-		                  ->get();
87
+						  ->from('auth_users')
88
+						  ->where('username', $username)
89
+						  ->get();
90 90
 
91 91
 		if($query->num_rows() > 0) {
92 92
 			$user = $query->row();
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 	
115 115
 	public function get_id_from_api_key(string $api_key) {
116 116
 		$query = $this->db->select('id')
117
-		                  ->from('auth_users')
118
-		                  ->where('api_key', $api_key)
119
-		                  ->get();
117
+						  ->from('auth_users')
118
+						  ->where('api_key', $api_key)
119
+						  ->get();
120 120
 
121 121
 		if($query->num_rows() > 0) {
122 122
 			$userID = $query->row('id');
Please login to merge, or discard this patch.
application/tests_codeception/_support/UnitTester.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 */
19 19
 class UnitTester extends \Codeception\Actor
20 20
 {
21
-    use _generated\UnitTesterActions;
21
+	use _generated\UnitTesterActions;
22 22
 
23 23
    /**
24 24
     * Define custom actions here
Please login to merge, or discard this patch.
application/tests_codeception/_support/AcceptanceTester.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 */
19 19
 class AcceptanceTester extends \Codeception\Actor
20 20
 {
21
-    use _generated\AcceptanceTesterActions;
21
+	use _generated\AcceptanceTesterActions;
22 22
 
23 23
    /**
24 24
     * Define custom actions here
Please login to merge, or discard this patch.
application/tests_codeception/_support/FunctionalTester.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 */
19 19
 class FunctionalTester extends \Codeception\Actor
20 20
 {
21
-    use _generated\FunctionalTesterActions;
21
+	use _generated\FunctionalTesterActions;
22 22
 
23 23
    /**
24 24
     * Define custom actions here
Please login to merge, or discard this patch.
application/models/Tracker_Model.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 
156 156
 	public function getSiteDataFromURL(string $site_url) {
157 157
 		$query = $this->db->select('id, site_class')
158
-		                  ->from('tracker_sites')
159
-		                  ->where('site', $site_url)
160
-		                  ->get();
158
+						  ->from('tracker_sites')
159
+						  ->where('site', $site_url)
160
+						  ->get();
161 161
 
162 162
 		if($query->num_rows() > 0) {
163 163
 			$siteData = $query->row();
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 
169 169
 	public function getTitleID(string $titleURL, int $siteID) {
170 170
 		$query = $this->db->select('tracker_titles.id, tracker_titles.title, tracker_titles.title_url, tracker_titles.complete, tracker_sites.site_class, (tracker_titles.last_checked > DATE_SUB(NOW(), INTERVAL 3 DAY)) AS active', FALSE)
171
-		                  ->from('tracker_titles')
172
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
173
-		                  ->where('tracker_titles.title_url', $titleURL)
174
-		                  ->where('tracker_titles.site_id', $siteID)
175
-		                  ->get();
171
+						  ->from('tracker_titles')
172
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
173
+						  ->where('tracker_titles.title_url', $titleURL)
174
+						  ->where('tracker_titles.site_id', $siteID)
175
+						  ->get();
176 176
 
177 177
 		if($query->num_rows() > 0) {
178 178
 			$id = (int) $query->row('id');
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 						//Make sure last_checked is always updated on successful run.
186 186
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
187 187
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
188
-						         ->where('id', $id)
189
-						         ->update('tracker_titles');
188
+								 ->where('id', $id)
189
+								 ->update('tracker_titles');
190 190
 					}
191 191
 				} else {
192 192
 					log_message('error', "{$query->row('title')} failed to update successfully");
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 			}
225 225
 
226 226
 			$idQuery = $this->db->select('id')
227
-			                    ->where('user_id', $userID)
228
-			                    ->where('title_id', $titleID)
229
-			                    ->get('tracker_chapters');
227
+								->where('user_id', $userID)
228
+								->where('title_id', $titleID)
229
+								->get('tracker_chapters');
230 230
 			if($idQuery->num_rows() > 0) {
231 231
 				$success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL])
232
-				                    ->where('user_id', $userID)
233
-				                    ->where('title_id', $titleID)
234
-				                    ->update('tracker_chapters');
232
+									->where('user_id', $userID)
233
+									->where('title_id', $titleID)
234
+									->update('tracker_chapters');
235 235
 
236 236
 				if($success) {
237 237
 					$idQueryRow = $idQuery->row();
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 
257 257
 	public function updateTrackerByID(int $userID, int $chapterID, string $chapter) : bool {
258 258
 		$success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL])
259
-		                    ->where('user_id', $userID)
260
-		                    ->where('id', $chapterID)
261
-		                    ->update('tracker_chapters');
259
+							->where('user_id', $userID)
260
+							->where('id', $chapterID)
261
+							->update('tracker_chapters');
262 262
 
263 263
 		if($success) {
264 264
 			$this->History->userUpdateTitle($chapterID, $chapter);
@@ -271,23 +271,23 @@  discard block
 block discarded – undo
271 271
 		//This is to allow user history to function properly.
272 272
 
273 273
 		$success = $this->db->set(['active' => 'N', 'last_updated' => NULL])
274
-		                    ->where('user_id', $userID)
275
-		                    ->where('id', $chapterID)
276
-		                    ->update('tracker_chapters');
274
+							->where('user_id', $userID)
275
+							->where('id', $chapterID)
276
+							->update('tracker_chapters');
277 277
 
278 278
 		return (bool) $success;
279 279
 	}
280 280
 	private function updateTitleById(int $id, string $latestChapter) {
281 281
 		//FIXME: Really not too happy with how we're doing history stuff here, it just feels messy.
282 282
 		$query = $this->db->select('latest_chapter AS current_chapter')
283
-		                  ->from('tracker_titles')
284
-		                  ->where('id', $id)
285
-		                  ->get();
283
+						  ->from('tracker_titles')
284
+						  ->where('id', $id)
285
+						  ->get();
286 286
 		$row = $query->row();
287 287
 
288 288
 		$success = $this->db->set(['latest_chapter' => $latestChapter]) //last_updated gets updated via a trigger if something changes
289
-		                    ->where('id', $id)
290
-		                    ->update('tracker_titles');
289
+							->where('id', $id)
290
+							->update('tracker_titles');
291 291
 
292 292
 		//Update History
293 293
 		//NOTE: To avoid doing another query to grab the last_updated time, we just use time() which <should> get the same thing.
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
 	}
299 299
 	private function updateTitleDataById(int $id, array $titleData) {
300 300
 		$success = $this->db->set($titleData)
301
-		                    ->where('id', $id)
302
-		                    ->update('tracker_titles');
301
+							->where('id', $id)
302
+							->update('tracker_titles');
303 303
 
304 304
 		return (bool) $success;
305 305
 	}
306 306
 	private function addTitle(string $titleURL, int $siteID) {
307 307
 		$query = $this->db->select('site, site_class')
308
-		                  ->from('tracker_sites')
309
-		                  ->where('id', $siteID)
310
-		                  ->get();
308
+						  ->from('tracker_sites')
309
+						  ->where('id', $siteID)
310
+						  ->get();
311 311
 
312 312
 		$titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL);
313 313
 		//FIXME: getTitleData can fail, which will in turn cause the below to fail aswell, we should try and account for that
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 						//Make sure last_checked is always updated on successful run.
360 360
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
361 361
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
362
-						         ->where('id', $row->id)
363
-						         ->update('tracker_titles');
362
+								 ->where('id', $row->id)
363
+								 ->update('tracker_titles');
364 364
 
365 365
 						print " - ({$titleData['latest_chapter']})\n";
366 366
 					}
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
 	}
478 478
 	public function setCategoryTrackerByID(int $userID, int $chapterID, string $category) : bool {
479 479
 		$success = $this->db->set(['category' => $category, 'active' => 'Y', 'last_updated' => NULL])
480
-		                    ->where('user_id', $userID)
481
-		                    ->where('id', $chapterID)
482
-		                    ->update('tracker_chapters');
480
+							->where('user_id', $userID)
481
+							->where('id', $chapterID)
482
+							->update('tracker_chapters');
483 483
 
484 484
 		return (bool) $success;
485 485
 	}
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
 		$success = FALSE;
490 490
 		if(preg_match("/^[a-z0-9-_,]{0,255}$/", $tag_string)) {
491 491
 			$success = (bool) $this->db->set(['tags' => $tag_string, 'active' => 'Y', 'last_updated' => NULL])
492
-			                           ->where('user_id', $userID)
493
-			                           ->where('id', $chapterID)
494
-			                           ->update('tracker_chapters');
492
+									   ->where('user_id', $userID)
493
+									   ->where('id', $chapterID)
494
+									   ->update('tracker_chapters');
495 495
 		}
496 496
 
497 497
 		if($success) {
@@ -529,23 +529,23 @@  discard block
 block discarded – undo
529 529
 
530 530
 			//We need the series to be tracked
531 531
 			$idCQuery = $this->db->select('id')
532
-			                    ->where('user_id', $userID)
533
-			                    ->where('title_id', $titleID)
534
-			                    ->get('tracker_chapters');
532
+								->where('user_id', $userID)
533
+								->where('title_id', $titleID)
534
+								->get('tracker_chapters');
535 535
 			if($idCQuery->num_rows() > 0) {
536 536
 				$idCQueryRow = $idCQuery->row();
537 537
 
538 538
 				//Check if it is already favourited
539 539
 				$idFQuery = $this->db->select('id')
540
-				                    ->where('chapter_id', $idCQueryRow->id)
541
-				                    ->where('chapter', $chapter)
542
-				                    ->get('tracker_favourites');
540
+									->where('chapter_id', $idCQueryRow->id)
541
+									->where('chapter', $chapter)
542
+									->get('tracker_favourites');
543 543
 				if($idFQuery->num_rows() > 0) {
544 544
 					//Chapter is already favourited, so remove it from DB
545 545
 					$idFQueryRow = $idFQuery->row();
546 546
 
547 547
 					$isSuccess = (bool) $this->db->where('id', $idFQueryRow->id)
548
-					                           ->delete('tracker_favourites');
548
+											   ->delete('tracker_favourites');
549 549
 
550 550
 					if($isSuccess) {
551 551
 						$success = array(
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
 
617 617
 	public function getUsedCategories(int $userID) : array {
618 618
 		$query = $this->db->distinct()
619
-		                  ->select('category')
620
-		                  ->from('tracker_chapters')
621
-		                  ->where('tracker_chapters.active', 'Y')
622
-		                  ->where('user_id', $userID)
623
-		                  ->get();
619
+						  ->select('category')
620
+						  ->from('tracker_chapters')
621
+						  ->where('tracker_chapters.active', 'Y')
622
+						  ->where('user_id', $userID)
623
+						  ->get();
624 624
 
625 625
 		return array_column($query->result_array(), 'category');
626 626
 	}
@@ -631,51 +631,51 @@  discard block
 block discarded – undo
631 631
 
632 632
 			//CHECK: Is it possible to merge some of these queries?
633 633
 			$queryUsers = $this->db->select([
634
-			                            'COUNT(*) AS total_users',
635
-			                            'SUM(CASE WHEN api_key IS NOT NULL THEN 1 ELSE 0 END) AS validated_users',
636
-			                            'SUM(CASE WHEN (api_key IS NOT NULL AND from_unixtime(last_login) > DATE_SUB(NOW(), INTERVAL 7 DAY)) THEN 1 ELSE 0 END) AS active_users'
637
-			                       ], FALSE)
638
-			                       ->from('auth_users')
639
-			                       ->get();
634
+										'COUNT(*) AS total_users',
635
+										'SUM(CASE WHEN api_key IS NOT NULL THEN 1 ELSE 0 END) AS validated_users',
636
+										'SUM(CASE WHEN (api_key IS NOT NULL AND from_unixtime(last_login) > DATE_SUB(NOW(), INTERVAL 7 DAY)) THEN 1 ELSE 0 END) AS active_users'
637
+								   ], FALSE)
638
+								   ->from('auth_users')
639
+								   ->get();
640 640
 			$stats = array_merge($stats, $queryUsers->result_array()[0]);
641 641
 
642 642
 			$queryCounts = $this->db->select([
643
-			                             'tracker_titles.title',
644
-			                             'COUNT(tracker_chapters.title_id) AS count'
645
-			                        ], FALSE)
646
-			                        ->from('tracker_chapters')
647
-			                        ->join('tracker_titles', 'tracker_titles.id = tracker_chapters.title_id', 'left')
648
-			                        ->group_by('tracker_chapters.title_id')
649
-			                        ->having('count > 1')
650
-			                        ->order_by('count DESC')
651
-			                        ->get();
643
+										 'tracker_titles.title',
644
+										 'COUNT(tracker_chapters.title_id) AS count'
645
+									], FALSE)
646
+									->from('tracker_chapters')
647
+									->join('tracker_titles', 'tracker_titles.id = tracker_chapters.title_id', 'left')
648
+									->group_by('tracker_chapters.title_id')
649
+									->having('count > 1')
650
+									->order_by('count DESC')
651
+									->get();
652 652
 			$stats['titles_tracked_more'] = count($queryCounts->result_array());
653 653
 			$stats['top_title_name']  = $queryCounts->result_array()[0]['title'] ?? 'N/A';
654 654
 			$stats['top_title_count'] = $queryCounts->result_array()[0]['count'] ?? 'N/A';
655 655
 
656 656
 			$queryTitles = $this->db->select([
657
-			                             'COUNT(DISTINCT tracker_titles.id) AS total_titles',
658
-			                             'COUNT(DISTINCT tracker_titles.site_id) AS total_sites',
659
-			                             'SUM(CASE WHEN from_unixtime(auth_users.last_login) > DATE_SUB(NOW(), INTERVAL 120 HOUR) IS NOT NULL THEN 0 ELSE 1 END) AS inactive_titles',
660
-			                             'SUM(CASE WHEN (tracker_titles.last_updated > DATE_SUB(NOW(), INTERVAL 24 HOUR)) THEN 1 ELSE 0 END) AS updated_titles'
661
-			                        ], FALSE)
662
-			                        ->from('tracker_titles')
663
-			                        ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
664
-			                        ->join('tracker_chapters', 'tracker_titles.id = tracker_chapters.title_id', 'left')
665
-			                        ->join('auth_users', 'tracker_chapters.user_id = auth_users.id', 'left')
666
-			                        ->get();
657
+										 'COUNT(DISTINCT tracker_titles.id) AS total_titles',
658
+										 'COUNT(DISTINCT tracker_titles.site_id) AS total_sites',
659
+										 'SUM(CASE WHEN from_unixtime(auth_users.last_login) > DATE_SUB(NOW(), INTERVAL 120 HOUR) IS NOT NULL THEN 0 ELSE 1 END) AS inactive_titles',
660
+										 'SUM(CASE WHEN (tracker_titles.last_updated > DATE_SUB(NOW(), INTERVAL 24 HOUR)) THEN 1 ELSE 0 END) AS updated_titles'
661
+									], FALSE)
662
+									->from('tracker_titles')
663
+									->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
664
+									->join('tracker_chapters', 'tracker_titles.id = tracker_chapters.title_id', 'left')
665
+									->join('auth_users', 'tracker_chapters.user_id = auth_users.id', 'left')
666
+									->get();
667 667
 			$stats = array_merge($stats, $queryTitles->result_array()[0]);
668 668
 
669 669
 			$querySites = $this->db->select([
670
-			                           'tracker_sites.site',
671
-			                           'COUNT(*) AS count'
672
-			                       ], FALSE)
673
-			                       ->from('tracker_titles')
674
-			                       ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
675
-			                       ->group_by('tracker_titles.site_id')
676
-			                       ->order_by('count DESC')
677
-			                       ->limit(3)
678
-			                       ->get();
670
+									   'tracker_sites.site',
671
+									   'COUNT(*) AS count'
672
+								   ], FALSE)
673
+								   ->from('tracker_titles')
674
+								   ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
675
+								   ->group_by('tracker_titles.site_id')
676
+								   ->order_by('count DESC')
677
+								   ->limit(3)
678
+								   ->get();
679 679
 			$querySitesResult = $querySites->result_array();
680 680
 			$stats['rank1_site']       = $querySitesResult[0]['site'];
681 681
 			$stats['rank1_site_count'] = $querySitesResult[0]['count'];
@@ -685,17 +685,17 @@  discard block
 block discarded – undo
685 685
 			$stats['rank3_site_count'] = $querySitesResult[2]['count'];
686 686
 
687 687
 			$queryTitlesU = $this->db->select([
688
-			                             'COUNT(*) AS title_updated_count'
689
-			                         ], FALSE)
690
-			                         ->from('tracker_titles_history')
691
-			                         ->get();
688
+										 'COUNT(*) AS title_updated_count'
689
+									 ], FALSE)
690
+									 ->from('tracker_titles_history')
691
+									 ->get();
692 692
 			$stats = array_merge($stats, $queryTitlesU->result_array()[0]);
693 693
 
694 694
 			$queryUsersU = $this->db->select([
695
-			                            'COUNT(*) AS user_updated_count'
696
-			                        ], FALSE)
697
-			                        ->from('tracker_user_history')
698
-			                        ->get();
695
+										'COUNT(*) AS user_updated_count'
696
+									], FALSE)
697
+									->from('tracker_user_history')
698
+									->get();
699 699
 			$stats = array_merge($stats, $queryUsersU->result_array()[0]);
700 700
 
701 701
 			$stats['live_time'] = timespan(/*2016-09-10T03:17:19*/ 1473477439, time(), 2);
Please login to merge, or discard this patch.
application/models/User_Options_Model.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -170,10 +170,10 @@
 block discarded – undo
170 170
 		//This function assumes we've already done some basic validation.
171 171
 		if(!($data = $this->session->tempdata("option_{$option}"))) {
172 172
 			$query = $this->db->select('value_str, value_int')
173
-			                  ->from('user_options')
174
-			                  ->where('user_id', $userID)
175
-			                  ->where('name',    $option)
176
-			                  ->limit(1);
173
+							  ->from('user_options')
174
+							  ->where('user_id', $userID)
175
+							  ->where('name',    $option)
176
+							  ->limit(1);
177 177
 			$data = $query->get()->row_array();
178 178
 			$this->session->set_tempdata("option_{$option}", $data, 3600);
179 179
 		}
Please login to merge, or discard this patch.