@@ -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'); |
|
| 48 | - $postId = (int)$this->request->getData("postId"); |
|
| 47 | + $state = (bool) ($this->request->getData("state") === 'true'); |
|
| 48 | + $postId = (int) $this->request->getData("postId"); |
|
| 49 | 49 | |
| 50 | 50 | $result = array(); |
| 51 | 51 | $result["success"] = $this->postModule->setOnFrontPage(!$state, $postId); |
@@ -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):bool |
| 172 | 172 | { |
| 173 | - return preg_match("/[\da-f]/",$string); |
|
| 173 | + return preg_match("/[\da-f]/", $string); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace Core\Dependency; |
| 4 | 4 | |
| 5 | -class Cookie{ |
|
| 5 | +class Cookie { |
|
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * set a cookie |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function deleteCookie(string $name):void |
| 23 | 23 | { |
| 24 | - setcookie($name, "", time()-3600); //expire the cookie |
|
| 24 | + setcookie($name, "", time() - 3600); //expire the cookie |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -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'); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | public function disconnect() |
| 309 | 309 | { |
| 310 | 310 | $userId = $this->session->get("userId"); |
| 311 | - if($userId) |
|
| 311 | + if ($userId) |
|
| 312 | 312 | { |
| 313 | 313 | $userHash = $this->rememberedLoginModel->getTokenHashFromId($userId); |
| 314 | 314 | $this->rememberedLoginModel->deleteToken($userHash); |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | use Core\Container; |
| 7 | 7 | use Core\Model; |
| 8 | 8 | |
| 9 | -class RoleModel extends Model{ |
|
| 9 | +class RoleModel extends Model { |
|
| 10 | 10 | |
| 11 | 11 | private $roleTbl; |
| 12 | 12 | |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | use Core\Constant; |
| 6 | 6 | use \Core\Container; |
| 7 | 7 | |
| 8 | -class Debug extends Module{ |
|
| 8 | +class Debug extends Module { |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Var dump a var |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | $this->onlyUser(); |
| 97 | 97 | $this->onlyPost(); |
| 98 | 98 | |
| 99 | - $user = (object)$this->request->getDataFull(); |
|
| 99 | + $user = (object) $this->request->getDataFull(); |
|
| 100 | 100 | $redirectUrl = "/admin"; |
| 101 | 101 | |
| 102 | 102 | if ($user->userId !== $this->session->get("userId") || isset($user->userRoleSelector) || isset($user->locked_out)) { |
| 103 | 103 | //an admin is trying to update a user or form tampered with |
| 104 | 104 | $this->onlyAdmin(); |
| 105 | - $redirectUrl = "/admin/home/view-user/" . $user->userId; |
|
| 106 | - } else { |
|
| 105 | + $redirectUrl = "/admin/home/view-user/".$user->userId; |
|
| 106 | + }else { |
|
| 107 | 107 | //set the role to the original state for update |
| 108 | 108 | $beforeUser = $this->userModel->getUserDetailsById($user->userId); |
| 109 | 109 | $user->userRoleSelector = $beforeUser->roles_idroles; |
@@ -117,13 +117,13 @@ discard block |
||
| 117 | 117 | $error = false; |
| 118 | 118 | $registerErrors = new \stdClass(); |
| 119 | 119 | |
| 120 | - if($userId == 1 && $user->userLockedOut == 1) |
|
| 120 | + if ($userId == 1 && $user->userLockedOut == 1) |
|
| 121 | 121 | { |
| 122 | 122 | $error = true; |
| 123 | 123 | $this->alertBox->setAlert("Original admin may not be deactivated", "error"); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if($userId == 1 && $user->userRoleSelector != 2) |
|
| 126 | + if ($userId == 1 && $user->userRoleSelector != 2) |
|
| 127 | 127 | { |
| 128 | 128 | $error = true; |
| 129 | 129 | $this->alertBox->setAlert("Original admin must stay admin", "error"); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | throw new \Exception("Error in passed ID"); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if($userId === 1) |
|
| 207 | + if ($userId === 1) |
|
| 208 | 208 | { |
| 209 | 209 | $this->alertBox->setAlert('Original Admin can not be deleted', "error"); |
| 210 | 210 | $this->response->redirect("/admin/home/list-users"); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | use Core\JsonException; |
| 9 | 9 | use Core\Traits\StringFunctions; |
| 10 | 10 | |
| 11 | -class User extends AjaxController{ |
|
| 11 | +class User extends AjaxController { |
|
| 12 | 12 | |
| 13 | 13 | use StringFunctions; |
| 14 | 14 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | //the router needs a parameter with get functions else throsw a wobbly |
| 26 | 26 | //we pass a get variable and call the /controller/function/get?bla |
| 27 | 27 | //for better use and security, we must pass "get" as the parameter |
| 28 | - if(!$this->startsWith(strtolower($get),"get")) |
|
| 28 | + if (!$this->startsWith(strtolower($get), "get")) |
|
| 29 | 29 | { |
| 30 | 30 | throw new JsonException("invalid call"); |
| 31 | 31 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $this->onlyAdmin(); |
| 48 | 48 | $this->onlyPost(); |
| 49 | - $state = (bool)($this->request->getData("state") === 'true'); |
|
| 50 | - $userId = (int)$this->request->getData("userId"); |
|
| 49 | + $state = (bool) ($this->request->getData("state") === 'true'); |
|
| 50 | + $userId = (int) $this->request->getData("userId"); |
|
| 51 | 51 | |
| 52 | 52 | $result = array(); |
| 53 | 53 | $result["success"] = false; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $result["userId"] = $userId; |
| 56 | 56 | |
| 57 | 57 | // we can not update the Original Admin activation state |
| 58 | - if($userId !== 1) |
|
| 58 | + if ($userId !== 1) |
|
| 59 | 59 | { |
| 60 | 60 | $result["success"] = $this->userModel->activateUser(!$state, $userId); |
| 61 | 61 | $result["state"] = !$state; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | use Swift_Message; |
| 9 | 9 | use Swift_SmtpTransport; |
| 10 | 10 | |
| 11 | -class SendMail extends Module{ |
|
| 11 | +class SendMail extends Module { |
|
| 12 | 12 | |
| 13 | 13 | private $siteConfig; |
| 14 | 14 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | // Create the Transport for mail sending |
| 26 | 26 | //$config = $this->siteConfig->getSiteConfig(); |
| 27 | - $this->transport = (new Swift_SmtpTransport($this->siteConfig["SMTP_server"], (int)$this->siteConfig["SMTP_port"])) |
|
| 27 | + $this->transport = (new Swift_SmtpTransport($this->siteConfig["SMTP_server"], (int) $this->siteConfig["SMTP_port"])) |
|
| 28 | 28 | ->setUsername($this->siteConfig["SMTP_user"]) |
| 29 | 29 | ->setPassword($this->siteConfig["SMTP_pass"]) |
| 30 | 30 | ; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | ->setBody($message, 'text/html') |
| 52 | 52 | ; |
| 53 | 53 | |
| 54 | - if($from === null) |
|
| 54 | + if ($from === null) |
|
| 55 | 55 | { |
| 56 | 56 | //if we haven't set a from, get the config value |
| 57 | 57 | $from = $this->siteConfig["SMTP_from"]; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $message = "<h1>Message from <a href='".$this->container->getRequest()->getBaseUrl()."'>".$this->siteConfig["site_name"]."</a></h1>"; |
| 78 | 78 | $message .= "<p>You have asked to reset your password, please click <a href=\"".$url."\">Here</a> to define a new password</p>"; |
| 79 | 79 | |
| 80 | - $this->send($to, "Define New Password", $message ); |
|
| 80 | + $this->send($to, "Define New Password", $message); |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $message .= "<p>You have sucsessfuly created an account, now all you need to do is <a href=\"".$url."\">Create your new password</a></p>"; |
| 98 | 98 | $message .= "<p>Have fun</p>"; |
| 99 | 99 | |
| 100 | - $this->send($to, "Define Password at ".$this->siteConfig["site_name"], $message ); |
|
| 100 | + $this->send($to, "Define Password at ".$this->siteConfig["site_name"], $message); |
|
| 101 | 101 | |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | \ No newline at end of file |