@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $this->onlyAdmin(); |
| 28 | 28 | $this->onlyPost(); |
| 29 | - $state = (bool)($this->request->getData("state") === 'true'); |
|
| 30 | - $postId = (int)$this->request->getData("postId"); |
|
| 29 | + $state = (bool) ($this->request->getData("state") === 'true'); |
|
| 30 | + $postId = (int) $this->request->getData("postId"); |
|
| 31 | 31 | |
| 32 | 32 | $result = array(); |
| 33 | 33 | $result["success"] = $this->postModule->setPublished(!$state, $postId); |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $this->onlyAdmin(); |
| 46 | 46 | $this->onlyPost(); |
| 47 | - $state = (bool)($this->request->getData("state") === 'true'); //TODO test this element |
|
| 48 | - $postId = (int)$this->request->getData("postId"); |
|
| 47 | + $state = (bool) ($this->request->getData("state") === 'true'); //TODO test this element |
|
| 48 | + $postId = (int) $this->request->getData("postId"); |
|
| 49 | 49 | |
| 50 | 50 | $result = array(); |
| 51 | 51 | $result["success"] = $this->postModule->setOnFrontPage(!$state, $postId); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function reset($get) |
| 46 | 46 | { |
| 47 | 47 | //only get messages here |
| 48 | - if(!$this->startsWith(strtolower($get),"get")) |
|
| 48 | + if (!$this->startsWith(strtolower($get), "get")) |
|
| 49 | 49 | { |
| 50 | 50 | throw new \Exception("invalid call"); |
| 51 | 51 | } |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | $userId = $this->request->getData("userId"); |
| 56 | 56 | |
| 57 | 57 | //verify if token is valid |
| 58 | - if(!$this->isHexa($token)|| !$this->isInt($userId)) |
|
| 58 | + if (!$this->isHexa($token) || !$this->isInt($userId)) |
|
| 59 | 59 | { |
| 60 | 60 | $this->alertBox->setAlert('Badly formatted Token', 'error'); |
| 61 | 61 | $this->response->redirect(); |
| 62 | 62 | } |
| 63 | - if(!$this->userModel->getUserDetailsByToken($token, $userId)) |
|
| 63 | + if (!$this->userModel->getUserDetailsByToken($token, $userId)) |
|
| 64 | 64 | { |
| 65 | 65 | $this->alertBox->setAlert('Invalid reset token, please request a new password', 'error'); |
| 66 | 66 | $this->response->redirect(); |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | $token = $request["token"]; |
| 84 | 84 | $userId = $request["userId"]; |
| 85 | 85 | |
| 86 | - if(!$this->isHexa($token) || !$this->isInt($userId) ) |
|
| 86 | + if (!$this->isHexa($token) || !$this->isInt($userId)) |
|
| 87 | 87 | { |
| 88 | 88 | throw new \Exception("Bad Token or ID request"); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $error = false; |
| 92 | 92 | $registerErrors = new \stdClass(); |
| 93 | - if($password !== $confirm) |
|
| 93 | + if ($password !== $confirm) |
|
| 94 | 94 | { |
| 95 | 95 | $error = true; |
| 96 | 96 | $registerErrors->forgotPassword = "password and confirmation do not match"; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | private function populateUserFromId(int $userId) |
| 77 | 77 | { |
| 78 | 78 | $result = $this->userModel->getUserDetailsById($userId); |
| 79 | - $this->populateUser((array)$result); |
|
| 79 | + $this->populateUser((array) $result); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function index() |
| 99 | 99 | { |
| 100 | - if($this->session->isParamSet("user")) |
|
| 100 | + if ($this->session->isParamSet("user")) |
|
| 101 | 101 | { |
| 102 | 102 | //we are already connected, redirect |
| 103 | 103 | $this->response->redirect(); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function register() |
| 128 | 128 | { |
| 129 | - if($this->session->isParamSet("user")) |
|
| 129 | + if ($this->session->isParamSet("user")) |
|
| 130 | 130 | { |
| 131 | 131 | //we are already connected, redirect |
| 132 | 132 | $this->response->redirect(); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | $authUser = $this->userModel->authenticateUser($email, $password); |
| 186 | - if(!$authUser->success) |
|
| 186 | + if (!$authUser->success) |
|
| 187 | 187 | { |
| 188 | 188 | $error = true; |
| 189 | 189 | $loginErrors->global = $authUser->message; |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | //we are authenticated here |
| 203 | 203 | |
| 204 | 204 | //populate the user object with returned data |
| 205 | - $this->populateUser((array)$authUser->user); |
|
| 205 | + $this->populateUser((array) $authUser->user); |
|
| 206 | 206 | |
| 207 | 207 | //if the user wanted to be remembered |
| 208 | - if($rememberMe) |
|
| 208 | + if ($rememberMe) |
|
| 209 | 209 | { |
| 210 | 210 | $this->rememberedLoginModel->setToken(); //generate a new token |
| 211 | 211 | $rememberMeToken = $this->rememberedLoginModel->rememberMe($this->user->idusers); |
| 212 | - if($rememberMeToken->success) |
|
| 212 | + if ($rememberMeToken->success) |
|
| 213 | 213 | { |
| 214 | 214 | //set cookie |
| 215 | 215 | $this->cookie->setCookie("rememberMe", $rememberMeToken->token, $rememberMeToken->expiry_timestamp); |
@@ -292,10 +292,10 @@ discard block |
||
| 292 | 292 | $baseUrl = $this->request->getBaseUrl(); |
| 293 | 293 | $redirectUrl = $this->removeFromBeginning($refererUrl, $baseUrl); |
| 294 | 294 | |
| 295 | - if($redirectUrl === "login/register") |
|
| 295 | + if ($redirectUrl === "login/register") |
|
| 296 | 296 | { |
| 297 | 297 | //if we were already on the register page, go to home page |
| 298 | - $redirectUrl=""; |
|
| 298 | + $redirectUrl = ""; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | $this->alertBox->setAlert('Account created, please check your mailbox to activate account'); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | //check if email is valid for sanity |
| 172 | 172 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 173 | 173 | $email = htmlspecialchars($email); |
| 174 | - throw new BlogocException("invalid email " . $email); |
|
| 174 | + throw new BlogocException("invalid email ".$email); |
|
| 175 | 175 | } |
| 176 | 176 | $sql = $this->baseSqlSelect(); |
| 177 | 177 | $sql .= " |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $this->bind(':roles_idroles', 1); //we set to one, should probably get from database and config |
| 215 | 215 | $this->execute(); |
| 216 | 216 | |
| 217 | - return (int)$this->dbh->lastInsertId(); |
|
| 217 | + return (int) $this->dbh->lastInsertId(); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | if ($this->isAccountPasswordBlocked($user)) { |
| 248 | - $response->message = "too many bad passwords, account is blocked for " . Constant::LOCKOUT_MINUTES . " minutes"; |
|
| 248 | + $response->message = "too many bad passwords, account is blocked for ".Constant::LOCKOUT_MINUTES." minutes"; |
|
| 249 | 249 | return $response; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $categories = $categoryModel->getCategories(); |
| 51 | 51 | foreach ($categories as $category) { |
| 52 | 52 | $data += [ |
| 53 | - $category->category_name => '/category/posts/' . $category->categories_slug |
|
| 53 | + $category->category_name => '/category/posts/'.$category->categories_slug |
|
| 54 | 54 | ]; |
| 55 | 55 | } |
| 56 | 56 | return $data; |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | $session = $this->container->getSession(); |
| 69 | 69 | |
| 70 | 70 | $userToken = $cookie->getCookie("rememberMe"); |
| 71 | - if($userToken && $this->isHexa($userToken)) |
|
| 71 | + if ($userToken && $this->isHexa($userToken)) |
|
| 72 | 72 | { |
| 73 | 73 | //we have a rememberMe Hash, login |
| 74 | 74 | $rememberedLogin = $rememberedLoginModel->findByToken($userToken); |
| 75 | - if($rememberedLogin){ |
|
| 75 | + if ($rememberedLogin) { |
|
| 76 | 76 | //we have a hash, login |
| 77 | 77 | $user = $userModel->getUserDetailsById($rememberedLogin->users_idusers); |
| 78 | 78 | $session->regenerateSessionId(); //regenerate the ID to avoid session ghosting |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | //Searching for the page break tag |
| 85 | 85 | $breakTagPosition = strpos($text, "<!-- EndOfExcerptBlogOc -->"); |
| 86 | - if($breakTagPosition > 0){ |
|
| 86 | + if ($breakTagPosition > 0) { |
|
| 87 | 87 | return $this->completeDom(substr($text, 0, $breakTagPosition)); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $string = preg_split('/(<img[^>]+\>)|(<p[^>]+\>)|(<span[^>]+\>)|\s/', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); |
| 92 | 92 | |
| 93 | 93 | //The preg split can return false, probably will never happen but just in case. |
| 94 | - if(!$string) |
|
| 94 | + if (!$string) |
|
| 95 | 95 | { |
| 96 | 96 | throw new \Error("excerpt generation failed"); |
| 97 | 97 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $trimed .= $string[$wordCounter]; |
| 105 | 105 | if ($wordCounter < $count - 1) { |
| 106 | 106 | $trimed .= " "; |
| 107 | - } else { |
|
| 107 | + }else { |
|
| 108 | 108 | $trimed .= "[...]"; |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $result = true; |
| 156 | 156 | foreach ($strings as $string) |
| 157 | 157 | { |
| 158 | - if(!$this->isAlphaNum($string)) |
|
| 158 | + if (!$this->isAlphaNum($string)) |
|
| 159 | 159 | { |
| 160 | 160 | $result = false; |
| 161 | 161 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function isHexa(string $string) |
| 172 | 172 | { |
| 173 | - return preg_match("/[\da-f]/",$string); |
|
| 173 | + return preg_match("/[\da-f]/", $string); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | public function isInt($int) |