Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/web/server/serverstatus.phps
<? // Get system data
$monit = getstat('monitor');
$ram = getstat('ram');
$swap = getstat('swap');
$cpu = getstat('cpu');
$uptime = getstat('uptime');
global $T;
?>

<div align="center">
<?
if ($action AND $confirm == "true" AND $userdata['type'] != 'demo') {
	// Initialize
	unset($error);

	$error = service($action,$service);

	if ($error)
		echo "<br>&nbsp;&nbsp;&bull; ".implode("<br>\n&nbsp;&nbsp;&bull; ",$error)."<br>\n";
	else {
		// Save old state
		$state = $T[$monit[$service]];

		$service_complete = false;

		// wait monitor refresh before to print the page
		if (($action == "restart") AND ($state == $T['down']))
			$refresh = 1;
		elseif ($action != "restart")
			$refresh = 1;
		else {
			$refresh = 0;
			$service_complete = true;
		}
			
		if ( $refresh ) {
			$monit = getstat('monitor');
			$i = 0;
			while(($T[$monit[$service]] == $state) && ($i < $cfg['init']['timeout'])) {
				$i += 1;
				sleep(1);
				$monit = getstat('monitor');
			}
			if ($T[$monit[$service]] != $state) {
				$service_complete = true;
			}
		}
		
		if ($service_complete) {
			// print action result				
			echo $T['service '.$action]."<b>".$service."</b><br><br>\n";
		} else {
			// print action waiting
			echo $T['service waiting '.$action]."<b>".$service."</b><br><br>\n";
		}
	}
} elseif ($action AND $confirm == "true" AND $userdata['type'] == 'demo') {
	echo "<center>".$T['err']['demo user']."</center>";
}
if ($action AND $confirm != "true") { ?>
	<blockquote>
	<form action="<?=$current_url;?>" method="post">
	&nbsp;&nbsp;&bull; <?=$T['really '.$action];?><b><?=$service;?></b><br>
	&nbsp;&nbsp;&nbsp;<input type="submit" value="<?=$T['yes'];?>">
	<input type="hidden" name="action" value="<?=$action;?>">
	<input type="hidden" name="service" value="<?=$service;?>">
	<input type="hidden" name="confirm" value="true">
	</form>
	</blockquote>
<? } ?>

