40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
// auto_login_genieacs.php
|
|
|
|
// Konfigurasi login GenieACS
|
|
$genieacs_host = 'http://172.16.96.10:3000';
|
|
$username = 'dwi';
|
|
$password = 'jalo';
|
|
|
|
// URL target setelah login
|
|
$target_path = '/#!/devices';
|
|
|
|
// Mulai cURL untuk login
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $genieacs_host . '/login'); // endpoint login GenieACS
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
|
'username' => $username,
|
|
'password' => $password
|
|
]));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
|
curl_setopt($ch, CURLOPT_COOKIEJAR, __DIR__ . '/genieacs_cookie.txt'); // simpan cookie
|
|
curl_setopt($ch, CURLOPT_COOKIEFILE, __DIR__ . '/genieacs_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 target dengan session cookie
|
|
curl_close($ch);
|
|
|
|
// Gunakan header untuk redirect
|
|
header('Location: ' . $genieacs_host . $target_path);
|
|
exit();
|
|
?>
|