diff --git a/src/app/controllers/Page/ComposePage.php b/src/app/controllers/Page/ComposePage.php
index b9cae5a3d7e5924cc01f169b3ab7a64f8480f70f..b3ff610233a987ef30945c0e56bf1a3775d1c5d8 100644
--- a/src/app/controllers/Page/ComposePage.php
+++ b/src/app/controllers/Page/ComposePage.php
@@ -19,14 +19,7 @@ class ComposePage extends BaseController{
return self::$instance;
}
- public function post($urlParams)
- {
- $srv->compose();
- require PAGE_PATH . "/submission.php";
- exit();
- }
-
- public function get($urlParams)
+ protected function get($urlParams)
{
require PAGE_PATH . "/post.php";
exit();
diff --git a/src/app/controllers/Post/PostController.php b/src/app/controllers/Post/PostController.php
index 6416ee8f0ca996ea080b5c09c3c531a97df02144..3abd51571a151fb3f3b01c643e90a9a51e1e5fdb 100644
--- a/src/app/controllers/Post/PostController.php
+++ b/src/app/controllers/Post/PostController.php
@@ -86,7 +86,7 @@ class PostController extends BaseController
}
}
- public function compose()
+ protected function compose()
{
$resources = [];
@@ -110,4 +110,11 @@ class PostController extends BaseController
$resources
);
}
+
+ protected function post($urlParams)
+ {
+ $this->compose();
+ require PAGE_PATH . "/submission.php";
+ exit();
+ }
}
\ No newline at end of file
diff --git a/src/app/core/fileAccess.php b/src/app/core/fileAccess.php
index 7c0181ae712288c531d64c8e840f82e0ce1200da..ecc7381348090e5c65be1e228b3c15084dd69cc3 100644
--- a/src/app/core/fileAccess.php
+++ b/src/app/core/fileAccess.php
@@ -81,12 +81,13 @@ class FileAccess
$newfilename = md5(uniqid(mt_rand(), true)) . (SUPPORTED_FILES[$filetype])[$mimetype];
} while (file_exists($newDir . $filename));
- $success = move_uploaded_file($filename, $newDir . $newfilename);
+ $newfilepath = $newDir . $newfilename;
+ $success = move_uploaded_file($filename, $newfilepath);
if (!$success) {
throw new LoggedException('Internal Server Error', 500);
}
- return $newfilename;
+ return $newfilepath;
}
/**
diff --git a/src/app/router/Router.php b/src/app/router/Router.php
index 87503aa97cf7a37f235aec3842b0721e19611a69..af4770fdb6ebde70df53e08b0a3e13f4f1bd4798 100644
--- a/src/app/router/Router.php
+++ b/src/app/router/Router.php
@@ -47,8 +47,13 @@ class Router {
echo $value[0]->handle($method, $match[1]);
exit();
}
+ else {
+ header("Location: /");
+ exit();
+ }
}
}
+ header("Location: /");
throw new MethodNotAllowedException("Method not allowed");
}
diff --git a/src/app/view/home.php b/src/app/view/home.php
index b597546e082dc329e413b5916f083c0994706341..60decc68a9728dea609f33baa92832fe4a56e7f1 100644
--- a/src/app/view/home.php
+++ b/src/app/view/home.php
@@ -5,24 +5,24 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
- <link rel="stylesheet" href="home.css" />
+ <link rel="stylesheet" href="/public/css/home.css" />
</head>
<body>
<div class="layout">
<div class="layout__left-sidebar">
- <img src="../../public/assets/github.png" class="brand" />
+ <img src="/public/assets/github.png" class="brand" />
<div class="sidebar-menu">
<div class="sidebar-menu__item sidebar-menu__item--active">
- <img src="home.svg" class="sidebar-menu__item-icon" />
+ <img src="/public/assets/home.svg" class="sidebar-menu__item-icon" />
Home
</div>
<div class="sidebar-menu__item">
- <img src="followed.jpg" class="sidebar-menu__item-icon" />
+ <img src="/public/assets/followed.jpg" class="sidebar-menu__item-icon" />
Followed
</div>
<div class="sidebar-menu__item">
- <img src="profile.svg" class="sidebar-menu__item-icon" />
+ <img src="/public/assets/profile.svg" class="sidebar-menu__item-icon" />
Profile
</div>
</div>
diff --git a/src/index.php b/src/index.php
index 47bb4bcc053b35014df5152dd292e95fff91e15c..5b0158e2bafd141ece65c39fa59e6a7d61ebec37 100644
--- a/src/index.php
+++ b/src/index.php
@@ -15,6 +15,7 @@ require_once CONTROLLER_PATH . "/Admin/BanController.php";
require_once CONTROLLER_PATH . "/Admin/UnbanController.php";
require_once CONTROLLER_PATH . "/Admin/SetAdmin.php";
+require_once CONTROLLER_PATH . "/Page/HomePage.php";
require_once CONTROLLER_PATH . "/Page/LoginPage.php";
require_once CONTROLLER_PATH . "/Page/ComposePage.php";
require_once CONTROLLER_PATH . "/Page/SettingsPage.php";
@@ -31,11 +32,12 @@ $router->addHandler("/api/ban", BanController::getInstance(), []);
$router->addHandler("/api/unban", UnbanController::getInstance(), []);
$router->addHandler("/api/setadmin", SetAdminController::getInstance(), []);
+$router->addHandler("/", HomePage::getInstance(), []);
$router->addHandler("/login", LoginPage::getInstance(), []);
$router->addHandler("/compose/kicau", ComposePage::getInstance(), []);
+$router->addHandler("/compose/create", PostController::getInstance(), []);
$router->addHandler("/*", UserPage::getInstance(), []);
$router->addHandler("/settings/*", SettingsPage::getInstance(), []);
$router->addHandler("/admin/*", AdminPage::getInstance(), []);
-$router->addHandler("/compose/kicau/*", ComposePage::getInstance(), []);
$router->run($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
\ No newline at end of file