add-to-blog #34
@ -1,18 +1,19 @@
|
|||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"slim/slim-skeleton": "^4.3",
|
"slim/slim-skeleton": "^4.3",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"slim/psr7": "^1.4",
|
"slim/psr7": "^1.4",
|
||||||
"nyholm/psr7": "^1.4",
|
"nyholm/psr7": "^1.4",
|
||||||
"nyholm/psr7-server": "^1.0",
|
"nyholm/psr7-server": "^1.0",
|
||||||
"guzzlehttp/psr7": "^2.0",
|
"guzzlehttp/psr7": "^2.0",
|
||||||
"http-interop/http-factory-guzzle": "^1.2",
|
"http-interop/http-factory-guzzle": "^1.2",
|
||||||
"laminas/laminas-diactoros": "^2.6",
|
"laminas/laminas-diactoros": "^2.6",
|
||||||
"laminas/laminas-httphandlerrunner": "^2.0",
|
"laminas/laminas-httphandlerrunner": "^2.0",
|
||||||
"selective/samesite-cookie": "^0.3.0",
|
"selective/samesite-cookie": "^0.3.0",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"slim/slim": "^4.10",
|
"slim/slim": "^4.10",
|
||||||
"rbdwllr/psr-jwt": "^2.0",
|
"rbdwllr/psr-jwt": "^2.0",
|
||||||
"tuupola/slim-jwt-auth": "^3.6"
|
"tuupola/slim-jwt-auth": "^3.6",
|
||||||
|
"ext-dom": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
131
dist/api/blog/blogData.php
vendored
131
dist/api/blog/blogData.php
vendored
@ -1,8 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace api\blog;
|
namespace api\blog;
|
||||||
|
use api\utils\imgUtils;
|
||||||
|
use DOMDocument;
|
||||||
use PDO;
|
use PDO;
|
||||||
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
|
||||||
require_once __DIR__ . "/../utils/config.php";
|
require_once __DIR__ . "/../utils/config.php";
|
||||||
|
require_once __DIR__ . "/../utils/imgUtils.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blog Data Class
|
* Blog Data Class
|
||||||
@ -14,10 +18,10 @@ class blogData
|
|||||||
* Get all blog posts
|
* Get all blog posts
|
||||||
* @return array - Array of all blog posts or error message
|
* @return array - Array of all blog posts or error message
|
||||||
*/
|
*/
|
||||||
function getBlogPosts(): array
|
public function getBlogPosts(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, body, tags FROM blog ORDER BY dateCreated DESC;");
|
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, body, categories FROM blog ORDER BY dateCreated DESC;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// set the resulting array to associative
|
// set the resulting array to associative
|
||||||
@ -36,10 +40,10 @@ class blogData
|
|||||||
* @param string $ID - ID of the blog post to get
|
* @param string $ID - ID of the blog post to get
|
||||||
* @return array - Array of all blog posts or error message
|
* @return array - Array of all blog posts or error message
|
||||||
*/
|
*/
|
||||||
function getBlogPost(string $ID): array
|
public function getBlogPost(string $ID): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, tags FROM blog WHERE ID = :ID;");
|
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, categories FROM blog WHERE ID = :ID;");
|
||||||
$stmt->bindParam(":ID", $ID);
|
$stmt->bindParam(":ID", $ID);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
@ -58,10 +62,10 @@ class blogData
|
|||||||
* Get the latest blog post
|
* Get the latest blog post
|
||||||
* @return array - Array of the latest blog post or error message
|
* @return array - Array of the latest blog post or error message
|
||||||
*/
|
*/
|
||||||
function getLatestBlogPost(): array
|
public function getLatestBlogPost(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, tags FROM blog ORDER BY dateCreated DESC LIMIT 1;");
|
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, categories FROM blog ORDER BY dateCreated DESC LIMIT 1;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// set the resulting array to associative
|
// set the resulting array to associative
|
||||||
@ -79,10 +83,10 @@ class blogData
|
|||||||
* Get featured blog post
|
* Get featured blog post
|
||||||
* @return array - Array of the featured blog post or error message
|
* @return array - Array of the featured blog post or error message
|
||||||
*/
|
*/
|
||||||
function getFeaturedBlogPost(): array
|
public function getFeaturedBlogPost(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, tags FROM blog WHERE featured = 1;");
|
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, categories FROM blog WHERE featured = 1;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@ -94,4 +98,115 @@ class blogData
|
|||||||
|
|
||||||
return array("errorMessage" => "Error, blog post could not found");
|
return array("errorMessage" => "Error, blog post could not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload the images in the post to temp folder and return image location
|
||||||
|
* @param UploadedFileInterface $img - Image to upload
|
||||||
|
* @return string|array - String with error message or array with the location of the uploaded file
|
||||||
|
*/
|
||||||
|
public function uploadPostImage(UploadedFileInterface $img): string|array
|
||||||
|
{
|
||||||
|
$targetDir = "../blog/imgs/tmp/";
|
||||||
|
$imagUtils = new imgUtils();
|
||||||
|
$targetFile = $imagUtils->uploadFile($targetDir, $img);
|
||||||
|
|
||||||
|
$file = $targetDir . basename($img->getClientFilename());
|
||||||
|
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
return array("url" => $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_array($targetFile))
|
||||||
|
{
|
||||||
|
return $targetFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists($targetFile["imgLocation"]))
|
||||||
|
{
|
||||||
|
return array("url" => $targetFile["imgLocation"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Couldn't upload the image";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new post directory, uploads the header image and moves the images from the
|
||||||
|
* temp folder to the new folder, then updates the post html to point to the new images, finally
|
||||||
|
* it creates the post in the database
|
||||||
|
* @param string $title - Title of the blog post
|
||||||
|
* @param string $body - Body of the blog post
|
||||||
|
* @param string $dateCreated - Date the blog post was created
|
||||||
|
* @param string $featured - Whether the blog post is featured or not
|
||||||
|
* @param string $categories - Categories of the blog post
|
||||||
|
* @param UploadedFileInterface $headerImg - Header image of the blog post
|
||||||
|
* @return int|string - ID of the blog post or error message
|
||||||
|
*/
|
||||||
|
public function createPost(string $title, string $body, string $dateCreated, string $featured, string $categories, UploadedFileInterface $headerImg): int|string
|
||||||
|
{
|
||||||
|
$conn = dbConn();
|
||||||
|
$targetDir = "../blog/imgs/" . $title . "_" . uniqid() . "/";
|
||||||
|
mkdir($targetDir, 0777, true);
|
||||||
|
$imagUtils = new imgUtils();
|
||||||
|
$targetFile = $imagUtils->uploadFile($targetDir, $headerImg);
|
||||||
|
if (!is_array($targetFile))
|
||||||
|
{
|
||||||
|
return $targetFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
$htmlDoc = new DOMDocument();
|
||||||
|
$htmlDoc->loadHTML($body, LIBXML_NOERROR);
|
||||||
|
$doc = $htmlDoc->getElementsByTagName('body')->item(0);
|
||||||
|
$imgs = $doc->getElementsByTagName('img');
|
||||||
|
|
||||||
|
$srcList = array();
|
||||||
|
|
||||||
|
foreach ($imgs as $img)
|
||||||
|
{
|
||||||
|
$src = $img->getAttribute("src");
|
||||||
|
$srcList[] = $src;
|
||||||
|
$fileName = basename($src);
|
||||||
|
|
||||||
|
$img->setAttribute("src", $targetDir . $fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = scandir("../blog/imgs/tmp/");
|
||||||
|
foreach ($files as $file)
|
||||||
|
{
|
||||||
|
if ($file != "." && $file != "..")
|
||||||
|
{
|
||||||
|
if (!in_array("../blog/imgs/tmp/" . $file, $srcList))
|
||||||
|
{
|
||||||
|
unlink("../blog/imgs/tmp/" . $file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rename("../blog/imgs/tmp/" . $file, $targetDir . $file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$newBody = '';
|
||||||
|
foreach ($doc->childNodes as $node)
|
||||||
|
{
|
||||||
|
$newBody .= $htmlDoc->saveHTML($node);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("INSERT INTO blog (title, dateCreated, dateModified, featured, headerImg, body, categories)
|
||||||
|
VALUES (:title, :dateCreated, :dateModified, :featured, :headerImg, :body, :categories);");
|
||||||
|
$stmt->bindParam(":title", $title);
|
||||||
|
$stmt->bindParam(":dateCreated", $dateCreated);
|
||||||
|
$stmt->bindParam(":dateModified", $dateCreated);
|
||||||
|
$stmt->bindParam(":featured", $featured);
|
||||||
|
$stmt->bindParam(":headerImg", $targetFile["imgLocation"]);
|
||||||
|
$stmt->bindParam(":body", $newBody);
|
||||||
|
$stmt->bindParam(":categories", $categories);
|
||||||
|
|
||||||
|
if ($stmt->execute())
|
||||||
|
{
|
||||||
|
return intval($conn->lastInsertId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Error, couldn't create post";
|
||||||
|
}
|
||||||
}
|
}
|
45
dist/api/blog/blogRoutes.php
vendored
45
dist/api/blog/blogRoutes.php
vendored
@ -12,7 +12,6 @@ use Slim\App;
|
|||||||
class blogRoutes implements routesInterface
|
class blogRoutes implements routesInterface
|
||||||
{
|
{
|
||||||
private blogData $blogData;
|
private blogData $blogData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor used to instantiate a base blog routes, to be used in the index.php file.
|
* constructor used to instantiate a base blog routes, to be used in the index.php file.
|
||||||
* @param App $app - the slim app used to create the routes
|
* @param App $app - the slim app used to create the routes
|
||||||
@ -30,6 +29,48 @@ class blogRoutes implements routesInterface
|
|||||||
*/
|
*/
|
||||||
public function createRoutes(App $app): void
|
public function createRoutes(App $app): void
|
||||||
{
|
{
|
||||||
// TODO: Implement createRoutes() method.
|
$app->post("/blog/post", function (Request $request, Response $response, array $args)
|
||||||
|
{
|
||||||
|
$data = $request->getParsedBody();
|
||||||
|
$files = $request->getUploadedFiles();
|
||||||
|
if (empty($data["title"]) || empty($data["body"]) || empty($data["dateCreated"]) || empty($data["featured"]) || empty($data["categories"]) || empty($files["headerImg"]))
|
||||||
|
{
|
||||||
|
// uh oh sent some empty data
|
||||||
|
$response->getBody()->write(json_encode(array("error" => "Error, empty data sent")));
|
||||||
|
return $response->withStatus(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$insertedID = $this->blogData->createPost($data["title"], $data["body"], $data["dateCreated"], $data["featured"], $data["categories"], $files["headerImg"]);
|
||||||
|
if (!is_int($insertedID))
|
||||||
|
{
|
||||||
|
// uh oh something went wrong
|
||||||
|
$response->getBody()->write(json_encode(array("error" => $insertedID)));
|
||||||
|
return $response->withStatus(500);
|
||||||
|
}
|
||||||
|
$response->getBody()->write(json_encode(array("ID" => $insertedID)));
|
||||||
|
return $response->withStatus(201);
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->post("/blog/uploadPostImage", function (Request $request, Response $response)
|
||||||
|
{
|
||||||
|
$files = $request->getUploadedFiles();
|
||||||
|
if (empty($files))
|
||||||
|
{
|
||||||
|
// uh oh sent some empty data
|
||||||
|
$response->getBody()->write(json_encode(array("error" => array("message" => "Error, empty data sent"))));
|
||||||
|
return $response->withStatus(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $this->blogData->uploadPostImage($files["upload"]);
|
||||||
|
if (!is_array($message))
|
||||||
|
{
|
||||||
|
$response->getBody()->write(json_encode(array("error" => array("message" => $message))));
|
||||||
|
return $response->withStatus(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$response->getBody()->write(json_encode($message));
|
||||||
|
return $response->withStatus(201);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
38
dist/api/project/projectData.php
vendored
38
dist/api/project/projectData.php
vendored
@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace api\project;
|
namespace api\project;
|
||||||
|
use api\utils\imgUtils;
|
||||||
use PDO;
|
use PDO;
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
|
||||||
require_once __DIR__ . "/../utils/config.php";
|
require_once __DIR__ . "/../utils/config.php";
|
||||||
|
require_once __DIR__ . "/../utils/imgUtils.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project Data Class
|
* Project Data Class
|
||||||
@ -15,7 +17,7 @@ class projectData
|
|||||||
* Get all project data
|
* Get all project data
|
||||||
* @return array - Array of all project data or error message
|
* @return array - Array of all project data or error message
|
||||||
*/
|
*/
|
||||||
function getProjectData(): array
|
public function getProjectData(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, isMainProject, information, imgLocation, projectLink, gitLink FROM projects ORDER BY isMainProject DESC;");
|
$stmt = $conn->prepare("SELECT ID, title, isMainProject, information, imgLocation, projectLink, gitLink FROM projects ORDER BY isMainProject DESC;");
|
||||||
@ -43,7 +45,7 @@ class projectData
|
|||||||
* @param string $gitLink - Link to the git repository
|
* @param string $gitLink - Link to the git repository
|
||||||
* @return bool|string - True if project was updated, false if not and there was an error, or an error string
|
* @return bool|string - True if project was updated, false if not and there was an error, or an error string
|
||||||
*/
|
*/
|
||||||
function updateProjectData(string $ID, string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): bool | string
|
public function updateProjectData(string $ID, string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): bool|string
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
|
|
||||||
@ -82,7 +84,7 @@ class projectData
|
|||||||
* @param int $ID - ID of the project in the database to delete
|
* @param int $ID - ID of the project in the database to delete
|
||||||
* @return string - True if project was deleted, false if not and there was an error
|
* @return string - True if project was deleted, false if not and there was an error
|
||||||
*/
|
*/
|
||||||
function deleteProjectData(int $ID): string
|
public function deleteProjectData(int $ID): string
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
|
|
||||||
@ -121,7 +123,7 @@ class projectData
|
|||||||
* @param string $gitLink - Link to the github repository
|
* @param string $gitLink - Link to the github repository
|
||||||
* @return int|bool - ID of the project if it was added, false if not and there was an error
|
* @return int|bool - ID of the project if it was added, false if not and there was an error
|
||||||
*/
|
*/
|
||||||
function addProjectData(string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): int|bool
|
public function addProjectData(string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): int|bool
|
||||||
{
|
{
|
||||||
|
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
@ -157,31 +159,15 @@ class projectData
|
|||||||
public function uploadImage(int $ID, UploadedFileInterface $img): string | array
|
public function uploadImage(int $ID, UploadedFileInterface $img): string | array
|
||||||
{
|
{
|
||||||
$targetDir = "../imgs/projects/";
|
$targetDir = "../imgs/projects/";
|
||||||
$targetFile = $targetDir . basename($img->getClientFilename());
|
$imgUtils = new imgUtils();
|
||||||
$uploadOk = 1;
|
$targetFile = $imgUtils->uploadFile($targetDir, $img);
|
||||||
$imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
|
|
||||||
|
|
||||||
// Check if file already exists
|
if (!is_array($targetFile))
|
||||||
if (file_exists($targetFile))
|
|
||||||
{
|
{
|
||||||
return "The file already exists";
|
return $targetFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check file size
|
if (file_exists($targetFile["imgLocation"]))
|
||||||
if ($img->getSize() > 2000000)
|
|
||||||
{
|
|
||||||
return "The file is too large, max 2MB";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow certain file formats
|
|
||||||
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif")
|
|
||||||
{
|
|
||||||
return "Only JPG, JPEG, PNG & GIF files are allowed";
|
|
||||||
}
|
|
||||||
|
|
||||||
$img->moveTo($targetFile);
|
|
||||||
|
|
||||||
if (file_exists($targetFile))
|
|
||||||
{
|
{
|
||||||
$this->deleteImage($ID);
|
$this->deleteImage($ID);
|
||||||
// update the database with the new image location
|
// update the database with the new image location
|
||||||
@ -193,7 +179,7 @@ class projectData
|
|||||||
|
|
||||||
if ($stmt->rowCount() > 0)
|
if ($stmt->rowCount() > 0)
|
||||||
{
|
{
|
||||||
return array("imgLocation" => $targetFile);
|
return array("imgLocation" => $targetFile["imgLocation"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Couldn't update the database";
|
return "Couldn't update the database";
|
||||||
|
6
dist/api/project/projectRoutes.php
vendored
6
dist/api/project/projectRoutes.php
vendored
@ -113,7 +113,7 @@ class projectRoutes implements routesInterface
|
|||||||
{
|
{
|
||||||
// uh oh sent some empty data
|
// uh oh sent some empty data
|
||||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||||
return $response->withStatus(400);
|
return $response->withStatus(400)->withStatus(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
$insertedID = $this->projectData->addProjectData($data["title"], $data["isMainProject"], $data["information"], $data["projectLink"], $data["gitLink"]);
|
$insertedID = $this->projectData->addProjectData($data["title"], $data["isMainProject"], $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||||
@ -125,7 +125,7 @@ class projectRoutes implements routesInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$response->getBody()->write(json_encode(array("ID" => $insertedID)));
|
$response->getBody()->write(json_encode(array("ID" => $insertedID)));
|
||||||
return $response;
|
return $response->withStatus(201);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->post("/projectImage/{id}", function (Request $request, Response $response, array $args)
|
$app->post("/projectImage/{id}", function (Request $request, Response $response, array $args)
|
||||||
@ -147,7 +147,7 @@ class projectRoutes implements routesInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$response->getBody()->write(json_encode($message));
|
$response->getBody()->write(json_encode($message));
|
||||||
return $response;
|
return $response->withStatus(201);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
22
dist/api/timeline/timelineData.php
vendored
22
dist/api/timeline/timelineData.php
vendored
@ -16,7 +16,7 @@ class timelineData
|
|||||||
* Get all education data
|
* Get all education data
|
||||||
* @return array - Array of all education data or error message
|
* @return array - Array of all education data or error message
|
||||||
*/
|
*/
|
||||||
function getEduData(): array
|
public function getEduData(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, grade, course FROM edu ORDER BY startPeriod DESC;");
|
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, grade, course FROM edu ORDER BY startPeriod DESC;");
|
||||||
@ -24,7 +24,7 @@ class timelineData
|
|||||||
|
|
||||||
// set the resulting array to associative
|
// set the resulting array to associative
|
||||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
return $result;
|
return $result;
|
||||||
@ -36,7 +36,7 @@ class timelineData
|
|||||||
* Get all work data
|
* Get all work data
|
||||||
* @return array - Array of all work data or error message
|
* @return array - Array of all work data or error message
|
||||||
*/
|
*/
|
||||||
function getWorkData(): array
|
public function getWorkData(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, companyName, area, title FROM work ORDER BY work.startPeriod DESC;");
|
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, companyName, area, title FROM work ORDER BY work.startPeriod DESC;");
|
||||||
@ -61,7 +61,7 @@ class timelineData
|
|||||||
* @param string $id - ID of the education data
|
* @param string $id - ID of the education data
|
||||||
* @return bool - True if successful, false if not
|
* @return bool - True if successful, false if not
|
||||||
*/
|
*/
|
||||||
function updateEduData(string $dateFrom, string $dateTo, string $grade, string $course, string $id): bool
|
public function updateEduData(string $dateFrom, string $dateTo, string $grade, string $course, string $id): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("UPDATE edu SET startPeriod = :dateFrom, endPeriod = :dateTo, grade = :grade, course = :course WHERE ID = :id;");
|
$stmt = $conn->prepare("UPDATE edu SET startPeriod = :dateFrom, endPeriod = :dateTo, grade = :grade, course = :course WHERE ID = :id;");
|
||||||
@ -101,7 +101,7 @@ class timelineData
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return bool - True if successful, false if not
|
* @return bool - True if successful, false if not
|
||||||
*/
|
*/
|
||||||
function deleteEduData(int $id): bool
|
public function deleteEduData(int $id): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("DELETE FROM edu WHERE ID = :id;");
|
$stmt = $conn->prepare("DELETE FROM edu WHERE ID = :id;");
|
||||||
@ -130,7 +130,7 @@ class timelineData
|
|||||||
* @param string $course - Course
|
* @param string $course - Course
|
||||||
* @return bool|int - ID of the new education data or false if not successful
|
* @return bool|int - ID of the new education data or false if not successful
|
||||||
*/
|
*/
|
||||||
function addEduData(string $dateFrom, string $dateTo, string $grade, string $course): bool|int
|
public function addEduData(string $dateFrom, string $dateTo, string $grade, string $course): bool|int
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("INSERT INTO edu (startPeriod, endPeriod, grade, course) VALUES (:dateFrom, :dateTo, :grade, :course);");
|
$stmt = $conn->prepare("INSERT INTO edu (startPeriod, endPeriod, grade, course) VALUES (:dateFrom, :dateTo, :grade, :course);");
|
||||||
@ -138,8 +138,8 @@ class timelineData
|
|||||||
$stmt->bindParam(":dateTo", $dateTo);
|
$stmt->bindParam(":dateTo", $dateTo);
|
||||||
$stmt->bindParam(":grade", $grade);
|
$stmt->bindParam(":grade", $grade);
|
||||||
$stmt->bindParam(":course", $course);
|
$stmt->bindParam(":course", $course);
|
||||||
|
|
||||||
if($stmt->execute())
|
if ($stmt->execute())
|
||||||
{
|
{
|
||||||
return $conn->lastInsertId();
|
return $conn->lastInsertId();
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ class timelineData
|
|||||||
* @param string $title - Title
|
* @param string $title - Title
|
||||||
* @return bool|int - ID of the new work data if successful, false if not
|
* @return bool|int - ID of the new work data if successful, false if not
|
||||||
*/
|
*/
|
||||||
function addWorkData(string $dateFrom, string $dateTo, string $companyName, string $area, string $title): bool|int
|
public function addWorkData(string $dateFrom, string $dateTo, string $companyName, string $area, string $title): bool|int
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("INSERT INTO work (startPeriod, endPeriod, companyName, area, title) VALUES (:dateFrom, :dateTo, :companyName, :area, :title);");
|
$stmt = $conn->prepare("INSERT INTO work (startPeriod, endPeriod, companyName, area, title) VALUES (:dateFrom, :dateTo, :companyName, :area, :title);");
|
||||||
@ -164,8 +164,8 @@ class timelineData
|
|||||||
$stmt->bindParam(":companyName", $companyName);
|
$stmt->bindParam(":companyName", $companyName);
|
||||||
$stmt->bindParam(":area", $area);
|
$stmt->bindParam(":area", $area);
|
||||||
$stmt->bindParam(":title", $title);
|
$stmt->bindParam(":title", $title);
|
||||||
|
|
||||||
if($stmt->execute())
|
if ($stmt->execute())
|
||||||
{
|
{
|
||||||
return $conn->lastInsertId();
|
return $conn->lastInsertId();
|
||||||
}
|
}
|
||||||
|
26
dist/api/user/userData.php
vendored
26
dist/api/user/userData.php
vendored
@ -17,16 +17,16 @@ class userData
|
|||||||
* @param $password string - Password
|
* @param $password string - Password
|
||||||
* @return bool - True if logged in, false if not
|
* @return bool - True if logged in, false if not
|
||||||
*/
|
*/
|
||||||
function checkUser(string $username, string $password): bool
|
public function checkUser(string $username, string $password): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = :username");
|
$stmt = $conn->prepare("SELECT * FROM users WHERE username = :username");
|
||||||
$stmt->bindParam(":username", $username);
|
$stmt->bindParam(":username", $username);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// set the resulting array to associative
|
// set the resulting array to associative
|
||||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
if (password_verify($password, $result[0]["password"]))
|
if (password_verify($password, $result[0]["password"]))
|
||||||
@ -43,15 +43,15 @@ class userData
|
|||||||
* @param $username string - Username
|
* @param $username string - Username
|
||||||
* @return string - JWT token
|
* @return string - JWT token
|
||||||
*/
|
*/
|
||||||
function createToken(string $username): string
|
public function createToken(string $username): string
|
||||||
{
|
{
|
||||||
$now = time();
|
$now = time();
|
||||||
$future = strtotime('+6 hour',$now);
|
$future = strtotime('+6 hour', $now);
|
||||||
$secretKey = getSecretKey();
|
$secretKey = getSecretKey();
|
||||||
$payload = [
|
$payload = [
|
||||||
"jti"=>$username,
|
"jti" => $username,
|
||||||
"iat"=>$now,
|
"iat" => $now,
|
||||||
"exp"=>$future
|
"exp" => $future
|
||||||
];
|
];
|
||||||
|
|
||||||
return JWT::encode($payload,$secretKey,"HS256");
|
return JWT::encode($payload,$secretKey,"HS256");
|
||||||
@ -62,7 +62,7 @@ class userData
|
|||||||
* @param string $email - Email to check
|
* @param string $email - Email to check
|
||||||
* @return bool - True if email exists, false if not
|
* @return bool - True if email exists, false if not
|
||||||
*/
|
*/
|
||||||
function checkEmail(string $email): bool
|
public function checkEmail(string $email): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT * FROM users WHERE email = :email");
|
$stmt = $conn->prepare("SELECT * FROM users WHERE email = :email");
|
||||||
@ -84,14 +84,14 @@ class userData
|
|||||||
* @param $email - email address of the userData
|
* @param $email - email address of the userData
|
||||||
* @return string - verification code
|
* @return string - verification code
|
||||||
*/
|
*/
|
||||||
function sendResetEmail($email): string
|
public function sendResetEmail($email): string
|
||||||
{
|
{
|
||||||
//generate a random token and email the address
|
//generate a random token and email the address
|
||||||
$token = uniqid("rpe-");
|
$token = uniqid("rpe-");
|
||||||
$headers1 = "From: noreply@rohitpai.co.uk\r\n";
|
$headers1 = "From: noreply@rohitpai.co.uk\r\n";
|
||||||
$headers1 .= "MIME-Version: 1.0\r\n";
|
$headers1 .= "MIME-Version: 1.0\r\n";
|
||||||
$headers1 .= "Content-Type: text/html; charset=UTF-8\r\n";
|
$headers1 .= "Content-Type: text/html; charset=UTF-8\r\n";
|
||||||
|
|
||||||
$message = "
|
$message = "
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang='en'>
|
<html lang='en'>
|
||||||
@ -119,14 +119,14 @@ class userData
|
|||||||
* @param $password string Password
|
* @param $password string Password
|
||||||
* @return bool - true if the password was changed, false if not
|
* @return bool - true if the password was changed, false if not
|
||||||
*/
|
*/
|
||||||
function changePassword(string $email, string $password): bool
|
public function changePassword(string $email, string $password): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("UPDATE users SET password = :password WHERE email = :email");
|
$stmt = $conn->prepare("UPDATE users SET password = :password WHERE email = :email");
|
||||||
$newPwd = password_hash($password, PASSWORD_BCRYPT);
|
$newPwd = password_hash($password, PASSWORD_BCRYPT);
|
||||||
$stmt->bindParam(":password", $newPwd);
|
$stmt->bindParam(":password", $newPwd);
|
||||||
$stmt->bindParam(":email", $email);
|
$stmt->bindParam(":email", $email);
|
||||||
|
|
||||||
if ($stmt->execute())
|
if ($stmt->execute())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
2
dist/api/user/userRoutes.php
vendored
2
dist/api/user/userRoutes.php
vendored
@ -145,7 +145,7 @@ class userRoutes implements routesInterface
|
|||||||
// yay, password changed
|
// yay, password changed
|
||||||
unset($_SESSION["resetToken"]);
|
unset($_SESSION["resetToken"]);
|
||||||
unset($_SESSION["resetEmail"]);
|
unset($_SESSION["resetEmail"]);
|
||||||
return $response;
|
return $response->withStatus(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response->withStatus(500);
|
return $response->withStatus(500);
|
||||||
|
20
dist/api/utils/middleware.php
vendored
20
dist/api/utils/middleware.php
vendored
@ -27,7 +27,7 @@ class middleware
|
|||||||
* Constructor for middleware
|
* Constructor for middleware
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function __construct(App $app)
|
public function __construct(App $app)
|
||||||
{
|
{
|
||||||
$this->baseMiddleware($app);
|
$this->baseMiddleware($app);
|
||||||
$this->sameSiteConfig($app);
|
$this->sameSiteConfig($app);
|
||||||
@ -40,7 +40,7 @@ class middleware
|
|||||||
* Base middleware
|
* Base middleware
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function baseMiddleware(App $app): void
|
public function baseMiddleware(App $app): void
|
||||||
{
|
{
|
||||||
$app->addBodyParsingMiddleware();
|
$app->addBodyParsingMiddleware();
|
||||||
$app->addRoutingMiddleware();
|
$app->addRoutingMiddleware();
|
||||||
@ -50,7 +50,7 @@ class middleware
|
|||||||
* SameSite Cookie Configuration
|
* SameSite Cookie Configuration
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function sameSiteConfig(App $app): void
|
public function sameSiteConfig(App $app): void
|
||||||
{
|
{
|
||||||
$ssConfig = new SameSiteCookieConfiguration(["same_site" => "strict"]);
|
$ssConfig = new SameSiteCookieConfiguration(["same_site" => "strict"]);
|
||||||
$app->add(new SameSiteCookieMiddleware($ssConfig));
|
$app->add(new SameSiteCookieMiddleware($ssConfig));
|
||||||
@ -60,7 +60,7 @@ class middleware
|
|||||||
* Return all responses as JSON
|
* Return all responses as JSON
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function returnAsJSON(App $app): void
|
public function returnAsJSON(App $app): void
|
||||||
{
|
{
|
||||||
$app->add(function ($request, $handler)
|
$app->add(function ($request, $handler)
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ class middleware
|
|||||||
* JWT Authentication
|
* JWT Authentication
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function jwtAuth(App $app): void
|
public function jwtAuth(App $app): void
|
||||||
{
|
{
|
||||||
$jwtSecret = getSecretKey();
|
$jwtSecret = getSecretKey();
|
||||||
$app->add(new JwtAuthentication([
|
$app->add(new JwtAuthentication([
|
||||||
@ -90,14 +90,18 @@ class middleware
|
|||||||
"error" => function ($response)
|
"error" => function ($response)
|
||||||
{
|
{
|
||||||
session_destroy();
|
session_destroy();
|
||||||
$response->getBody()->write(json_encode(array("status" => "401", "message" =>
|
$response->getBody()->write(json_encode(array("status" => "401", "message" =>
|
||||||
"Unauthorized, please provide a valid token")));
|
"Unauthorized, please provide a valid token")));
|
||||||
return $response->withStatus(401);
|
return $response->withStatus(401);
|
||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorHandling(App $app): void
|
/**
|
||||||
|
* Error handling
|
||||||
|
* @param App $app - Slim App
|
||||||
|
*/
|
||||||
|
public function errorHandling(App $app): void
|
||||||
{
|
{
|
||||||
$app->add(function (ServerRequestInterface $request, RequestHandlerInterface $handler)
|
$app->add(function (ServerRequestInterface $request, RequestHandlerInterface $handler)
|
||||||
{
|
{
|
||||||
|
2
dist/blog/index.html
vendored
2
dist/blog/index.html
vendored
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Blog</title></head><body>this is a test<script src="/blog/index.js"></script></body></html>
|
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Blog</title></head><body>this is a test<script src="/blog/js/index.js"></script></body></html>
|
2
dist/css/main.css
vendored
2
dist/css/main.css
vendored
File diff suppressed because one or more lines are too long
2
dist/editor/css/main.css
vendored
2
dist/editor/css/main.css
vendored
File diff suppressed because one or more lines are too long
2
dist/editor/editor.html
vendored
2
dist/editor/editor.html
vendored
File diff suppressed because one or more lines are too long
6
dist/editor/js/CKEditor/ckeditor.js
vendored
Normal file
6
dist/editor/js/CKEditor/ckeditor.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/ckeditor.js.map
vendored
Normal file
1
dist/editor/js/CKEditor/ckeditor.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/af.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/af.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const n=e.af=e.af||{};n.dictionary=Object.assign(n.dictionary||{},{"%0 of %1":"%0 van %1","Align center":"Belyn in die middel","Align left":"Belyn links","Align right":"Belyn regs","Block quote":"Verwysingsaanhaling",Bold:"Vet",Cancel:"Kanselleer",Code:"Bronkode",Find:"Soek","Find and replace":"Soek en vervang","Find in text…":"Soek in teks …","Insert code block":"Voeg bronkodeblok in",Italic:"Kursief",Justify:"Belyn beide kante","Match case":"Hooflettersensitief","Next result":"Volgende resultaat","Plain text":"Gewone skrif","Previous result":"Vorige resultaat","Remove color":"Verwyder kleur","Remove Format":"Verwyder formatering",Replace:"Vervang","Replace all":"Vervang alles","Replace with…":"Vervang met ...","Restore default":"Herstel verstek",Save:"Stoor","Show more items":"Wys meer items","Show options":"Wys opsies",Strikethrough:"Deurstreep",Subscript:"Onderskrif",Superscript:"Boskrif","Text alignment":"Teksbelyning","Text alignment toolbar":"Teksbelyning nutsbank","Text to find must not be empty.":"Soekteks mag nie leeg wees nie.","Tip: Find some text first in order to replace it.":"Wenk: Soek eers 'n bietjie teks om dit te vervang.",Underline:"Onderstreep","Whole words only":"Slegs hele woorde"}),n.getPluralForm=function(e){return 1!=e}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/ar.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ar.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/ast.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ast.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const t=e.ast=e.ast||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"",Aquamarine:"",Black:"",Blue:"",Bold:"Negrina","Break text":"","Bulleted List":"Llista con viñetes","Bulleted list styles toolbar":"",Cancel:"Encaboxar","Caption for image: %0":"","Caption for the image":"","Centered image":"","Change image text alternative":"",Circle:"",Code:"",Decimal:"","Decimal with leading zero":"","Dim grey":"",Disc:"",Downloadable:"","Dropdown toolbar":"","Edit block":"","Edit link":"","Editor block content toolbar":"","Editor contextual toolbar":"","Editor editing area: %0":"","Editor toolbar":"","Enter image caption":"","Full size image":"Imaxen a tamañu completu",Green:"",Grey:"",HEX:"","Image resize list":"","Image toolbar":"","image widget":"complementu d'imaxen","In line":"",Insert:"","Insert image":"","Insert image via URL":"",Italic:"Cursiva","Left aligned image":"","Light blue":"","Light green":"","Light grey":"",Link:"Enllazar","Link image":"","Link URL":"URL del enllaz","List properties":"","Lower-latin":"","Lower–roman":"",Next:"","Numbered List":"Llista numberada","Numbered list styles toolbar":"","Open in a new tab":"","Open link in new tab":"",Orange:"",Original:"",Previous:"",Purple:"",Red:"",Redo:"Refacer","Remove color":"","Resize image":"","Resize image to %0":"","Resize image to the original size":"","Restore default":"","Reversed order":"","Rich Text Editor":"Editor de testu arriquecíu","Right aligned image":"",Save:"Guardar","Show more items":"","Side image":"Imaxen llateral",Square:"","Start at":"","Start index must be greater than 0.":"",Strikethrough:"",Subscript:"",Superscript:"","Text alternative":"","This link has no URL":"","To-do List":"","Toggle the circle list style":"","Toggle the decimal list style":"","Toggle the decimal with leading zero list style":"","Toggle the disc list style":"","Toggle the lower–latin list style":"","Toggle the lower–roman list style":"","Toggle the square list style":"","Toggle the upper–latin list style":"","Toggle the upper–roman list style":"",Turquoise:"",Underline:"",Undo:"Desfacer",Unlink:"Desenllazar",Update:"","Update image URL":"","Upload failed":"","Upper-latin":"","Upper-roman":"",White:"","Wrap text":"",Yellow:""}),t.getPluralForm=function(e){return 1!=e}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/az.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/az.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/bg.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/bg.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/bn.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/bn.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/bs.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/bs.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const i=e.bs=e.bs||{};i.dictionary=Object.assign(i.dictionary||{},{"%0 of %1":"%0 od %1",Accept:"","Align center":"Centrirati","Align left":"Lijevo poravnanje","Align right":"Desno poravnanje",Big:"","Block quote":"Citat",Bold:"Podebljano","Break text":"",Cancel:"Poništi","Caption for image: %0":"","Caption for the image":"","Centered image":"Centrirana slika","Change image text alternative":"Promijeni ALT atribut za sliku","Choose heading":"Odaberi naslov",Code:"Kod",Default:"Zadani","Document colors":"","Edit source":"Uredi izvor","Empty snippet content":"HTML odlomak nema sadžaj","Enter image caption":"Unesi naziv slike",Find:"Pronađi","Find and replace":"Pronađi i zamijeni","Find in text…":"Pronađi u tekstu","Font Background Color":"Boja pozadine","Font Color":"Boja","Font Family":"Font","Font Size":"Veličina fonta","Full size image":"",Heading:"Naslov","Heading 1":"Naslov 1","Heading 2":"Naslov 2","Heading 3":"Naslov 3","Heading 4":"Naslov 4","Heading 5":"Naslov 5","Heading 6":"Naslov 6","Horizontal line":"Horizontalna linija","HTML snippet":"HTML odlomak",Huge:"","Image resize list":"Lista veličina slike","Image toolbar":"","image widget":"","In line":"",Insert:"Umetni","Insert code block":"Umetni kod blok","Insert HTML":"Umetni HTML","Insert image":"Umetni sliku","Insert image via URL":"Umetni sliku preko URLa",Italic:"Zakrivljeno",Justify:"","Left aligned image":"Lijevo poravnata slika","Match case":"Podudaranje","Next result":"","No preview available":"Pregled nedostupan",Original:"Original",Paragraph:"Paragraf","Paste raw HTML here...":"Zalijepi HTML ovdje...","Plain text":"Tekst","Previous result":"Prethodni rezultat","Remove color":"Ukloni boju",Replace:"Zamijeni","Replace all":"Zamijeni sve","Replace with…":"Zamijeni sa...","Resize image":"Promijeni veličinu slike","Resize image to %0":"","Resize image to the original size":"Postavi originalnu veličinu slike","Restore default":"Vrati na zadano","Right aligned image":"Desno poravnata slika",Save:"Sačuvaj","Save changes":"Sačuvaj izmjene","Show more items":"Prikaži više stavki","Show options":"Prikaži opcije","Side image":"",Small:"",Strikethrough:"Precrtano",Subscript:"",Superscript:"","Text alignment":"Poravnanje teksta","Text alignment toolbar":"Traka za poravnanje teksta","Text alternative":"ALT atribut","Text to find must not be empty.":"Unesite tekst za pretragu.",Tiny:"","Tip: Find some text first in order to replace it.":"","Type or paste your content here.":"Unesite ili zalijepite vaš sadržaj ovdje","Type your title":"Unesite naslov",Underline:"Podcrtano",Update:"Ažuriraj","Update image URL":"Ažuriraj URL slike","Upload failed":"Učitavanje slike nije uspjelo","Whole words only":"Samo cijele riječi","Wrap text":"Prelomi tekst"}),i.getPluralForm=function(e){return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/ca.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ca.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/cs.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/cs.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/da.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/da.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/de-ch.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/de-ch.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/de.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/de.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/el.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/el.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/en-au.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/en-au.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/en.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/en.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/eo.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/eo.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const i=e.eo=e.eo||{};i.dictionary=Object.assign(i.dictionary||{},{"%0 of %1":"",Aquamarine:"",Black:"",Blue:"",Bold:"grasa","Break text":"","Bulleted List":"Bula Listo","Bulleted list styles toolbar":"",Cancel:"Nuligi","Caption for image: %0":"","Caption for the image":"","Centered image":"","Change image text alternative":"Ŝanĝu la alternativan tekston de la bildo","Choose heading":"Elektu ĉapon",Circle:"",Code:"",Decimal:"","Decimal with leading zero":"","Dim grey":"",Disc:"",Downloadable:"","Dropdown toolbar":"","Edit block":"","Edit link":"","Editor block content toolbar":"","Editor contextual toolbar":"","Editor editing area: %0":"","Editor toolbar":"","Enter image caption":"Skribu klarigon pri la bildo","Full size image":"Bildo kun reala dimensio",Green:"",Grey:"",Heading:"Ĉapo","Heading 1":"Ĉapo 1","Heading 2":"Ĉapo 2","Heading 3":"Ĉapo 3","Heading 4":"","Heading 5":"","Heading 6":"",HEX:"","Image resize list":"","Image toolbar":"","image widget":"bilda fenestraĵo","In line":"",Insert:"","Insert image":"Enmetu bildon","Insert image via URL":"",Italic:"kursiva","Left aligned image":"","Light blue":"","Light green":"","Light grey":"",Link:"Ligilo","Link image":"","Link URL":"URL de la ligilo","List properties":"","Lower-latin":"","Lower–roman":"",Next:"","Numbered List":"Numerita Listo","Numbered list styles toolbar":"","Open in a new tab":"","Open link in new tab":"",Orange:"",Original:"",Paragraph:"Paragrafo",Previous:"",Purple:"",Red:"",Redo:"Refari","Remove color":"","Resize image":"","Resize image to %0":"","Resize image to the original size":"","Restore default":"","Reversed order":"","Rich Text Editor":"Redaktilo de Riĉa Teksto","Right aligned image":"",Save:"Konservi","Show more items":"","Side image":"Flanka biildo",Square:"","Start at":"","Start index must be greater than 0.":"",Strikethrough:"",Subscript:"",Superscript:"","Text alternative":"Alternativa teksto","This link has no URL":"","To-do List":"","Toggle the circle list style":"","Toggle the decimal list style":"","Toggle the decimal with leading zero list style":"","Toggle the disc list style":"","Toggle the lower–latin list style":"","Toggle the lower–roman list style":"","Toggle the square list style":"","Toggle the upper–latin list style":"","Toggle the upper–roman list style":"",Turquoise:"","Type or paste your content here.":"","Type your title":"",Underline:"",Undo:"Malfari",Unlink:"Malligi",Update:"","Update image URL":"","Upload failed":"","Upper-latin":"","Upper-roman":"",White:"","Wrap text":"",Yellow:""}),i.getPluralForm=function(e){return 1!=e}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/es-co.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/es-co.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const r=e["es-co"]=e["es-co"]||{};r.dictionary=Object.assign(r.dictionary||{},{"%0 of %1":"%0 de %1","Align center":"Centrar","Align left":"Alinear a la izquierda","Align right":"Alinear a la derecha","Block quote":"Cita de bloque",Bold:"Negrita",Cancel:"Cancelar","Characters: %0":"Caracteres: %0",Code:"Código","Insert code block":"Insertar bloque de código",Italic:"Cursiva",Justify:"Justificar","Plain text":"Texto plano","Remove color":"Quitar color","Restore default":"Restaurar valores predeterminados",Save:"Guardar","Show more items":"Mostrar más elementos",Strikethrough:"Tachado",Subscript:"Subíndice",Superscript:"Superíndice","Text alignment":"Alineación de texto","Text alignment toolbar":"Herramientas de alineación de texto",Underline:"Subrayado","Upload in progress":"Carga en progreso","Words: %0":"Palabras: %0"}),r.getPluralForm=function(e){return 1==e?0:0!=e&&e%1e6==0?1:2}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/es.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/es.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/et.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/et.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/eu.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/eu.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const t=e.eu=e.eu||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"",Aquamarine:"",Black:"","Block quote":"Aipua",Blue:"",Bold:"Lodia","Break text":"","Bulleted List":"Buletdun zerrenda","Bulleted list styles toolbar":"",Cancel:"Utzi","Caption for image: %0":"","Caption for the image":"","Centered image":"Zentratutako irudia","Change image text alternative":"Aldatu irudiaren ordezko testua","Choose heading":"Aukeratu izenburua",Circle:"",Code:"Kodea",Decimal:"","Decimal with leading zero":"","Dim grey":"",Disc:"",Downloadable:"","Dropdown toolbar":"","Edit block":"","Edit link":"","Editor block content toolbar":"","Editor contextual toolbar":"","Editor editing area: %0":"","Editor toolbar":"","Enter image caption":"Sartu irudiaren epigrafea","Full size image":"Tamaina osoko irudia",Green:"",Grey:"",Heading:"Izenburua","Heading 1":"Izenburua 1","Heading 2":"Izenburua 2","Heading 3":"Izenburua 3","Heading 4":"","Heading 5":"","Heading 6":"",HEX:"","Image resize list":"","Image toolbar":"","image widget":"irudi widgeta","In line":"",Insert:"","Insert image":"Txertatu irudia","Insert image via URL":"",Italic:"Etzana","Left aligned image":"Ezkerrean lerrokatutako irudia","Light blue":"","Light green":"","Light grey":"",Link:"Esteka","Link image":"","Link URL":"Estekaren URLa","List properties":"","Lower-latin":"","Lower–roman":"",Next:"","Numbered List":"Zenbakidun zerrenda","Numbered list styles toolbar":"","Open in a new tab":"","Open link in new tab":"",Orange:"",Original:"",Paragraph:"Paragrafoa",Previous:"",Purple:"",Red:"",Redo:"Berregin","Remove color":"","Resize image":"","Resize image to %0":"","Resize image to the original size":"","Restore default":"","Reversed order":"","Rich Text Editor":"Testu aberastuaren editorea","Right aligned image":"Eskuinean lerrokatutako irudia",Save:"Gorde","Show more items":"","Side image":"Alboko irudia",Square:"","Start at":"","Start index must be greater than 0.":"",Strikethrough:"",Subscript:"",Superscript:"","Text alternative":"Ordezko testua","This link has no URL":"","To-do List":"","Toggle the circle list style":"","Toggle the decimal list style":"","Toggle the decimal with leading zero list style":"","Toggle the disc list style":"","Toggle the lower–latin list style":"","Toggle the lower–roman list style":"","Toggle the square list style":"","Toggle the upper–latin list style":"","Toggle the upper–roman list style":"",Turquoise:"","Type or paste your content here.":"","Type your title":"",Underline:"Azpimarra",Undo:"Desegin",Unlink:"Desestekatu",Update:"","Update image URL":"","Upload failed":"Kargatzeak huts egin du","Upper-latin":"","Upper-roman":"",White:"","Wrap text":"",Yellow:""}),t.getPluralForm=function(e){return 1!=e}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/fa.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/fa.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/fi.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/fi.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/fr.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/fr.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/gl.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/gl.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/gu.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/gu.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(o){const e=o.gu=o.gu||{};e.dictionary=Object.assign(e.dictionary||{},{"%0 of %1":"","Block quote":" વિચાર ટાંકો",Bold:"ઘાટુ - બોલ્ડ્",Cancel:"",Code:"",Italic:"ત્રાંસુ - ઇટલિક્","Remove color":"","Restore default":"",Save:"","Show more items":"",Strikethrough:"",Subscript:"",Superscript:"",Underline:"નીચે લિટી - અન્ડરલાઇન્"}),e.getPluralForm=function(o){return 1!=o}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/he.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/he.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/hi.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/hi.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/hr.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/hr.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/hu.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/hu.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/id.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/id.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/it.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/it.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/ja.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ja.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/jv.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/jv.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const a=e.jv=e.jv||{};a.dictionary=Object.assign(a.dictionary||{},{"%0 of %1":"%0 saking %1",Accept:"","Align center":"Rata tengah","Align left":"Rata kiwa","Align right":"Rata tengen",Big:"Ageng","Blue marker":"Penandha biru",Bold:"Kandhel","Break text":"","Bulleted List":"","Bulleted list styles toolbar":"",Cancel:"Batal","Caption for image: %0":"","Caption for the image":"","Centered image":"Gambar ing tengah","Change image text alternative":"","Choose heading":"","Choose language":"Pilih basa",Circle:"Bunder",Code:"Kode",Decimal:"","Decimal with leading zero":"",Default:"Default",Disc:"Kaset","Document colors":"Warni dokumen","Edit source":"","Empty snippet content":"","Enter image caption":"",Find:"Pados","Find and replace":"Pados lan gantos","Find in text…":"Pados ing seratan","Font Background Color":"Warni Latar Aksara","Font Color":"Warni aksara","Font Family":"Jinising Aksara","Font Size":"Ukuran aksara","Full size image":"Gambar ukuran kebak","Green marker":"Panandha ijem","Green pen":"Pen ijem",Heading:"","Heading 1":"","Heading 2":"","Heading 3":"","Heading 4":"","Heading 5":"","Heading 6":"",Highlight:"Sorot","Horizontal line":"Garis horisontal","HTML object":"Obyek HTML","HTML snippet":"",Huge:"Langkung ageng","Image resize list":"","Image toolbar":"","image widget":"","In line":"",Insert:"Tambah","Insert code block":"","Insert HTML":"Tambahaken HTML","Insert image":"Tambahaken gambar","Insert image via URL":"Tambah gambar saking URL",Italic:"Miring",Justify:"Rata kiwa tengen",Language:"Basa","Left aligned image":"Gambar ing kiwa","List properties":"","Lower-latin":"","Lower–roman":"","Match case":"Samikaken aksara","Next result":"Kasil salajengipun","No preview available":"","Numbered List":"","Numbered list styles toolbar":"",Original:"Asli",Paragraph:"","Paste raw HTML here...":"","Pink marker":"Penandha abrit jambon","Plain text":"Seratan biasa","Previous result":"Kasil saderengipun","Red pen":"Penandha abrit","Remove color":"Busek warni","Remove highlight":"Busek sorot","Remove language":"Busek basa",Replace:"Gantos","Replace all":"Gantos sedaya","Replace with…":"Gantos kaliyan...","Resize image":"","Resize image to %0":"","Resize image to the original size":"","Restore default":"Mangsulaken default","Reversed order":"Dipunwangsul","Right aligned image":"Gambar ing tengen",Save:"Rimat","Save changes":"","Show more items":"Tampilaken langkung kathah","Show options":"Tampilaken pilihan","Side image":"",Small:"Alit",Square:"Kotak","Start at":"Wiwit saking","Start index must be greater than 0.":"",Strikethrough:"Seratan dicoret",Subscript:"",Superscript:"","Text alignment":"Perataan seratan","Text alignment toolbar":"","Text alternative":"","Text highlight toolbar":"","Text to find must not be empty.":"Seratan ingkang dipunpadosi mboten angsal kosong.",Tiny:"Langkung alit","Tip: Find some text first in order to replace it.":"","To-do List":"","Toggle the circle list style":"","Toggle the decimal list style":"","Toggle the decimal with leading zero list style":"","Toggle the disc list style":"","Toggle the lower–latin list style":"","Toggle the lower–roman list style":"","Toggle the square list style":"","Toggle the upper–latin list style":"","Toggle the upper–roman list style":"","Type or paste your content here.":"Serataken utawi nyukani babagan ing ngriki","Type your title":"Serataken irah-irahan",Underline:"Garis ngandhap",Update:"","Update image URL":"","Upload failed":"","Upper-latin":"","Upper-roman":"","Whole words only":"Sedayaning ukanten","Wrap text":"","Yellow marker":"Panandha jene"}),a.getPluralForm=function(e){return 0}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/kk.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/kk.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(n){const t=n.kk=n.kk||{};t.dictionary=Object.assign(t.dictionary||{},{"Align center":"Ортадан туралау","Align left":"Солға туралау","Align right":"Оңға туралау",Justify:"","Text alignment":"Мәтінді туралау","Text alignment toolbar":"Мәтінді туралау құралдар тақтасы"}),t.getPluralForm=function(n){return 1!=n}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/km.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/km.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const t=e.km=e.km||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"","Align center":"តម្រឹមកណ្ដាល","Align left":"តម្រឹមឆ្វេង","Align right":"តម្រឹមស្ដាំ",Aquamarine:"",Black:"","Block quote":"ប្លុកពាក្យសម្រង់",Blue:"",Bold:"ដិត","Break text":"","Bulleted List":"បញ្ជីជាចំណុច","Bulleted list styles toolbar":"",Cancel:"បោះបង់","Caption for image: %0":"","Caption for the image":"","Centered image":"","Change image text alternative":"","Choose heading":"ជ្រើសរើសក្បាលអត្ថបទ",Circle:"",Code:"កូដ",Decimal:"","Decimal with leading zero":"","Dim grey":"",Disc:"",Downloadable:"","Dropdown toolbar":"","Edit block":"","Edit link":"","Editor block content toolbar":"","Editor contextual toolbar":"","Editor editing area: %0":"","Editor toolbar":"","Enter image caption":"បញ្ចូលពាក្យពណ៌នារូបភាព","Full size image":"រូបភាពពេញទំហំ",Green:"",Grey:"",Heading:"ក្បាលអត្ថបទ","Heading 1":"ក្បាលអត្ថបទ 1","Heading 2":"ក្បាលអត្ថបទ 2","Heading 3":"ក្បាលអត្ថបទ 3","Heading 4":"","Heading 5":"","Heading 6":"",HEX:"","Image resize list":"","Image toolbar":"","image widget":"វិដជិតរូបភាព","In line":"",Insert:"","Insert image":"បញ្ចូលរូបភាព","Insert image via URL":"",Italic:"ទ្រេត",Justify:"តម្រឹមសងខាង","Left aligned image":"","Light blue":"","Light green":"","Light grey":"",Link:"តំណ","Link image":"","Link URL":"URL តំណ","List properties":"","Lower-latin":"","Lower–roman":"",Next:"","Numbered List":"បញ្ជីជាលេខ","Numbered list styles toolbar":"","Open in a new tab":"","Open link in new tab":"",Orange:"",Original:"",Paragraph:"កថាខណ្ឌ",Previous:"",Purple:"",Red:"",Redo:"ធ្វើវិញ","Remove color":"","Resize image":"","Resize image to %0":"","Resize image to the original size":"","Restore default":"","Reversed order":"","Rich Text Editor":"កម្មវិធីកែសម្រួលអត្ថបទសម្បូរបែប","Right aligned image":"",Save:"រក្សាទុ","Show more items":"","Side image":"រូបភាពនៅខាង",Square:"","Start at":"","Start index must be greater than 0.":"",Strikethrough:"ឆូតកណ្ដាល",Subscript:"អក្សរតូចក្រោម",Superscript:"អក្សរតូចលើ","Text alignment":"ការតម្រឹមអក្សរ","Text alignment toolbar":"របារឧបករណ៍តម្រឹមអក្សរ","Text alternative":"","This link has no URL":"","To-do List":"","Toggle the circle list style":"","Toggle the decimal list style":"","Toggle the decimal with leading zero list style":"","Toggle the disc list style":"","Toggle the lower–latin list style":"","Toggle the lower–roman list style":"","Toggle the square list style":"","Toggle the upper–latin list style":"","Toggle the upper–roman list style":"",Turquoise:"","Type or paste your content here.":"","Type your title":"",Underline:"គូសបន្ទាត់ក្រោម",Undo:"លែងធ្វើវិញ",Unlink:"ផ្ដាច់តំណ",Update:"","Update image URL":"","Upload failed":"អាប់ឡូតមិនបាន","Upper-latin":"","Upper-roman":"",White:"","Wrap text":"",Yellow:""}),t.getPluralForm=function(e){return 0}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/kn.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/kn.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const t=e.kn=e.kn||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"",Aquamarine:"",Black:"","Block quote":"ಗುರುತಿಸಲಾದ ಉಲ್ಲೇಖ",Blue:"",Bold:"ದಪ್ಪ","Break text":"","Bulleted List":"ಬುಲೆಟ್ ಪಟ್ಟಿ","Bulleted list styles toolbar":"",Cancel:"ರದ್ದುಮಾಡು","Caption for image: %0":"","Caption for the image":"","Centered image":"","Change image text alternative":"ಚಿತ್ರದ ಬದಲಿ ಪಠ್ಯ ಬದಲಾಯಿಸು","Choose heading":"ಶೀರ್ಷಿಕೆ ಆಯ್ಕೆಮಾಡು",Circle:"",Code:"",Decimal:"","Decimal with leading zero":"","Dim grey":"",Disc:"",Downloadable:"","Dropdown toolbar":"","Edit block":"","Edit link":"","Editor block content toolbar":"","Editor contextual toolbar":"","Editor editing area: %0":"","Editor toolbar":"","Enter image caption":"ಚಿತ್ರದ ಶೀರ್ಷಿಕೆ ಸೇರಿಸು","Full size image":"ಪೂರ್ಣ ಅಳತೆಯ ಚಿತ್ರ",Green:"",Grey:"",Heading:"ಶೀರ್ಷಿಕೆ","Heading 1":"ಶೀರ್ಷಿಕೆ 1","Heading 2":"ಶೀರ್ಷಿಕೆ 2","Heading 3":"ಶೀರ್ಷಿಕೆ 3","Heading 4":"","Heading 5":"","Heading 6":"",HEX:"","Image resize list":"","Image toolbar":"","image widget":"ಚಿತ್ರ ವಿಜೆಟ್","In line":"",Insert:"","Insert image":"","Insert image via URL":"",Italic:"ಇಟಾಲಿಕ್","Left aligned image":"","Light blue":"","Light green":"","Light grey":"",Link:"ಕೊಂಡಿ","Link image":"","Link URL":"ಕೊಂಡಿ ಸಂಪರ್ಕಿಸು","List properties":"","Lower-latin":"","Lower–roman":"",Next:"","Numbered List":"ಸಂಖ್ಯೆಯ ಪಟ್ಟಿ","Numbered list styles toolbar":"","Open in a new tab":"","Open link in new tab":"",Orange:"",Original:"",Paragraph:"ಪ್ಯಾರಾಗ್ರಾಫ್",Previous:"",Purple:"",Red:"",Redo:"ಮತ್ತೆ ಮಾಡು","Remove color":"","Resize image":"","Resize image to %0":"","Resize image to the original size":"","Restore default":"","Reversed order":"","Rich Text Editor":"ಸಮೃದ್ಧ ಪಠ್ಯ ಸಂಪಾದಕ","Right aligned image":"",Save:"ಉಳಿಸು","Show more items":"","Side image":"ಪಕ್ಕದ ಚಿತ್ರ",Square:"","Start at":"","Start index must be greater than 0.":"",Strikethrough:"",Subscript:"",Superscript:"","Text alternative":"ಪಠ್ಯದ ಬದಲಿ","This link has no URL":"","To-do List":"","Toggle the circle list style":"","Toggle the decimal list style":"","Toggle the decimal with leading zero list style":"","Toggle the disc list style":"","Toggle the lower–latin list style":"","Toggle the lower–roman list style":"","Toggle the square list style":"","Toggle the upper–latin list style":"","Toggle the upper–roman list style":"",Turquoise:"","Type or paste your content here.":"","Type your title":"",Underline:"",Undo:"ರದ್ದು",Unlink:"ಕೊಂಡಿ ತೆಗೆ",Update:"","Update image URL":"","Upload failed":"","Upper-latin":"","Upper-roman":"",White:"","Wrap text":"",Yellow:""}),t.getPluralForm=function(e){return e>1}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/ko.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ko.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/ku.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ku.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/lt.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/lt.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/lv.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/lv.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/ms.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ms.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/nb.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/nb.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/ne.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ne.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/nl.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/nl.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/no.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/no.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/oc.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/oc.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(o){const r=o.oc=o.oc||{};r.dictionary=Object.assign(r.dictionary||{},{"%0 of %1":"",Bold:"Gras",Cancel:"Anullar",Code:"",Italic:"Italica","Remove color":"","Restore default":"",Save:"Enregistrar","Show more items":"",Strikethrough:"",Subscript:"",Superscript:"",Underline:""}),r.getPluralForm=function(o){return o>1}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/pl.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/pl.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/pt-br.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/pt-br.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/pt.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/pt.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/ro.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ro.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/ru.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ru.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/si.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/si.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const t=e.si=e.si||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"",Bold:"තදකුරු","Break text":"","Bulleted List":"බුලටිත ලැයිස්තුව","Bulleted list styles toolbar":"",Cancel:"","Caption for image: %0":"","Caption for the image":"","Centered image":"","Change image text alternative":"",Circle:"",Code:"",Decimal:"","Decimal with leading zero":"",Disc:"","Enter image caption":"","Full size image":"","Image resize list":"","Image toolbar":"","image widget":"","In line":"",Insert:"","Insert image":"පින්තූරය ඇතුල් කරන්න","Insert image via URL":"",Italic:"ඇලකුරු","Left aligned image":"","List properties":"","Lower-latin":"","Lower–roman":"","Numbered List":"අංකිත ලැයිස්තුව","Numbered list styles toolbar":"",Original:"",Redo:"නැවත කරන්න","Remove color":"","Resize image":"","Resize image to %0":"","Resize image to the original size":"","Restore default":"","Reversed order":"","Right aligned image":"",Save:"","Show more items":"","Side image":"",Square:"","Start at":"","Start index must be greater than 0.":"",Strikethrough:"",Subscript:"",Superscript:"","Text alternative":"","To-do List":"","Toggle the circle list style":"","Toggle the decimal list style":"","Toggle the decimal with leading zero list style":"","Toggle the disc list style":"","Toggle the lower–latin list style":"","Toggle the lower–roman list style":"","Toggle the square list style":"","Toggle the upper–latin list style":"","Toggle the upper–roman list style":"",Underline:"",Undo:"අහෝසි කරන්න",Update:"","Update image URL":"","Upload failed":"උඩුගත කිරීම අසාර්ථක විය","Upper-latin":"","Upper-roman":"","Wrap text":""}),t.getPluralForm=function(e){return 1!=e}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/sk.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/sk.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/sl.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/sl.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const o=e.sl=e.sl||{};o.dictionary=Object.assign(o.dictionary||{},{"%0 of %1":"",Accept:"","Align cell text to the bottom":"","Align cell text to the center":"","Align cell text to the left":"","Align cell text to the middle":"","Align cell text to the right":"","Align cell text to the top":"","Align center":"Sredinska poravnava","Align left":"Poravnava levo","Align right":"Poravnava desno","Align table to the left":"","Align table to the right":"",Alignment:"",Aquamarine:"Akvamarin",Background:"",Big:"Veliko",Black:"Črna","Block quote":"Blokiraj citat",Blue:"Modra","Blue marker":"Modra oznaka",Bold:"Krepko",Border:"",Cancel:"Prekliči","Cell properties":"","Center table":"","Choose heading":"Izberi naslov",Code:"Koda",Color:"","Color picker":"",Column:"",Dashed:"",Default:"Privzeto","Delete column":"","Delete row":"","Dim grey":"Temno siva",Dimensions:"","Document colors":"Barve dokumenta",Dotted:"",Double:"","Dropdown toolbar":"","Edit block":"","Edit source":"Uredi izvorno kodo","Editor block content toolbar":"","Editor contextual toolbar":"","Editor editing area: %0":"","Editor toolbar":"","Empty snippet content":"","Enter table caption":"","Font Background Color":"Barva ozadja pisave","Font Color":"Barva pisave","Font Family":"Vrsta oz. tip pisave","Font Size":"Velikost pisave",Green:"Zelena","Green marker":"Zelena oznaka","Green pen":"Zeleno pisalo",Grey:"Siva",Groove:"","Header column":"","Header row":"",Heading:"Naslov","Heading 1":"Naslov 1","Heading 2":"Naslov 2","Heading 3":"Naslov 3","Heading 4":"Naslov 4","Heading 5":"Naslov 5","Heading 6":"Naslov 6",Height:"",HEX:"",Highlight:"Označi","Horizontal line":"Vodoravna črta","Horizontal text alignment toolbar":"","HTML snippet":"HTML izsek",Huge:"Ogromno","Insert column left":"","Insert column right":"","Insert HTML":"Vstavi HTML","Insert row above":"","Insert row below":"","Insert table":"Vstavi tabelo",Inset:"",Italic:"Poševno",Justify:"Postavi na sredino","Justify cell text":"","Light blue":"Svetlo modra","Light green":"Svetlo zelena","Light grey":"Svetlo siva","Merge cell down":"","Merge cell left":"","Merge cell right":"","Merge cell up":"","Merge cells":"",Next:"","No preview available":"",None:"",Orange:"Oranžna",Outset:"",Padding:"",Paragraph:"Odstavek","Paste raw HTML here...":"Prilepi HTML kodo ...","Pink marker":"Rožnata oznaka",Previous:"",Purple:"Vijolična",Red:"Rdeča","Red pen":"Rdeče pisalo","Remove color":"Odstrani barvo","Remove highlight":"Odstrani oznako","Restore default":"","Rich Text Editor":"",Ridge:"",Row:"",Save:"Shrani","Save changes":"Shrani spremembe","Select column":"","Select row":"","Show more items":"",Small:"Majhna",Solid:"","Split cell horizontally":"","Split cell vertically":"",Strikethrough:"Prečrtano",Style:"",Subscript:"Naročnik",Superscript:"Nadpis","Table alignment toolbar":"","Table cell text alignment":"","Table properties":"","Table toolbar":"","Text alignment":"Poravnava besedila","Text alignment toolbar":"Orodna vrstica besedila","Text highlight toolbar":"Orodna vrstica označevanja",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':"",'The value is invalid. Try "10px" or "2em" or simply "2".':"",Tiny:"Drobna","Toggle caption off":"","Toggle caption on":"",Turquoise:"Turkizna","Type or paste your content here.":"Vnesi ali prilepi vsebino","Type your title":"Vnesi naslov",Underline:"Podčrtaj","Vertical text alignment toolbar":"",White:"Bela",Width:"",Yellow:"Rumena","Yellow marker":"Rumena oznaka"}),o.getPluralForm=function(e){return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/sq.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/sq.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/sr-latn.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/sr-latn.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/sr.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/sr.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/sv.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/sv.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/th.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/th.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/tk.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/tk.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/tr.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/tr.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/tt.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/tt.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e){const t=e.tt=e.tt||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"","Align cell text to the bottom":"","Align cell text to the center":"","Align cell text to the left":"","Align cell text to the middle":"","Align cell text to the right":"","Align cell text to the top":"","Align table to the left":"","Align table to the right":"",Alignment:"",Aquamarine:"Аквамарин",Background:"",Black:"Кара",Blue:"Зәңгәр",Bold:"Калын",Border:"","Break text":"","Bulleted List":"","Bulleted list styles toolbar":"",Cancel:"Баш тарт","Caption for image: %0":"","Caption for the image":"","Cell properties":"","Center table":"","Centered image":"","Change image text alternative":"","Choose language":"",Circle:"Түгәрәк",Code:"Код",Color:"Төс","Color picker":"",Column:"",Dashed:"",Decimal:"","Decimal with leading zero":"","Delete column":"","Delete row":"","Dim grey":"",Dimensions:"",Disc:"Диск",Dotted:"",Double:"",Downloadable:"","Dropdown toolbar":"","Edit block":"","Edit link":"","Editor block content toolbar":"","Editor contextual toolbar":"","Editor editing area: %0":"","Editor toolbar":"","Enter image caption":"","Enter table caption":"",Find:"Таб","Find and replace":"","Find in text…":"Текстта таб...","Full size image":"",Green:"Яшел",Grey:"Соры",Groove:"","Header column":"","Header row":"",Height:"",HEX:"","Horizontal text alignment toolbar":"","Image resize list":"","Image toolbar":"","image widget":"","In line":"",Insert:"","Insert column left":"","Insert column right":"","Insert image":"","Insert image via URL":"","Insert row above":"","Insert row below":"","Insert table":"",Inset:"",Italic:"","Justify cell text":"",Language:"Тел","Left aligned image":"","Light blue":"Ачык зәңгәр","Light green":"Ачык яшел","Light grey":"Ачык соры",Link:"Сылтама","Link image":"","Link URL":"","List properties":"","Lower-latin":"","Lower–roman":"","Match case":"","Merge cell down":"","Merge cell left":"","Merge cell right":"","Merge cell up":"","Merge cells":"",Next:"","Next result":"",None:"","Numbered List":"","Numbered list styles toolbar":"","Open in a new tab":"","Open link in new tab":"",Orange:"Кызгылт",Original:"",Outset:"",Padding:"",Previous:"","Previous result":"",Purple:"Шәмәхә",Red:"Кызыл",Redo:"Кабатла","Remove color":"","Remove language":"",Replace:"","Replace all":"","Replace with…":"","Resize image":"","Resize image to %0":"","Resize image to the original size":"","Restore default":"","Reversed order":"","Rich Text Editor":"",Ridge:"","Right aligned image":"",Row:"",Save:"Сакла","Select column":"","Select row":"","Show more items":"","Show options":"","Side image":"",Solid:"","Split cell horizontally":"","Split cell vertically":"",Square:"","Start at":"","Start index must be greater than 0.":"",Strikethrough:"",Style:"",Subscript:"",Superscript:"","Table alignment toolbar":"","Table cell text alignment":"","Table properties":"","Table toolbar":"","Text alternative":"","Text to find must not be empty.":"",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':"",'The value is invalid. Try "10px" or "2em" or simply "2".':"","This link has no URL":"","Tip: Find some text first in order to replace it.":"","To-do List":"","Toggle caption off":"","Toggle caption on":"","Toggle the circle list style":"","Toggle the decimal list style":"","Toggle the decimal with leading zero list style":"","Toggle the disc list style":"","Toggle the lower–latin list style":"","Toggle the lower–roman list style":"","Toggle the square list style":"","Toggle the upper–latin list style":"","Toggle the upper–roman list style":"",Turquoise:"Фервоз",Underline:"",Undo:"",Unlink:"",Update:"Яңарт","Update image URL":"","Upload failed":"","Upper-latin":"","Upper-roman":"","Vertical text alignment toolbar":"",White:"Ак","Whole words only":"",Width:"","Wrap text":"",Yellow:"Сары"}),t.getPluralForm=function(e){return 0}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
1
dist/editor/js/CKEditor/translations/ug.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ug.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/uk.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/uk.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/ur.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/ur.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/uz.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/uz.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/vi.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/vi.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/zh-cn.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/zh-cn.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/editor/js/CKEditor/translations/zh.js
vendored
Normal file
1
dist/editor/js/CKEditor/translations/zh.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dist/editor/js/editor.js
vendored
2
dist/editor/js/editor.js
vendored
File diff suppressed because one or more lines are too long
1
dist/editor/js/main.js
vendored
1
dist/editor/js/main.js
vendored
@ -1 +0,0 @@
|
|||||||
function showErrorMessage(e){document.querySelector("#loginError").classList.remove("hidden"),document.querySelector("#loginError div").innerText=e}document.addEventListener("DOMContentLoaded",(e=>{fetch("/api/user/isLoggedIn").then((e=>{e.ok&&(window.location.href="./editor.html")}))})),document.querySelector("#login form").addEventListener("submit",(e=>{e.preventDefault();let r=new FormData;if(e.target.username.value.length>0&&e.target.password.value.length>0)return r.append("username",e.target.username.value),r.append("password",e.target.password.value),void fetch("/api/user/login",{method:"POST",body:r}).then((e=>{e.ok?window.location.href="./editor.html":400!==e.status?(document.querySelector("#loginError").classList.remove("hidden"),document.querySelector("#loginError div").innerHTML="Invalid username or password"):showErrorMessage("Please type in a username and password.")}));document.querySelector("#loginError").classList.remove("hidden"),document.querySelector("#loginError div").innerHTML="Please type in a username and password"})),document.querySelector("#loginError .close").addEventListener("click",(()=>document.querySelector("#loginError").classList.toggle("hidden")));
|
|
@ -1,8 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace api\blog;
|
namespace api\blog;
|
||||||
|
use api\utils\imgUtils;
|
||||||
|
use DOMDocument;
|
||||||
use PDO;
|
use PDO;
|
||||||
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
|
||||||
require_once __DIR__ . "/../utils/config.php";
|
require_once __DIR__ . "/../utils/config.php";
|
||||||
|
require_once __DIR__ . "/../utils/imgUtils.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blog Data Class
|
* Blog Data Class
|
||||||
@ -14,10 +18,10 @@ class blogData
|
|||||||
* Get all blog posts
|
* Get all blog posts
|
||||||
* @return array - Array of all blog posts or error message
|
* @return array - Array of all blog posts or error message
|
||||||
*/
|
*/
|
||||||
function getBlogPosts(): array
|
public function getBlogPosts(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, body, tags FROM blog ORDER BY dateCreated DESC;");
|
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, body, categories FROM blog ORDER BY dateCreated DESC;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// set the resulting array to associative
|
// set the resulting array to associative
|
||||||
@ -36,10 +40,10 @@ class blogData
|
|||||||
* @param string $ID - ID of the blog post to get
|
* @param string $ID - ID of the blog post to get
|
||||||
* @return array - Array of all blog posts or error message
|
* @return array - Array of all blog posts or error message
|
||||||
*/
|
*/
|
||||||
function getBlogPost(string $ID): array
|
public function getBlogPost(string $ID): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, tags FROM blog WHERE ID = :ID;");
|
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, categories FROM blog WHERE ID = :ID;");
|
||||||
$stmt->bindParam(":ID", $ID);
|
$stmt->bindParam(":ID", $ID);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
@ -58,10 +62,10 @@ class blogData
|
|||||||
* Get the latest blog post
|
* Get the latest blog post
|
||||||
* @return array - Array of the latest blog post or error message
|
* @return array - Array of the latest blog post or error message
|
||||||
*/
|
*/
|
||||||
function getLatestBlogPost(): array
|
public function getLatestBlogPost(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, tags FROM blog ORDER BY dateCreated DESC LIMIT 1;");
|
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, categories FROM blog ORDER BY dateCreated DESC LIMIT 1;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// set the resulting array to associative
|
// set the resulting array to associative
|
||||||
@ -79,10 +83,10 @@ class blogData
|
|||||||
* Get featured blog post
|
* Get featured blog post
|
||||||
* @return array - Array of the featured blog post or error message
|
* @return array - Array of the featured blog post or error message
|
||||||
*/
|
*/
|
||||||
function getFeaturedBlogPost(): array
|
public function getFeaturedBlogPost(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, tags FROM blog WHERE featured = 1;");
|
$stmt = $conn->prepare("SELECT ID, title, dateCreated, dateModified, featured, headerImg, body, categories FROM blog WHERE featured = 1;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@ -94,4 +98,115 @@ class blogData
|
|||||||
|
|
||||||
return array("errorMessage" => "Error, blog post could not found");
|
return array("errorMessage" => "Error, blog post could not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload the images in the post to temp folder and return image location
|
||||||
|
* @param UploadedFileInterface $img - Image to upload
|
||||||
|
* @return string|array - String with error message or array with the location of the uploaded file
|
||||||
|
*/
|
||||||
|
public function uploadPostImage(UploadedFileInterface $img): string|array
|
||||||
|
{
|
||||||
|
$targetDir = "../blog/imgs/tmp/";
|
||||||
|
$imagUtils = new imgUtils();
|
||||||
|
$targetFile = $imagUtils->uploadFile($targetDir, $img);
|
||||||
|
|
||||||
|
$file = $targetDir . basename($img->getClientFilename());
|
||||||
|
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
return array("url" => $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_array($targetFile))
|
||||||
|
{
|
||||||
|
return $targetFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists($targetFile["imgLocation"]))
|
||||||
|
{
|
||||||
|
return array("url" => $targetFile["imgLocation"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Couldn't upload the image";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new post directory, uploads the header image and moves the images from the
|
||||||
|
* temp folder to the new folder, then updates the post html to point to the new images, finally
|
||||||
|
* it creates the post in the database
|
||||||
|
* @param string $title - Title of the blog post
|
||||||
|
* @param string $body - Body of the blog post
|
||||||
|
* @param string $dateCreated - Date the blog post was created
|
||||||
|
* @param string $featured - Whether the blog post is featured or not
|
||||||
|
* @param string $categories - Categories of the blog post
|
||||||
|
* @param UploadedFileInterface $headerImg - Header image of the blog post
|
||||||
|
* @return int|string - ID of the blog post or error message
|
||||||
|
*/
|
||||||
|
public function createPost(string $title, string $body, string $dateCreated, string $featured, string $categories, UploadedFileInterface $headerImg): int|string
|
||||||
|
{
|
||||||
|
$conn = dbConn();
|
||||||
|
$targetDir = "../blog/imgs/" . $title . "_" . uniqid() . "/";
|
||||||
|
mkdir($targetDir, 0777, true);
|
||||||
|
$imagUtils = new imgUtils();
|
||||||
|
$targetFile = $imagUtils->uploadFile($targetDir, $headerImg);
|
||||||
|
if (!is_array($targetFile))
|
||||||
|
{
|
||||||
|
return $targetFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
$htmlDoc = new DOMDocument();
|
||||||
|
$htmlDoc->loadHTML($body, LIBXML_NOERROR);
|
||||||
|
$doc = $htmlDoc->getElementsByTagName('body')->item(0);
|
||||||
|
$imgs = $doc->getElementsByTagName('img');
|
||||||
|
|
||||||
|
$srcList = array();
|
||||||
|
|
||||||
|
foreach ($imgs as $img)
|
||||||
|
{
|
||||||
|
$src = $img->getAttribute("src");
|
||||||
|
$srcList[] = $src;
|
||||||
|
$fileName = basename($src);
|
||||||
|
|
||||||
|
$img->setAttribute("src", $targetDir . $fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = scandir("../blog/imgs/tmp/");
|
||||||
|
foreach ($files as $file)
|
||||||
|
{
|
||||||
|
if ($file != "." && $file != "..")
|
||||||
|
{
|
||||||
|
if (!in_array("../blog/imgs/tmp/" . $file, $srcList))
|
||||||
|
{
|
||||||
|
unlink("../blog/imgs/tmp/" . $file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rename("../blog/imgs/tmp/" . $file, $targetDir . $file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$newBody = '';
|
||||||
|
foreach ($doc->childNodes as $node)
|
||||||
|
{
|
||||||
|
$newBody .= $htmlDoc->saveHTML($node);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("INSERT INTO blog (title, dateCreated, dateModified, featured, headerImg, body, categories)
|
||||||
|
VALUES (:title, :dateCreated, :dateModified, :featured, :headerImg, :body, :categories);");
|
||||||
|
$stmt->bindParam(":title", $title);
|
||||||
|
$stmt->bindParam(":dateCreated", $dateCreated);
|
||||||
|
$stmt->bindParam(":dateModified", $dateCreated);
|
||||||
|
$stmt->bindParam(":featured", $featured);
|
||||||
|
$stmt->bindParam(":headerImg", $targetFile["imgLocation"]);
|
||||||
|
$stmt->bindParam(":body", $newBody);
|
||||||
|
$stmt->bindParam(":categories", $categories);
|
||||||
|
|
||||||
|
if ($stmt->execute())
|
||||||
|
{
|
||||||
|
return intval($conn->lastInsertId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Error, couldn't create post";
|
||||||
|
}
|
||||||
}
|
}
|
@ -12,7 +12,6 @@ use Slim\App;
|
|||||||
class blogRoutes implements routesInterface
|
class blogRoutes implements routesInterface
|
||||||
{
|
{
|
||||||
private blogData $blogData;
|
private blogData $blogData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor used to instantiate a base blog routes, to be used in the index.php file.
|
* constructor used to instantiate a base blog routes, to be used in the index.php file.
|
||||||
* @param App $app - the slim app used to create the routes
|
* @param App $app - the slim app used to create the routes
|
||||||
@ -30,6 +29,48 @@ class blogRoutes implements routesInterface
|
|||||||
*/
|
*/
|
||||||
public function createRoutes(App $app): void
|
public function createRoutes(App $app): void
|
||||||
{
|
{
|
||||||
// TODO: Implement createRoutes() method.
|
$app->post("/blog/post", function (Request $request, Response $response, array $args)
|
||||||
|
{
|
||||||
|
$data = $request->getParsedBody();
|
||||||
|
$files = $request->getUploadedFiles();
|
||||||
|
if (empty($data["title"]) || empty($data["body"]) || empty($data["dateCreated"]) || empty($data["featured"]) || empty($data["categories"]) || empty($files["headerImg"]))
|
||||||
|
{
|
||||||
|
// uh oh sent some empty data
|
||||||
|
$response->getBody()->write(json_encode(array("error" => "Error, empty data sent")));
|
||||||
|
return $response->withStatus(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$insertedID = $this->blogData->createPost($data["title"], $data["body"], $data["dateCreated"], $data["featured"], $data["categories"], $files["headerImg"]);
|
||||||
|
if (!is_int($insertedID))
|
||||||
|
{
|
||||||
|
// uh oh something went wrong
|
||||||
|
$response->getBody()->write(json_encode(array("error" => $insertedID)));
|
||||||
|
return $response->withStatus(500);
|
||||||
|
}
|
||||||
|
$response->getBody()->write(json_encode(array("ID" => $insertedID)));
|
||||||
|
return $response->withStatus(201);
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->post("/blog/uploadPostImage", function (Request $request, Response $response)
|
||||||
|
{
|
||||||
|
$files = $request->getUploadedFiles();
|
||||||
|
if (empty($files))
|
||||||
|
{
|
||||||
|
// uh oh sent some empty data
|
||||||
|
$response->getBody()->write(json_encode(array("error" => array("message" => "Error, empty data sent"))));
|
||||||
|
return $response->withStatus(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $this->blogData->uploadPostImage($files["upload"]);
|
||||||
|
if (!is_array($message))
|
||||||
|
{
|
||||||
|
$response->getBody()->write(json_encode(array("error" => array("message" => $message))));
|
||||||
|
return $response->withStatus(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$response->getBody()->write(json_encode($message));
|
||||||
|
return $response->withStatus(201);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace api\project;
|
namespace api\project;
|
||||||
|
use api\utils\imgUtils;
|
||||||
use PDO;
|
use PDO;
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
|
||||||
require_once __DIR__ . "/../utils/config.php";
|
require_once __DIR__ . "/../utils/config.php";
|
||||||
|
require_once __DIR__ . "/../utils/imgUtils.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project Data Class
|
* Project Data Class
|
||||||
@ -15,7 +17,7 @@ class projectData
|
|||||||
* Get all project data
|
* Get all project data
|
||||||
* @return array - Array of all project data or error message
|
* @return array - Array of all project data or error message
|
||||||
*/
|
*/
|
||||||
function getProjectData(): array
|
public function getProjectData(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, title, isMainProject, information, imgLocation, projectLink, gitLink FROM projects ORDER BY isMainProject DESC;");
|
$stmt = $conn->prepare("SELECT ID, title, isMainProject, information, imgLocation, projectLink, gitLink FROM projects ORDER BY isMainProject DESC;");
|
||||||
@ -43,7 +45,7 @@ class projectData
|
|||||||
* @param string $gitLink - Link to the git repository
|
* @param string $gitLink - Link to the git repository
|
||||||
* @return bool|string - True if project was updated, false if not and there was an error, or an error string
|
* @return bool|string - True if project was updated, false if not and there was an error, or an error string
|
||||||
*/
|
*/
|
||||||
function updateProjectData(string $ID, string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): bool | string
|
public function updateProjectData(string $ID, string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): bool|string
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
|
|
||||||
@ -82,7 +84,7 @@ class projectData
|
|||||||
* @param int $ID - ID of the project in the database to delete
|
* @param int $ID - ID of the project in the database to delete
|
||||||
* @return string - True if project was deleted, false if not and there was an error
|
* @return string - True if project was deleted, false if not and there was an error
|
||||||
*/
|
*/
|
||||||
function deleteProjectData(int $ID): string
|
public function deleteProjectData(int $ID): string
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
|
|
||||||
@ -121,7 +123,7 @@ class projectData
|
|||||||
* @param string $gitLink - Link to the github repository
|
* @param string $gitLink - Link to the github repository
|
||||||
* @return int|bool - ID of the project if it was added, false if not and there was an error
|
* @return int|bool - ID of the project if it was added, false if not and there was an error
|
||||||
*/
|
*/
|
||||||
function addProjectData(string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): int|bool
|
public function addProjectData(string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): int|bool
|
||||||
{
|
{
|
||||||
|
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
@ -157,31 +159,15 @@ class projectData
|
|||||||
public function uploadImage(int $ID, UploadedFileInterface $img): string | array
|
public function uploadImage(int $ID, UploadedFileInterface $img): string | array
|
||||||
{
|
{
|
||||||
$targetDir = "../imgs/projects/";
|
$targetDir = "../imgs/projects/";
|
||||||
$targetFile = $targetDir . basename($img->getClientFilename());
|
$imgUtils = new imgUtils();
|
||||||
$uploadOk = 1;
|
$targetFile = $imgUtils->uploadFile($targetDir, $img);
|
||||||
$imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
|
|
||||||
|
|
||||||
// Check if file already exists
|
if (!is_array($targetFile))
|
||||||
if (file_exists($targetFile))
|
|
||||||
{
|
{
|
||||||
return "The file already exists";
|
return $targetFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check file size
|
if (file_exists($targetFile["imgLocation"]))
|
||||||
if ($img->getSize() > 2000000)
|
|
||||||
{
|
|
||||||
return "The file is too large, max 2MB";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow certain file formats
|
|
||||||
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif")
|
|
||||||
{
|
|
||||||
return "Only JPG, JPEG, PNG & GIF files are allowed";
|
|
||||||
}
|
|
||||||
|
|
||||||
$img->moveTo($targetFile);
|
|
||||||
|
|
||||||
if (file_exists($targetFile))
|
|
||||||
{
|
{
|
||||||
$this->deleteImage($ID);
|
$this->deleteImage($ID);
|
||||||
// update the database with the new image location
|
// update the database with the new image location
|
||||||
@ -193,7 +179,7 @@ class projectData
|
|||||||
|
|
||||||
if ($stmt->rowCount() > 0)
|
if ($stmt->rowCount() > 0)
|
||||||
{
|
{
|
||||||
return array("imgLocation" => $targetFile);
|
return array("imgLocation" => $targetFile["imgLocation"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Couldn't update the database";
|
return "Couldn't update the database";
|
||||||
|
@ -113,7 +113,7 @@ class projectRoutes implements routesInterface
|
|||||||
{
|
{
|
||||||
// uh oh sent some empty data
|
// uh oh sent some empty data
|
||||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||||
return $response->withStatus(400);
|
return $response->withStatus(400)->withStatus(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
$insertedID = $this->projectData->addProjectData($data["title"], $data["isMainProject"], $data["information"], $data["projectLink"], $data["gitLink"]);
|
$insertedID = $this->projectData->addProjectData($data["title"], $data["isMainProject"], $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||||
@ -125,7 +125,7 @@ class projectRoutes implements routesInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$response->getBody()->write(json_encode(array("ID" => $insertedID)));
|
$response->getBody()->write(json_encode(array("ID" => $insertedID)));
|
||||||
return $response;
|
return $response->withStatus(201);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->post("/projectImage/{id}", function (Request $request, Response $response, array $args)
|
$app->post("/projectImage/{id}", function (Request $request, Response $response, array $args)
|
||||||
@ -147,7 +147,7 @@ class projectRoutes implements routesInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$response->getBody()->write(json_encode($message));
|
$response->getBody()->write(json_encode($message));
|
||||||
return $response;
|
return $response->withStatus(201);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ class timelineData
|
|||||||
* Get all education data
|
* Get all education data
|
||||||
* @return array - Array of all education data or error message
|
* @return array - Array of all education data or error message
|
||||||
*/
|
*/
|
||||||
function getEduData(): array
|
public function getEduData(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, grade, course FROM edu ORDER BY startPeriod DESC;");
|
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, grade, course FROM edu ORDER BY startPeriod DESC;");
|
||||||
@ -24,7 +24,7 @@ class timelineData
|
|||||||
|
|
||||||
// set the resulting array to associative
|
// set the resulting array to associative
|
||||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
return $result;
|
return $result;
|
||||||
@ -36,7 +36,7 @@ class timelineData
|
|||||||
* Get all work data
|
* Get all work data
|
||||||
* @return array - Array of all work data or error message
|
* @return array - Array of all work data or error message
|
||||||
*/
|
*/
|
||||||
function getWorkData(): array
|
public function getWorkData(): array
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, companyName, area, title FROM work ORDER BY work.startPeriod DESC;");
|
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, companyName, area, title FROM work ORDER BY work.startPeriod DESC;");
|
||||||
@ -61,7 +61,7 @@ class timelineData
|
|||||||
* @param string $id - ID of the education data
|
* @param string $id - ID of the education data
|
||||||
* @return bool - True if successful, false if not
|
* @return bool - True if successful, false if not
|
||||||
*/
|
*/
|
||||||
function updateEduData(string $dateFrom, string $dateTo, string $grade, string $course, string $id): bool
|
public function updateEduData(string $dateFrom, string $dateTo, string $grade, string $course, string $id): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("UPDATE edu SET startPeriod = :dateFrom, endPeriod = :dateTo, grade = :grade, course = :course WHERE ID = :id;");
|
$stmt = $conn->prepare("UPDATE edu SET startPeriod = :dateFrom, endPeriod = :dateTo, grade = :grade, course = :course WHERE ID = :id;");
|
||||||
@ -101,7 +101,7 @@ class timelineData
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return bool - True if successful, false if not
|
* @return bool - True if successful, false if not
|
||||||
*/
|
*/
|
||||||
function deleteEduData(int $id): bool
|
public function deleteEduData(int $id): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("DELETE FROM edu WHERE ID = :id;");
|
$stmt = $conn->prepare("DELETE FROM edu WHERE ID = :id;");
|
||||||
@ -130,7 +130,7 @@ class timelineData
|
|||||||
* @param string $course - Course
|
* @param string $course - Course
|
||||||
* @return bool|int - ID of the new education data or false if not successful
|
* @return bool|int - ID of the new education data or false if not successful
|
||||||
*/
|
*/
|
||||||
function addEduData(string $dateFrom, string $dateTo, string $grade, string $course): bool|int
|
public function addEduData(string $dateFrom, string $dateTo, string $grade, string $course): bool|int
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("INSERT INTO edu (startPeriod, endPeriod, grade, course) VALUES (:dateFrom, :dateTo, :grade, :course);");
|
$stmt = $conn->prepare("INSERT INTO edu (startPeriod, endPeriod, grade, course) VALUES (:dateFrom, :dateTo, :grade, :course);");
|
||||||
@ -138,8 +138,8 @@ class timelineData
|
|||||||
$stmt->bindParam(":dateTo", $dateTo);
|
$stmt->bindParam(":dateTo", $dateTo);
|
||||||
$stmt->bindParam(":grade", $grade);
|
$stmt->bindParam(":grade", $grade);
|
||||||
$stmt->bindParam(":course", $course);
|
$stmt->bindParam(":course", $course);
|
||||||
|
|
||||||
if($stmt->execute())
|
if ($stmt->execute())
|
||||||
{
|
{
|
||||||
return $conn->lastInsertId();
|
return $conn->lastInsertId();
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ class timelineData
|
|||||||
* @param string $title - Title
|
* @param string $title - Title
|
||||||
* @return bool|int - ID of the new work data if successful, false if not
|
* @return bool|int - ID of the new work data if successful, false if not
|
||||||
*/
|
*/
|
||||||
function addWorkData(string $dateFrom, string $dateTo, string $companyName, string $area, string $title): bool|int
|
public function addWorkData(string $dateFrom, string $dateTo, string $companyName, string $area, string $title): bool|int
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("INSERT INTO work (startPeriod, endPeriod, companyName, area, title) VALUES (:dateFrom, :dateTo, :companyName, :area, :title);");
|
$stmt = $conn->prepare("INSERT INTO work (startPeriod, endPeriod, companyName, area, title) VALUES (:dateFrom, :dateTo, :companyName, :area, :title);");
|
||||||
@ -164,8 +164,8 @@ class timelineData
|
|||||||
$stmt->bindParam(":companyName", $companyName);
|
$stmt->bindParam(":companyName", $companyName);
|
||||||
$stmt->bindParam(":area", $area);
|
$stmt->bindParam(":area", $area);
|
||||||
$stmt->bindParam(":title", $title);
|
$stmt->bindParam(":title", $title);
|
||||||
|
|
||||||
if($stmt->execute())
|
if ($stmt->execute())
|
||||||
{
|
{
|
||||||
return $conn->lastInsertId();
|
return $conn->lastInsertId();
|
||||||
}
|
}
|
||||||
|
@ -17,16 +17,16 @@ class userData
|
|||||||
* @param $password string - Password
|
* @param $password string - Password
|
||||||
* @return bool - True if logged in, false if not
|
* @return bool - True if logged in, false if not
|
||||||
*/
|
*/
|
||||||
function checkUser(string $username, string $password): bool
|
public function checkUser(string $username, string $password): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = :username");
|
$stmt = $conn->prepare("SELECT * FROM users WHERE username = :username");
|
||||||
$stmt->bindParam(":username", $username);
|
$stmt->bindParam(":username", $username);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// set the resulting array to associative
|
// set the resulting array to associative
|
||||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
if (password_verify($password, $result[0]["password"]))
|
if (password_verify($password, $result[0]["password"]))
|
||||||
@ -43,15 +43,15 @@ class userData
|
|||||||
* @param $username string - Username
|
* @param $username string - Username
|
||||||
* @return string - JWT token
|
* @return string - JWT token
|
||||||
*/
|
*/
|
||||||
function createToken(string $username): string
|
public function createToken(string $username): string
|
||||||
{
|
{
|
||||||
$now = time();
|
$now = time();
|
||||||
$future = strtotime('+6 hour',$now);
|
$future = strtotime('+6 hour', $now);
|
||||||
$secretKey = getSecretKey();
|
$secretKey = getSecretKey();
|
||||||
$payload = [
|
$payload = [
|
||||||
"jti"=>$username,
|
"jti" => $username,
|
||||||
"iat"=>$now,
|
"iat" => $now,
|
||||||
"exp"=>$future
|
"exp" => $future
|
||||||
];
|
];
|
||||||
|
|
||||||
return JWT::encode($payload,$secretKey,"HS256");
|
return JWT::encode($payload,$secretKey,"HS256");
|
||||||
@ -62,7 +62,7 @@ class userData
|
|||||||
* @param string $email - Email to check
|
* @param string $email - Email to check
|
||||||
* @return bool - True if email exists, false if not
|
* @return bool - True if email exists, false if not
|
||||||
*/
|
*/
|
||||||
function checkEmail(string $email): bool
|
public function checkEmail(string $email): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("SELECT * FROM users WHERE email = :email");
|
$stmt = $conn->prepare("SELECT * FROM users WHERE email = :email");
|
||||||
@ -84,14 +84,14 @@ class userData
|
|||||||
* @param $email - email address of the userData
|
* @param $email - email address of the userData
|
||||||
* @return string - verification code
|
* @return string - verification code
|
||||||
*/
|
*/
|
||||||
function sendResetEmail($email): string
|
public function sendResetEmail($email): string
|
||||||
{
|
{
|
||||||
//generate a random token and email the address
|
//generate a random token and email the address
|
||||||
$token = uniqid("rpe-");
|
$token = uniqid("rpe-");
|
||||||
$headers1 = "From: noreply@rohitpai.co.uk\r\n";
|
$headers1 = "From: noreply@rohitpai.co.uk\r\n";
|
||||||
$headers1 .= "MIME-Version: 1.0\r\n";
|
$headers1 .= "MIME-Version: 1.0\r\n";
|
||||||
$headers1 .= "Content-Type: text/html; charset=UTF-8\r\n";
|
$headers1 .= "Content-Type: text/html; charset=UTF-8\r\n";
|
||||||
|
|
||||||
$message = "
|
$message = "
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang='en'>
|
<html lang='en'>
|
||||||
@ -119,14 +119,14 @@ class userData
|
|||||||
* @param $password string Password
|
* @param $password string Password
|
||||||
* @return bool - true if the password was changed, false if not
|
* @return bool - true if the password was changed, false if not
|
||||||
*/
|
*/
|
||||||
function changePassword(string $email, string $password): bool
|
public function changePassword(string $email, string $password): bool
|
||||||
{
|
{
|
||||||
$conn = dbConn();
|
$conn = dbConn();
|
||||||
$stmt = $conn->prepare("UPDATE users SET password = :password WHERE email = :email");
|
$stmt = $conn->prepare("UPDATE users SET password = :password WHERE email = :email");
|
||||||
$newPwd = password_hash($password, PASSWORD_BCRYPT);
|
$newPwd = password_hash($password, PASSWORD_BCRYPT);
|
||||||
$stmt->bindParam(":password", $newPwd);
|
$stmt->bindParam(":password", $newPwd);
|
||||||
$stmt->bindParam(":email", $email);
|
$stmt->bindParam(":email", $email);
|
||||||
|
|
||||||
if ($stmt->execute())
|
if ($stmt->execute())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -145,7 +145,7 @@ class userRoutes implements routesInterface
|
|||||||
// yay, password changed
|
// yay, password changed
|
||||||
unset($_SESSION["resetToken"]);
|
unset($_SESSION["resetToken"]);
|
||||||
unset($_SESSION["resetEmail"]);
|
unset($_SESSION["resetEmail"]);
|
||||||
return $response;
|
return $response->withStatus(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response->withStatus(500);
|
return $response->withStatus(500);
|
||||||
|
43
src/api/utils/imgUtils.php
Normal file
43
src/api/utils/imgUtils.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace api\utils;
|
||||||
|
|
||||||
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
|
||||||
|
class imgUtils
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Checks and uploads a file to the given directory
|
||||||
|
* @param string $targetDir - Directory to upload the file to
|
||||||
|
* @param UploadedFileInterface $img - File to upload
|
||||||
|
* @return string|array - String with error message or array with the location of the uploaded file
|
||||||
|
*/
|
||||||
|
public function uploadFile(string $targetDir, UploadedFileInterface $img): string|array
|
||||||
|
{
|
||||||
|
$targetFile = $targetDir . basename($img->getClientFilename());
|
||||||
|
$uploadOk = 1;
|
||||||
|
$imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
// Check if file already exists
|
||||||
|
if (file_exists($targetFile))
|
||||||
|
{
|
||||||
|
return "The file already exists";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check file size
|
||||||
|
if ($img->getSize() > 2000000)
|
||||||
|
{
|
||||||
|
return "The file is too large, max 2MB";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow certain file formats
|
||||||
|
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif")
|
||||||
|
{
|
||||||
|
return "Only JPG, JPEG, PNG & GIF files are allowed";
|
||||||
|
}
|
||||||
|
|
||||||
|
$img->moveTo($targetFile);
|
||||||
|
|
||||||
|
return array("imgLocation" => $targetFile);
|
||||||
|
}
|
||||||
|
}
|
@ -27,7 +27,7 @@ class middleware
|
|||||||
* Constructor for middleware
|
* Constructor for middleware
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function __construct(App $app)
|
public function __construct(App $app)
|
||||||
{
|
{
|
||||||
$this->baseMiddleware($app);
|
$this->baseMiddleware($app);
|
||||||
$this->sameSiteConfig($app);
|
$this->sameSiteConfig($app);
|
||||||
@ -40,7 +40,7 @@ class middleware
|
|||||||
* Base middleware
|
* Base middleware
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function baseMiddleware(App $app): void
|
public function baseMiddleware(App $app): void
|
||||||
{
|
{
|
||||||
$app->addBodyParsingMiddleware();
|
$app->addBodyParsingMiddleware();
|
||||||
$app->addRoutingMiddleware();
|
$app->addRoutingMiddleware();
|
||||||
@ -50,7 +50,7 @@ class middleware
|
|||||||
* SameSite Cookie Configuration
|
* SameSite Cookie Configuration
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function sameSiteConfig(App $app): void
|
public function sameSiteConfig(App $app): void
|
||||||
{
|
{
|
||||||
$ssConfig = new SameSiteCookieConfiguration(["same_site" => "strict"]);
|
$ssConfig = new SameSiteCookieConfiguration(["same_site" => "strict"]);
|
||||||
$app->add(new SameSiteCookieMiddleware($ssConfig));
|
$app->add(new SameSiteCookieMiddleware($ssConfig));
|
||||||
@ -60,7 +60,7 @@ class middleware
|
|||||||
* Return all responses as JSON
|
* Return all responses as JSON
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function returnAsJSON(App $app): void
|
public function returnAsJSON(App $app): void
|
||||||
{
|
{
|
||||||
$app->add(function ($request, $handler)
|
$app->add(function ($request, $handler)
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ class middleware
|
|||||||
* JWT Authentication
|
* JWT Authentication
|
||||||
* @param App $app - Slim App
|
* @param App $app - Slim App
|
||||||
*/
|
*/
|
||||||
function jwtAuth(App $app): void
|
public function jwtAuth(App $app): void
|
||||||
{
|
{
|
||||||
$jwtSecret = getSecretKey();
|
$jwtSecret = getSecretKey();
|
||||||
$app->add(new JwtAuthentication([
|
$app->add(new JwtAuthentication([
|
||||||
@ -90,14 +90,18 @@ class middleware
|
|||||||
"error" => function ($response)
|
"error" => function ($response)
|
||||||
{
|
{
|
||||||
session_destroy();
|
session_destroy();
|
||||||
$response->getBody()->write(json_encode(array("status" => "401", "message" =>
|
$response->getBody()->write(json_encode(array("status" => "401", "message" =>
|
||||||
"Unauthorized, please provide a valid token")));
|
"Unauthorized, please provide a valid token")));
|
||||||
return $response->withStatus(401);
|
return $response->withStatus(401);
|
||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorHandling(App $app): void
|
/**
|
||||||
|
* Error handling
|
||||||
|
* @param App $app - Slim App
|
||||||
|
*/
|
||||||
|
public function errorHandling(App $app): void
|
||||||
{
|
{
|
||||||
$app->add(function (ServerRequestInterface $request, RequestHandlerInterface $handler)
|
$app->add(function (ServerRequestInterface $request, RequestHandlerInterface $handler)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
this is a test
|
this is a test
|
||||||
<script src="/blog/index.js"></script>
|
<script src="/blog/js/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -145,7 +145,7 @@ form .formControl {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: flex-start;
|
/*align-items: flex-start;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
form .formControl.passwordControl {
|
form .formControl.passwordControl {
|
||||||
@ -156,7 +156,9 @@ form input[type="submit"] {
|
|||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
form .formControl input:not([type="submit"]), form .formControl textarea {
|
form .formControl input:not([type="submit"]), form .formControl textarea,
|
||||||
|
form .formControl .ck.ck-editor__top .ck-sticky-panel .ck-toolbar,
|
||||||
|
form .formControl .ck.ck-editor__main .ck-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 4px solid var(--primaryDefault);
|
border: 4px solid var(--primaryDefault);
|
||||||
background: none;
|
background: none;
|
||||||
|
@ -4,7 +4,7 @@ textarea {
|
|||||||
resize: none;
|
resize: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
section#curriculumVitae, section#projects {
|
main.editor section {
|
||||||
margin: 0 2em;
|
margin: 0 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,11 +40,11 @@ div.editorContainer > *, div.projectsGrid > * {
|
|||||||
width: 45%;
|
width: 45%;
|
||||||
}
|
}
|
||||||
|
|
||||||
section#projects {
|
main.editor section {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
section#curriculumVitae {
|
section#addPost {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,12 +224,31 @@ section#projects form.projItem.editing div.linkContainer {
|
|||||||
|
|
||||||
section#projects form.projItem:not(.editing) div.formControl.projectTitleContainer input {
|
section#projects form.projItem:not(.editing) div.formControl.projectTitleContainer input {
|
||||||
font-size: 1.17em;
|
font-size: 1.17em;
|
||||||
/*margin: 1em 0;*/
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
section#projects form.projItem:not(.editing) div.formControl.projectTitleContainer input,
|
section#projects form.projItem:not(.editing) div.formControl.projectTitleContainer input,
|
||||||
section#projects form.projItem:not(.editing) div.formControl.infoContainer textarea{
|
section#projects form.projItem:not(.editing) div.formControl.infoContainer textarea {
|
||||||
color: #000000;
|
color: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section#addPost form {
|
||||||
|
margin: auto 4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
form .formControl .ck.ck-editor__top .ck-sticky-panel .ck-toolbar {
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
border-bottom: 2px solid var(--mutedGrey);
|
||||||
|
box-shadow: 0 3px 4px var(--mutedBlack);
|
||||||
|
}
|
||||||
|
|
||||||
|
form .formControl .ck.ck-editor__main .ck-content {
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-top: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
form .formControl .ck-editor__editable {
|
||||||
|
min-height: 400px;
|
||||||
|
}
|
@ -66,8 +66,7 @@ div#login input[type=submit]{
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.error {
|
div.error, div.success {
|
||||||
background: var(--errorDefault);
|
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
padding: 0.5em 0.8em;
|
padding: 0.5em 0.8em;
|
||||||
-webkit-border-radius: 4px;
|
-webkit-border-radius: 4px;
|
||||||
@ -91,7 +90,15 @@ div.error {
|
|||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.error button {
|
div.error {
|
||||||
|
background: var(--errorDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.success {
|
||||||
|
background-color: var(--primaryHover);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.error button, div.success button {
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
@ -106,7 +113,7 @@ div.error button {
|
|||||||
top: 10px;
|
top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.error.hidden {
|
div.error.hidden, div.success.hidden {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
height: 0;
|
height: 0;
|
||||||
@ -114,7 +121,7 @@ div.error.hidden {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.error button:hover {
|
div.error button:hover, div.success button:hover {
|
||||||
text-shadow: -1px 2px var(--mutedBlack);
|
text-shadow: -1px 2px var(--mutedBlack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user