<?


//acting ...
if ($sys['act'] && !$tmp['cancelAction']) {
	require_once($sys['root']."/system/actions/".$sys['act'].".inc");
}

if ($_GET['repair_table']) {
	$rs = $db->GetRow("REPAIR TABLE ".$_GET['repair_table']."");
	$msg = "REPAIR TABLE ".$_GET['repair_table']." : ".$rs['Msg_text'];
	$statusBarMessage[] = array($msg, 0);
}

if ($_GET['optimize_table']) {
	$rs = $db->GetRow("REPAIR TABLE ".$_GET['optimize_table']."");
	$msg = "OPTIMIZE TABLE ".$_GET['optimize_table']." : ".$rs['Msg_text'];
	$statusBarMessage[] = array($msg, 0);
}

require_once($sys['root']."/system/templates/popup/header.inc");
?>



<table cellspacing="0" cellpadding="0" border="0" style="width:100%;height:100%;background-color:#F2F2F2">
<tr>
    <td background="images/popup/top-bg.gif" height="26">&nbsp;</td>
</tr>

<tr>
    <td style="padding:10px;">
<!-- Popup Contents -->


<br>
<table border="0" cellspacing="1" cellpadding="6" width="620" align="center">
<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;">Server OS:</td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">
<?
	echo ($settings->config['demomode'])?$lang->get("Info unavailable in this demo version of Afian"):php_uname();
