<ul>
<?php 
foreach ($SITES as $site) {
    if (!is_array($site)) {
        continue;
    }
    ?>
	<li>
		<?php 
    echo ucwords($site['name']);
    ?>
		(<?php 
    echo interface_link('Add thread', array('page' => 'threadmgmt', 'action' => 'add', 'site' => $site['name']));
    ?>
) 
		<?php 
    echo templates_exec('site_thread_list', array('threads' => $site['threads'], 'site' => $site));
    ?>
	</li>
<?php 
}
?>
</ul>
<ul>
<?php 
foreach ($HOSTS as $host) {
    if (!is_array($host)) {
        continue;
    }
    ?>
	<li><?php 
    echo $host['pattern'];
    ?>
 (<?php 
    echo interface_link('Remove', array('page' => 'hostmgmt', 'action' => 'delete', 'host' => $host['pattern']));
    ?>
)</li>
<?php 
}
?>
</ul>
foreach ($threads as $thread) {
    if (!is_array($thread)) {
        continue;
    }
    ?>
	<li>
		<i><?php 
    echo strlen($thread['title']) > 0 ? $thread['title'] : $thread['url'];
    ?>
</i>
		(<?php 
    echo interface_link('Go', $thread['url']);
    ?>
, 
		<?php 
    echo interface_link('Remove', array('page' => 'threadmgmt', 'action' => 'delete', 'site_name' => $site['name'], 'thread_url' => urlencode($thread['url']), 'thread_title' => urlencode($thread['title'])));
    ?>
) 
		<?php 
    if (isset($LINK_CACHE['_threads'][$thread['url']]) && $LINK_CACHE['_threads'][$thread['url']]['last_scan'] > 0) {
        ?>
			(<?php 
        echo count($LINK_CACHE['_threads'][$thread['url']]['links']);
        ?>
 valid links in total, 
			last scanned <?php 
        echo date("F j, Y, H:i", $LINK_CACHE['_threads'][$thread['url']]['last_scan']);
        ?>
)
		<?php 
    } else {
echo $thread_url;
?>
</i>

<p>When deleted, all previously crawled links from this thread will be forgotten. Thus they will be readded to JD if the thread is readded.</p>

<form action="<?php 
echo interface_url(array('page' => 'threadmgmt', 'action' => 'delete_submit'));
?>
" method="post">
<input type="hidden" name="site_name" value="<?php 
echo $site_name;
?>
" />
<input type="hidden" name="thread_url" value="<?php 
echo $thread_url;
?>
" />
<input type="hidden" name="thread_title" value="<?php 
echo $thread_title;
?>
" />
<input type="checkbox" name="leave_cache" value="yes" /> Don't forget crawled links from this thread<br/>

<input type="submit" value="Delete" />
</form>

<p><?php 
echo interface_link('Return to Overview', array('page' => 'overview'));
?>
</p>
<h2>Stats</h2>
<?php 
echo templates_exec('stats_simple');
?>

<h2>Sites being Watched</h2>
<?php 
echo interface_link('Add Site', array('page' => 'sitemgmt', 'action' => 'add'));
echo templates_exec('site_list', array());
?>

<h2>Last crawl output</h2>
<?php 
echo interface_link('Crawl Now', 'crawl.php');
echo templates_exec('log_output');
?>

<h2>Configuration</h2>

<h3>Accepted Hosts</h3>
<?php 
echo interface_link('Add Host', array('page' => 'hostmgmt', 'action' => 'add'));
echo templates_exec('host_list');