2021-03-01 02:04:54 +01:00
|
|
|
<?php
|
2021-03-25 22:05:32 +01:00
|
|
|
require __DIR__ . "/vendor/autoload.php";
|
|
|
|
|
2021-03-01 02:04:54 +01:00
|
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
|
use Slim\Factory\AppFactory;
|
|
|
|
use Slim\Views\Twig;
|
|
|
|
use Slim\Views\TwigMiddleware;
|
|
|
|
|
2021-03-25 00:59:28 +01:00
|
|
|
include "brain/controller/IndexControl.inc.php";
|
|
|
|
include "brain/controller/DashControl.inc.php";
|
2021-03-25 22:05:32 +01:00
|
|
|
include "brain/data/Auth.inc.php";
|
2021-03-01 02:04:54 +01:00
|
|
|
|
|
|
|
$app = AppFactory::create();
|
2021-03-25 22:05:32 +01:00
|
|
|
$twig = Twig::create("brain/views/");
|
2021-03-01 02:04:54 +01:00
|
|
|
$app->add(TwigMiddleware::create($app, $twig));
|
|
|
|
|
|
|
|
//Index
|
2021-03-25 00:59:28 +01:00
|
|
|
$app->get("/[{first}[/{second}]]", function (
|
|
|
|
Request $request,
|
|
|
|
Response $response,
|
|
|
|
array $args
|
|
|
|
) {
|
|
|
|
$view = Twig::fromRequest($request);
|
|
|
|
if (isset($args["first"])) {
|
|
|
|
$first = $args["first"];
|
|
|
|
if (is_numeric($first)) {
|
|
|
|
$response->getBody()->write("FIND A PAGE, B!");
|
|
|
|
} else {
|
|
|
|
//$response->getBody()->write("This is the dash, brah!");
|
|
|
|
|
2021-03-25 22:05:32 +01:00
|
|
|
if ($first == "dashboard") {
|
|
|
|
if (isset($args["second"])) {
|
|
|
|
$section = $args["second"];
|
|
|
|
} else {
|
|
|
|
$section = "index";
|
|
|
|
}
|
2021-03-25 00:59:28 +01:00
|
|
|
|
2021-03-25 22:05:32 +01:00
|
|
|
$dash = new DashControl();
|
|
|
|
$pages = $dash->getPages($section);
|
2021-03-25 00:59:28 +01:00
|
|
|
|
2021-03-25 22:05:32 +01:00
|
|
|
$count = count($pages);
|
2021-03-25 00:59:28 +01:00
|
|
|
|
2021-03-25 22:05:32 +01:00
|
|
|
//$response->getBody()->write("There are " . $count . " pages, champ");
|
|
|
|
$auth = new Auth();
|
|
|
|
return $view->render($response, "dash/start.twig", [
|
|
|
|
"title" => "Fipamo Dash",
|
|
|
|
"status" => $auth->sessionStatus(),
|
|
|
|
"pages" => $pages,
|
|
|
|
"totalPages" => $count,
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
}
|
2021-03-01 02:04:54 +01:00
|
|
|
}
|
2021-03-25 00:59:28 +01:00
|
|
|
} else {
|
|
|
|
$response->getBody()->write("No Params, Homie!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($args["second"])) {
|
|
|
|
$year = $args["second"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $response;
|
2021-03-01 02:04:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
//Dashboard Index
|
|
|
|
/**
|
|
|
|
$app->get('/@/dashboard', function (Request $request, Response $response) {
|
2021-03-25 22:05:32 +01:00
|
|
|
$index = new IndexControl();
|
|
|
|
$settings = new Settings();
|
|
|
|
$folks = $settings->getFolks();
|
|
|
|
$secret = $index->getSecret();
|
|
|
|
$view = Twig::fromRequest($request);
|
|
|
|
|
|
|
|
return $view->render($response, 'index.twig', [
|
|
|
|
'title' => 'This is Fipamo',
|
|
|
|
'name' => 'Ro',
|
|
|
|
'occupation'=>'pretty cool... I guess',
|
|
|
|
'folks' => $folks[0]['handle'],
|
|
|
|
'secret' => $secret
|
|
|
|
]);
|
2021-03-01 02:04:54 +01:00
|
|
|
});
|
|
|
|
**/
|
2021-03-25 00:59:28 +01:00
|
|
|
$app->run();
|