#!/usr/local/bin/perl
# Redirecting to MGW ##IP Main Page

require 'ippbx-lib.pl';
ui_print_header(undef, $module_info{'desc'}, "", undef, 1, 1);
use strict;
use warnings;
use feature 'say';
use Mojo::UserAgent;
my $ua   = Mojo::UserAgent->new;
my $data = $ua->get('http://##IP/rebootApi.php?reboot=token')->res->json;
my $res = $data->{data};
print qq[
<h1>Please Wait While We Initialize Reboot For Media Gateway ##IP</h1>
];
if ($res ne "")
{
my $staticurl = "http://##IP/validation_reboot.php?token=$res";
print qq[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Redirecting...</title>
<meta HTTP-EQUIV="REFRESH" CONTENT="1;URL=$staticurl">
</head>
<body>
</body>
</html>
];
}
