<?php
session_start();
require('routeros_api.class.php');

$API = new RouterosAPI();
$API->debug = false;
$ipMikrotik = $_SESSION['ip'];
$username = $_SESSION['user'];
$password = $_SESSION['pass'];

if ($API->connect($ipMikrotik, $username, $password)) {
    $filename = "Backup_PPP_Secret_" . date('Ymd_His');
    $API->comm("/ppp/secret/export", ["file" => $filename]);
    $API->disconnect();
    echo "✅ File backup dibuat di Mikrotik: <b>$filename.rsc</b>";
} else {
    echo "❌ Gagal konek ke Mikrotik.";
}
?>
