add config.php
This commit is contained in:
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin', 'operator');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
|
||||
$id = (int) $_GET['id'];
|
||||
$stmt = $conn->prepare("SELECT * FROM rumah_prasejahtera WHERE id = ?");
|
||||
|
||||
@@ -3,8 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
// Pastikan nama database sudah benar
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
|
||||
if ($conn->connect_error) {
|
||||
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
$result = $conn->query("SELECT * FROM rumah_prasejahtera");
|
||||
$data = [];
|
||||
while ($row = $result->fetch_assoc()) $data[] = $row;
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin', 'operator');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin', 'operator');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if (!$data || !isset($data['id'])) {
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin', 'operator');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
|
||||
$id = (int) $_GET['id'];
|
||||
$stmt = $conn->prepare("SELECT * FROM rumah_ibadah WHERE id = ?");
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$stmt = $conn->prepare("DELETE FROM rumah_ibadah WHERE id = ?");
|
||||
$stmt->bind_param("i", $data['id']);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
|
||||
$result = $conn->query("SELECT * FROM rumah_ibadah");
|
||||
$data = [];
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin', 'operator');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli('localhost', 'root', '', 'webgis');
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$stmt = $conn->prepare("INSERT INTO rumah_ibadah (nama_ibadah, jenis, radius_m, lat, lng) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("ssidd", $data['nama_ibadah'], $data['jenis'], $data['radius_m'], $data['lat'], $data['lng']);
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin', 'operator');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if (!$data || !isset($data['id'])) {
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
|
||||
$id = (int) $_GET['id'];
|
||||
$stmt = $conn->prepare("SELECT id, nama, username, role FROM users WHERE id = ?");
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
$id = (int) $data['id'];
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once '../../auth.php';
|
||||
requireRole('admin');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../../../config.php';
|
||||
$conn = getDB();
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if (!$data || !isset($data['id'])) {
|
||||
|
||||
@@ -10,7 +10,8 @@ if (isset($_SESSION['user'])) {
|
||||
$error = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../config.php';
|
||||
$conn = getDB();
|
||||
|
||||
$username = trim($_POST['username']);
|
||||
$password = trim($_POST['password']);
|
||||
|
||||
@@ -3,7 +3,8 @@ require_once 'auth.php';
|
||||
requireLogin();
|
||||
requireRole('admin');
|
||||
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
require_once '../config.php';
|
||||
$conn = getDB();
|
||||
$error = '';
|
||||
$success = '';
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
define('DB_HOST', getenv('DB_HOST') ?: 'localhost');
|
||||
define('DB_USER', getenv('DB_USER') ?: 'root');
|
||||
define('DB_PASS', getenv('DB_PASS') ?: '');
|
||||
define('DB_NAME', getenv('DB_NAME') ?: 'webgis');
|
||||
|
||||
function getDB() {
|
||||
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||
if ($conn->connect_error) {
|
||||
http_response_code(500);
|
||||
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
|
||||
exit;
|
||||
}
|
||||
return $conn;
|
||||
}
|
||||
?>
|
||||
+69
-31
@@ -3,9 +3,9 @@
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Waktu pembuatan: 04 Jun 2026 pada 04.59
|
||||
-- Versi server: 10.4.32-MariaDB
|
||||
-- Versi PHP: 8.2.12
|
||||
-- Generation Time: Jun 10, 2026 at 04:05 PM
|
||||
-- Server version: 10.4.32-MariaDB
|
||||
-- PHP Version: 8.2.12
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
@@ -24,7 +24,7 @@ SET time_zone = "+00:00";
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktur dari tabel `area_polygon`
|
||||
-- Table structure for table `area_polygon`
|
||||
--
|
||||
|
||||
CREATE TABLE `area_polygon` (
|
||||
@@ -36,7 +36,7 @@ CREATE TABLE `area_polygon` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Dumping data untuk tabel `area_polygon`
|
||||
-- Dumping data for table `area_polygon`
|
||||
--
|
||||
|
||||
INSERT INTO `area_polygon` (`id`, `nama_kavling`, `status_kepemilikan`, `luas_m2`, `geojson`) VALUES
|
||||
@@ -50,7 +50,7 @@ INSERT INTO `area_polygon` (`id`, `nama_kavling`, `status_kepemilikan`, `luas_m2
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktur dari tabel `jalan_polyline`
|
||||
-- Table structure for table `jalan_polyline`
|
||||
--
|
||||
|
||||
CREATE TABLE `jalan_polyline` (
|
||||
@@ -62,7 +62,7 @@ CREATE TABLE `jalan_polyline` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Dumping data untuk tabel `jalan_polyline`
|
||||
-- Dumping data for table `jalan_polyline`
|
||||
--
|
||||
|
||||
INSERT INTO `jalan_polyline` (`id`, `nama_jalan`, `status`, `panjang_m`, `geojson`) VALUES
|
||||
@@ -78,7 +78,7 @@ INSERT INTO `jalan_polyline` (`id`, `nama_jalan`, `status`, `panjang_m`, `geojso
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktur dari tabel `rumah_ibadah`
|
||||
-- Table structure for table `rumah_ibadah`
|
||||
--
|
||||
|
||||
CREATE TABLE `rumah_ibadah` (
|
||||
@@ -91,16 +91,17 @@ CREATE TABLE `rumah_ibadah` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Dumping data untuk tabel `rumah_ibadah`
|
||||
-- Dumping data for table `rumah_ibadah`
|
||||
--
|
||||
|
||||
INSERT INTO `rumah_ibadah` (`id`, `nama_ibadah`, `jenis`, `radius_m`, `lat`, `lng`) VALUES
|
||||
(1, 'Babul Maghfirah', 'Masjid', 500, -0.05512207163471261, 109.35242215378504);
|
||||
(1, 'Babul Maghfirah', 'Masjid', 600, -0.05480292153321615, 109.35301758952382),
|
||||
(4, 'Masjid Raya Mujahiddin', 'Masjid', 500, -0.041434028832777574, 109.33632432523154);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktur dari tabel `rumah_prasejahtera`
|
||||
-- Table structure for table `rumah_prasejahtera`
|
||||
--
|
||||
|
||||
CREATE TABLE `rumah_prasejahtera` (
|
||||
@@ -120,19 +121,20 @@ CREATE TABLE `rumah_prasejahtera` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Dumping data untuk tabel `rumah_prasejahtera`
|
||||
-- Dumping data for table `rumah_prasejahtera`
|
||||
--
|
||||
|
||||
INSERT INTO `rumah_prasejahtera` (`id`, `nama_kepala_keluarga`, `penghasilan`, `jumlah_anak`, `umur_anak`, `status_ortu`, `ada_pensiun`, `nominal_pensiun`, `ada_terusan`, `nominal_terusan`, `keterangan`, `lat`, `lng`) VALUES
|
||||
(10, 'Pak Ambalingham', 2000000.00, 2, '12, 7', 'Bekerja', 'Tidak', 0.00, 'Tidak', 0.00, 'rokok 2 slop sehari', -0.04965587084748121, 109.35713631716),
|
||||
(11, 'Mas Us', 0.00, 3, '14, 9, 3', 'Pensiun', 'Ya', 400000.00, 'Tidak', 0.00, '', -0.05299500680178904, 109.35927377651974),
|
||||
(12, 'Robi', 0.00, 1, '13', 'Meninggal', 'Tidak', 0.00, 'Tidak', 0.00, '', -0.051968992262292006, 109.35091436068554),
|
||||
(13, 'Mas Rian', 0.00, 2, '4, 3', 'Meninggal', 'Tidak', 0.00, 'Ya', 200000.00, '', -0.04951572385615543, 109.3541283718652);
|
||||
(10, 'Pak Ambalingham', 2000000.00, 2, '12, 7', 'Bekerja', 'Tidak', 0.00, 'Tidak', 0.00, 'rokok 2 slop sehari', -0.04952435403005827, 109.3574379859713),
|
||||
(12, 'Robi', 0.00, 1, '13', 'Meninggal', 'Tidak', 0.00, 'Tidak', 0.00, '', -0.05197047474609275, 109.35194457542805),
|
||||
(13, 'Mas Rusdi', 0.00, 2, '4, 3', 'Meninggal', 'Tidak', 0.00, 'Ya', 200000.00, '', -0.04928832854879829, 109.3546487495755),
|
||||
(14, 'Mas Us', 0.00, 3, '14, 9, 3', 'Pensiun', 'Ya', 400000.00, 'Tidak', 0.00, '', -0.05883415577738937, 109.3555884504947),
|
||||
(15, 'Herman Santoso', 2000000.00, 2, '21, 10', 'Bekerja', 'Tidak', 0.00, 'Tidak', 0.00, 'rokok 8 slop sehari', -0.04387894972428997, 109.33540877797459);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktur dari tabel `spbu_point`
|
||||
-- Table structure for table `spbu_point`
|
||||
--
|
||||
|
||||
CREATE TABLE `spbu_point` (
|
||||
@@ -145,7 +147,7 @@ CREATE TABLE `spbu_point` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Dumping data untuk tabel `spbu_point`
|
||||
-- Dumping data for table `spbu_point`
|
||||
--
|
||||
|
||||
INSERT INTO `spbu_point` (`id`, `lat`, `lng`, `nama_spbu`, `no_wa`, `buka_24jam`) VALUES
|
||||
@@ -157,73 +159,109 @@ INSERT INTO `spbu_point` (`id`, `lat`, `lng`, `nama_spbu`, `no_wa`, `buka_24jam`
|
||||
(17, -0.17363396, 109.43607241, 'RUMAH AKU', '082150711624', 1),
|
||||
(18, -0.11209001, 109.36203003, 'rumah pak amba', '082849696767', 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `users`
|
||||
--
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`id` int(11) NOT NULL,
|
||||
`nama` varchar(100) NOT NULL,
|
||||
`username` varchar(50) NOT NULL,
|
||||
`password` varchar(255) NOT NULL,
|
||||
`role` enum('admin','operator') NOT NULL DEFAULT 'operator',
|
||||
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `users`
|
||||
--
|
||||
|
||||
INSERT INTO `users` (`id`, `nama`, `username`, `password`, `role`, `created_at`) VALUES
|
||||
(3, 'Administrator', 'admin', '$2y$10$A.PGTJ3iQJc8hK0maehBtO7a8xWZ5SqoqJnC4wMoSqlhH6PDmjAC.', 'admin', '2026-06-10 05:28:11'),
|
||||
(5, 'Pak Budi', 'operator', '$2y$10$d37JkJWWY1oYnxZHPqo.6O.q/AdoaW3K8oetf0kLj44o.OxOtJQQu', 'operator', '2026-06-10 08:25:55');
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indeks untuk tabel `area_polygon`
|
||||
-- Indexes for table `area_polygon`
|
||||
--
|
||||
ALTER TABLE `area_polygon`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indeks untuk tabel `jalan_polyline`
|
||||
-- Indexes for table `jalan_polyline`
|
||||
--
|
||||
ALTER TABLE `jalan_polyline`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indeks untuk tabel `rumah_ibadah`
|
||||
-- Indexes for table `rumah_ibadah`
|
||||
--
|
||||
ALTER TABLE `rumah_ibadah`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indeks untuk tabel `rumah_prasejahtera`
|
||||
-- Indexes for table `rumah_prasejahtera`
|
||||
--
|
||||
ALTER TABLE `rumah_prasejahtera`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indeks untuk tabel `spbu_point`
|
||||
-- Indexes for table `spbu_point`
|
||||
--
|
||||
ALTER TABLE `spbu_point`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT untuk tabel yang dibuang
|
||||
-- Indexes for table `users`
|
||||
--
|
||||
ALTER TABLE `users`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `username` (`username`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT untuk tabel `area_polygon`
|
||||
-- AUTO_INCREMENT for table `area_polygon`
|
||||
--
|
||||
ALTER TABLE `area_polygon`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT untuk tabel `jalan_polyline`
|
||||
-- AUTO_INCREMENT for table `jalan_polyline`
|
||||
--
|
||||
ALTER TABLE `jalan_polyline`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT untuk tabel `rumah_ibadah`
|
||||
-- AUTO_INCREMENT for table `rumah_ibadah`
|
||||
--
|
||||
ALTER TABLE `rumah_ibadah`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT untuk tabel `rumah_prasejahtera`
|
||||
-- AUTO_INCREMENT for table `rumah_prasejahtera`
|
||||
--
|
||||
ALTER TABLE `rumah_prasejahtera`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT untuk tabel `spbu_point`
|
||||
-- AUTO_INCREMENT for table `spbu_point`
|
||||
--
|
||||
ALTER TABLE `spbu_point`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `users`
|
||||
--
|
||||
ALTER TABLE `users`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
|
||||
Reference in New Issue
Block a user