<?php

require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
require('include/myconn.php');
require('include/getadmacc.php');
require('include/menu.php');
$menu['menu']['selected']=true;
$menu['menu']['submenu']['instances']['href']=null;
$menu['menu']['submenu']['instances']['selected']=true;
buildmenu($menu);

$dbg='';

use function mysqli_real_escape_string as myesc;

// praticamente una macro
function hspech($str) {
	return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
}

?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Mustard - Your instances</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Admin pages for Mastodon Startpage">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="icon" type="image/png" href="imgs/icona-32.png" sizes="32x32">
<link rel="icon" type="image/png" href="imgs/icona-192.png" sizes="192x192">
<link rel="icon" type="image/png" href="imgs/icona-512.png" sizes="512x512">
<link rel="apple-touch-icon-precomposed" href="imgs/icona-180.png">
<link rel="stylesheet" type="text/css" href="theme.css?v=<?php echo($cjrand); ?>">
<script language="JavaScript" src="js/menu.js?v=<?php echo($cjrand); ?>"></script>
<script language="JavaScript">
<!--
//-->
</script>
</head>
<body>

<nav>
<div id="hmenu">
<ul>
<?php echo($menuout); ?>
</ul>
<div class="mtit">Your instances</div>
<div id="rightdiv">
<img src="imgs/esci.svg" class="rlinks" title="Logout" onclick="document.location.href='logout.php';">
</div>
</div>
</nav>

<div id="popup">
<div id="inpopup">
<div id="popupcont">
...
</div>
</div>
</div>

<!-- <div id="footer">
</div> -->

<div id="fullscreen">
<div id="middlerow">
<?php

$res=mysqli_query($link,'SELECT *, ID AS IID FROM Instances WHERE GuestID='.$account['ID'])
	or muoribene(__LINE__.': '.mysqli_error($link),true);
$cinsts=mysqli_num_rows($res);
if ($cinsts>0) {
//	$out='<p>Your instances</p>'.N;
	require('include/columns.php');
	require('include/dispinst.php');
	$i=0;
	while ($row=mysqli_fetch_assoc($res)) {
		$i++;
		echo(dispinst($row,$cols,$link,$dlang,$account,true,$i,$cinsts));
	}
} else {
	$out='<p>No instances to show.</p>'.N;
}

mysqli_close($link);

?>
</div>
</div>

<div id="debug">
<?php echo($dbg); ?>
</div>

</body>
</html>
