Jump to content

PLEASE HELP! PHP code not displaying server ports connection list.....


ShadowIce

Recommended Posts

How can I make it so that if it finds NO table entries in my database, it displays: NO DATA CURRENTLY AVAILABLE! , and how can I make it so my tables look like this:

 

IP:                          Port: 
        127.0.0.1                24099

 

Instead of:

 

IP: 
        127.0.0.1
        Port: 
        24099

 

code:

 

<?
require('errorvalidation.php');
require('db_cnct.php');
?>

<?

////////////////////////////////
//
//


$action    = $_GET["action"];
$ip        = $_SERVER["REMOTE_ADDR"];
$port      = $_GET["port"];
$info      = $_GET["info"];


////////////////////
//
//

   switch  (strtolower($action)){																	 
 case "getlist";
		 db_get_list();
	         break;
 case "addhost";
		 db_add_Host($ip,$port,$info);
	         break;
 case "alive";
		 Hostalive($ip);
                         break;
         case "findhost";
                         DB_fnd_HOST($ip,$port);
	         break;
 case "delete";
		 db_del_host($ip,$port);
		 break;			 
}

mysql_close()

;//////////////////////////////////////////////

function DB_add_HOST($ip,$port,$info) 
{
$ctime=time();
db_del_host ($ip,$port);
$entry="INSERT INTO HOSTS (IP, PORT, INFO01, TIMESTAMP) VALUES ('$ip', '$port','$info','$ctime')";

$add_entry=mysql_query($entry);
echo "ip:'$ip' timestamp:'$ctime' info:'$info'";
//mysql_close();

}


;//////////////////////////////////////////////

function DB_del_HOST($ip,$port) 
{
$db_query=mysql_query("DELETE FROM `HOSTS` WHERE `IP` = '$ip' AND `PORT` = '$port' LIMIT 3");
}



;//////////////////////////////////////////////

function DB_get_LIST() 
{echo "<center>\r\n";
echo "Servers: <br>\r\n";
echo "<table border=\"1\">\r\n";
$db_pointer=mysql_query("select * from HOSTS");
while($host=mysql_fetch_array($db_pointer))
{
if($db_pointer == ""){
$atime=time();
$btime=$host['TIMESTAMP'];
$ctime =$atime-$btime;																	 
if($ctime > 1800)
{
db_del_host ( $host['IP'],$host['PORT'] );
}
else
{
echo "<tr>\r\n";
echo "<td>IP: </td>\r\n<td>".$host['IP']."</td>\r\n<br>\r\n";
echo "<tr><td>Port: </td>\r\n<td>".$host['PORT']."</td>\r\n</tr>\r\n<br>\r\n";
echo "Info:{$host['INFO01']}\r\n<br>\r\n";
}
}else{
echo "NO DATA CURRENTLY AVAILABLE!\r\n";
}
}

echo "</table>\r\n";
echo "</center>\r\n";

//mysql_close();

}

;//////////////////////////////////////////////

function HOSTAlive($ip) 
{
$timestamp= time();
$aendern	 = "UPDATE HOST Set TIMESTAMP = '$timestamp' WHERE ip = '$ip'";


//mysql_close();

}

;//////////////////////////////////////////////

;//////////////////////////////////////////////

function DB_fnd_HOST($ip,$port) 
{

  $abfrage = "SELECT * FROM HOSTS WHERE PORT LIKE
  '$port'";

//mysql_close();

}

;//////////////////////////////////////////////


?>

 

the function to look in is

 

DB_get_LIST()

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.