@@ -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 |
@@ -24,13 +24,13 @@ |
||
24 | 24 | const LIST_PER_PAGE = 10; |
25 | 25 | const COMMENTS_PER_PAGE = 10; |
26 | 26 | |
27 | - const EXCERPT_WORD_COUNT =50; |
|
27 | + const EXCERPT_WORD_COUNT = 50; |
|
28 | 28 | |
29 | 29 | //login security |
30 | 30 | const NUMBER_OF_BAD_PASSWORD_TRIES = 3; |
31 | 31 | const LOCKOUT_MINUTES = 5; |
32 | 32 | |
33 | - const PASSWORD_RESET_DURATION = 240;//number of minutes the reset password link is valid |
|
33 | + const PASSWORD_RESET_DURATION = 240; //number of minutes the reset password link is valid |
|
34 | 34 | |
35 | 35 | const HASH_KEY = "1337blogOcPass159758348ShaQpiss"; |
36 | 36 | } |
37 | 37 | \ No newline at end of file |
@@ -24,8 +24,8 @@ |
||
24 | 24 | { |
25 | 25 | $this->onlyAdmin(); |
26 | 26 | $this->onlyPost(); |
27 | - $state = (bool)($this->request->getData("state") === 'true'); |
|
28 | - $commentId = (int)$this->request->getData("commentId"); |
|
27 | + $state = (bool) ($this->request->getData("state") === 'true'); |
|
28 | + $commentId = (int) $this->request->getData("commentId"); |
|
29 | 29 | |
30 | 30 | $result = array(); |
31 | 31 | $result["success"] = $this->commentModel->setApproved(!$state, $commentId); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Core\Container; |
10 | 10 | use Core\Traits\StringFunctions; |
11 | 11 | |
12 | -class Comments extends AdminController{ |
|
12 | +class Comments extends AdminController { |
|
13 | 13 | |
14 | 14 | use StringFunctions; |
15 | 15 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | //update comment |
117 | - if($this->commentModel->update($commentId, $comment["commentTextArea"], $comment["commentApproved"])) |
|
117 | + if ($this->commentModel->update($commentId, $comment["commentTextArea"], $comment["commentApproved"])) |
|
118 | 118 | { |
119 | 119 | $this->alertBox->setAlert("Comment updated"); |
120 | 120 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | //Searching for the page break tag |
87 | 87 | $breakTagPosition = strpos($text, "<!-- EndOfExcerptBlogOc -->"); |
88 | - if($breakTagPosition > 0){ |
|
88 | + if ($breakTagPosition > 0) { |
|
89 | 89 | return $this->completeDom(substr($text, 0, $breakTagPosition)); |
90 | 90 | } |
91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $string = preg_split('/(<img[^>]+\>)|(<p[^>]+\>)|(<span[^>]+\>)|\s/', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); |
94 | 94 | |
95 | 95 | //The preg split can return false, probably will never happen but just in case. |
96 | - if(!$string) |
|
96 | + if (!$string) |
|
97 | 97 | { |
98 | 98 | throw new \Error("excerpt generation failed"); |
99 | 99 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $trimmed .= $string[$wordCounter]; |
107 | 107 | if ($wordCounter < $count - 1) { |
108 | 108 | $trimmed .= " "; |
109 | - } else { |
|
109 | + }else { |
|
110 | 110 | $trimmed .= "[...]"; |
111 | 111 | } |
112 | 112 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $result = true; |
147 | 147 | foreach ($strings as $string) |
148 | 148 | { |
149 | - if(!$this->isAlphaNum($string)) |
|
149 | + if (!$this->isAlphaNum($string)) |
|
150 | 150 | { |
151 | 151 | $result = false; |
152 | 152 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function isHexa(string $string):bool |
163 | 163 | { |
164 | - return preg_match("/[\da-f]/",$string); |
|
164 | + return preg_match("/[\da-f]/", $string); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use HTMLPurifier; |
9 | 9 | use HTMLPurifier_Config; |
10 | 10 | |
11 | -class CommentModel extends Model{ |
|
11 | +class CommentModel extends Model { |
|
12 | 12 | |
13 | 13 | private $commentTbl; |
14 | 14 | private $userTbl; |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | * @return int |
155 | 155 | * @throws \Exception |
156 | 156 | */ |
157 | - public function addComment(int $postId, int $userId, string $comment, bool $admin=false):int |
|
157 | + public function addComment(int $postId, int $userId, string $comment, bool $admin = false):int |
|
158 | 158 | { |
159 | 159 | $comment = $this->purifyHtml($comment); |
160 | - $sql=" |
|
160 | + $sql = " |
|
161 | 161 | INSERT INTO $this->commentTbl (users_idusers, posts_idposts, comment, approved) |
162 | 162 | VALUES (:userId, :postId, :comment, :approved) |
163 | 163 | "; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $this->bind(':approved', $admin); |
169 | 169 | |
170 | 170 | $this->execute(); |
171 | - return (int)$this->dbh->lastInsertId(); |
|
171 | + return (int) $this->dbh->lastInsertId(); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | $comment = $this->purifyHtml($comment); |
203 | 203 | |
204 | - $sql=" |
|
204 | + $sql = " |
|
205 | 205 | UPDATE $this->commentTbl |
206 | 206 | SET |
207 | 207 | comment = :comment, |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | $this->onlyUser(); |
84 | 84 | |
85 | 85 | //get the session userId |
86 | - $userId = (int)$this->session->get("userId"); |
|
86 | + $userId = (int) $this->session->get("userId"); |
|
87 | 87 | $comment = $this->request->getData("newComment"); |
88 | - $postId = (int)$this->request->getData("postId"); |
|
88 | + $postId = (int) $this->request->getData("postId"); |
|
89 | 89 | |
90 | 90 | //check if we are admin, Admins do not need moderation |
91 | 91 | $admin = $this->session->get('user_role_level') >= Constant::ADMIN_LEVEL; |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | $siteConfig = $this->siteConfig->getSiteConfig(); |
102 | 102 | $post = $this->postModel->getSinglePost($postId); |
103 | 103 | |
104 | - $emailMessage = "<h1>New comment on post " . $post->title . "</a></h1>"; |
|
105 | - $emailMessage .= "<p>Check it out <a href='" . $baseUrl . "admin/comments/moderate-comment/" . $commentId . "'>here</a> </p>"; |
|
104 | + $emailMessage = "<h1>New comment on post ".$post->title."</a></h1>"; |
|
105 | + $emailMessage .= "<p>Check it out <a href='".$baseUrl."admin/comments/moderate-comment/".$commentId."'>here</a> </p>"; |
|
106 | 106 | |
107 | 107 | $this->sendMail->send($siteConfig["admin_email_address"], "New comment added", $emailMessage); |
108 | 108 |
@@ -96,9 +96,11 @@ |
||
96 | 96 | $baseUrl = $this->request->getBaseUrl(); |
97 | 97 | $redirectUrl = $this->removeFromBeginning($refererUrl, $baseUrl); |
98 | 98 | |
99 | - if (!$admin) //if we are not an admin, send an email to alert and add an alertBox |
|
99 | + if (!$admin) { |
|
100 | + //if we are not an admin, send an email to alert and add an alertBox |
|
100 | 101 | { |
101 | 102 | $siteConfig = $this->siteConfig->getSiteConfig(); |
103 | + } |
|
102 | 104 | $post = $this->postModel->getSinglePost($postId); |
103 | 105 | |
104 | 106 | $emailMessage = "<h1>New comment on post " . $post->title . "</a></h1>"; |