<table border="0" cellspacing="0" cellpadding="0" class="tblbg">
	<tr>
		<td>
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="3" class="tbltop">&nbsp;<?=$T[$cp][$url];?>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Web Server'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;
					<? 
						if ($T[$monit['httpd']] == $T['up'])
							echo "<img src=\"icon/up.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['up']."\">";
						else
							echo "<img src=\"icon/down.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['down']."\">";
					?>
					&nbsp;</td>
				<td class="row1">&nbsp; 
					<? 
						if ($T[$monit['httpd']] == $T['up']) { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=httpd&action=stop"><img src="icon/stop.gif" border="0" width="32" height="32" alt="<?=$T['stop'];?>"></a>
						<? } else { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=httpd&action=start"><img src="icon/start.gif" border="0" width="32" height="32" alt="<?=$T['start'];?>"></a>
						<? } ?>
					<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=httpd&action=restart"><img src="icon/reboot.gif" border="0" width="32" height="32" alt="<?=$T['restart'];?>"></a>
				&nbsp;</td>
			</tr>
			<? if ($cfg['mailserver'] != 'none') { ?>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Outgoing Mail Server'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;
					<? 
						if ($T[$monit[$cfg['mailserver']]] == $T['up'])
							echo "<img src=\"icon/up.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['up']."\">";
						else
							echo "<img src=\"icon/down.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['down']."\">";
					?>
					&nbsp;</td>
				<td class="row1">&nbsp; 
					<? 
						if ($T[$monit[$cfg['mailserver']]] == $T['up']) { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['mailserver'];?>&action=stop"><img src="icon/stop.gif" border="0" width="32" height="32" alt="<?=$T['stop'];?>"></a>
						<? } else { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['mailserver'];?>&action=start"><img src="icon/start.gif" border="0" width="32" height="32" alt="<?=$T['start'];?>"></a>
						<? } ?>
					<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['mailserver'];?>&action=restart"><img src="icon/reboot.gif" border="0" width="32" height="32" alt="<?=$T['restart'];?>"></a>
				&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Incoming Mail Server'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;
					<? 
						if ($T[$monit['pop3']] == $T['up'])
							echo "<img src=\"icon/up.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['up']."\">";
						else
							echo "<img src=\"icon/down.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['down']."\">";
					?>
					&nbsp;</td>
				<td class="row1">&nbsp; 
					<? 
						if ($T[$monit['pop3']] == $T['up']) { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=pop3&action=stop"><img src="icon/stop.gif" border="0" width="32" height="32" alt="<?=$T['stop'];?>"></a>
						<? } else { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=pop3&action=start"><img src="icon/start.gif" border="0" width="32" height="32" alt="<?=$T['start'];?>"></a>
						<? } ?>
					<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=pop3&action=restart"><img src="icon/reboot.gif" border="0" width="32" height="32" alt="<?=$T['restart'];?>"></a>
				&nbsp;</td>
			</tr>
			<? } ?>
			<? if ($cfg['ftpserver'] != 'none') { ?>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['FTP Server'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;
					<? 
						if ($T[$monit[$cfg['ftpserver']]] == $T['up'])
							echo "<img src=\"icon/up.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['up']."\">";
						else
							echo "<img src=\"icon/down.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['down']."\">";
					?>
				&nbsp;</td>
				<td class="row1">&nbsp; 
					<? 
						if ($T[$monit[$cfg['ftpserver']]] == $T['up']) { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['ftpserver'];?>&action=stop"><img src="icon/stop.gif" border="0" width="32" height="32" alt="<?=$T['stop'];?>"></a>
						<? } else { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['ftpserver'];?>&action=start"><img src="icon/start.gif" border="0" width="32" height="32" alt="<?=$T['start'];?>"></a>
						<? } ?>
					<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['ftpserver'];?>&action=restart"><img src="icon/reboot.gif" border="0" width="32" height="32" alt="<?=$T['restart'];?>"></a>
				&nbsp;</td>
			</tr>
			<? } ?>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['DNS Server'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;
					<? 
						if ($T[$monit[$cfg['dns_system']]] == $T['up'])
							echo "<img src=\"icon/up.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['up']."\">";
						else
							echo "<img src=\"icon/down.gif\" border=\"0\" width=\"16\" height=\"16\" alt=\"".$T['down']."\">";
					?>
				&nbsp;</td>
				<td class="row1">&nbsp; 
					<? 
						if ($T[$monit[$cfg['dns_system']]] == $T['up']) { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['dns_system'];?>&action=stop"><img src="icon/stop.gif" border="0" width="32" height="32" alt="<?=$T['stop'];?>"></a>
						<? } else { ?>
							<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['dns_system'];?>&action=start"><img src="icon/start.gif" border="0" width="32" height="32" alt="<?=$T['start'];?>"></a>
						<? } ?>
					<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=<?=$cfg['dns_system'];?>&action=restart"><img src="icon/reboot.gif" border="0" width="32" height="32" alt="<?=$T['restart'];?>"></a>
				&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Memory Usage'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<?=$ram['used']."/".$ram['total'];?> RAM, <?=$swap['used']."/".$swap['total'];?> Swap&nbsp;</td>
				<td rowspan="3" class="row1"><div align="right">&nbsp; 
					<a href="./?url=serverstatus&cp=server&number=<?=$number;?>&user=<?=$user;?>&service=system&action=reboot"><img src="icon/reboot.gif" border="0" width="32" height="32" alt="<?=$T['restart'];?>"></a>
				&nbsp;</div></td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Processor Usage'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<?=$cpu['cpu'];?>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Uptime'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<?=$cpu['uptime'];?>&nbsp;</td>
			</tr>
			<?
			$dom = fetchdata("domains","total",0);
			$sub = fetchdata("subdomains","total",0);
			$ptr = fetchdata("pointers","total",0);
			$usr = fetchdata("users","total",0);
			?>
			<tr>
				<td class="row1"><b>&nbsp;Number of Domains&nbsp;</b></td>
				<td class="row2" colspan="2">&nbsp;<?=$dom['domains'];?>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;Number of Sub-Domains&nbsp;</b></td>
				<td class="row2" colspan="2">&nbsp;<?=$sub['subdomains'];?>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;Number of Domain Pointers&nbsp;</b></td>
				<td class="row2" colspan="2">&nbsp;<?=$ptr['pointers'];?>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;Number of Users&nbsp;</b></td>
				<td class="row2" colspan="2">&nbsp;<?=$usr['users'];?>&nbsp;</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</div>

Return current item: web-cp - Web Hosting Control Panel