feat: add module-specific directory structure, routing, and environment security configuration

This commit is contained in:
Syariffullah
2026-06-13 11:23:17 +07:00
parent be05153168
commit 97d18dcabd
10 changed files with 88 additions and 90 deletions
+49
View File
@@ -0,0 +1,49 @@
# =============================================
# WebGIS — .htaccess (Root)
# Kompatibel dengan InfinityFree / Apache
# =============================================
# Set halaman index
DirectoryIndex index.html index.php
# Blokir akses ke file sensitif
<Files ".env">
Order allow,deny
Deny from all
</Files>
<Files "env_loader.php">
Order allow,deny
Deny from all
</Files>
<Files "db_connect.php">
Order allow,deny
Deny from all
</Files>
# Blokir akses ke file .sql
<FilesMatch "\.sql$">
Order allow,deny
Deny from all
</FilesMatch>
# Blokir akses ke file .gitignore dan .git
<FilesMatch "^\.(git|gitignore|env)">
Order allow,deny
Deny from all
</FilesMatch>
# Aktifkan kompres GZIP untuk performa
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json
</IfModule>
# Cache statis untuk performa
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
</IfModule>
+25 -10
View File
@@ -1,17 +1,32 @@
<?php <?php
$host = "localhost"; /**
$user = "root"; * Koneksi database terpusat — WebGIS
$pass = ""; * Semua subfolder (spbu/, jalan/, parsil/, poverty/api/) include file ini.
$db = "webgis_poverty"; *
* Untuk InfinityFree: ganti nilai di bawah dengan kredensial hosting.
* Untuk XAMPP lokal : nilai default sudah sesuai.
*/
// Coba koneksi ke server dan pilih database // ── Konfigurasi ──────────────────────────────────────────────
$conn = new mysqli($host, $user, $pass, $db); $host = getenv('DB_HOST') ?: 'localhost';
$port = (int)(getenv('DB_PORT') ?: 3306);
$user = getenv('DB_USER') ?: 'root';
$pass = getenv('DB_PASS') ?: '';
$db = getenv('DB_NAME') ?: 'webgis_poverty';
// ─────────────────────────────────────────────────────────────
$conn = new mysqli($host, $user, $pass, $db, $port);
if ($conn->connect_error) { if ($conn->connect_error) {
die("Koneksi gagal: " . $conn->connect_error); if (!headers_sent()) {
http_response_code(500);
header('Content-Type: application/json; charset=UTF-8');
}
die(json_encode([
'status' => 'error',
'message' => 'Koneksi database gagal: ' . $conn->connect_error,
]));
} }
// Set charset
$conn->set_charset("utf8mb4");
// Jika di-include oleh file API, biarkan $conn tersedia $conn->set_charset('utf8mb4');
?> ?>
+4 -4
View File
@@ -994,7 +994,7 @@
<div class="projects-grid"> <div class="projects-grid">
<!-- ===== PROJECT 1: POVERTY ===== --> <!-- ===== PROJECT 1: POVERTY ===== -->
<a <a
href="/webgis/poverty/index.php" href="poverty/index.php"
class="project-card" class="project-card"
id="card-poverty" id="card-poverty"
style="animation-delay: 0.05s" style="animation-delay: 0.05s"
@@ -1050,7 +1050,7 @@
<!-- ===== PROJECT 2: JALAN ===== --> <!-- ===== PROJECT 2: JALAN ===== -->
<a <a
href="/webgis/jalan/index.php" href="jalan/index.php"
class="project-card" class="project-card"
id="card-jalan" id="card-jalan"
style="animation-delay: 0.1s" style="animation-delay: 0.1s"
@@ -1102,7 +1102,7 @@
<!-- ===== PROJECT 3: PARSIL ===== --> <!-- ===== PROJECT 3: PARSIL ===== -->
<a <a
href="/webgis/parsil/index.php" href="parsil/index.php"
class="project-card" class="project-card"
id="card-parsil" id="card-parsil"
style="animation-delay: 0.15s" style="animation-delay: 0.15s"
@@ -1154,7 +1154,7 @@
<!-- ===== PROJECT 4: SPBU ===== --> <!-- ===== PROJECT 4: SPBU ===== -->
<a <a
href="/webgis/spbu/index.php" href="spbu/index.php"
class="project-card" class="project-card"
id="card-spbu" id="card-spbu"
style="animation-delay: 0.2s" style="animation-delay: 0.2s"
+2 -24
View File
@@ -1,26 +1,4 @@
<?php <?php
// Load konfigurasi dari file .env di root webgis/ // Gunakan koneksi terpusat dari root project
require_once dirname(__DIR__) . '/env_loader.php'; require_once dirname(__DIR__) . '/db_connect.php';
$host = env('DB_HOST', 'localhost');
$port = (int) env('DB_PORT', 3306);
$user = env('DB_USER', 'root');
$pass = env('DB_PASS', '');
$db = env('DB_NAME', 'webgis_poverty');
// Koneksi ke MySQL/MariaDB
$conn = new mysqli($host, $user, $pass, $db, $port);
if ($conn->connect_error) {
http_response_code(500);
die(json_encode([
'status' => 'error',
'message' => 'Koneksi database gagal: ' . $conn->connect_error,
]));
}
// Set charset
$conn->set_charset('utf8mb4');
// Jika di-include oleh file API, biarkan $conn tersedia
?> ?>
+1 -1
View File
@@ -52,7 +52,7 @@
</button> </button>
<!-- Tombol Kembali ke Beranda --> <!-- Tombol Kembali ke Beranda -->
<a href="/webgis/index.html" class="btn-back-home" title="Kembali ke Beranda"> <a href="../index.html" class="btn-back-home" title="Kembali ke Beranda">
<i class="fas fa-arrow-left"></i> <i class="fas fa-arrow-left"></i>
<span>Beranda</span> <span>Beranda</span>
</a> </a>
+2 -24
View File
@@ -1,26 +1,4 @@
<?php <?php
// Load konfigurasi dari file .env di root webgis/ // Gunakan koneksi terpusat dari root project
require_once dirname(__DIR__) . '/env_loader.php'; require_once dirname(__DIR__) . '/db_connect.php';
$host = env('DB_HOST', 'localhost');
$port = (int) env('DB_PORT', 3306);
$user = env('DB_USER', 'root');
$pass = env('DB_PASS', '');
$db = env('DB_NAME', 'webgis_poverty');
// Koneksi ke MySQL/MariaDB
$conn = new mysqli($host, $user, $pass, $db, $port);
if ($conn->connect_error) {
http_response_code(500);
die(json_encode([
'status' => 'error',
'message' => 'Koneksi database gagal: ' . $conn->connect_error,
]));
}
// Set charset
$conn->set_charset('utf8mb4');
// Jika di-include oleh file API, biarkan $conn tersedia
?> ?>
+1 -1
View File
@@ -52,7 +52,7 @@
</button> </button>
<!-- Tombol Kembali ke Beranda --> <!-- Tombol Kembali ke Beranda -->
<a href="/webgis/index.html" class="btn-back-home" title="Kembali ke Beranda"> <a href="../index.html" class="btn-back-home" title="Kembali ke Beranda">
<i class="fas fa-arrow-left"></i> <i class="fas fa-arrow-left"></i>
<span>Beranda</span> <span>Beranda</span>
</a> </a>
+1 -1
View File
@@ -1,6 +1,6 @@
<?php <?php
header("Content-Type: application/json; charset=UTF-8"); header("Content-Type: application/json; charset=UTF-8");
require_once('../poverty/api/auth_helper.php'); require_once(dirname(__DIR__) . '/poverty/api/auth_helper.php');
requireAdmin(); requireAdmin();
include_once('db_connect.php'); include_once('db_connect.php');
+2 -24
View File
@@ -1,26 +1,4 @@
<?php <?php
// Load konfigurasi dari file .env di root webgis/ // Gunakan koneksi terpusat dari root project
require_once dirname(__DIR__) . '/env_loader.php'; require_once dirname(__DIR__) . '/db_connect.php';
$host = env('DB_HOST', 'localhost');
$port = (int) env('DB_PORT', 3306);
$user = env('DB_USER', 'root');
$pass = env('DB_PASS', '');
$db = env('DB_NAME', 'webgis_poverty');
// Koneksi ke MySQL/MariaDB
$conn = new mysqli($host, $user, $pass, $db, $port);
if ($conn->connect_error) {
http_response_code(500);
die(json_encode([
'status' => 'error',
'message' => 'Koneksi database gagal: ' . $conn->connect_error,
]));
}
// Set charset
$conn->set_charset('utf8mb4');
// Jika di-include oleh file API, biarkan $conn tersedia
?> ?>
+1 -1
View File
@@ -52,7 +52,7 @@
</button> </button>
<!-- Tombol Kembali ke Beranda --> <!-- Tombol Kembali ke Beranda -->
<a href="/webgis/index.html" class="btn-back-home" title="Kembali ke Beranda"> <a href="../index.html" class="btn-back-home" title="Kembali ke Beranda">
<i class="fas fa-arrow-left"></i> <i class="fas fa-arrow-left"></i>
<span>Beranda</span> <span>Beranda</span>
</a> </a>