Completed
Pull Request — master (#425)
by Randy
07:59
created
application/models/User_Model.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 		$this->load->database();
46 46
 
47 47
 		$query = $this->db->select('*')
48
-		                  ->from('auth_users')
49
-		                  ->where('username', $username)
50
-		                  ->get();
48
+						  ->from('auth_users')
49
+						  ->where('username', $username)
50
+						  ->get();
51 51
 
52 52
 		return (bool) $query->num_rows();
53 53
 	}
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 			$this->load->database();
70 70
 
71 71
 			$query = $this->db->select('email')
72
-			                  ->from('auth_users')
73
-			                  ->where('username', $identity)
74
-			                  ->get();
72
+							  ->from('auth_users')
73
+							  ->where('username', $identity)
74
+							  ->get();
75 75
 
76 76
 			if($query->num_rows() > 0) {
77 77
 				//username exists, grab email
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 		$user = NULL;
90 90
 
91 91
 		$query = $this->db->select('*')
92
-		                  ->from('auth_users')
93
-		                  ->where('username', $username)
94
-		                  ->get();
92
+						  ->from('auth_users')
93
+						  ->where('username', $username)
94
+						  ->get();
95 95
 
96 96
 		if($query->num_rows() > 0) {
97 97
 			$user = $query->row();
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 		$api_key = NULL;
121 121
 		if($this->logged_in()) {
122 122
 			$this->db->select('api_key')
123
-			         ->where('id', $this->User->id)
124
-			         ->get('auth_users');
123
+					 ->where('id', $this->User->id)
124
+					 ->get('auth_users');
125 125
 
126 126
 			$query = $this->db->select('api_key')
127
-			                  ->where('id', $this->User->id)
128
-			                  ->get('auth_users');
127
+							  ->where('id', $this->User->id)
128
+							  ->get('auth_users');
129 129
 
130 130
 			if($query->num_rows() > 0) {
131 131
 				$api_key = $query->row('api_key');
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	
138 138
 	public function get_id_from_api_key(string $api_key) {
139 139
 		$query = $this->db->select('id')
140
-		                  ->from('auth_users')
141
-		                  ->where('api_key', $api_key)
142
-		                  ->get();
140
+						  ->from('auth_users')
141
+						  ->where('api_key', $api_key)
142
+						  ->get();
143 143
 
144 144
 		if($query->num_rows() > 0) {
145 145
 			$userID = $query->row('id');
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 	public function hideLatestNotice() {
203 203
 		$idQuery = $this->db->select('1')
204
-		                    ->where('user_id', $this->User->id)
205
-		                    ->get('tracker_user_notices');
204
+							->where('user_id', $this->User->id)
205
+							->get('tracker_user_notices');
206 206
 		if($idQuery->num_rows() > 0) {
207 207
 			$success = (bool) $this->db->set('hidden_notice_id', '(SELECT id FROM tracker_notices ORDER BY id DESC LIMIT 1)', FALSE)
208
-			                           ->where('user_id', $this->User->id)
209
-			                           ->update('tracker_user_notices');
208
+									   ->where('user_id', $this->User->id)
209
+									   ->update('tracker_user_notices');
210 210
 		} else {
211 211
 			$success = (bool) $this->db->insert('tracker_user_notices', [
212 212
 				'user_id'           => $this->User->id,
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Issue_Model.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@
 block discarded – undo
11 11
 
12 12
 		//This is pretty barebones issue reporting, and honestly not a great way to do it, but it works for now (until the Github is public).
13 13
 		$body = "".
14
-		        (!is_null($url) && !empty($url) ? "URL: ".htmlspecialchars(substr($url, 0, 255))."<br>\n" : "").
15
-		        "Submitted by: ".$this->input->ip_address().(!is_null($userID) ? "| {$userID}" : "")."<br>\n".
16
-		        "<br>Bug report: ".htmlspecialchars(substr($text, 0, 1000));
14
+				(!is_null($url) && !empty($url) ? "URL: ".htmlspecialchars(substr($url, 0, 255))."<br>\n" : "").
15
+				"Submitted by: ".$this->input->ip_address().(!is_null($userID) ? "| {$userID}" : "")."<br>\n".
16
+				"<br>Bug report: ".htmlspecialchars(substr($text, 0, 1000));
17 17
 
18 18
 		$success = TRUE;
19 19
 		$this->email->from('[email protected]', $this->config->item('site_title', 'ion_auth'));
Please login to merge, or discard this patch.
application/models/Auth_Model.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	public function verificationCheck(string $verificationCode) {
77 77
 		//user is trying to validate their email for signup, check if verification code is still valid/exists
78 78
 		$query = $this->db->select('email, verification_code_time')
79
-		                  ->from('auth_signup_verification')
80
-		                  ->where(array('verification_code' => $verificationCode))
81
-		                  ->get();
79
+						  ->from('auth_signup_verification')
80
+						  ->where(array('verification_code' => $verificationCode))
81
+						  ->get();
82 82
 
83 83
 		$return = FALSE;
84 84
 		if($query->num_rows() > 0) {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 				$this->session->set_flashdata('errors', 'Verification code expired. Please re-submit signup.');
91 91
 				$this->db->delete('auth_signup_verification')
92
-				         ->where(array('verification_code' => $verificationCode));
92
+						 ->where(array('verification_code' => $verificationCode));
93 93
 			} else {
94 94
 				//not expired, verification is valid, return email
95 95
 				$return =  $result->email;
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 			$this->load->database();
126 126
 
127 127
 			$query = $this->db->select('email')
128
-			                  ->from('auth_users')
129
-			                  ->where('username', $identity)
130
-			                  ->get();
128
+							  ->from('auth_users')
129
+							  ->where('username', $identity)
130
+							  ->get();
131 131
 
132 132
 			if($query->num_rows() > 0) {
133 133
 				//username exists, grab email
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Favourites_Model.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -115,34 +115,34 @@
 block discarded – undo
115 115
 
116 116
 			////We need the series to be tracked
117 117
 			$idCQuery = $this->db->select('id')
118
-			                     ->where('user_id', $userID)
119
-			                     ->where('title_id', $titleID)
120
-			                     ->get('tracker_chapters');
118
+								 ->where('user_id', $userID)
119
+								 ->where('title_id', $titleID)
120
+								 ->get('tracker_chapters');
121 121
 			if(!($idCQuery->num_rows() > 0)) {
122 122
 				//NOTE: This pretty much repeats a lot of what we already did above. Is there a better way to do this?
123 123
 				$this->Tracker->list->update($userID, $site, $title, $chapter, FALSE);
124 124
 
125 125
 				$idCQuery = $this->db->select('id')
126
-				                     ->where('user_id', $userID)
127
-				                     ->where('title_id', $titleID)
128
-				                     ->get('tracker_chapters');
126
+									 ->where('user_id', $userID)
127
+									 ->where('title_id', $titleID)
128
+									 ->get('tracker_chapters');
129 129
 			}
130 130
 			if($idCQuery->num_rows() > 0) {
131 131
 				$idCQueryRow = $idCQuery->row();
132 132
 
133 133
 				//Check if it is already favourited
134 134
 				$idFQuery = $this->db->select('id')
135
-				                     ->where('chapter_id', $idCQueryRow->id)
136
-				                     ->where('chapter', $chapter)
137
-				                     ->where('page', $page)
138
-				                     ->get('tracker_favourites');
135
+									 ->where('chapter_id', $idCQueryRow->id)
136
+									 ->where('chapter', $chapter)
137
+									 ->where('page', $page)
138
+									 ->get('tracker_favourites');
139 139
 				if($idFQuery->num_rows() > 0) {
140 140
 					//Chapter is already favourited, so remove it from DB
141 141
 					if($removeIfExists) {
142 142
 						$idFQueryRow = $idFQuery->row();
143 143
 
144 144
 						$isSuccess = (bool) $this->db->where('id', $idFQueryRow->id)
145
-						                             ->delete('tracker_favourites');
145
+													 ->delete('tracker_favourites');
146 146
 
147 147
 						if($isSuccess) {
148 148
 							$success = array(
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Title_Model.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	public function getID(string $titleURL, int $siteID, bool $create = TRUE, bool $returnData = FALSE) {
19 19
 		$query = $this->db->select('tracker_titles.id, tracker_titles.title, tracker_titles.title_url, tracker_titles.latest_chapter, tracker_titles.status, tracker_sites.site_class, (tracker_titles.last_checked > DATE_SUB(NOW(), INTERVAL 3 DAY)) AS active', FALSE)
20
-		                  ->from('tracker_titles')
21
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
22
-		                  ->where('tracker_titles.title_url', $titleURL)
23
-		                  ->where('tracker_titles.site_id', $siteID)
24
-		                  ->get();
20
+						  ->from('tracker_titles')
21
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
22
+						  ->where('tracker_titles.title_url', $titleURL)
23
+						  ->where('tracker_titles.site_id', $siteID)
24
+						  ->get();
25 25
 
26 26
 		if($query->num_rows() > 0) {
27 27
 			$id = (int) $query->row('id');
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 						//Make sure last_checked is always updated on successful run.
36 36
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
37 37
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
38
-						         ->where('id', $id)
39
-						         ->update('tracker_titles');
38
+								 ->where('id', $id)
39
+								 ->update('tracker_titles');
40 40
 					}
41 41
 				} else {
42 42
 					log_message('error', "{$siteClass} | {$query->row('title')} ({$query->row('title_url')}) | Failed to update.");
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	private function addTitle(string $titleURL, int $siteID) : int {
78 78
 		$query = $this->db->select('site, site_class')
79
-		                  ->from('tracker_sites')
80
-		                  ->where('id', $siteID)
81
-		                  ->get();
79
+						  ->from('tracker_sites')
80
+						  ->where('id', $siteID)
81
+						  ->get();
82 82
 
83 83
 		$titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL, TRUE);
84 84
 
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
 	public function updateByID(int $titleID, ?string $latestChapter) : bool {
105 105
 		//FIXME: Really not too happy with how we're doing history stuff here, it just feels messy.
106 106
 		$query = $this->db->select('latest_chapter AS current_chapter')
107
-		                  ->from('tracker_titles')
108
-		                  ->where('id', $titleID)
109
-		                  ->get();
107
+						  ->from('tracker_titles')
108
+						  ->where('id', $titleID)
109
+						  ->get();
110 110
 		$row = $query->row();
111 111
 
112 112
 		//TODO (CHECK): If failed_checks changes won't that trigger affected_rows?
113 113
 		$success = $this->db->set(['latest_chapter' => $latestChapter, 'failed_checks' => 0]) //last_updated gets updated via a trigger if something changes
114
-		                    ->where('id', $titleID)
115
-		                    ->update('tracker_titles');
114
+							->where('id', $titleID)
115
+							->update('tracker_titles');
116 116
 
117 117
 		if($this->db->affected_rows() > 0) {
118 118
 			//Clear hidden latest chapter
119 119
 			$this->db->set(['ignore_chapter' => 'NULL', 'last_updated' => 'last_updated'], NULL, FALSE)
120
-			         ->where('title_id', $titleID)
121
-			         ->update('tracker_chapters');
120
+					 ->where('title_id', $titleID)
121
+					 ->update('tracker_chapters');
122 122
 		}
123 123
 
124 124
 		//Update History
@@ -135,20 +135,20 @@  discard block
 block discarded – undo
135 135
 		if(!array_diff(array_keys($data), TITLEDATA_COLUMNS)) {
136 136
 			$newData = array_merge($data, ['failed_checks' => 0]);
137 137
 			$oldData = $this->db->select('latest_chapter AS current_chapter')
138
-			                    ->from('tracker_titles')
139
-			                    ->where('id', $titleID)
140
-			                    ->get()->row_array();
138
+								->from('tracker_titles')
139
+								->where('id', $titleID)
140
+								->get()->row_array();
141 141
 
142 142
 
143 143
 			$success = $this->db->set($newData) //last_updated gets updated via a trigger if something changes
144
-			                    ->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
145
-			                    ->where('id', $titleID)
146
-			                    ->update('tracker_titles');
144
+								->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
145
+								->where('id', $titleID)
146
+								->update('tracker_titles');
147 147
 			if(in_array('latest_chapter', $newData, TRUE) && $newData['latest_chapter'] !== $oldData['current_chapter'] && $this->db->affected_rows() > 0) {
148 148
 				//Clear hidden latest chapter
149 149
 				$this->db->set(['ignore_chapter' => 'NULL', 'last_updated' => 'last_updated'], NULL, FALSE)
150
-				         ->where('title_id', $titleID)
151
-				         ->update('tracker_chapters');
150
+						 ->where('title_id', $titleID)
151
+						 ->update('tracker_chapters');
152 152
 			}
153 153
 
154 154
 			//Update History
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 
165 165
 	public function updateFailedChecksByID(int $titleID) : bool {
166 166
 		$success = $this->db->set('failed_checks', 'failed_checks + 1', FALSE)
167
-		                    ->where('id', $titleID)
168
-		                    ->update('tracker_titles');
167
+							->where('id', $titleID)
168
+							->update('tracker_titles');
169 169
 
170 170
 		return $success;
171 171
 	}
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function getSiteDataFromURL(string $site_url) {
179 179
 		$query = $this->db->select('*')
180
-		                  ->from('tracker_sites')
181
-		                  ->where('site', $site_url)
182
-		                  ->get();
180
+						  ->from('tracker_sites')
181
+						  ->where('site', $site_url)
182
+						  ->get();
183 183
 
184 184
 		return $query->row();
185 185
 	}
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Admin_Model.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	public function updateCustom() {
225 225
 		$query = $this->db->select('*')
226
-		                  ->from('tracker_sites')
227
-		                  ->where('tracker_sites.status', 'enabled')
228
-		                  ->where('tracker_sites.use_custom', 'Y')
229
-		                  ->get();
226
+						  ->from('tracker_sites')
227
+						  ->where('tracker_sites.status', 'enabled')
228
+						  ->where('tracker_sites.use_custom', 'Y')
229
+						  ->get();
230 230
 
231 231
 		$sites = $query->result_array();
232 232
 		foreach ($sites as $site) {
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 									//Make sure last_checked is always updated on successful run.
244 244
 									//CHECK: Is there a reason we aren't just doing this in updateByID?
245 245
 									$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
246
-									         ->where('id', $titleID)
247
-									         ->update('tracker_titles');
246
+											 ->where('id', $titleID)
247
+											 ->update('tracker_titles');
248 248
 
249 249
 									print " - ({$titleData['latest_chapter']})\n";
250 250
 								} else {
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
 
274 274
 	public function refollowCustom() {
275 275
 		$query = $this->db->select('tracker_titles.id, tracker_titles.title_url, tracker_sites.site_class')
276
-		                  ->from('tracker_titles')
277
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
278
-		                  ->where('tracker_titles.followed','N')
279
-		                  ->where('tracker_titles !=', '255')
280
-		                  ->where('tracker_sites.status', 'enabled')
281
-		                  ->where('tracker_sites.use_custom', 'Y')
282
-		                  ->get();
276
+						  ->from('tracker_titles')
277
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
278
+						  ->where('tracker_titles.followed','N')
279
+						  ->where('tracker_titles !=', '255')
280
+						  ->where('tracker_sites.status', 'enabled')
281
+						  ->where('tracker_sites.use_custom', 'Y')
282
+						  ->get();
283 283
 
284 284
 		if($query->num_rows() > 0) {
285 285
 			foreach($query->result() as $row) {
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 
291 291
 					if(!empty($titleData)) {
292 292
 						$this->db->set($titleData)
293
-						         ->where('id', $row->id)
294
-						         ->update('tracker_titles');
293
+								 ->where('id', $row->id)
294
+								 ->update('tracker_titles');
295 295
 
296 296
 						print "> {$row->site_class}:{$row->id}:{$row->title_url} FOLLOWED\n";
297 297
 					} else {
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 		$date = $temp_now->format('Y-m-d');
312 312
 
313 313
 		$query = $this->db->select('1')
314
-		                  ->from('site_stats')
315
-		                  ->where('date', $date)
316
-		                  ->get();
314
+						  ->from('site_stats')
315
+						  ->where('date', $date)
316
+						  ->get();
317 317
 
318 318
 		if($query->num_rows() > 0) {
319 319
 			$this->db->set('total_requests', 'total_requests+1', FALSE)
320
-			         ->where('date', $date)
321
-			         ->update('site_stats');
320
+					 ->where('date', $date)
321
+					 ->update('site_stats');
322 322
 		} else {
323 323
 			$this->db->insert('site_stats', [
324 324
 				'date'           => $date,
Please login to merge, or discard this patch.