@@ -72,7 +72,7 @@ |
||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @param string $verificationCode |
| 75 | - * @return mixed |
|
| 75 | + * @return string |
|
| 76 | 76 | */ |
| 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 |
@@ -77,9 +77,9 @@ |
||
| 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) { |
@@ -88,6 +88,9 @@ |
||
| 88 | 88 | return $arr; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | + /** |
|
| 92 | + * @return string |
|
| 93 | + */ |
|
| 91 | 94 | public function getSiteDataFromURL(string $site_url) { |
| 92 | 95 | $query = $this->db->select('id, site_class') |
| 93 | 96 | ->from('tracker_sites') |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | public function getSiteDataFromURL(string $site_url) { |
| 93 | 93 | $query = $this->db->select('id, site_class') |
| 94 | - ->from('tracker_sites') |
|
| 95 | - ->where('site', $site_url) |
|
| 96 | - ->get(); |
|
| 94 | + ->from('tracker_sites') |
|
| 95 | + ->where('site', $site_url) |
|
| 96 | + ->get(); |
|
| 97 | 97 | |
| 98 | 98 | if($query->num_rows() > 0) { |
| 99 | 99 | $siteData = $query->row(); |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | public function getTitleID(string $titleURL, int $siteID) { |
| 106 | 106 | $query = $this->db->select('id') |
| 107 | - ->from('tracker_titles') |
|
| 108 | - ->where('title_url', $titleURL) |
|
| 109 | - ->where('site_id', $siteID) |
|
| 110 | - ->get(); |
|
| 107 | + ->from('tracker_titles') |
|
| 108 | + ->where('title_url', $titleURL) |
|
| 109 | + ->where('site_id', $siteID) |
|
| 110 | + ->get(); |
|
| 111 | 111 | |
| 112 | 112 | if($query->num_rows() > 0) { |
| 113 | 113 | $titleID = $query->row('id'); |
@@ -141,14 +141,14 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $idQuery = $this->db->select('id') |
| 144 | - ->where('user_id', $userID) |
|
| 145 | - ->where('title_id', $titleID) |
|
| 146 | - ->get('tracker_chapters'); |
|
| 144 | + ->where('user_id', $userID) |
|
| 145 | + ->where('title_id', $titleID) |
|
| 146 | + ->get('tracker_chapters'); |
|
| 147 | 147 | if($idQuery->num_rows() > 0) { |
| 148 | 148 | $success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL]) |
| 149 | - ->where('user_id', $userID) |
|
| 150 | - ->where('title_id', $titleID) |
|
| 151 | - ->update('tracker_chapters'); |
|
| 149 | + ->where('user_id', $userID) |
|
| 150 | + ->where('title_id', $titleID) |
|
| 151 | + ->update('tracker_chapters'); |
|
| 152 | 152 | |
| 153 | 153 | if($success) { |
| 154 | 154 | $idQueryRow = $idQuery->row(); |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | public function updateTrackerByID(int $userID, int $chapterID, string $chapter) : bool { |
| 175 | 175 | $success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL]) |
| 176 | - ->where('user_id', $userID) |
|
| 177 | - ->where('id', $chapterID) |
|
| 178 | - ->update('tracker_chapters'); |
|
| 176 | + ->where('user_id', $userID) |
|
| 177 | + ->where('id', $chapterID) |
|
| 178 | + ->update('tracker_chapters'); |
|
| 179 | 179 | |
| 180 | 180 | if($success) { |
| 181 | 181 | $this->History->userUpdateTitle($chapterID, $chapter); |
@@ -188,23 +188,23 @@ discard block |
||
| 188 | 188 | //This is to allow user history to function properly. |
| 189 | 189 | |
| 190 | 190 | $success = $this->db->set(['active' => 'N', 'last_updated' => NULL]) |
| 191 | - ->where('user_id', $userID) |
|
| 192 | - ->where('id', $chapterID) |
|
| 193 | - ->update('tracker_chapters'); |
|
| 191 | + ->where('user_id', $userID) |
|
| 192 | + ->where('id', $chapterID) |
|
| 193 | + ->update('tracker_chapters'); |
|
| 194 | 194 | |
| 195 | 195 | return (bool) $success; |
| 196 | 196 | } |
| 197 | 197 | private function updateTitleById(int $id, string $latestChapter) { |
| 198 | 198 | //FIXME: Really not too happy with how we're doing history stuff here, it just feels messy. |
| 199 | 199 | $query = $this->db->select('latest_chapter AS current_chapter') |
| 200 | - ->from('tracker_titles') |
|
| 201 | - ->where('id', $id) |
|
| 202 | - ->get(); |
|
| 200 | + ->from('tracker_titles') |
|
| 201 | + ->where('id', $id) |
|
| 202 | + ->get(); |
|
| 203 | 203 | $row = $query->row(); |
| 204 | 204 | |
| 205 | 205 | $success = $this->db->set(['latest_chapter' => $latestChapter]) //last_updated gets updated via a trigger if something changes |
| 206 | - ->where('id', $id) |
|
| 207 | - ->update('tracker_titles'); |
|
| 206 | + ->where('id', $id) |
|
| 207 | + ->update('tracker_titles'); |
|
| 208 | 208 | |
| 209 | 209 | //Update History |
| 210 | 210 | //NOTE: To avoid doing another query to grab the last_updated time, we just use time() which <should> get the same thing. |
@@ -215,16 +215,16 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | private function updateTitleDataById(int $id, array $titleData) { |
| 217 | 217 | $success = $this->db->set($titleData) |
| 218 | - ->where('id', $id) |
|
| 219 | - ->update('tracker_titles'); |
|
| 218 | + ->where('id', $id) |
|
| 219 | + ->update('tracker_titles'); |
|
| 220 | 220 | |
| 221 | 221 | return (bool) $success; |
| 222 | 222 | } |
| 223 | 223 | private function addTitle(string $titleURL, int $siteID) { |
| 224 | 224 | $query = $this->db->select('site, site_class') |
| 225 | - ->from('tracker_sites') |
|
| 226 | - ->where('id', $siteID) |
|
| 227 | - ->get(); |
|
| 225 | + ->from('tracker_sites') |
|
| 226 | + ->where('id', $siteID) |
|
| 227 | + ->get(); |
|
| 228 | 228 | |
| 229 | 229 | $titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL); |
| 230 | 230 | $this->db->insert('tracker_titles', array_merge($titleData, ['title_url' => $titleURL, 'site_id' => $siteID])); |
@@ -275,8 +275,8 @@ discard block |
||
| 275 | 275 | //Make sure last_checked is always updated on successful run. |
| 276 | 276 | //CHECK: Is there a reason we aren't just doing this in updateTitleById? |
| 277 | 277 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 278 | - ->where('id', $row->id) |
|
| 279 | - ->update('tracker_titles'); |
|
| 278 | + ->where('id', $row->id) |
|
| 279 | + ->update('tracker_titles'); |
|
| 280 | 280 | |
| 281 | 281 | print " - ({$titleData['latest_chapter']})\n"; |
| 282 | 282 | } |
@@ -393,9 +393,9 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | public function setCategoryTrackerByID(int $userID, int $chapterID, string $category) : bool { |
| 395 | 395 | $success = $this->db->set(['category' => $category, 'active' => 'Y', 'last_updated' => NULL]) |
| 396 | - ->where('user_id', $userID) |
|
| 397 | - ->where('id', $chapterID) |
|
| 398 | - ->update('tracker_chapters'); |
|
| 396 | + ->where('user_id', $userID) |
|
| 397 | + ->where('id', $chapterID) |
|
| 398 | + ->update('tracker_chapters'); |
|
| 399 | 399 | |
| 400 | 400 | return (bool) $success; |
| 401 | 401 | } |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | $success = FALSE; |
| 406 | 406 | if(preg_match("/^[a-z0-9-_,]{0,255}$/", $tag_string)) { |
| 407 | 407 | $success = (bool) $this->db->set(['tags' => $tag_string, 'active' => 'Y', 'last_updated' => NULL]) |
| 408 | - ->where('user_id', $userID) |
|
| 409 | - ->where('id', $chapterID) |
|
| 410 | - ->update('tracker_chapters'); |
|
| 408 | + ->where('user_id', $userID) |
|
| 409 | + ->where('id', $chapterID) |
|
| 410 | + ->update('tracker_chapters'); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | if($success) { |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | $usedCategories = []; |
| 422 | 422 | |
| 423 | 423 | $query = $this->db->distinct() |
| 424 | - ->select('category') |
|
| 425 | - ->from('tracker_chapters') |
|
| 426 | - ->where('tracker_chapters.active', 'Y') |
|
| 427 | - ->get(); |
|
| 424 | + ->select('category') |
|
| 425 | + ->from('tracker_chapters') |
|
| 426 | + ->where('tracker_chapters.active', 'Y') |
|
| 427 | + ->get(); |
|
| 428 | 428 | |
| 429 | 429 | return array_column($query->result_array(), 'category'); |
| 430 | 430 | } |
@@ -144,6 +144,10 @@ |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | //utility functions |
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @param string $field |
|
| 150 | + */ |
|
| 147 | 151 | function get_error_message(/*str*/$field, /*obj*/ $customObj = FALSE) { |
| 148 | 152 | $obj = $customObj ?: $this->form_validation; |
| 149 | 153 | $error_messages = ReflectionHelper::getPrivateProperty( |
@@ -210,10 +210,10 @@ |
||
| 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? |
@@ -29,27 +29,27 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function getMock_ion_auth_logged_in() { |
| 31 | 31 | $ion_auth = $this->getMockBuilder('Ion_auth') |
| 32 | - ->disableOriginalConstructor() |
|
| 33 | - ->getMock(); |
|
| 32 | + ->disableOriginalConstructor() |
|
| 33 | + ->getMock(); |
|
| 34 | 34 | |
| 35 | 35 | $ion_auth->expects($this->at(0)) |
| 36 | - ->method('logged_in') |
|
| 37 | - ->willReturn(TRUE); |
|
| 36 | + ->method('logged_in') |
|
| 37 | + ->willReturn(TRUE); |
|
| 38 | 38 | $ion_auth->expects($this->at(1)) |
| 39 | - ->method('logged_in') |
|
| 40 | - ->willReturn(TRUE); |
|
| 39 | + ->method('logged_in') |
|
| 40 | + ->willReturn(TRUE); |
|
| 41 | 41 | |
| 42 | 42 | $ion_auth->expects($this->any()) |
| 43 | - ->method($this->anything()) |
|
| 44 | - ->will($this->returnSelf()); |
|
| 43 | + ->method($this->anything()) |
|
| 44 | + ->will($this->returnSelf()); |
|
| 45 | 45 | |
| 46 | 46 | return $ion_auth; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function getMock_CI_DB_result(array $methods) { |
| 50 | 50 | $db_result = $this->getMockBuilder('CI_DB_result') |
| 51 | - ->disableOriginalConstructor() |
|
| 52 | - ->getMock(); |
|
| 51 | + ->disableOriginalConstructor() |
|
| 52 | + ->getMock(); |
|
| 53 | 53 | |
| 54 | 54 | foreach ($methods as $method => $return) { |
| 55 | 55 | $db_result->method($method)->willReturn($return); |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function getMock_CI_DB($return) { |
| 61 | 61 | $db = $this->getMockBuilder('CI_DB') |
| 62 | - ->disableOriginalConstructor() |
|
| 63 | - ->setMethods(array('select', 'from', 'where', 'get')) |
|
| 64 | - ->getMock(); |
|
| 62 | + ->disableOriginalConstructor() |
|
| 63 | + ->setMethods(array('select', 'from', 'where', 'get')) |
|
| 64 | + ->getMock(); |
|
| 65 | 65 | |
| 66 | 66 | $db->expects($this->at(3)) |
| 67 | 67 | ->method('get') |
@@ -30,8 +30,8 @@ |
||
| 30 | 30 | $User_Model = $this->User_Model; |
| 31 | 31 | |
| 32 | 32 | $ion_auth = $this->getMockBuilder('ion_auth') |
| 33 | - ->disableOriginalConstructor() |
|
| 34 | - ->getMock(); |
|
| 33 | + ->disableOriginalConstructor() |
|
| 34 | + ->getMock(); |
|
| 35 | 35 | $ion_auth->method('logged_in')->willReturn(FALSE); |
| 36 | 36 | |
| 37 | 37 | $User_Model->ion_auth = $ion_auth; |
@@ -138,10 +138,10 @@ |
||
| 138 | 138 | private function get_db(string $option, int $userID) { |
| 139 | 139 | //This function assumes we've already done some basic validation. |
| 140 | 140 | $query = $this->db->select('value_str, value_int') |
| 141 | - ->from('user_options') |
|
| 142 | - ->where('user_id', $userID) |
|
| 143 | - ->where('name', $option) |
|
| 144 | - ->limit(1); |
|
| 141 | + ->from('user_options') |
|
| 142 | + ->where('user_id', $userID) |
|
| 143 | + ->where('name', $option) |
|
| 144 | + ->limit(1); |
|
| 145 | 145 | return $query->get()->row_array(); |
| 146 | 146 | } |
| 147 | 147 | private function set_db(string $option, $value) : bool {} |
@@ -73,11 +73,15 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * Get user option, or default option if it does not exist. |
| 75 | 75 | * @param string $option |
| 76 | - * @return mixed Returns option value as STRING, or FALSE if option does not exist. |
|
| 76 | + * @return string Returns option value as STRING, or FALSE if option does not exist. |
|
| 77 | 77 | */ |
| 78 | 78 | public function get(string $option) { |
| 79 | 79 | return $this->get_by_userid($option, (int) $this->User->id); |
| 80 | 80 | } |
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @return string |
|
| 84 | + */ |
|
| 81 | 85 | public function get_by_userid(string $option, int $userID) { |
| 82 | 86 | //Check if option is valid |
| 83 | 87 | if(array_key_exists($option, $this->options)) { |
@@ -135,6 +139,9 @@ discard block |
||
| 135 | 139 | return $success; |
| 136 | 140 | } |
| 137 | 141 | |
| 142 | + /** |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 138 | 145 | private function get_db(string $option, int $userID) { |
| 139 | 146 | //This function assumes we've already done some basic validation. |
| 140 | 147 | $query = $this->db->select('value_str, value_int') |
@@ -228,8 +228,8 @@ |
||
| 228 | 228 | //Bato.to is annoying and locks stuff behind auth. See: https://github.com/DakuTree/manga-tracker/issues/14#issuecomment-233830855 |
| 229 | 229 | $cookies = [ |
| 230 | 230 | "lang_option={$title_lang}", |
| 231 | - "member_id=" . $this->config->item('batoto_cookie_member_id'), |
|
| 232 | - "pass_hash=" . $this->config->item('batoto_cookie_pass_hash') |
|
| 231 | + "member_id=" . $this->config->item('batoto_cookie_member_id'), |
|
| 232 | + "pass_hash=" . $this->config->item('batoto_cookie_pass_hash') |
|
| 233 | 233 | ]; |
| 234 | 234 | $data = $this->get_content($title_url, implode("; ", $cookies)); |
| 235 | 235 | if(!$data) { |
@@ -40,9 +40,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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'); |