Seite 1 von 1

[Navigations-Box] Eine neue Box dazufügen !

Verfasst: 29.07.2008 19:17
von n3oth3on3
Guten Tag,
ich habe ein kleines Problem mit meinem Forum.

Möchte eine neue Box mit Server Stats dazufügen, das Problem ist das Script ist in PHP.

serverstats.php

Code: Alles auswählen

<?
//config
$cfg['server_ip'] = "xxx.xxx.xxx.xxx";
$cfg['server_port'] = 7171;

//server packet that needs to be sent to get info 
$info = chr(6).chr(0).chr(255).chr(255).'info'; 
//making socket connection to an ip and port 7171 
$sock = @fsockopen($server_ip, 7171, $errno, $errstr, 1); 

//show source request 
if($_REQUEST['action']=='source'){ 
highlight_file(__FILE__); 
} 
else{ 
if ($sock) 
{ 
//writes the info gotten by sending the server packet. 
fwrite($sock, $info); 
$data=''; 

while (!feof($sock)) 
{ 
$data .= fgets($sock, 1024); 
} 
fclose($sock); 

//players online and max (ex. Players online: 24 / 100) 
preg_match('/players online="(\d+)" max="(\d+)"/', $data, $matches); 
echo '<p>Status:<b><font color="#00FF00"> Online</font></b>'; 
echo '<br />Players: '.$matches[1].' / '.$matches[2]; 


//Uptime (Uptime: 23h 12m) 
preg_match('/uptime="(\d+)"/', $data, $matches); 
$d = floor($matches[1] / 86400);
$Rest1 = $matches[1]-($d*86400);
$h = floor($Rest1 / 3600);
$Rest2 = $Rest1-($h*3600);
$m = floor($Rest2 / 60);
$Rest3 = $Rest2-($m*60);
$s = floor($Rest3);

echo '<br />Uptime: '. $d .'d '. $h .'h '. $m. 'm '. $s .'s</p>'; 
} 
else 
{ 
echo '<p>Server Status:<b><font color="#FF0000"> Offline</font></b></p>'; 
} 
} 
?>
Habs ihn die Index_body.html so eingefügt.

Code: Alles auswählen

	<div class="tabhead">
	<span class="dt">Server Stats</span></div>
	<div class="tabcell">
	<span class="dn">
	<!-- INCLUDE serverstats.php -->
	</span></div>
Das Problem ist ob ich nun serverstats.php oder serverstats.html mache es geht nich nur bei .html !

Wie kann ich also .php Datein includen so das sie angezeigt werden?

Verfasst: 30.07.2008 12:30
von n3oth3on3
Keiner eine Idee wie man Perfekt eine php Datei einbinden kann?

Per iframe gehts aber dann hab ich das Problem das die Schrift anderes ist, will alles im Forum Style haben also das die css mit eingebunden werden...

Verfasst: 30.07.2008 14:45
von Dr.Death
Doch, schon.... aber direkt PHP Code in eine HTML Seite einbauen ist der unsauberste Weg.


Besser so:
http://code.phpbb.com/devwiki/Adding_pages
http://code.phpbb.com/devwiki/Template_Syntax

Den eigentlichen PHP Code kannst Du ja in die index.php einbauen.
Du musst dann nur noch die Variablen an das Template index_body.html übergeben.

Verfasst: 31.07.2008 12:31
von n3oth3on3
und wie würde das in etwas aussehen für diesen code Oo ?

Will das dieser Code 100 % die css vom Board übernimmt das alles gleich aussieht :(