37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
// auto_login_observium.php
|
|
|
|
// Konfigurasi login Observium
|
|
$observium_host = 'http://rmtstb.megadataisp.net:8131'; // ganti sesuai IP Observium
|
|
$username = 'megadata';
|
|
$password = 'megadata';
|
|
|
|
// Mulai cURL untuk login
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $observium_host . '/login.php'); // endpoint login Observium
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
|
'username' => $username,
|
|
'password' => $password,
|
|
'login' => 'Login'
|
|
]));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
|
curl_setopt($ch, CURLOPT_COOKIEJAR, __DIR__ . '/observium_cookie.txt'); // simpan cookie
|
|
curl_setopt($ch, CURLOPT_COOKIEFILE, __DIR__ . '/observium_cookie.txt');
|
|
curl_setopt($ch, CURLOPT_HEADER, false);
|
|
|
|
// Jalankan login
|
|
$response = curl_exec($ch);
|
|
|
|
if (curl_errno($ch)) {
|
|
die('Login error: ' . curl_error($ch));
|
|
}
|
|
|
|
// Redirect user ke halaman dashboard Observium
|
|
curl_close($ch);
|
|
|
|
header('Location: ' . $observium_host . '/'); // ganti path kalau mau ke halaman tertentu
|
|
exit();
|
|
?>
|