commit 534d2d926deb5a2ac9207f76b097425932887569 Author: Januar Date: Sat Jun 13 11:51:34 2026 +0700 Initial commit - SIG Bansos diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ea7761d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +.gitignore +README.md \ No newline at end of file diff --git a/login.html b/login.html new file mode 100644 index 0000000..65705f0 --- /dev/null +++ b/login.html @@ -0,0 +1,80 @@ + + + + + + SIG Bansos - Login + + + + + +
+
+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..d990d80 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name _; + root /app; + index index.html; + + location / { + try_files $uri $uri/ =404; + } + + location /sig-jalan/ { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} \ No newline at end of file diff --git a/nixpacks.toml.toml b/nixpacks.toml.toml new file mode 100644 index 0000000..f57f583 --- /dev/null +++ b/nixpacks.toml.toml @@ -0,0 +1,14 @@ +[providers] +type = "php" + +[phases.setup] +nixPkgs = ["php", "php82Extensions.mysqli", "php82Extensions.pdo", "php82Extensions.pdo_mysql"] + +[phases.build] +cmds = [] + +[phases.install] +cmds = [] + +[start] +cmd = "php-fpm -D && nginx -g 'daemon off;'" \ No newline at end of file diff --git a/sig-bansos/DASHBOARD ADMIN.html b/sig-bansos/DASHBOARD ADMIN.html new file mode 100644 index 0000000..1ad98b5 --- /dev/null +++ b/sig-bansos/DASHBOARD ADMIN.html @@ -0,0 +1,142 @@ + + + + + + SIG Bansos - Dashboard Admin + + + + + + + + + + + + +
+
+
+
+

0

+

Orang Berkebutuhan

+
+
+
+
+

0

+

Tempat Ibadah

+
+
+ + +
+ +
+
+
+ Legenda: + Orang + Masjid + Gereja + Klenteng + Vihara + Pura +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/sig-bansos/ORANG BERKEBUTUHAN.html b/sig-bansos/ORANG BERKEBUTUHAN.html new file mode 100644 index 0000000..f87d4ed --- /dev/null +++ b/sig-bansos/ORANG BERKEBUTUHAN.html @@ -0,0 +1,274 @@ + + + + + + SIG Bansos - Orang Berkebutuhan + + + + + + + + + + +
+
+

SIG Bansos - Orang Berkebutuhan

+ +
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/sig-bansos/PENGGUNA UMUM.html b/sig-bansos/PENGGUNA UMUM.html new file mode 100644 index 0000000..488ff8a --- /dev/null +++ b/sig-bansos/PENGGUNA UMUM.html @@ -0,0 +1,236 @@ + + + + + + SIG Bansos - Pengguna Umum + + + + + + + + +
+
+

SIG Bantuan Sosial - Peta Persebaran

+ Pengguna Umum +
+ + +
+
+
+

0

+

Orang Berkebutuhan

+
+
+
+
+

0

+

Tempat Ibadah

+
+
+
+
+ Legenda: +
+
+
Orang Berkebutuhan
+
Masjid
+
Gereja
+
+
+
Klenteng
+
Vihara
+
Pura
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/sig-bansos/RUMAH IBADAT.html b/sig-bansos/RUMAH IBADAT.html new file mode 100644 index 0000000..280d45a --- /dev/null +++ b/sig-bansos/RUMAH IBADAT.html @@ -0,0 +1,329 @@ + + + + + + SIG Bansos - Tempat Ibadah + + + + + + + + + + +
+
+

SIG Bansos - Tempat Ibadah

