SMF For Free Support Forum
Signup For Free Forum
July 04, 2008, 10:24:40 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to SMF For Free. The best free SMF Host
 
   Home   Help Search Arcade Gallery Login Register  

Pages: [1]
  Print  
Author Topic: ServerStatus Page.  (Read 1519 times)
0 Members and 1 Guest are viewing this topic.
|-|Java()|-|
SMF For Free Newbie
*
Offline Offline

Posts: 13


View Profile
« on: July 18, 2007, 10:31:33 pm »

Hi, i have decided to make a code for people as they keep asking for a server status page.

First make a new table in your database called servers with 3 feilds,
id auto increcement int(11) primary
host varcher(250)
port varchar(250)


Code:
CREATE TABLE `servers` (
  `id` int(11) NOT NULL auto_increment,
  `host` varchar(250) NOT NULL default '',
  `port` varchar(250) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

Now create a php page, it can be called whatever you want  :eek: as long as its a php document, dont forget to edit the database details...
<?php
session_start
();
echo 
"<font face=arial size=2>";

//edit this
$host='localhost'// this is usually localhost, but might be something else
$username='DATABASE USERNAME'//database username here
$pass='DATABASE PASSWORD'//database password here
$database='DATABASE NAME'// database name here

mysql_connect ($host$username$pass);
mysql_select_db($database) or die('Could not connect to the Database');

$action $_GET['action'];
if(!
$action){
echo 
"<a href=$_SERVER[PHP_SELF]?action=1>Add new server</a><br /><table width=400><tr><td><font size=2><b>Address</d></font></td><td><font size=2><b>Port</b></font></td><td><font size=2><b>Status</b></font></td></tr>";
$query mysql_query("SELECT * FROM servers");
while (
$row mysql_fetch_array($query)){
@
$fp fsockopen($row[host], $row[port], $no$str4);
if(
$fp){
echo 
"<tr><td>$row[host]</td><td>$row[port]</td><td><font face=arial color=#00ff00><b>Online</b></font></td></tr>";
}else{
echo 
"<tr><td>$row[host]</td><td><font face=arial color=#ff0000><b>Offline</b></font></td></tr>";
}}
echo 
"</table><br /><a href=$_SERVER[PHP_SELF]?action=1>Add new server</a>"; }
if(
$action>0){
echo 
"<a href=$_SERVER[PHP_SELF]>Back to server list</a><br />";
if(isset(
$submit)){
@
$fp fsockopen($_POST[host], $_POST[port], $no$str4);
if(
$fp){
$number mysql_num_rows(mysql_query("SELECT * FROM servers WHERE host='$_POST[host]'"));
if(
$number==0){
mysql_query("INSERT INTO servers(`host`, `port`)VALUES('$_POST[host]', '$_POST[port]')");
echo 
"$_POST[host] $_POST[port] has succesfully been added to the database"; }
if(
$number>0){ echo "This host has already been submited to our database"; }
}else{
echo 
"There was a problem connecting to the set server, please check the feilds<br />
<form action='$_SERVER[PHP_SELF]?action=1' method=post name=form>
<table width=400>
<tr><td valign=left>host:(without http://)</td><td><input type=text name=host value=$_POST[host]  /></td></tr>
<tr><td valign=left>Port:</td><td><input type=text name=port value=$_POST[port]  /></td></tr>
<tr><td valign=left><input type=submit name=submit value=Submit  /></td></tr>
</table></form>
"
; }}
if(!isset(
$submit)){
echo 
"
<form action='$_SERVER[PHP_SELF]?action=1' method=POST name=form>
<table width=400>
<tr><td valign=left><font size=2>Host:(without http://)</font></td><td><input type=text name=host value=$_POST[host]  /></td></tr>
<tr><td valign=left><font size=2>Port:</font></td><td><input type=text name=port value=$_POST[port]  /></td></tr>
<tr><td valign=left><input name=submit type=submit value=Submit></td></tr>
</table></form>
"
; }
echo 
"<br /><a href=$_SERVER[PHP_SELF]>Back to server list</a>";
}


echo 
"</font>";

?>

Logged

I am a moparScape expert so if you need anyhelp!
Pm me here or on moparscape and I'll help!!
If you need more help add me on my msn moparsc4p3@hotmail.com

Thanks!
BadgerGirl*naf
SMF For Free Full Member
*
Offline Offline

Posts: 139



View Profile WWW
« Reply #1 on: September 29, 2007, 09:45:51 pm »

is this for smf? and how do u add a new table?
Logged

Sarah
SMF For Free Member
*
Offline Offline

Posts: 66


www.creativ.com.net.sc


View Profile WWW
« Reply #2 on: September 29, 2007, 09:48:31 pm »

wow kool
Logged

Visit my site ... www.creativ.com.net.sc
mr_css
SMF For Free Sr. Member
*
Offline Offline

Posts: 264



View Profile
« Reply #3 on: October 20, 2007, 05:58:12 pm »

sounds good, can I get a preview? I've done this before on MoparScape. No one commented so I removed about two days after. What i'm thinking is this is best for RuneScape Private servers. but its good.
Logged


            WOLFSCAPE FORUMS
*ballin*
SMF For Free Member
*
Offline Offline

Posts: 33


View Profile WWW
« Reply #4 on: May 26, 2008, 04:46:17 pm »

Ye, maybe you should add a preview and maybe people will start using Tongue
Logged

Crasy
Global Moderator
*
Offline Offline

Posts: 3231


I Approve of this Message


View Profile
« Reply #5 on: May 27, 2008, 02:26:19 pm »

Ye, maybe you should add a preview and maybe people will start using Tongue

Man, this was written nearly a year ago.

The user hasn't even signing in since February.
Logged

fallenmonkscape
SMF For Free Member
*
Offline Offline

Posts: 54


View Profile
« Reply #6 on: June 13, 2008, 05:43:56 pm »

To learn more about php go-to http://w3schools.com/php/default.asp
Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
ServerBeach Coupon
Page created in 0.226 seconds with 19 queries.