Add temp import script + update koneksi.php
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// TEMPORARY IMPORT SCRIPT - DELETE AFTER USE
|
||||
if ($_GET['key'] !== 'geomiskin2024') {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
$host = getenv('DB_HOST') ?: 'localhost';
|
||||
$user = getenv('DB_USER') ?: 'root';
|
||||
$pass = getenv('DB_PASS') ?: '';
|
||||
$name = getenv('DB_NAME') ?: 'db_webgis';
|
||||
$port = (int)(getenv('DB_PORT') ?: 3306);
|
||||
|
||||
$conn = new mysqli($host, $user, $pass, $name, $port);
|
||||
if ($conn->connect_error) {
|
||||
die("Koneksi gagal: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
$sql = file_get_contents(__DIR__ . '/db_webgis.sql');
|
||||
if (!$sql) {
|
||||
die("File SQL tidak ditemukan");
|
||||
}
|
||||
|
||||
$conn->multi_query($sql);
|
||||
do {
|
||||
$conn->store_result();
|
||||
} while ($conn->next_result());
|
||||
|
||||
if ($conn->errno) {
|
||||
echo "Error: " . $conn->error;
|
||||
} else {
|
||||
echo "Import berhasil! Hapus file ini sekarang.";
|
||||
}
|
||||
$conn->close();
|
||||
+6
-1
@@ -1,8 +1,13 @@
|
||||
<?php
|
||||
if (isset($conn)) return;
|
||||
$host = getenv('DB_HOST') ?: '127.0.0.1';
|
||||
$user = getenv('DB_USER') ?: 'root';
|
||||
$pass = getenv('DB_PASS') ?: '';
|
||||
$name = getenv('DB_NAME') ?: 'db_webgis';
|
||||
$port = (int)(getenv('DB_PORT') ?: 3306);
|
||||
$conn = mysqli_init();
|
||||
mysqli_options($conn, MYSQLI_OPT_CONNECT_TIMEOUT, 5);
|
||||
$ok = @mysqli_real_connect($conn, '127.0.0.1', 'root', '', 'db_webgis', 3306);
|
||||
$ok = @mysqli_real_connect($conn, $host, $user, $pass, $name, $port);
|
||||
if (!$ok) {
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['status' => 'error', 'message' => 'Koneksi DB gagal: ' . mysqli_connect_error()]));
|
||||
|
||||
Reference in New Issue
Block a user