<?php $root=$_SERVER['DOCUMENT_ROOT'];$wroot=dirname($_SERVER['SCRIPT_NAME']);while((strlen($wroot)>1)&&(!file_exists($root.$wroot.'/main')))$wroot=dirname($wroot);if($wroot=='/')$wroot='';require_once($root.$wroot.'/main/app/App.php');
if (!$app->privileged('admin')) $app->nopage('This page can only be accessed by admins.');
else{
	$app->heads('AnswerPhone Configuration');
	$app->header();
	if (isset($_POST['deleteme'])) unlink($_SERVER['DOCUMENT_ROOT'].'/main/.calls/'.$_POST['url']);
?>
<section>
	<article>
		<h1 class='article'>AnswerPhone Configuration</h1>
		<h5>This module has no settings.</h5>
		<p class='center'>This module will create a hidden folder on the document
		root of your webserver <code>/main/.calls</code> which will not be
		indexable. Note that the main folder will be created on the document root
		if the document root is is not the location of this current installation.
		</p>
	</article>
	<article>
		<h1 class='article'>Calls Received</h1>
		<h5>The following calls have been received</h5>
		<?php
			$calls=glob($_SERVER['DOCUMENT_ROOT'].'/main/.calls/*');
			foreach($calls as $call){
				$url=substr($call,strlen($_SERVER['DOCUMENT_ROOT']));
				$bn=basename($url);
				echo "<form method='post'>";
				echo "<p class='center'>";
				echo "<a href='$url' target='_blank'>$bn</a>";
				echo "<input name='url' type='hidden' value='$bn' />";
				echo "<input type='submit' value='X' class='red round' name='deleteme' />";
				echo "</p>";
				echo "</form>";
			}
		?>
	</article>
</section>
<?php
	$app->footer();
	$app->tails();
}
?>
