@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $table = $reflect->getShortName(); //this is to only get the model name, otherwise we get the full namespace |
| 140 | 140 | //since our models all end with Model, we should remove it. |
| 141 | 141 | $table = $this->removeFromEnd($table, 'Model'); |
| 142 | - $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 |
|
| 142 | + $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 |
|
| 143 | 143 | $table = strtolower($table); //the database names are in lowercase |
| 144 | 144 | } |
| 145 | 145 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | //if we are here, then table doesn't exist, check for view |
| 165 | - $view = 'v_' . $table; |
|
| 165 | + $view = 'v_'.$table; |
|
| 166 | 166 | $stmt->bindValue(':table', $view, PDO::PARAM_STR); |
| 167 | 167 | $stmt->execute(); |
| 168 | 168 | $exists = $stmt->rowCount() > 0; //will return 1 if table exists or 0 if non existant |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | protected function getTablePrefix($table) |
| 187 | 187 | { |
| 188 | 188 | if (Config::TABLE_PREFIX != '') { |
| 189 | - $table = Config::TABLE_PREFIX . '_' . $table; |
|
| 189 | + $table = Config::TABLE_PREFIX.'_'.$table; |
|
| 190 | 190 | } |
| 191 | 191 | return $table; |
| 192 | 192 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | protected function getRowById($rowId, $table = null) |
| 256 | 256 | { |
| 257 | 257 | $tableName = $this->getTable($table); |
| 258 | - $idName = 'id' . $tableName; |
|
| 258 | + $idName = 'id'.$tableName; |
|
| 259 | 259 | $sql = "SELECT * FROM $tableName WHERE $idName = :rowId"; |
| 260 | 260 | $this->query($sql); |
| 261 | 261 | $this->bind(':rowId', $rowId); |
@@ -211,10 +211,12 @@ |
||
| 211 | 211 | $this->alertBox->setAlert("empty slug not allowed", "error"); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if ($postSlug != $originalPostSlug) //if the slug has been updated |
|
| 214 | + if ($postSlug != $originalPostSlug) { |
|
| 215 | + //if the slug has been updated |
|
| 215 | 216 | { |
| 216 | 217 | if (!$this->postModel->isPostSlugUnique($postSlug)) { |
| 217 | 218 | $error = true; |
| 219 | + } |
|
| 218 | 220 | $originalPostSlug = $this->postModel->getPostSlugFromId($postId); |
| 219 | 221 | $this->alertBox->setAlert("Slug not unique", "error"); |
| 220 | 222 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $this->onlyPost(); |
| 118 | 118 | |
| 119 | 119 | $posts = $this->request->getDataFull(); |
| 120 | - $userSessionId = (int)$this->session->get("userId"); |
|
| 120 | + $userSessionId = (int) $this->session->get("userId"); |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | $title = trim($posts["postTitle"]); |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | //checking result and redirecting |
| 165 | 165 | if ($postId != null) { |
| 166 | - $this->alertBox->setAlert("Post " . $title . " Created"); |
|
| 167 | - $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug); |
|
| 166 | + $this->alertBox->setAlert("Post ".$title." Created"); |
|
| 167 | + $this->container->getResponse()->redirect("admin/post/modify/".$postSlug); |
|
| 168 | 168 | } |
| 169 | - $this->alertBox->setAlert("Error creating " . $title, "error"); |
|
| 169 | + $this->alertBox->setAlert("Error creating ".$title, "error"); |
|
| 170 | 170 | $this->container->getResponse()->redirect("admin/post/new"); |
| 171 | 171 | |
| 172 | 172 | } |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | //checking result and redirecting |
| 233 | 233 | if ($postUpdate) { |
| 234 | - $this->alertBox->setAlert("Post " . $title . " Updated"); |
|
| 235 | - $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug); |
|
| 234 | + $this->alertBox->setAlert("Post ".$title." Updated"); |
|
| 235 | + $this->container->getResponse()->redirect("admin/post/modify/".$postSlug); |
|
| 236 | 236 | } |
| 237 | - $this->alertBox->setAlert("Error updating " . $title, "error"); |
|
| 238 | - $this->container->getResponse()->redirect("admin/post/modify/" . $originalPostSlug); |
|
| 237 | + $this->alertBox->setAlert("Error updating ".$title, "error"); |
|
| 238 | + $this->container->getResponse()->redirect("admin/post/modify/".$originalPostSlug); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $removedPost = $this->postModel->deletePost($postId); |
| 253 | 253 | |
| 254 | 254 | if ($removedPost) { |
| 255 | - $this->alertBox->setAlert("Post " . $postTitle . " deleted"); |
|
| 255 | + $this->alertBox->setAlert("Post ".$postTitle." deleted"); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | $this->response->redirect("admin/post/list/"); |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | //checking result and redirecting |
| 105 | 105 | if ($categoryUpdate) { |
| 106 | - $this->alertBox->setAlert("Category " . $categoryName . " updated"); |
|
| 106 | + $this->alertBox->setAlert("Category ".$categoryName." updated"); |
|
| 107 | 107 | $this->container->getResponse()->redirect("/admin/category/list/"); |
| 108 | 108 | } |
| 109 | - $this->alertBox->setAlert("Error updating " . $categoryName, "error"); |
|
| 109 | + $this->alertBox->setAlert("Error updating ".$categoryName, "error"); |
|
| 110 | 110 | $this->container->getResponse()->redirect("/admin/category/list/"); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $removedCategory = $this->categoryModel->delete($categoryId); |
| 124 | 124 | |
| 125 | 125 | if ($removedCategory) { |
| 126 | - $this->alertBox->setAlert("Category " . $categoryName . " deleted"); |
|
| 126 | + $this->alertBox->setAlert("Category ".$categoryName." deleted"); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $this->response->redirect("/admin/category/list/"); |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | //checking result and redirecting |
| 170 | 170 | if ($categoryNew) { |
| 171 | - $this->alertBox->setAlert("Category " . $categoryName . " created"); |
|
| 171 | + $this->alertBox->setAlert("Category ".$categoryName." created"); |
|
| 172 | 172 | $this->container->getResponse()->redirect("/admin/category/list/"); |
| 173 | 173 | } |
| 174 | - $this->alertBox->setAlert("Error creating " . $categoryName, "error"); |
|
| 174 | + $this->alertBox->setAlert("Error creating ".$categoryName, "error"); |
|
| 175 | 175 | $this->container->getResponse()->redirect("/admin/category/list/"); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | \ No newline at end of file |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | //checking result and redirecting |
| 91 | 91 | if ($tagUpdate) { |
| 92 | - $this->alertBox->setAlert("Tag " . $tagName . " updated"); |
|
| 92 | + $this->alertBox->setAlert("Tag ".$tagName." updated"); |
|
| 93 | 93 | $this->response->redirect("/admin/tag/list/"); |
| 94 | 94 | } |
| 95 | - $this->alertBox->setAlert("Error updating " . $tagName, "error"); |
|
| 95 | + $this->alertBox->setAlert("Error updating ".$tagName, "error"); |
|
| 96 | 96 | $this->response->redirect("/admin/tag/list/"); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $removedTag = $this->tagModel->delete($tagId); |
| 110 | 110 | |
| 111 | 111 | if ($removedTag) { |
| 112 | - $this->alertBox->setAlert("Tag " . $tagName . " deleted"); |
|
| 112 | + $this->alertBox->setAlert("Tag ".$tagName." deleted"); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $this->response->redirect("/admin/tag/list/"); |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | //checking result and redirecting |
| 147 | 147 | if ($tagNew) { |
| 148 | - $this->alertBox->setAlert("Tag " . $tagName . " created"); |
|
| 148 | + $this->alertBox->setAlert("Tag ".$tagName." created"); |
|
| 149 | 149 | $this->response->redirect("/admin/tag/list/"); |
| 150 | 150 | } |
| 151 | - $this->alertBox->setAlert("Error creating " . $tagName, "error"); |
|
| 151 | + $this->alertBox->setAlert("Error creating ".$tagName, "error"); |
|
| 152 | 152 | $this->response->redirect("/admin/tag/list/"); |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | \ No newline at end of file |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | //make sure we have the right type or throw an error |
| 30 | 30 | |
| 31 | 31 | if (!in_array($type, $this->allowedTypes)) { |
| 32 | - throw new \Exception("Invalid toastr alert type " . $type); |
|
| 32 | + throw new \Exception("Invalid toastr alert type ".$type); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $message = htmlspecialchars($message); //avoid any injection |
@@ -44,24 +44,24 @@ discard block |
||
| 44 | 44 | private function getFilename(string $folder, string $file): string |
| 45 | 45 | { |
| 46 | 46 | //slugify the file name to avoid security errors or bugs with special characters. |
| 47 | - $fileName = pathinfo($file, PATHINFO_FILENAME ); |
|
| 48 | - $fileExtension = pathinfo($file, PATHINFO_EXTENSION ); |
|
| 47 | + $fileName = pathinfo($file, PATHINFO_FILENAME); |
|
| 48 | + $fileExtension = pathinfo($file, PATHINFO_EXTENSION); |
|
| 49 | 49 | $slugify = new Slugify(); |
| 50 | 50 | $fileName = $slugify->slugify($fileName); |
| 51 | 51 | //if the filename has only special chars, the slugify will be empty, create a unique ID |
| 52 | - if($fileName ==="") |
|
| 52 | + if ($fileName === "") |
|
| 53 | 53 | { |
| 54 | 54 | $fileName = uniqid(); |
| 55 | 55 | } |
| 56 | 56 | $file = $fileName.".".$fileExtension; |
| 57 | - $fileUrl = $folder . $file; |
|
| 57 | + $fileUrl = $folder.$file; |
|
| 58 | 58 | $docRoot = $this->request->getDocumentRoot(); |
| 59 | - $filePath = $docRoot . "/public/" . $fileUrl; |
|
| 59 | + $filePath = $docRoot."/public/".$fileUrl; |
|
| 60 | 60 | if (file_exists($filePath) !== 1) { |
| 61 | 61 | $fileNum = 0; |
| 62 | 62 | while (file_exists($filePath)) { |
| 63 | - $fileUrl = $folder . $fileNum . "_" . $file; |
|
| 64 | - $filePath = $docRoot . "/public/" . $fileUrl; |
|
| 63 | + $fileUrl = $folder.$fileNum."_".$file; |
|
| 64 | + $filePath = $docRoot."/public/".$fileUrl; |
|
| 65 | 65 | $fileNum += 1; |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | // Respond to the successful upload with JSON. |
| 87 | 87 | echo json_encode(array('location' => $filetowrite)); |
| 88 | - } else { |
|
| 88 | + }else { |
|
| 89 | 89 | // Notify editor that the upload failed |
| 90 | 90 | echo json_encode(array('error' => 'Upload failed, file might be too big')); |
| 91 | 91 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | // Respond to the successful upload with JSON. |
| 121 | 121 | echo json_encode(array('location' => $filetowrite)); |
| 122 | - } else { |
|
| 122 | + }else { |
|
| 123 | 123 | // Notify editor that the upload failed |
| 124 | 124 | header("HTTP/1.1 500 Server Error"); |
| 125 | 125 | } |
@@ -204,9 +204,11 @@ |
||
| 204 | 204 | |
| 205 | 205 | $user = $this->getUserDetailsByEmail($email); |
| 206 | 206 | |
| 207 | - if ($user === false) //no user exists |
|
| 207 | + if ($user === false) { |
|
| 208 | + //no user exists |
|
| 208 | 209 | { |
| 209 | 210 | $response->message = "email doesn't exist, register a new account?"; |
| 211 | + } |
|
| 210 | 212 | return $response; |
| 211 | 213 | } |
| 212 | 214 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | //check if email is valid for sanity |
| 193 | 193 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 194 | 194 | $email = htmlspecialchars($email); |
| 195 | - throw new BlogocException("invalid email " . $email); |
|
| 195 | + throw new BlogocException("invalid email ".$email); |
|
| 196 | 196 | } |
| 197 | 197 | $sql = $this->baseSqlSelect(); |
| 198 | 198 | $sql .= " |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $this->bind(':roles_idroles', 1); //we set to one, should probably get from database and config |
| 236 | 236 | $this->execute(); |
| 237 | 237 | |
| 238 | - return (int)$this->dbh->lastInsertId(); |
|
| 238 | + return (int) $this->dbh->lastInsertId(); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function updateUser(\stdClass $user):void |
| 247 | 247 | { |
| 248 | - $sql=" |
|
| 248 | + $sql = " |
|
| 249 | 249 | UPDATE $this->userTbl |
| 250 | 250 | SET |
| 251 | 251 | name=:name, |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | if ($this->isAccountPasswordBlocked($user)) { |
| 299 | - $response->message = "too many bad passwords, account is blocked for " . Constant::LOCKOUT_MINUTES . " minutes"; |
|
| 299 | + $response->message = "too many bad passwords, account is blocked for ".Constant::LOCKOUT_MINUTES." minutes"; |
|
| 300 | 300 | return $response; |
| 301 | 301 | } |
| 302 | 302 | |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | $twigOptions = []; |
| 51 | 51 | if (!Config::DEV_ENVIRONMENT) { |
| 52 | 52 | $twigOptions = [ |
| 53 | - 'cache' => dirname(__DIR__) . '/Cache' |
|
| 53 | + 'cache' => dirname(__DIR__).'/Cache' |
|
| 54 | 54 | ]; |
| 55 | 55 | } |
| 56 | - $loader = new \Twig_Loader_Filesystem(dirname(__DIR__) . '/App/Views'); |
|
| 56 | + $loader = new \Twig_Loader_Filesystem(dirname(__DIR__).'/App/Views'); |
|
| 57 | 57 | $twig = new \Twig_Environment($loader, $twigOptions); |
| 58 | 58 | |
| 59 | 59 | return $twig; |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | if ($this->dbh) { |
| 69 | 69 | return $this->dbh; |
| 70 | 70 | } |
| 71 | - $dsn = "mysql:host=" . Config::DB_HOST . ";dbname=" . Config::DB_NAME . ";charset=utf8"; //Creating the Data Source name |
|
| 71 | + $dsn = "mysql:host=".Config::DB_HOST.";dbname=".Config::DB_NAME.";charset=utf8"; //Creating the Data Source name |
|
| 72 | 72 | $opt = [ |
| 73 | 73 | PDO::ATTR_PERSISTENT => true, |
| 74 | 74 | PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, |
| 75 | 75 | PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ |
| 76 | 76 | ]; |
| 77 | - $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt);; |
|
| 77 | + $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt); ; |
|
| 78 | 78 | return $this->dbh; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function getCookie(): Dependency\Cookie |
| 122 | 122 | { |
| 123 | - if(!$this->cookie){ |
|
| 123 | + if (!$this->cookie) { |
|
| 124 | 124 | $this->cookie = new Cookie(); |
| 125 | 125 | } |
| 126 | 126 | return $this->cookie; |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | { |
| 28 | 28 | if ($token_value) { |
| 29 | 29 | $this->token = $token_value; |
| 30 | - } else { |
|
| 30 | + }else { |
|
| 31 | 31 | $this->token = $this->generateToken(); |
| 32 | 32 | } |
| 33 | 33 | } |