<?php
if (!$root) {
	$returnlink = "/";
} else {
	$returnlink = $root;
}
$host = explode('.', $_SERVER['HTTP_HOST']); $host = end($host);
$indexfile = "_index.php";
$heads = array("head.gif", "head2.gif", "head3.gif", "head4.gif", "head5.gif", "head6.gif", "head7.gif", "head8.gif", "head9.gif");
$usehead = array_rand($heads);

function asideLink ($linkname, $page, $root) {
	$currentfile = basename($_SERVER['PHP_SELF']);
	if ($currentfile == $page) {
		echo '<li class="asideitem greyed">'.$linkname.'</li>';
	} else {
		echo '<li class="asideitem"><a href="'.$root.$page.'">'.$linkname.'</a></li>';
	}
}

function asideSubLink ($linkname, $root, $indexfile, $strike) {
	$workingdirarr = explode('/', getcwd());
	$workingdir = end($workingdirarr);
	if ($workingdir == $linkname && !isset($_GET['post'])) {
		if ($strike == true) {
			echo '<li class="asidesubitem greyed"><s>'.$linkname.'</s></li>';
		} else {
			echo '<li class="asidesubitem greyed">'.$linkname.'</li>';
		}
	} else {
		if ($strike == true) {
			echo '<li class="asidesubitem"><s><a href="'.$root.$linkname.'/'.$indexfile.'">'.$linkname.'</a></s></li>';
		} else {
			echo '<li class="asidesubitem"><a href="'.$root.$linkname.'/'.$indexfile.'">'.$linkname.'</a></li>';
		}
	}
}

echo '<div class="asidehomeimage centre"><a href="'.$root.'home.php"><img src="'.$root.'images/heads/'.$heads[$usehead].'" alt="Home" /></a></div>';
echo '<span class="asidehometext"><a href="'.$root.'home.php">Home</a></span>';
echo '<ul class="blogbox">';
	asideSubLink('Media', $root, $indexfile, false);
	asideSubLink('Technology', $root, $indexfile, false);
	asideSubLink('News', $root, $indexfile, false);
echo '</ul>';
echo '<ul>';
	asideLink('Other Pages', 'other.php', $root);
	asideLink('About', 'about.php', $root);
	asideLink('Contact', 'contact.php', $root);
	echo '<li class="asideitem"><a href="'.$returnlink.'">Return</a></li>';
echo '</ul>';
echo '<div class="centre">';
	//echo '<a href="/rss.xml" target="_blank"><img class="asidebottomimage" src="'.$root.'images/rss.gif" alt="RSS" /></a>';
	if ($host == 'onion') {
		/*echo '<a href="http://opxr3vfzliykjbkqf6uvvmagscsc77iyq5xe6dglnh63yip4b7zkhpqd.onion/" target="_blank"><img class="asidebottomimage" src="'.$root.'images/git.gif" alt="Git Server" /></a>';
		echo '<a href="http://fvmquvda235lwlvdec5nhdwtajlwitfwutsnhsxwcc5wzwzrgcsrc3qd.onion/" target="_blank"><img class="asidebottomimage" src="'.$root.'images/rainchan.gif" alt="Rainchan Imageboard" /></a>';
		echo '<a href="https://concealed.world'.$_SERVER['REQUEST_URI'].'" target="_blank"><img class="asidebottomimage" src="'.$root.'images/clearnet.gif" alt="Browse Site on Clearnet" /></a>';*/
		echo '<p>Currently not on TOR! If you are seeing this, thats an error!</p>';
	} else {
		echo '<a href="https://git.broken-moon.net" target="_blank"><img class="asidebottomimage" src="'.$root.'images/git.gif" alt="Git Server" /></a>';
	//	echo '<a href="https://boards.concealed.world/" target="_blank"><img class="asidebottomimage" src="'.$root.'images/rainchan.gif" alt="Rainchan Imageboard" /></a>';
	//	echo '<a href="http://kpzscgdqezpen5zpnc4gky5vx4r56thl5syq2x45j6hbjy5w7tjilwid.onion'.$_SERVER['REQUEST_URI'].'" target="_blank"><img class="asidebottomimage" src="'.$root.'images/tor.gif" alt="Browse Site on Tor" /></a>';
		echo '<p>Wow, this is empty!</p>';
	}
echo '</div>';
?>
