<?php
include("template.php"); 

$siteName = $_GET['siteName'] . " RESPONSE";

?>

 <body>
        <header id='header'>
                <?php echo $siteName; ?></br>
                <a href="logout.php">Logout</a>
        </header>
        <section id='hyperlinks' class='leftlinks'>
        <?php
        require_once('inc/config.php');
        $permission = getUserAccessRoleByID($_SESSION['user_role_id']);
        include("mid_template.php");
         printSideLinks($currentPage, $permission);
        ?>
        </section>
        <section id='container'>
<?php 
//START WRITING PHP CODE HERE


//Variables
$phone= $_GET['enum'];
$enum_array= str_split(($_GET['enum']));
$enum_reverse= array_reverse($enum_array);


//converts array into string with a . in front of the output
$enum = implode('.',$enum_reverse);

//enum servers
//$servers = array("172.17.1.26", "172.17.0.26", "172.17.1.23", "172.17.0.23");
$servers = array("34.194.142.97", "34.198.193.41");

/*
Creates a random number based on server array,
so that we can issue the command on all servers randomly.
*/
$randomNumber = rand(0,sizeof($servers)-1);

echo 'Command executed against phone 1'.$phone.':</br>';
echo '</br>';
echo 'dig -t naptr '.$enum.'.1.e164.arpa @'.$servers[$randomNumber].'</br>';
echo '</br>';
echo '</br>';

//Since this is not an option echo is the best bet.
echo '###################################################################</br>';
echo '</br>';
$output = shell_exec('dig -t naptr '.$enum.'.1.e164.arpa @'.$servers[$randomNumber]);
echo "<pre>$output</pre>";
echo '###################################################################</br>';
echo '</br>';
?>
<!--  </section>     -->                                                                                                                                         
        </section>
<?php
include("footer.php")
?>
