Server status HELP!!

04/10/2011 02:30 neverhere#1
how i put this :


PHP Code:
<?php
require_once ('config.php');



mysql_select_db($accdb);
$res mysql_query('SELECT count(id) FROM account;');
$val mysql_fetch_array($res);
echo 
'<font color="#45BEFF", size="2px"> <b>Total Accounts:</b> '.$val[0].'<br />';



mysql_select_db($gamedb);
$res mysql_query('SELECT count(id) FROM cq_user;');
$val mysql_fetch_array($res);
echo 
'<b>Total Characters:</b> '.$val[0].'<br />';



echo 
'<b>Server Status:</b> ';
$fp = @fsockopen($serveraddress$serverport$errno$errstr1);
if (!
$fp) {
echo 
'<font style="color: #FF3300"><b>Offline</b></font><br />';
}
else
{
echo 
'<font style="color: #FFFFFF"><b>Online</b></font><br />';
fclose($fp);
}

?>
<b>Total Players Online:</b> <b><?php echo (exec('netstat -a -n |find "5816" |find "ESTABLISHED" /c')-3); ?></b><br />
in my website(html), like all the server did.
like this one
[Only registered and activated users can see links. Click Here To Register...]
04/10/2011 19:18 synergie#2
Hi,

Well put you php script into a random php file

Example: Status.php with your codes in it
Code:
<?php
require_once ('config.php');



mysql_select_db($accdb);
$res = mysql_query('SELECT count(id) FROM account;');
$val = mysql_fetch_array($res);
echo '<font color="#45BEFF", size="2px"> <b>Total Accounts:</b> '.$val[0].'<br />';



mysql_select_db($gamedb);
$res = mysql_query('SELECT count(id) FROM cq_user;');
$val = mysql_fetch_array($res);
echo '<b>Total Characters:</b> '.$val[0].'<br />';



echo '<b>Server Status:</b> ';
$fp = @fsockopen($serveraddress, $serverport, $errno, $errstr, 1);
if (!$fp) {
echo '<font style="color: #FF3300"><b>Offline</b></font><br />';
}
else
{
echo '<font style="color: #FFFFFF"><b>Online</b></font><br />';
fclose($fp);
}

?>
<b>Total Players Online:</b> <b><?php echo (exec('netstat -a -n |find "5816" |find "ES
save it and place it with your source (into the website folder of your server , normally C:/AppsServer/www)


Then put this into your HTML source codes at the place you want

Code:
<IFRAME style=" border="0" name="I1" src="http://[COLOR="Red"][SERVERIP][/COLOR]/Status.php" frameborder="0" width="626" height="801" resizing="no">
you can cange the height and width to your own preferences. so the box with all info i fully shown

This is the basic and most used way to put in your script in HTML. I hope it helps you

Greets
Synergie
04/10/2011 19:29 .Kinshi#3
Yes lets use IFrames because this is the 90s!
04/10/2011 20:47 synergie#4
Quote:
Originally Posted by .Kinshi View Post
Yes lets use IFrames because this is the 90s!
Lol, why not its easy and works ^^
04/10/2011 21:00 pro4never#5
It's bad practice... just place the php code within your existing template.
04/10/2011 23:36 .Kinshi#6
Quote:
Originally Posted by synergie View Post
Lol, why not its easy and works ^^
It's old and outdated, plus it looks bad and doesn't play well with a lot of things.

Use a php include() instead.
04/11/2011 14:19 synergie#7
Quote:
Originally Posted by .Kinshi View Post
It's old and outdated, plus it looks bad and doesn't play well with a lot of things.

Use a php include() instead.
include only works when your site is also build in PHP. won't work for html
04/12/2011 03:41 .Kinshi#8
Quote:
Originally Posted by synergie View Post
include only works when your site is also build in PHP. won't work for html
As long as your web server supports PHP, you can put it anywhere.

Code:
<html>
  <body>
    <h1>My awesome server</h2>
    <p><?php include('serverstatus.php'); ?></p>
  </body>
</html>
04/13/2011 12:21 Secured#9
Quote:
Originally Posted by .Kinshi View Post
As long as your web server supports PHP, you can put it anywhere.

Code:
<html>
  <body>
    <h1>My awesome server</h2>
    <p><?php include('serverstatus.php'); ?></p>
  </body>
</html>
Only if the extenstion is .php.
It won't work for htm, html, xml etc.

The point is OP is using html for his site and it won't work if he ain't switching his file extenstion to .php.
04/13/2011 12:36 Korvacs#10
Quote:
Originally Posted by Secured View Post
Only if the extenstion is .php.
It won't work for htm, html, xml etc.

The point is OP is using html for his site and it won't work if he ain't switching his file extenstion to .php.
Actually by modifying .htaccess you can have html parsed for php.
04/13/2011 13:38 Secured#11
Quote:
Originally Posted by Korvacs View Post
Actually by modifying .htaccess you can have html parsed for php.
And you assume OP knows how to do that?
04/13/2011 13:49 Korvacs#12
Quote:
Originally Posted by Secured View Post
And you assume OP knows how to do that?
No, but you stated explicitly that it couldnt be done, assuming that the OP doesnt know how to do it, so i thought i would mention that it is actually possible.
04/14/2011 21:32 .Kinshi#13
Quote:
Originally Posted by Secured View Post
Only if the extenstion is .php.
It won't work for htm, html, xml etc.

The point is OP is using html for his site and it won't work if he ain't switching his file extenstion to .php.
Quote:
Originally Posted by Korvacs View Post
Actually by modifying .htaccess you can have html parsed for php.
Exactly.