Completed
Push — master ( 5ae889...256588 )
by Angus
08:21
created
application/models/Tracker/Tracker_Admin_Model.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 							//Make sure last_checked is always updated on successful run.
89 89
 							//CHECK: Is there a reason we aren't just doing this in updateByID?
90 90
 							$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
91
-							         ->where('id', $row->title_id)
92
-							         ->update('tracker_titles');
91
+									 ->where('id', $row->title_id)
92
+									 ->update('tracker_titles');
93 93
 
94 94
 							print " - ({$titleData['latest_chapter']})\n";
95 95
 						} else {
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 							//Make sure last_checked is always updated on successful run.
104 104
 							//CHECK: Is there a reason we aren't just doing this in updateByID?
105 105
 							$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
106
-							         ->where('id', $row->title_id)
107
-							         ->update('tracker_titles');
106
+									 ->where('id', $row->title_id)
107
+									 ->update('tracker_titles');
108 108
 
109 109
 							print " - (No chapters found?)\n";
110 110
 						} else {
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 						//Make sure last_checked is always updated on successful run.
183 183
 						//CHECK: Is there a reason we aren't just doing this in updateByID?
184 184
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
185
-						         ->where('id', $row->title_id)
186
-						         ->update('tracker_titles');
185
+								 ->where('id', $row->title_id)
186
+								 ->update('tracker_titles');
187 187
 
188 188
 						print " - ({$titleData['latest_chapter']})\n";
189 189
 					} else {
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	public function updateCustom() {
209 209
 		$query = $this->db->select('*')
210
-		                  ->from('tracker_sites')
211
-		                  ->where('status', 'enabled')
212
-		                  ->where('tracker_sites.use_custom', 'Y')
213
-		                  ->get();
210
+						  ->from('tracker_sites')
211
+						  ->where('status', 'enabled')
212
+						  ->where('tracker_sites.use_custom', 'Y')
213
+						  ->get();
214 214
 
215 215
 		$sites = $query->result_array();
216 216
 		foreach ($sites as $site) {
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 									//Make sure last_checked is always updated on successful run.
228 228
 									//CHECK: Is there a reason we aren't just doing this in updateByID?
229 229
 									$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
230
-									         ->where('id', $titleID)
231
-									         ->update('tracker_titles');
230
+											 ->where('id', $titleID)
231
+											 ->update('tracker_titles');
232 232
 
233 233
 									print " - ({$titleData['latest_chapter']})\n";
234 234
 								} else {
@@ -257,13 +257,13 @@  discard block
 block discarded – undo
257 257
 
258 258
 	public function refollowCustom() {
259 259
 		$query = $this->db->select('tracker_titles.id, tracker_titles.title_url, tracker_sites.site_class')
260
-		                  ->from('tracker_titles')
261
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
262
-		                  ->where('tracker_titles.followed','N')
263
-		                  ->where('tracker_titles !=', '255')
264
-		                  ->where('tracker_sites.status', 'enabled')
265
-		                  ->where('tracker_sites.use_custom', 'Y')
266
-		                  ->get();
260
+						  ->from('tracker_titles')
261
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
262
+						  ->where('tracker_titles.followed','N')
263
+						  ->where('tracker_titles !=', '255')
264
+						  ->where('tracker_sites.status', 'enabled')
265
+						  ->where('tracker_sites.use_custom', 'Y')
266
+						  ->get();
267 267
 
268 268
 		if($query->num_rows() > 0) {
269 269
 			foreach($query->result() as $row) {
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 
275 275
 					if(!empty($titleData)) {
276 276
 						$this->db->set($titleData)
277
-						         ->where('id', $row->id)
278
-						         ->update('tracker_titles');
277
+								 ->where('id', $row->id)
278
+								 ->update('tracker_titles');
279 279
 
280 280
 						print "> {$row->site_class}:{$row->id}:{$row->title_url} FOLLOWED\n";
281 281
 					} else {
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 				if($titleData['title'] && is_array($titleData) && !is_null($titleData['latest_chapter'])) {
324 324
 					if($titleData['title'] !== $row->title) {
325 325
 						$this->db->set('title', $titleData['title'])
326
-						         ->where('id', $row->id)
327
-						         ->update('tracker_titles');
326
+								 ->where('id', $row->id)
327
+								 ->update('tracker_titles');
328 328
 						//TODO: Add to history somehow?
329 329
 						print " - NEW TITLE ({$titleData['title']})\n";
330 330
 					} else {
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 					//We might as well try to update as well.
335 335
 					if($this->Tracker->title->updateByID((int) $row->id, $titleData['latest_chapter'])) {
336 336
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
337
-						         ->where('id', $row->id)
338
-						         ->update('tracker_titles');
337
+								 ->where('id', $row->id)
338
+								 ->update('tracker_titles');
339 339
 					}
340 340
 				} else {
341 341
 					log_message('error', "{$row->title} failed to update title successfully");
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
 		$date = $temp_now->format('Y-m-d');
352 352
 
353 353
 		$query = $this->db->select('1')
354
-		                  ->from('site_stats')
355
-		                  ->where('date', $date)
356
-		                  ->get();
354
+						  ->from('site_stats')
355
+						  ->where('date', $date)
356
+						  ->get();
357 357
 
358 358
 		if($query->num_rows() > 0) {
359 359
 			$this->db->set('total_requests', 'total_requests+1', FALSE)
360
-			         ->where('date', $date)
361
-			         ->update('site_stats');
360
+					 ->where('date', $date)
361
+					 ->update('site_stats');
362 362
 		} else {
363 363
 			$this->db->insert('site_stats', [
364 364
 				'date'           => $date,
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_List_Model.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 class Tracker_List_Model extends Tracker_Base_Model {
4 4
 	public function __construct() {
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
 			];
34 34
 		}
35 35
 		if($result->num_rows() > 0) {
36
-			foreach ($result->result() as $row) {
36
+			foreach($result->result() as $row) {
37 37
 				$is_unread = intval((is_null($row->latest_chapter)) || ($row->latest_chapter == $row->ignore_chapter) || ($row->latest_chapter == $row->current_chapter) ? '1' : '0');
38 38
 				$arr['series'][$row->category]['unread_count'] = (($arr['series'][$row->category]['unread_count'] ?? 0) + !$is_unread);
39 39
 				$data = [
40 40
 					'id' => $row->id,
41 41
 					'generated_current_data' => $this->sites->{$row->site_class}->getChapterData($row->title_url, $row->current_chapter),
42
-					'generated_latest_data'  => !is_null($row->latest_chapter) ? $this->sites->{$row->site_class}->getChapterData($row->title_url, $row->latest_chapter) : ['url' => '#', 'number' => 'No chapters found'] ,
42
+					'generated_latest_data'  => !is_null($row->latest_chapter) ? $this->sites->{$row->site_class}->getChapterData($row->title_url, $row->latest_chapter) : ['url' => '#', 'number' => 'No chapters found'],
43 43
 					'generated_ignore_data'  => ($row->ignore_chapter ? $this->sites->{$row->site_class}->getChapterData($row->title_url, $row->ignore_chapter) : NULL),
44 44
 
45 45
 					'full_title_url'        => $this->sites->{$row->site_class}->getFullTitleURL($row->title_url),
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 			$sortOrder = $this->User_Options->get('list_sort_order', $userID);
90 90
 			switch($this->User_Options->get('list_sort_type', $userID)) {
91 91
 				case 'unread':
92
-					foreach (array_keys($arr['series']) as $category) {
93
-						usort($arr['series'][$category]['manga'], function ($a, $b) use($sortOrder) {
92
+					foreach(array_keys($arr['series']) as $category) {
93
+						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
94 94
 							$a_text = strtolower("{$a['new_chapter_exists']} - {$a['title_data']['title']}");
95 95
 							$b_text = strtolower("{$b['new_chapter_exists']} - {$b['title_data']['title']}");
96 96
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 					break;
105 105
 
106 106
 				case 'unread_latest':
107
-					foreach (array_keys($arr['series']) as $category) {
108
-						usort($arr['series'][$category]['manga'], function ($a, $b) use($sortOrder) {
107
+					foreach(array_keys($arr['series']) as $category) {
108
+						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
109 109
 							$a_text = $a['new_chapter_exists'];
110 110
 							$b_text = $b['new_chapter_exists'];
111 111
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 					break;
127 127
 
128 128
 				case 'alphabetical':
129
-					foreach (array_keys($arr['series']) as $category) {
129
+					foreach(array_keys($arr['series']) as $category) {
130 130
 						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
131 131
 							$a_text = strtolower("{$a['title_data']['title']}");
132 132
 							$b_text = strtolower("{$b['title_data']['title']}");
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 					break;
142 142
 
143 143
 				case 'my_status':
144
-					foreach (array_keys($arr['series']) as $category) {
144
+					foreach(array_keys($arr['series']) as $category) {
145 145
 						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
146 146
 							$a_text = strtolower("{$a['generated_current_data']['number']}");
147 147
 							$b_text = strtolower("{$b['generated_current_data']['number']}");
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 					break;
157 157
 
158 158
 				case 'latest':
159
-					foreach (array_keys($arr['series']) as $category) {
159
+					foreach(array_keys($arr['series']) as $category) {
160 160
 						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
161 161
 							$a_text = new DateTime("{$a['title_data']['last_updated']}");
162 162
 							$b_text = new DateTime("{$b['title_data']['last_updated']}");
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Sites_Model.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 /**
4 4
  * Class Tracker_Sites_Model
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 			$ch = curl_init();
166 166
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
167
-			curl_setopt($ch, CURLOPT_ENCODING , "gzip");
167
+			curl_setopt($ch, CURLOPT_ENCODING, "gzip");
168 168
 			//curl_setopt($ch, CURLOPT_VERBOSE, 1);
169 169
 			curl_setopt($ch, CURLOPT_HEADER, 1);
170 170
 
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 			curl_setopt($ch, CURLOPT_URL, $url);
187 187
 
188 188
 			if($isPost) {
189
-				curl_setopt($ch,CURLOPT_POST, count($postFields));
190
-				curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields));
189
+				curl_setopt($ch, CURLOPT_POST, count($postFields));
190
+				curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
191 191
 			}
192 192
 
193 193
 			$response = curl_exec($ch);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 			$result = shell_exec('python '.APPPATH.'../_scripts/get_cloudflare_cookie.py '.escapeshellarg(json_encode($urlData)));
235 235
 			$cookieData = json_decode($result, TRUE);
236 236
 
237
-			$this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'],  31536000 /* 1 year, or until we renew it */);
237
+			$this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */);
238 238
 			log_message('debug', "Saving CloudFlare Cookies for {$this->site}");
239 239
 
240 240
 			$refresh = TRUE;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 				$dom = new DOMDocument();
288 288
 				libxml_use_internal_errors(TRUE);
289
-				$dom->loadHTML('<?xml encoding="utf-8" ?>' . $data);
289
+				$dom->loadHTML('<?xml encoding="utf-8" ?>'.$data);
290 290
 				libxml_use_internal_errors(FALSE);
291 291
 
292 292
 				$xpath = new DOMXPath($dom);
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 				if($nodes_title->length === 1) {
296 296
 					if($nodes_row->length === 1) {
297 297
 						$firstRow      = $nodes_row->item(0);
298
-						$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
298
+						$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
299 299
 
300 300
 						if($node_chapter_string !== '') {
301 301
 							$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 		$chapter_parts = explode('/', $chapter); //returns #LANG#/#VOLUME#/#CHAPTER#/#CHAPTER_EXTRA#(/#PAGE#/)
502 502
 		return [
503 503
 			'url'    => $this->getChapterURL($title_url, $chapter),
504
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
504
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
505 505
 		];
506 506
 	}
507 507
 	public function getChapterURL(string $title_url, string $chapter) : string {
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 
684 684
 							$dateString = str_replace('/', '-', trim($nodes_latest->item(0)->nodeValue)); //NOTE: We replace slashes here as it stops strtotime interpreting the date as US date format.
685 685
 							if($dateString == 'T') {
686
-								$dateString = date("Y-m-d",now());
686
+								$dateString = date("Y-m-d", now());
687 687
 							}
688
-							$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString . ' 00:00'));
688
+							$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString.' 00:00'));
689 689
 
690 690
 							$titleDataList[$title_url] = $titleData;
691 691
 						}
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 			//For whatever reason, DOMDocument breaks the <link> element we need to grab the chapter, so we have to grab it elsewhere.
741 741
 			$titleData['latest_chapter'] = preg_replace('/^.*? - ([0-9\.]+) - .*?$/', '$1', trim($data['nodes_chapter']->textContent));
742 742
 
743
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->textContent));
743
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->textContent));
744 744
 		}
745 745
 
746 746
 		return (!empty($titleData) ? $titleData : NULL);
@@ -842,11 +842,11 @@  discard block
 block discarded – undo
842 842
 			""
843 843
 		);
844 844
 		if($data) {
845
-			$titleData['title'] = trim(preg_replace('/ Added on .*$/','', $data['nodes_title']->textContent));
845
+			$titleData['title'] = trim(preg_replace('/ Added on .*$/', '', $data['nodes_title']->textContent));
846 846
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9\.]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
847 847
 
848
-			$dateString = preg_replace('/^Added (?:on )?/', '',$data['nodes_latest']->textContent);
849
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime($dateString));
848
+			$dateString = preg_replace('/^Added (?:on )?/', '', $data['nodes_latest']->textContent);
849
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString));
850 850
 		}
851 851
 		return (!empty($titleData) ? $titleData : NULL);
852 852
 	}
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Title_Model.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	public function getID(string $titleURL, int $siteID, bool $create = TRUE, bool $returnData = FALSE) {
17 17
 		$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)
18
-		                  ->from('tracker_titles')
19
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
20
-		                  ->where('tracker_titles.title_url', $titleURL)
21
-		                  ->where('tracker_titles.site_id', $siteID)
22
-		                  ->get();
18
+						  ->from('tracker_titles')
19
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
20
+						  ->where('tracker_titles.title_url', $titleURL)
21
+						  ->where('tracker_titles.site_id', $siteID)
22
+						  ->get();
23 23
 
24 24
 		if($query->num_rows() > 0) {
25 25
 			$id = (int) $query->row('id');
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 						//Make sure last_checked is always updated on successful run.
33 33
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
34 34
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
35
-						         ->where('id', $id)
36
-						         ->update('tracker_titles');
35
+								 ->where('id', $id)
36
+								 ->update('tracker_titles');
37 37
 					}
38 38
 				} else {
39 39
 					log_message('error', "{$query->row('title')} failed to update successfully");
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	private function addTitle(string $titleURL, int $siteID) : int {
75 75
 		$query = $this->db->select('site, site_class')
76
-		                  ->from('tracker_sites')
77
-		                  ->where('id', $siteID)
78
-		                  ->get();
76
+						  ->from('tracker_sites')
77
+						  ->where('id', $siteID)
78
+						  ->get();
79 79
 
80 80
 		$titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL, TRUE);
81 81
 
@@ -101,21 +101,21 @@  discard block
 block discarded – undo
101 101
 	public function updateByID(int $titleID, ?string $latestChapter) : bool {
102 102
 		//FIXME: Really not too happy with how we're doing history stuff here, it just feels messy.
103 103
 		$query = $this->db->select('latest_chapter AS current_chapter')
104
-		                  ->from('tracker_titles')
105
-		                  ->where('id', $titleID)
106
-		                  ->get();
104
+						  ->from('tracker_titles')
105
+						  ->where('id', $titleID)
106
+						  ->get();
107 107
 		$row = $query->row();
108 108
 
109 109
 		//TODO (CHECK): If failed_checks changes won't that trigger affected_rows?
110 110
 		$success = $this->db->set(['latest_chapter' => $latestChapter, 'failed_checks' => 0]) //last_updated gets updated via a trigger if something changes
111
-		                    ->where('id', $titleID)
112
-		                    ->update('tracker_titles');
111
+							->where('id', $titleID)
112
+							->update('tracker_titles');
113 113
 
114 114
 		if($this->db->affected_rows() > 0) {
115 115
 			//Clear hidden latest chapter
116 116
 			$this->db->set(['ignore_chapter' => 'NULL', 'last_updated' => 'last_updated'], NULL, FALSE)
117
-			         ->where('title_id', $titleID)
118
-			         ->update('tracker_chapters');
117
+					 ->where('title_id', $titleID)
118
+					 ->update('tracker_chapters');
119 119
 		}
120 120
 
121 121
 		//Update History
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 
129 129
 	public function updateFailedChecksByID(int $titleID) : bool {
130 130
 		$success = $this->db->set('failed_checks', 'failed_checks + 1', FALSE)
131
-		                    ->where('id', $titleID)
132
-		                    ->update('tracker_titles');
131
+							->where('id', $titleID)
132
+							->update('tracker_titles');
133 133
 
134 134
 		return $success;
135 135
 	}
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function getSiteDataFromURL(string $site_url) {
143 143
 		$query = $this->db->select('*')
144
-		                  ->from('tracker_sites')
145
-		                  ->where('site', $site_url)
146
-		                  ->get();
144
+						  ->from('tracker_sites')
145
+						  ->where('site', $site_url)
146
+						  ->get();
147 147
 
148 148
 		return $query->row();
149 149
 	}
Please login to merge, or discard this patch.