diff --git a/.env b/.env index 831e36579fee329d96662ae6ae2971ee1bd40d14..4f70e3d709b67de83b9b0e8839b00c9e34ba876c 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ -POSTGRES_USER="postgres" -POSTGRES_PASSWORD="postgres" -POSTGRES_DB="labpro" \ No newline at end of file +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres +POSTGRES_DB=labpro +POSTGRES_HOST=db \ No newline at end of file diff --git a/README.md b/README.md index 18d4abbab8fd9125e78e6146673101acefef98aa..8c16d522172a21d4bbf2990f707109bd1d28fe50 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ - [Cara Instalasi](#cara-instalasi) - [Cara Menjalankan Server](#cara-menjalankan-server) - [Screenshot Tampilan Aplikasi](#screenshot-tampilan-aplikasi) -- [Entity Relationship Diagram](#entity-relationship-diagram) - [Pembagian Tugas](#pembagian-tugas) ## Deskripsi Aplikasi Web @@ -67,9 +66,81 @@ Pengguna dapat mengakses berbagai modul dan materi pembelajaran yang terdapat da  +### Pop Up + + + ### Search, Sort, dan Filter  +### Enroll + + + +### Add Course + + + +### Not-Found + + + +### Search Page + + + +### Lighthous + + + + + + + + + + ## Pembagian Tugas + +### _Server Side_ + +| Fitur | NIM | +| ------------------------------| -------- | +| Database and Container Setup | 13521139 | +| Routing | 13521139 | +| Login | 13521139, 13521161 | +| Register | 13521139, 13521161 | +| Update Profile | 13521164 | +| Admin CRUD List Courses | 13521139 | +| Admin CRUD List Users | 13521139 | +| Enroll Course Process | 13521139 | +| Add Module | 13521161 | +| CRUD Modules | 13521164 | +| CRUD Materials | 13521164 | +| Logout | 13521139 | +| Modals | 13521139 | +| Middleware | 13521139 | +| Not Found | 13521161 | + +### _Client Side_ + +| Fitur | NIM | +| ------------------------------------- | -------- | +| Login | 13521139, 13521161 | +| Register | 13521139, 13521161 | +| Homepage and Card Courses | 13521164 | +| Navbar | 13521139, 13521164 | +| Course Detail | 13521139, 13521164 | +| Module Detail | 13521164 | +| Material Detail (Accordion) | 13521164 | +| Not Found | 13521161 | +| Add Module | 13521164 | +| Admin Dashboard | 13521139 | +| Search Page | 13521139 | +| User List Admin | 13521139, 13521161 | +| Course List Admin | 13521139, 13521164 | +| Pagination, Search Bar, Filter, Sort | 13521161, 13521164 | +| Logout Popup | 13521164 | +| Popup Windows Add, Delete, Edit | 13521161, 13521164 | diff --git a/api/auth/login.php b/api/auth/login.php index 6e50ebd26fa141656c92f5699a996fbcd62e63fa..3e84db03e511a39964050a725b9e25d68f0b43ad 100644 --- a/api/auth/login.php +++ b/api/auth/login.php @@ -4,7 +4,8 @@ require_once("../../app/models/User.php"); require_once("../../app/core/Table.php"); require_once("../../config/config.php"); - + // $dotenv = DotEnv::getInstance(__DIR__. "/../../.env"); + // $dotenv->load(); $xml = file_get_contents('php://input'); $data = json_decode($xml, true); if(session_status() === PHP_SESSION_NONE){ diff --git a/api/auth/register.php b/api/auth/register.php index c67f48d6dd62c53fd6570fd9a4c4e7dd7fbc5ec3..f28d8b897019f6cfcd498b199ec03c4e022eaeca 100644 --- a/api/auth/register.php +++ b/api/auth/register.php @@ -4,6 +4,9 @@ require_once("../../app/core/Database.php"); require_once("../../app/models/User.php"); require_once("../../app/core/Table.php"); require_once("../../config/config.php"); + +// $dotenv = DotEnv::getInstance(__DIR__. "/../../.env"); +// $dotenv->load(); if(session_status() === PHP_SESSION_NONE){ session_start(); } diff --git a/app/core/App.php b/app/core/App.php index 0d18797dd331071b47ea6bb8b36430d7891b212d..b795779b65bdd778e778e06d50c70eb12ba28a2d 100644 --- a/app/core/App.php +++ b/app/core/App.php @@ -1,4 +1,4 @@ -<?php +<?php class App{ private $controllers; private $methods = 'index'; diff --git a/app/core/Database.php b/app/core/Database.php index 335b13fee38212b9d6732830b392add9bc0cb1c2..6da163c0dcf56d4e2af259aa4770fd0efb957e06 100644 --- a/app/core/Database.php +++ b/app/core/Database.php @@ -1,14 +1,18 @@ <?php class Database{ public static $instance; - private $host = "db"; - private $username = "postgres"; - private $password = "postgres"; - private $db = "labpro"; + private $host; + private $username; + private $password; + private $db; private $connection; private $port = 5432; private $stmt; public function __construct(){ + $this->host = getenv("POSTGRES_HOST"); + $this->username = getenv("POSTGRES_USER"); + $this->password = getenv("POSTGRES_PASSWORD"); + $this->db = getenv("POSTGRES_DB"); $dsn = "pgsql:host=" . $this->host . ";dbname=" . $this->db . ";user=" . $this->username . ";password=" . $this->password; try { $this->connection = new PDO($dsn); diff --git a/app/models/Course.php b/app/models/Course.php index 74b28f51d2704074b16281e3030143ead4a59505..d44f0bfcee9cfc13fc2d2f45a0305cb61a1e2845 100644 --- a/app/models/Course.php +++ b/app/models/Course.php @@ -56,7 +56,6 @@ require_once(__DIR__."/Model.php"); public function searchCourses($data){ $query = "SELECT * FROM courses "; $search = false; - if(isset($data["title"])){ $query.= "WHERE (LOWER(title) LIKE :title OR LOWER(description) LIKE :title)"; $search = true; diff --git a/app/views/register/index.php b/app/views/register/index.php index 001a1695b8b17ed9814c805fad3128624a5364e3..40801598397ec234e88c788126974966ee90cac2 100644 --- a/app/views/register/index.php +++ b/app/views/register/index.php @@ -36,7 +36,7 @@ id="username-input" name="username" class="login-input" - onkeyup="check_username_debounce()" + onkeyup="check_username()" required /> </div> diff --git a/config/config.php b/config/config.php index f50d10b3bb133765431a04ca8cd4cd07abd05ec9..4cf8fc1bf7d6b0885c4cf70eb968dd313f03e16d 100644 --- a/config/config.php +++ b/config/config.php @@ -1,3 +1,6 @@ <?php - define("BASE_URL",__DIR__); + require_once("dotenv.php"); + $dir = __DIR__."/../.env"; + $dotenv = DotEnv::getInstance($dir); + $dotenv->load(); ?> \ No newline at end of file diff --git a/config/dotenv.php b/config/dotenv.php new file mode 100644 index 0000000000000000000000000000000000000000..f489b9bcebe27c1b281b01e8ed8f49f8785a0641 --- /dev/null +++ b/config/dotenv.php @@ -0,0 +1,49 @@ +<?php + class DotEnv + { + private static $instance; + protected $path; + + private function __construct(string $path) + { + if (!file_exists($path)) { + throw new InvalidArgumentException(sprintf("File doesn't exists")); + } + $this->path = $path; + } + + public static function getInstance(string $path) + { + if (!self::$instance) { + self::$instance = new self($path); + } + return self::$instance; + } + public function load(){ + if(!is_readable($this->path)){ + throw new RuntimeException(sprintf("File is not readable!")); + } + $lines = file($this->path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach ($lines as $line) { + + if (strpos(trim($line), '#') === 0) { + continue; + } + + list($name, $value) = explode('=', $line, 2); + $name = trim($name); + $value = trim($value); + + if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) { + putenv(sprintf('%s=%s', $name, $value)); + $_ENV[$name] = $value; + $_SERVER[$name] = $value; + } + } + define('POSTGRES_USER', getenv('POSTGRES_USER')); + define('POSTGRES_PASSWORD',getenv("POSTGRES_PASSWORD")); + define('POSTGRES_DB',getenv("POSTGRES_DB")); + define('POSTGRES_HOST',getenv("POSTGRES_HOST")); + } + }; +?> \ No newline at end of file diff --git a/index.php b/index.php index 2d4017d1e23562e8580e8f415bd0cd437620724b..dd494dfe204782a6994ea087494ad4471dd2f4af 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,6 @@ <?php - session_start(); - require_once("app/init.php"); + define("BASE_URL",__DIR__); + session_start(); require_once("config/config.php"); + require_once("app/init.php"); ?> \ No newline at end of file diff --git a/public/file/.gitkeep b/public/file/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/public/image/course/Screenshot(740).png b/public/image/course/Screenshot(740).png new file mode 100644 index 0000000000000000000000000000000000000000..1e2ccfe2c47b3ba5d8926d7bbc3cc85235d9fc88 Binary files /dev/null and b/public/image/course/Screenshot(740).png differ diff --git a/public/image/course/Screenshot2023-10-14141641.png b/public/image/course/Screenshot2023-10-14141641.png new file mode 100644 index 0000000000000000000000000000000000000000..31de82f8b35b133336b10d86f00cf4e90714db41 Binary files /dev/null and b/public/image/course/Screenshot2023-10-14141641.png differ diff --git a/public/image/profile/course.jpg b/public/image/profile/course.jpg new file mode 100644 index 0000000000000000000000000000000000000000..19bd9625054e41c5521a38adb2fbd1535b7d3b90 Binary files /dev/null and b/public/image/profile/course.jpg differ diff --git a/public/js/login.js b/public/js/login.js index 3e008d8cff4ac8d8bbb5f429ebabb3ba5bd33dd5..a3d54d563d9cb277e7f8359dcb9ced3e221cf60c 100644 --- a/public/js/login.js +++ b/public/js/login.js @@ -16,6 +16,7 @@ const check_username = () => { const xml = new XMLHttpRequest(); xml.open("POST", "/api/auth/login.php"); xml.onload = function () { + console.log(this); if (this.status == 200) { let response = JSON.parse(this.responseText); if (response.status === "success") { diff --git a/screenshot/courses-lighthouse.png b/screenshot/courses-lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..a1a79d3ba428625f2a0f197a2758257b0f0568ac Binary files /dev/null and b/screenshot/courses-lighthouse.png differ diff --git a/screenshot/homepage-lighthouse.png b/screenshot/homepage-lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..4786b0aa53260d1882fe095d4bf68b775b4c5896 Binary files /dev/null and b/screenshot/homepage-lighthouse.png differ diff --git a/screenshot/login-lighthouse.png b/screenshot/login-lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..9a6acc85d1aed87ddf9c79235908d099b6308549 Binary files /dev/null and b/screenshot/login-lighthouse.png differ diff --git a/screenshot/module-lighthouse.png b/screenshot/module-lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..eb134f0273940638a76825dcfaabc58d5b63018e Binary files /dev/null and b/screenshot/module-lighthouse.png differ diff --git a/screenshot/mycourse-lighthouse.png b/screenshot/mycourse-lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..f18a6a3136517497d7ac5f1928f678b86bedf480 Binary files /dev/null and b/screenshot/mycourse-lighthouse.png differ diff --git a/screenshot/profile-lighthouse.png b/screenshot/profile-lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..c9471ec190a9ec808de3696d0954fb73e6c02d67 Binary files /dev/null and b/screenshot/profile-lighthouse.png differ diff --git a/screenshot/search-lighthouse.png b/screenshot/search-lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..b8d122699517f8406ef9eea71a80be02c9b2dde4 Binary files /dev/null and b/screenshot/search-lighthouse.png differ diff --git a/screenshot/users-lighthouse.png b/screenshot/users-lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..c79899fc6a2e350303afebac724557a311c524c7 Binary files /dev/null and b/screenshot/users-lighthouse.png differ