feat: add module-specific directory structure, routing, and environment security configuration
This commit is contained in:
@@ -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
@@ -1,17 +1,32 @@
|
||||
<?php
|
||||
$host = "localhost";
|
||||
$user = "root";
|
||||
$pass = "";
|
||||
$db = "webgis_poverty";
|
||||
/**
|
||||
* Koneksi database terpusat — WebGIS
|
||||
* Semua subfolder (spbu/, jalan/, parsil/, poverty/api/) include file ini.
|
||||
*
|
||||
* Untuk InfinityFree: ganti nilai di bawah dengan kredensial hosting.
|
||||
* Untuk XAMPP lokal : nilai default sudah sesuai.
|
||||
*/
|
||||
|
||||
// Coba koneksi ke server dan pilih database
|
||||
$conn = new mysqli($host, $user, $pass, $db);
|
||||
// ── Konfigurasi ──────────────────────────────────────────────
|
||||
$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) {
|
||||
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
@@ -994,7 +994,7 @@
|
||||
<div class="projects-grid">
|
||||
<!-- ===== PROJECT 1: POVERTY ===== -->
|
||||
<a
|
||||
href="/webgis/poverty/index.php"
|
||||
href="poverty/index.php"
|
||||
class="project-card"
|
||||
id="card-poverty"
|
||||
style="animation-delay: 0.05s"
|
||||
@@ -1050,7 +1050,7 @@
|
||||
|
||||
<!-- ===== PROJECT 2: JALAN ===== -->
|
||||
<a
|
||||
href="/webgis/jalan/index.php"
|
||||
href="jalan/index.php"
|
||||
class="project-card"
|
||||
id="card-jalan"
|
||||
style="animation-delay: 0.1s"
|
||||
@@ -1102,7 +1102,7 @@
|
||||
|
||||
<!-- ===== PROJECT 3: PARSIL ===== -->
|
||||
<a
|
||||
href="/webgis/parsil/index.php"
|
||||
href="parsil/index.php"
|
||||
class="project-card"
|
||||
id="card-parsil"
|
||||
style="animation-delay: 0.15s"
|
||||
@@ -1154,7 +1154,7 @@
|
||||
|
||||
<!-- ===== PROJECT 4: SPBU ===== -->
|
||||
<a
|
||||
href="/webgis/spbu/index.php"
|
||||
href="spbu/index.php"
|
||||
class="project-card"
|
||||
id="card-spbu"
|
||||
style="animation-delay: 0.2s"
|
||||
|
||||
+2
-24
@@ -1,26 +1,4 @@
|
||||
<?php
|
||||
// Load konfigurasi dari file .env di root webgis/
|
||||
require_once dirname(__DIR__) . '/env_loader.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
|
||||
// Gunakan koneksi terpusat dari root project
|
||||
require_once dirname(__DIR__) . '/db_connect.php';
|
||||
?>
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
</button>
|
||||
|
||||
<!-- 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>
|
||||
<span>Beranda</span>
|
||||
</a>
|
||||
|
||||
+2
-24
@@ -1,26 +1,4 @@
|
||||
<?php
|
||||
// Load konfigurasi dari file .env di root webgis/
|
||||
require_once dirname(__DIR__) . '/env_loader.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
|
||||
// Gunakan koneksi terpusat dari root project
|
||||
require_once dirname(__DIR__) . '/db_connect.php';
|
||||
?>
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
</button>
|
||||
|
||||
<!-- 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>
|
||||
<span>Beranda</span>
|
||||
</a>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
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();
|
||||
include_once('db_connect.php');
|
||||
|
||||
|
||||
+2
-24
@@ -1,26 +1,4 @@
|
||||
<?php
|
||||
// Load konfigurasi dari file .env di root webgis/
|
||||
require_once dirname(__DIR__) . '/env_loader.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
|
||||
// Gunakan koneksi terpusat dari root project
|
||||
require_once dirname(__DIR__) . '/db_connect.php';
|
||||
?>
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
</button>
|
||||
|
||||
<!-- 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>
|
||||
<span>Beranda</span>
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user