<? 
$CLS='server_info';
class server_info
{
	function init() {
		global $X;
		$X->NAVI[] = $X->ADMIN->module_name();

		if(filemtime(CACHE.'/sysinfo.cache')<time()-5) {
			@unlink(CACHE.'/sysinfo.cache');
			$X->URL->go();
		}

		$e=get_loaded_extensions();
		if(count($e)>0) {
			natcasesort($e);
			foreach($e as $ex) $ext.='<tr><td><a href="#" onclick="$.scrollTo($(\'a[name=module_'.$ex.']\'));">'.$ex.'</a></td></tr>';
		}

		if(count($X->CONF->ENV)>0) {
			foreach($X->CONF->ENV as $p_name => $p_value) {
				if(is_int($p_name)) $p_name=$p_value='';
				$info.='
					<tr'.(empty($p_name) ? ' class="row_sep"':'').'>
						<td>'.$p_name.'</td>
						<td class="center"><b>'.$p_value.'</b></td>
					</tr>
				';
			}
			$info.='
				<tr class="row_sep"><td></td><td></td></tr>
				<tr>
					<td>server_datetime</td>
					<td class="center"><b>'.date('Y-m-d H:i:s').'</b></td>
				</tr>
			';
		}

		$check_f=array('fsockopen','curl_exec','iconv','exec','system','ini_get','ini_set','memory_get_usage');
		if(count($check_f)>0) foreach($check_f as $f) {
			$funcs.='
				<tr>
					<td width="160">'.$f.'</td>
					<td class="center"><b>'.(function_exists($f) ? 'yes' : 'no').'</b></td>
				</tr>
			';
		}

		ob_start();
		phpinfo();
		$phpinfo=preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', ob_get_contents());
		ob_end_clean();

		$html.='
			<br />
			<div class="fleft" style="width:320px;">
					'.$X->ADMIN->inline_table(array(
						'head' => '<th>PARAM</th><th class="center">VALUE</th>',
						'body' => $info,
						'width' => 320
					)).'
					<br /><br />
					'.$X->ADMIN->inline_table(array(
						'head' => '<th>FUNCTION</th><th class="center">AVAILABLE</th>',
						'body' => $funcs,
						'width' => 320
					)).'
					<br /><br />
					'.$X->ADMIN->inline_table(array(
						'head' => '<th>LOADED EXTENSIONS</th>',
						'body' => $ext,
						'width' => 320
					)).'
			</div>

			<style type="text/css">
				#phpinfo { color:#000000; margin:0px auto; text-align:center; padding-left:30px; font-size:12px; width:600px; overflow:hidden; float:left; }
				#phpinfo td, #phpinfo th, #phpinfo h1, #phpinfo h2 {}
				#phpinfo pre {margin: 0px; font-family: monospace;}
				#phpinfo a:link {color: #000099; text-decoration: none; background: #ffffff;}
				#phpinfo a:hover {text-decoration: underline;}
				#phpinfo table {border-collapse: collapse;}
				#phpinfo .center {text-align: center;}
				#phpinfo .center table { margin-left: auto; margin-right: auto; text-align: left;}
				#phpinfo .center th { text-align: center !important; }
				#phpinfo td, #phpinfo th { border: 1px solid #000000; font-size: 11px; vertical-align: baseline;}
				#phpinfo h1 {font-size: 25px; text-shadow:0px 0px 0px #000;}
				#phpinfo h2 {font-size: 18px; text-shadow:0px 0px 0px #000;}
				#phpinfo .p {text-align: left;}
				#phpinfo .e {background: #ccccff; font-weight: bold; color: #000000;}
				#phpinfo .h {background: #9999cc; font-weight: bold; color: #000000;}
				#phpinfo .v {background: #cccccc; color: #000000;}
				#phpinfo .vr {background: #cccccc; text-align: right; color: #000000;}
				#phpinfo img {float: right; border: 0px;}
				#phpinfo hr {width: 600px; background: #cccccc; border: 0px; height: 1px; color: #000000;}
			</style>
			<div id="phpinfo">'.$phpinfo.'</div>
			<div class="clear"></div><br />
		';

		return $X->ADMIN->formbox($html);
	}

}
?>