echo"\n".gettext("Is this the backup you wish to restore?")."\n";
echo"\nIs this the backup you wish to restore?\n";
list_backups($number);
$filename=array_keys($confvers)[$number-1];
$thisbackup=$confvers[$filename];
echogettext("Y/N?")." : ";
echo'Y/N? : ';
$confirm=strtoupper(chop(fgets($fp)));
if($confirm==gettext("Y")){
if($confirm=='Y'){
$cnf=OPNsense\Core\Config::getInstance();
if($cnf->restoreBackup($filename)){
echo"\n";
echosprintf(gettext('Successfully reverted to timestamp %s with description "%s".'),date(gettext("n/j/y H:i:s"),$thisbackup['time']),$thisbackup['description']);
echo"\n".gettext("You may need to reboot the firewall or restart services before the restored configuration is fully active.")."\n\n";
echosprintf('Successfully reverted to timestamp %s with description "%s".',date('n/j/y H:i:s',$thisbackup['time']),$thisbackup['description']);
echo"\nYou may need to reboot the firewall or restart services before the restored configuration is fully active.\n\n";
}else{
echogettext("Unable to revert to the selected configuration.")."\n";
echo"Unable to revert to the selected configuration.\n";
}
}else{
echogettext("Restore canceled.")."\n";
echo"Restore canceled.\n";
}
}else{
echogettext("Restore canceled due to invalid input.")."\n";
echo"Restore canceled due to invalid input.\n";
}
}
while(true){
echo"\n";
echogettext("Restore Backup from Configuration History")."\n\n";
echo"1) ".gettext("List Backups")."\n";
echo"2) ".gettext("Restore Backup")."\n";
echo"Q) ".gettext("Quit")."\n";
echo"\n\n";
echogettext("Please select an option to continue").": ";
echo"\nRestore Backup from Configuration History\n\n";
echo"1) List Backups\n";
echo"2) Restore Backup\n";
echo"q) Quit\n\n\n";
echo"Please select an option to continue: ";
$command=strtolower(chop(fgets($fp)));
// Make sure we can detect a foreign language "quit" command.