+ +
+
+
+
+
+ + + + + + +
+
+
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/sig-jalan/api.php b/sig-jalan/api.php new file mode 100644 index 0000000..5cd90da --- /dev/null +++ b/sig-jalan/api.php @@ -0,0 +1,300 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => 'Database connection failed: ' . $e->getMessage()]); + exit(); +} + +// Get request parameters +$type = isset($_GET['type']) ? $_GET['type'] : ''; +$action = isset($_GET['action']) ? $_GET['action'] : ''; +$id = isset($_GET['id']) ? intval($_GET['id']) : null; +$method = $_SERVER['REQUEST_METHOD']; + +// Map type to table name +$tables = [ + 'spbu' => 'spbu', + 'jalan' => 'jalan', + 'parsil' => 'parsil', + 'rusak' => 'jalan_rusak' +]; + +if (!isset($tables[$type])) { + echo json_encode(['success' => false, 'message' => 'Invalid type']); + exit(); +} + +$table = $tables[$type]; + +// Handle different actions +switch ($action) { + case 'getAll': + getAll($pdo, $table); + break; + case 'getOne': + getOne($pdo, $table, $id); + break; + case 'create': + if ($method === 'POST') { + create($pdo, $table, $type); + } + break; + case 'update': + if ($method === 'PUT') { + update($pdo, $table, $type, $id); + } + break; + case 'delete': + if ($method === 'DELETE') { + delete($pdo, $table, $id); + } + break; + case 'add': // Alias for create (SPBU) + if ($method === 'POST') { + create($pdo, $table, $type); + } + break; + default: + echo json_encode(['success' => false, 'message' => 'Invalid action']); +} + +// ==================== FUNCTIONS ==================== + +function getAll($pdo, $table) { + try { + if ($table === 'jalan' || $table === 'parsil') { + $stmt = $pdo->query("SELECT * FROM $table ORDER BY id DESC"); + $data = $stmt->fetchAll(PDO::FETCH_ASSOC); + + // Decode JSON coordinates + foreach ($data as &$row) { + if (isset($row['coordinates'])) { + $row['coordinates'] = json_decode($row['coordinates'], true); + } + } + } else { + $stmt = $pdo->query("SELECT * FROM $table ORDER BY id DESC"); + $data = $stmt->fetchAll(PDO::FETCH_ASSOC); + } + + echo json_encode(['success' => true, 'data' => $data]); + } catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + } +} + +function getOne($pdo, $table, $id) { + try { + $stmt = $pdo->prepare("SELECT * FROM $table WHERE id = ?"); + $stmt->execute([$id]); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($data) { + if (isset($data['coordinates'])) { + $data['coordinates'] = json_decode($data['coordinates'], true); + } + echo json_encode(['success' => true, 'data' => $data]); + } else { + echo json_encode(['success' => false, 'message' => 'Data not found']); + } + } catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + } +} + +function create($pdo, $table, $type) { + $input = json_decode(file_get_contents('php://input'), true); + + if (!$input) { + // Check if it's form-data (for file upload) + if ($type === 'rusak' && isset($_POST['nama'])) { + createRusak($pdo); + return; + } + echo json_encode(['success' => false, 'message' => 'No input data']); + return; + } + + try { + switch ($type) { + case 'spbu': + $stmt = $pdo->prepare("INSERT INTO spbu (nama, no_spbu, tipe, latitude, longitude) VALUES (?, ?, ?, ?, ?)"); + $stmt->execute([ + $input['nama'], + $input['no_spbu'], + $input['tipe'], + $input['latitude'], + $input['longitude'] + ]); + break; + + case 'jalan': + $coordinates = json_encode($input['coordinates']); + $stmt = $pdo->prepare("INSERT INTO jalan (nama, status, panjang, coordinates) VALUES (?, ?, ?, ?)"); + $stmt->execute([ + $input['nama'], + $input['status'], + $input['panjang'], + $coordinates + ]); + break; + + case 'parsil': + $coordinates = json_encode($input['coordinates']); + $stmt = $pdo->prepare("INSERT INTO parsil (nama, status, luas, coordinates) VALUES (?, ?, ?, ?)"); + $stmt->execute([ + $input['nama'], + $input['status'], + $input['luas'], + $coordinates + ]); + break; + } + + $newId = $pdo->lastInsertId(); + echo json_encode(['success' => true, 'message' => 'Data created successfully', 'id' => $newId]); + } catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + } +} + +function createRusak($pdo) { + try { + $nama = $_POST['nama']; + $latitude = $_POST['latitude']; + $longitude = $_POST['longitude']; + $fotoPath = ''; + + // Handle file upload + if (isset($_FILES['foto']) && $_FILES['foto']['error'] === UPLOAD_ERR_OK) { + $uploadDir = 'uploads/rusak/'; + if (!is_dir($uploadDir)) { + mkdir($uploadDir, 0777, true); + } + + $fileExtension = pathinfo($_FILES['foto']['name'], PATHINFO_EXTENSION); + $fileName = 'rusak_' . time() . '_' . uniqid() . '.' . $fileExtension; + $uploadPath = $uploadDir . $fileName; + + if (move_uploaded_file($_FILES['foto']['tmp_name'], $uploadPath)) { + $fotoPath = $uploadPath; + } + } + + $stmt = $pdo->prepare("INSERT INTO jalan_rusak (nama, latitude, longitude, foto) VALUES (?, ?, ?, ?)"); + $stmt->execute([$nama, $latitude, $longitude, $fotoPath]); + + $newId = $pdo->lastInsertId(); + echo json_encode(['success' => true, 'message' => 'Data created successfully', 'id' => $newId]); + } catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + } +} + +function update($pdo, $table, $type, $id) { + $input = json_decode(file_get_contents('php://input'), true); + + if (!$input) { + echo json_encode(['success' => false, 'message' => 'No input data']); + return; + } + + try { + switch ($type) { + case 'spbu': + $stmt = $pdo->prepare("UPDATE spbu SET nama=?, no_spbu=?, tipe=?, latitude=?, longitude=? WHERE id=?"); + $stmt->execute([ + $input['nama'], + $input['no_spbu'], + $input['tipe'], + $input['latitude'], + $input['longitude'], + $id + ]); + break; + + case 'jalan': + $coordinates = json_encode($input['coordinates']); + $stmt = $pdo->prepare("UPDATE jalan SET nama=?, status=?, panjang=?, coordinates=? WHERE id=?"); + $stmt->execute([ + $input['nama'], + $input['status'], + $input['panjang'], + $coordinates, + $id + ]); + break; + + case 'parsil': + $coordinates = json_encode($input['coordinates']); + $stmt = $pdo->prepare("UPDATE parsil SET nama=?, status=?, luas=?, coordinates=? WHERE id=?"); + $stmt->execute([ + $input['nama'], + $input['status'], + $input['luas'], + $coordinates, + $id + ]); + break; + + case 'rusak': + $stmt = $pdo->prepare("UPDATE jalan_rusak SET nama=?, latitude=?, longitude=? WHERE id=?"); + $stmt->execute([ + $input['nama'], + $input['latitude'], + $input['longitude'], + $id + ]); + break; + } + + echo json_encode(['success' => true, 'message' => 'Data updated successfully']); + } catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + } +} + +function delete($pdo, $table, $id) { + try { + // Delete associated file for rusak + if ($table === 'jalan_rusak') { + $stmt = $pdo->prepare("SELECT foto FROM jalan_rusak WHERE id = ?"); + $stmt->execute([$id]); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + if ($data && $data['foto'] && file_exists($data['foto'])) { + unlink($data['foto']); + } + } + + $stmt = $pdo->prepare("DELETE FROM $table WHERE id = ?"); + $stmt->execute([$id]); + + if ($stmt->rowCount() > 0) { + echo json_encode(['success' => true, 'message' => 'Data deleted successfully']); + } else { + echo json_encode(['success' => false, 'message' => 'Data not found']); + } + } catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + } +} +?> \ No newline at end of file diff --git a/sig-jalan/api_ibadah.php b/sig-jalan/api_ibadah.php new file mode 100644 index 0000000..55e2629 --- /dev/null +++ b/sig-jalan/api_ibadah.php @@ -0,0 +1,106 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => 'Database connection failed']); + exit(); +} + +$type = isset($_GET['type']) ? $_GET['type'] : ''; +$action = isset($_GET['action']) ? $_GET['action'] : ''; +$id = isset($_GET['id']) ? intval($_GET['id']) : null; +$method = $_SERVER['REQUEST_METHOD']; + +$validTypes = ['masjid', 'gereja', 'klenteng', 'vihara', 'pura']; + +if (!in_array($type, $validTypes)) { + echo json_encode(['success' => false, 'message' => 'Invalid type']); + exit(); +} + +$table = 'tempat_ibadah'; + +switch ($action) { + case 'getAll': + $stmt = $pdo->prepare("SELECT * FROM $table WHERE jenis = ? ORDER BY nama ASC"); + $stmt->execute([$type]); + $data = $stmt->fetchAll(PDO::FETCH_ASSOC); + echo json_encode(['success' => true, 'data' => $data]); + break; + + case 'getOne': + $stmt = $pdo->prepare("SELECT * FROM $table WHERE id = ? AND jenis = ?"); + $stmt->execute([$id, $type]); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + if ($data) { + echo json_encode(['success' => true, 'data' => $data]); + } else { + echo json_encode(['success' => false, 'message' => 'Data tidak ditemukan']); + } + break; + + case 'create': + if ($method === 'POST') { + $input = json_decode(file_get_contents('php://input'), true); + $stmt = $pdo->prepare("INSERT INTO $table (jenis, nama, alamat, no_hp, latitude, longitude, radius, keterangan) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt->execute([ + $type, + $input['nama'], + $input['alamat'] ?? '', + $input['no_hp'] ?? '', + $input['latitude'], + $input['longitude'], + $input['radius'] ?? 500, + $input['keterangan'] ?? '' + ]); + echo json_encode(['success' => true, 'message' => 'Data berhasil disimpan', 'id' => $pdo->lastInsertId()]); + } + break; + + case 'update': + if ($method === 'PUT') { + $input = json_decode(file_get_contents('php://input'), true); + $stmt = $pdo->prepare("UPDATE $table SET nama=?, alamat=?, no_hp=?, latitude=?, longitude=?, radius=?, keterangan=? WHERE id=? AND jenis=?"); + $stmt->execute([ + $input['nama'], + $input['alamat'] ?? '', + $input['no_hp'] ?? '', + $input['latitude'], + $input['longitude'], + $input['radius'] ?? 500, + $input['keterangan'] ?? '', + $id, + $type + ]); + echo json_encode(['success' => true, 'message' => 'Data berhasil diupdate']); + } + break; + + case 'delete': + if ($method === 'DELETE') { + $stmt = $pdo->prepare("DELETE FROM $table WHERE id = ?"); + $stmt->execute([$id]); + echo json_encode(['success' => true, 'message' => 'Data berhasil dihapus']); + } + break; + + default: + echo json_encode(['success' => false, 'message' => 'Invalid action']); +} +?> \ No newline at end of file diff --git a/sig-jalan/api_login.php b/sig-jalan/api_login.php new file mode 100644 index 0000000..89b1549 --- /dev/null +++ b/sig-jalan/api_login.php @@ -0,0 +1,55 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => 'Database connection failed']); + exit(); +} + +$action = isset($_GET['action']) ? $_GET['action'] : ''; + +if ($action === 'login' && $_SERVER['REQUEST_METHOD'] === 'POST') { + $input = json_decode(file_get_contents('php://input'), true); + + if (!$input || !isset($input['username']) || !isset($input['password'])) { + echo json_encode(['success' => false, 'message' => 'Username dan password harus diisi']); + exit(); + } + + $stmt = $pdo->prepare("SELECT * FROM users WHERE username = ? AND password = MD5(?)"); + $stmt->execute([$input['username'], $input['password']]); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($user) { + echo json_encode([ + 'success' => true, + 'message' => 'Login berhasil', + 'data' => [ + 'id' => $user['id'], + 'username' => $user['username'], + 'role' => $user['role'] + ] + ]); + } else { + echo json_encode(['success' => false, 'message' => 'Username atau password salah']); + } +} else { + echo json_encode(['success' => false, 'message' => 'Invalid action']); +} +?> \ No newline at end of file diff --git a/sig-jalan/api_orang.php b/sig-jalan/api_orang.php new file mode 100644 index 0000000..beed974 --- /dev/null +++ b/sig-jalan/api_orang.php @@ -0,0 +1,93 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch(PDOException $e) { + echo json_encode(['success' => false, 'message' => 'Database connection failed']); + exit(); +} + +$action = isset($_GET['action']) ? $_GET['action'] : ''; +$id = isset($_GET['id']) ? intval($_GET['id']) : null; +$method = $_SERVER['REQUEST_METHOD']; + +switch ($action) { + case 'getAll': + $stmt = $pdo->query("SELECT * FROM orang_berkebutuhan ORDER BY id DESC"); + $data = $stmt->fetchAll(PDO::FETCH_ASSOC); + echo json_encode(['success' => true, 'data' => $data]); + break; + + case 'getOne': + $stmt = $pdo->prepare("SELECT * FROM orang_berkebutuhan WHERE id = ?"); + $stmt->execute([$id]); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + if ($data) { + echo json_encode(['success' => true, 'data' => $data]); + } else { + echo json_encode(['success' => false, 'message' => 'Data tidak ditemukan']); + } + break; + + case 'create': + if ($method === 'POST') { + $input = json_decode(file_get_contents('php://input'), true); + $stmt = $pdo->prepare("INSERT INTO orang_berkebutuhan (nama, alamat, jenis_kebutuhan, no_hp, latitude, longitude, keterangan) VALUES (?, ?, ?, ?, ?, ?, ?)"); + $stmt->execute([ + $input['nama'], + $input['alamat'] ?? '', + $input['jenis_kebutuhan'] ?? '', + $input['no_hp'] ?? '', + $input['latitude'], + $input['longitude'], + $input['keterangan'] ?? '' + ]); + echo json_encode(['success' => true, 'message' => 'Data berhasil disimpan', 'id' => $pdo->lastInsertId()]); + } + break; + + case 'update': + if ($method === 'PUT') { + $input = json_decode(file_get_contents('php://input'), true); + $stmt = $pdo->prepare("UPDATE orang_berkebutuhan SET nama=?, alamat=?, jenis_kebutuhan=?, no_hp=?, latitude=?, longitude=?, keterangan=? WHERE id=?"); + $stmt->execute([ + $input['nama'], + $input['alamat'] ?? '', + $input['jenis_kebutuhan'] ?? '', + $input['no_hp'] ?? '', + $input['latitude'], + $input['longitude'], + $input['keterangan'] ?? '', + $id + ]); + echo json_encode(['success' => true, 'message' => 'Data berhasil diupdate']); + } + break; + + case 'delete': + if ($method === 'DELETE') { + $stmt = $pdo->prepare("DELETE FROM orang_berkebutuhan WHERE id = ?"); + $stmt->execute([$id]); + echo json_encode(['success' => true, 'message' => 'Data berhasil dihapus']); + } + break; + + default: + echo json_encode(['success' => false, 'message' => 'Invalid action']); +} +?> \ No newline at end of file diff --git a/sig-jalan/uploads/rusak/rusak_1780971487_6a2777df24ae2.png b/sig-jalan/uploads/rusak/rusak_1780971487_6a2777df24ae2.png new file mode 100644 index 0000000..8d65093 Binary files /dev/null and b/sig-jalan/uploads/rusak/rusak_1780971487_6a2777df24ae2.png differ