?>
</td>
</tr>
<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("PHP version:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">

<?echo phpversion();?>

</td>
</tr>
<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("File permissions:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">

<?
$files = array(
"data/temp",
"data/trash"
);

for ($i = 0 ; $i < sizeof($files) ; $i++) {
	$path = gluePath($sys['root'],"/system/",$files[$i]);
	if (!is_readable($path)) {
		echo $lang->get("%1 is not readable.", array($path));
		echo "<br>";
		$filePermProblem = 1;
	}
	
	if (!is_writable($path)) {
		echo $lang->get("%1 is not writable.", array($path));
		echo "<br>";
		$filePermProblem = 1;
	}
}


if (!$filePermProblem) {
	echo "OK";
}

?>
<br><br>
<?
echo $lang->get("%1 runs under user", array(($sys['license']['unbranded']?$sys['license']['unbranded']:"Afian")))." ".(($settings->config['demomode'])?"n/a":get_current_user()). " (uid ".(($settings->config['demomode'])?"n/a":getmyuid()).").";
?>
&nbsp;
	</td>
</tr>

<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("File uploads:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">
<?
if (isCfgOn("file_uploads")) {
	$lang->display("Uploads are enabled.");
} else {
	$lang->display("Uploads are disabled.");
}

?>
<br>
<?$lang->display("Each uploaded file can have a size of up to %1. Maximum POST size is %2.", array(ini_get("upload_max_filesize"), ini_get("post_max_size")));?>
</td>
</tr>
<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("PHP script execution time:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black"><?$lang->display("%1 seconds.", array(ini_get("max_execution_time")));?>
</td>
</tr>
<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("PHP GD library:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">
<?
if (extension_loaded("gd")) {
?>
<?$lang->display("GD extension loaded.");?>
<br>
<?$lang->display("Thumbnails available for the following image formats:");?>
 <?$types = "";
	if (function_exists("imagecreatefromgif")) {
		$types .= "GIF";
	}
	if (function_exists("imagecreatefrompng")) {
		$types .= " PNG";
	}
	if (function_exists("imagecreatefromjpeg")) {
		$types .= " JPEG";
	}
	echo $types;
?>
<?
} else {
?>
<?$lang->display("GD extension not loaded.");?>
<br>
<?$lang->display("Thumbnails unavailable.");?>
<?
}?>





</td>
</tr>
<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("PHP ZLIB library:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">
<?
if (function_exists('gzcompress') == false || in_array("zlib", get_loaded_extensions()) == false) {
?>
<?$lang->display("ZLIB extension not loaded.<br>HTTP gzip compression unavailable.");?>
<?
} else {
?>
<?$lang->display("ZLIB extension loaded.<br>HTTP gzip compression is ON.");?>
<?
}
?>

</td>
</tr>

<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("E-mail:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">

<?
if (function_exists("mail")) {
	$lang->display("E-mail available.");
} else {
	$lang->display("No e-mail support available.");
}
?>

</td>
</tr>
<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("Disk space:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">

<?
$freeSpace = disk_free_space(getcwd());
$totalSpace = disk_total_space(getcwd());
$notFree = $totalSpace - $freeSpace;
?>
	

<?$lang->display("Free disk space:");?>
<?
echo ($settings->config['demomode'])?"n/a":$fm->formatFileSize($freeSpace, 2, "0");
?>.
<br><br>
<table style="border:1px solid white;width:170px;height:8px;float:left;margin-right:5px;" cellpadding="0" cellspacing="0" border="0">
	<tr>
	<?if ($notFree > 0){?>
	<td style="width:<?echo  round(($notFree*100)/$totalSpace)?>%;height:8px;border-top:1px  solid #848684;border-right:1px solid #848684;border-left:1px solid #848684;background-image:url(images/interface/progressfill.gif);">
		<div style="width:1px;height:1px;overflow:hidden">&nbsp;</div>
	</td>
	<?}?>
	<?if ($totalSpace-$notFree >= 0){?>
	<td style="width:<?echo  100-round(($notFree*100)/$totalSpace)?>%;border-top:1px solid #848684;border-left:1px solid #848684;background-color:#E0DCD0;">
		<div style="width:1px;height:1px;overflow:hidden">&nbsp;</div>
	</td>
	<?}?>
	</tr>
</table> 
<div style="font-size:7pt;color:<?if ($totalSpace > $notFree){?>black<?}else{?>red<?}?>"> <?$lang->display("Used:");?> 
<?
echo ($settings->config['demomode'])?"n/a":$fm->formatFileSize($notFree, 2, "0");
?> / 
<?
	echo ($settings->config['demomode'])?"n/a":$fm->formatFileSize($totalSpace, 2, "0");
?>
</div>

</td>
</tr>

<tr>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;background-color:#E3E3E3;color:black;"><?$lang->display("Database status:");?></td>
	<td valign="top" style="border-top:1px solid white;border-bottom:1px solid gray;border-left:1px solid white;border-right:1px solid gray;color:black">

<table border="1" cellspacing="0" cellpadding="2" width="100%">
<tr style="font-weight:bold;background-color:dimgray;color:white">
	<td><?$lang->display("Table");?></td>
	<td><?$lang->display("Status");?></td>
</tr>
<?

$tables[] = $settings->config['auth_tablename'];
$tables[] = $settings->config['interauth_tablename'];
$tables[] = $settings->config['users_tablename'];
$tables[] = $settings->config['groups_tablename'];
$tables[] = $settings->config['activity_logs_tablename'];
$tables[] = $settings->config['flags_tablename'];
$tables[] = $settings->config['filetypes_tablename'];
$tables[] = $settings->config['last_uploads_tablename'];
$tables[] = $settings->config['permvars_tablename'];
$tables[] = $settings->config['settings_tablename'];
$tables[] = $settings->config['share_info_tablename'];
$tables[] = $settings->config['trash_tablename'];
$tables[] = $settings->config['optinfo_tablename'];
$tables[] = $settings->config['history_tablename'];

for ($i = 0 ; $i < sizeof($tables) ; $i++) {


$check = $db->GetRow("CHECK TABLE ".$tables[$i]."");
$analyze = $db->GetRow("ANALYZE TABLE ".$tables[$i]."");
$status = $db->GetRow("SHOW TABLE STATUS LIKE '".$tables[$i]."'");
?>
<tr>
	<td><?echo $check['Table'];?></td>
	<td><?
	
	echo $check['Msg_text'];
	
	if ($check['Msg_text'] != "OK") {
	?> 
<span class="comment">(<a href="?admin=1&sub=diagnostics&repair_table=<?echo $str->forURL($tables[$i]);?>"><?$lang->display("repair");?></a>)</span>
	<?
	}
	
	if ($status['Data_free'] > 0) {
	?> 
<span class="comment">(<a href="?admin=1&sub=diagnostics&optimize_table=<?echo $str->forURL($tables[$i]);?>"><?$lang->display("optimize");?></a>)</span>
	<?
	}
	?></td>
</tr>
<?

}


?>
</table>

</td>
</tr>

</table>



<br>

	</td>
</tr>
<tr>
    <td align="center" height="20">
<div style="position:relative;top:16px;z-index:1">
<?
$tpl->btn(
$lang->get(" Close "), 
"window.close();self.close();"
);
?>
</div>
	</td>
</tr>
<tr>
    <td background="images/popup/bottom-bg.gif" height="46">&nbsp;</td>
</tr>
</table>


<?
require_once($sys['root']."/system/templates/popup/footer.inc");
?>