@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $categories = $this->categoryModel->getCategories(); |
| 61 | 61 | foreach ($categories as $category) { |
| 62 | 62 | $data += [ |
| 63 | - $category->category_name => '/category/posts/' . $category->categories_slug |
|
| 63 | + $category->category_name => '/category/posts/'.$category->categories_slug |
|
| 64 | 64 | ]; |
| 65 | 65 | } |
| 66 | 66 | return $data; |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | $session = $this->container->getSession(); |
| 77 | 77 | $userToken = $cookie->getCookie("rememberMe"); |
| 78 | 78 | |
| 79 | - if($userToken && $this->isHexa($userToken)) |
|
| 79 | + if ($userToken && $this->isHexa($userToken)) |
|
| 80 | 80 | { |
| 81 | 81 | //we have a rememberMe Hash, login |
| 82 | 82 | $rememberedLogin = $this->rememberedLoginModel->findByToken($userToken); |
| 83 | - if($rememberedLogin){ |
|
| 83 | + if ($rememberedLogin) { |
|
| 84 | 84 | //we have a hash, login |
| 85 | 85 | $user = $this->userModel->getUserDetailsById($rememberedLogin->users_idusers); |
| 86 | 86 | $session->regenerateSessionId(); //regenerate the ID to avoid session ghosting |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $table = $reflect->getShortName(); //this is to only get the model name, otherwise we get the full namespace |
| 160 | 160 | //since our models all end with Model, we should remove it. |
| 161 | 161 | $table = $this->removeFromEnd($table, 'Model'); |
| 162 | - $table = $table . 's'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s |
|
| 162 | + $table = $table.'s'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s |
|
| 163 | 163 | $table = strtolower($table); //the database names are in lowercase |
| 164 | 164 | } |
| 165 | 165 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | //if we are here, then table doesn't exist, check for view |
| 185 | - $view = 'v_' . $table; |
|
| 185 | + $view = 'v_'.$table; |
|
| 186 | 186 | $stmt->bindValue(':table', $view, PDO::PARAM_STR); |
| 187 | 187 | $stmt->execute(); |
| 188 | 188 | $exists = $stmt->rowCount() > 0; //will return 1 if table exists or 0 if non existant |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | protected function getTablePrefix($table) |
| 207 | 207 | { |
| 208 | 208 | if (Config::TABLE_PREFIX != '') { |
| 209 | - $table = Config::TABLE_PREFIX . '_' . $table; |
|
| 209 | + $table = Config::TABLE_PREFIX.'_'.$table; |
|
| 210 | 210 | } |
| 211 | 211 | return $table; |
| 212 | 212 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | protected function getRowById($rowId, $table = null) |
| 276 | 276 | { |
| 277 | 277 | $tableName = $this->getTable($table); |
| 278 | - $idName = 'id' . str_replace(Config::TABLE_PREFIX."_","",$tableName); |
|
| 278 | + $idName = 'id'.str_replace(Config::TABLE_PREFIX."_", "", $tableName); |
|
| 279 | 279 | $sql = "SELECT * FROM $tableName WHERE $idName = :rowId"; |
| 280 | 280 | $this->query($sql); |
| 281 | 281 | $this->bind(':rowId', $rowId); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | if (!$this->configModel->updateConfig($update->name, $update->value)) { |
| 48 | 48 | $result['success'] = false; |
| 49 | 49 | $result['errorId'][] = $update->name; |
| 50 | - } else { |
|
| 50 | + }else { |
|
| 51 | 51 | $result['successId'][] = $update->name; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -59,15 +59,15 @@ discard block |
||
| 59 | 59 | * Send a test mail |
| 60 | 60 | * @throws JsonException |
| 61 | 61 | */ |
| 62 | - public function testMail(){ |
|
| 62 | + public function testMail() { |
|
| 63 | 63 | $this->onlyAdmin(); |
| 64 | 64 | $this->onlyPost(); |
| 65 | 65 | $result = array(); |
| 66 | 66 | $result['success'] = false; |
| 67 | - try{ |
|
| 67 | + try { |
|
| 68 | 68 | $this->sendMail->sendTestMail(); |
| 69 | 69 | $result['success'] = true; |
| 70 | - }catch (Swift_TransportException $e) { |
|
| 70 | + } catch (Swift_TransportException $e) { |
|
| 71 | 71 | $result['success'] = false; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | try{ |
| 68 | 68 | $this->sendMail->sendTestMail(); |
| 69 | 69 | $result['success'] = true; |
| 70 | - }catch (Swift_TransportException $e) { |
|
| 70 | + } catch (Swift_TransportException $e) { |
|
| 71 | 71 | $result['success'] = false; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | // Create the Transport for mail sending |
| 27 | 27 | //$config = $this->siteConfig->getSiteConfig(); |
| 28 | 28 | $this->transport = (new Swift_SmtpTransport($this->siteConfig["SMTP_server"], |
| 29 | - (int)$this->siteConfig["SMTP_port"])) |
|
| 29 | + (int) $this->siteConfig["SMTP_port"])) |
|
| 30 | 30 | ->setUsername($this->siteConfig["SMTP_user"]) |
| 31 | 31 | ->setPassword($this->siteConfig["SMTP_pass"]); |
| 32 | 32 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | public function sendResetPasswordMail(string $to, string $token, int $userId) |
| 69 | 69 | { |
| 70 | 70 | $url = $this->container->getRequest()->getBaseUrl(); |
| 71 | - $url .= "password/reset/get&token=" . $token; |
|
| 72 | - $url .= "&userId=" . $userId; |
|
| 71 | + $url .= "password/reset/get&token=".$token; |
|
| 72 | + $url .= "&userId=".$userId; |
|
| 73 | 73 | |
| 74 | - $message = "<h1>Message from <a href='" . $this->container->getRequest()->getBaseUrl() . "'>" . $this->siteConfig["site_name"] . "</a></h1>"; |
|
| 75 | - $message .= "<p>You have asked to reset your password, please click <a href=\"" . $url . "\">Here</a> to define a new password</p>"; |
|
| 74 | + $message = "<h1>Message from <a href='".$this->container->getRequest()->getBaseUrl()."'>".$this->siteConfig["site_name"]."</a></h1>"; |
|
| 75 | + $message .= "<p>You have asked to reset your password, please click <a href=\"".$url."\">Here</a> to define a new password</p>"; |
|
| 76 | 76 | |
| 77 | 77 | $this->send($to, "Define New Password", $message); |
| 78 | 78 | } |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | public function sendNewPasswordMail(string $to, string $token, int $userId) |
| 87 | 87 | { |
| 88 | 88 | $url = $this->container->getRequest()->getBaseUrl(); |
| 89 | - $url .= "password/reset/get&token=" . $token; |
|
| 90 | - $url .= "&userId=" . $userId; |
|
| 91 | - $message = "<h1>Message from <a href='" . $this->container->getRequest()->getBaseUrl() . "'>" . $this->siteConfig["site_name"] . "</a></h1>"; |
|
| 89 | + $url .= "password/reset/get&token=".$token; |
|
| 90 | + $url .= "&userId=".$userId; |
|
| 91 | + $message = "<h1>Message from <a href='".$this->container->getRequest()->getBaseUrl()."'>".$this->siteConfig["site_name"]."</a></h1>"; |
|
| 92 | 92 | $message .= "<h2>Welcome to the site</h2>"; |
| 93 | - $message .= "<p>You have sucsessfuly created an account, now all you need to do is <a href=\"" . $url . "\">Create your new password</a></p>"; |
|
| 93 | + $message .= "<p>You have sucsessfuly created an account, now all you need to do is <a href=\"".$url."\">Create your new password</a></p>"; |
|
| 94 | 94 | $message .= "<p>Have fun</p>"; |
| 95 | 95 | |
| 96 | - $this->send($to, "Define Password at " . $this->siteConfig["site_name"], $message); |
|
| 96 | + $this->send($to, "Define Password at ".$this->siteConfig["site_name"], $message); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | die(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if(!$this->categoryModel->isCategorySlugUnique($send["categories_slug"])) |
|
| 54 | + if (!$this->categoryModel->isCategorySlugUnique($send["categories_slug"])) |
|
| 55 | 55 | { |
| 56 | 56 | $result["success"] = false; |
| 57 | 57 | $result["errorMessage"] = "Slug is not unique"; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $this->query($sql); |
| 91 | 91 | $this->bind(":tag", $tag); |
| 92 | 92 | $this->execute(); |
| 93 | - return (int)$this->dbh->lastInsertId(); |
|
| 93 | + return (int) $this->dbh->lastInsertId(); |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getTags(): array |
| 120 | 120 | { |
| 121 | - if($this->countTags() > 0) |
|
| 121 | + if ($this->countTags() > 0) |
|
| 122 | 122 | { |
| 123 | 123 | return $this->getResultSet($this->tagTbl); |
| 124 | 124 | } |
@@ -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); |
@@ -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; |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | * @return int |
| 167 | 167 | * @throws \Exception |
| 168 | 168 | */ |
| 169 | - public function addComment(int $postId, int $userId, string $comment, bool $admin=false):int |
|
| 169 | + public function addComment(int $postId, int $userId, string $comment, bool $admin = false):int |
|
| 170 | 170 | { |
| 171 | 171 | $comment = $this->purifyHtml($comment); |
| 172 | - $sql=" |
|
| 172 | + $sql = " |
|
| 173 | 173 | INSERT INTO $this->commentTbl (users_idusers, posts_idposts, comment, approved, comment_date) |
| 174 | 174 | VALUES (:userId, :postId, :comment, :approved, NOW()) |
| 175 | 175 | "; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $this->bind(':approved', $admin); |
| 181 | 181 | |
| 182 | 182 | $this->execute(); |
| 183 | - return (int)$this->dbh->lastInsertId(); |
|
| 183 | + return (int) $this->dbh->lastInsertId(); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | $comment = $this->purifyHtml($comment); |
| 214 | 214 | |
| 215 | - $sql=" |
|
| 215 | + $sql = " |
|
| 216 | 216 | UPDATE $this->commentTbl |
| 217 | 217 | SET |
| 218 | 218 | comment = :comment, |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $this->config = $this->siteConfig->getSiteConfig(); |
| 37 | 37 | $this->userModel = new UserModel($this->container); |
| 38 | 38 | $this->postModel = new PostModel($this->container); |
| 39 | - if($this->auth->isuser()) |
|
| 39 | + if ($this->auth->isuser()) |
|
| 40 | 40 | { |
| 41 | 41 | $this->data["user"] = $this->userModel->getUserDetailsById($this->session->get("userId")); |
| 42 | 42 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | private function testCapcha(string $gCapchaResponse):bool |
| 51 | 51 | { |
| 52 | 52 | $error = false; |
| 53 | - if(Config::GOOGLE_RECAPCHA_PUBLIC_KEY !== "" && Config::GOOGLE_RECAPCHA_SECRET_KEY !== "") |
|
| 53 | + if (Config::GOOGLE_RECAPCHA_PUBLIC_KEY !== "" && Config::GOOGLE_RECAPCHA_SECRET_KEY !== "") |
|
| 54 | 54 | { |
| 55 | - if(empty($gCapchaResponse)) |
|
| 55 | + if (empty($gCapchaResponse)) |
|
| 56 | 56 | { |
| 57 | 57 | $error = true; |
| 58 | 58 | $this->alertBox->setAlert('Capcha not set', 'error'); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $grequest = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.Config::GOOGLE_RECAPCHA_SECRET_KEY.'&response='.$gCapchaResponse); |
| 62 | 62 | // The result is in a JSON format. Decoding.. |
| 63 | 63 | $gresponse = json_decode($grequest); |
| 64 | - if(!$gresponse->success) |
|
| 64 | + if (!$gresponse->success) |
|
| 65 | 65 | { |
| 66 | 66 | $error = true; |
| 67 | 67 | $this->alertBox->setAlert('Capcha Error', 'error'); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | $capchaError = $this->testCapcha($message["g-recaptcha-response"]); |
| 161 | 161 | |
| 162 | - if($capchaError === true) |
|
| 162 | + if ($capchaError === true) |
|
| 163 | 163 | { |
| 164 | 164 | $error = true; |
| 165 | 165 | } |