add this to git finally

This commit is contained in:
2025-05-19 12:51:46 +03:00
parent 7a8e69d87d
commit 11b7696c19
13 changed files with 760 additions and 0 deletions

49
index.php Normal file
View File

@ -0,0 +1,49 @@
<?php
include_once 'database.php';
$request = $_SERVER['REQUEST_URI'];
$path = parse_url($request, PHP_URL_PATH);
if (isset($_COOKIE["user_id"])) {
error_log('cookie is set', 0);
} else {
error_log('cookie is NOT set', 0);
$ids = initializeApp(null);
setcookie("user_id", $ids["user_id"], time() + 3600, "/");
setcookie("db_file", $ids["db_file"], time() + 3600, "/");
$_COOKIE["user_id"] = $ids["user_id"];
$_COOKIE["db_file"] = $ids["db_file"];
}
/* TODO: remove for prod code */
$file_path = __DIR__.$request;
$extension = pathinfo($file_path, PATHINFO_EXTENSION);
if ($extension === 'css') {
header('Content-Type: text/css');
readfile($file_path);
exit;
}
/* TODO: remove for prod code */
switch($path) {
case '': case '/': case '/products':
require __DIR__.'/products.php';
break;
case '/login':
require __DIR__.'/login.php';
break;
case '/register':
require __DIR__.'/register.php';
break;
case '/logout':
require __DIR__.'/logout.php';
break;
case '/orders':
require __DIR__.'/orders.php';
break;
case '/users':
require __DIR__.'/users.php';
break;
}
?>