Jump to content
xisto Community
Sign in to follow this  
motili

Php Nuke Create Block

Recommended Posts

Hi all!Im want create server status block with these codes

<?php if (eregi("block-Onlineplayers.php", $PHP_SELF)) {Header("Location: index.php");die();}  //set server, port and timeout information $server = "same adress"; $portg = "7777"; $portl = "2106"; $timeout = "1"; //try to open a connection to the game and login server  $game = @fsockopen("$server", $portg, $errno, $errstr, $timeout); $login = @fsockopen("$server", $portl, $errno, $errstr, $timeout);   //let us know if the servers are up or not  echo $game ? "<img src=\"gameonline.jpg\">" : "<img src=\"gameoffline.jpg\">"; echo $login ? "<img src=\"loginonline.jpg\">" : "<img src=\"loginoffline.jpg\">"; //set host, username and password for MySQL $dbhost = "some adress"; $dbuser = "some user"; $dbpass = "some password";   //connect to MySQL or return an error $conn = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die('Could not connect: ' . mysql_error());   //set database name $dbname = "some database";   //select database or return an error $dbselect = mysql_select_db("$dbname") or die ('Could not select database');   //select all records from the characters table where that character is currently online $chars = mysql_query("SELECT online FROM characters where online='1'") or die ('Query failed: ' . mysql_error());   //count how many online characters there are $rows = mysql_num_rows($chars);   //convert the number of online characters to a string $count =(string)$rows;   //convert each digit in the string to a graphic for ($i=0; $i < strlen($count); $i++) { echo('<img src="' . $count{$i} . '.jpg">'); }    //close MySQL connection mysql_close();   ?>

Im already create the block-Onlineplayers.php and the block with administrator just the content is showing out the block and inside the block is show this:"There isn't content right now for this block."Please help me someone.ThxOk im look in the other blocks and made this just block is not working.Where is the problem?

<?php if (eregi("block-Onlineplayers.php", $PHP_SELF)) {Header("Location: index.php");die();}  $content  =  "//set server, port and timeout information ";$content  =  "$server =\ "some ip";\ ";$content  =  "$portg =\ "7777";\ ";$content  =  "$portl =\ "2106";\ ";$content  =  "$timeout =\ "1";\ ";$content  =  "//try to open a connection to the game and login server ";$content  =  "$game =\ @fsockopen("$server", $portg, $errno, $errstr, $timeout); ";$content  =  "$login =\ @fsockopen("$server", $portl, $errno, $errstr, $timeout); "; $content  =  "//let us know if the servers are up or not ";$content  .= "echo $game ? "<img src=\"gameonline.jpg\">" : "<img src=\"gameoffline.jpg\">"; ";$content  .= "echo $login ? "<img src=\"loginonline.jpg\">" : "<img src=\"loginoffline.jpg\">"; ";$content  .= "echo $login ? "<img src=\"online.jpg\">" : "<img src=\"offline.jpg\">"; ";$content  =  "//set host, username and password for MySQL ";$content  =  "$dbhost =\ "some ip";\ ";$content  =  "$dbuser =\ "some user";\ ";$content  =  "$dbpass =\ "some password"; ";$content  =  "//connect to MySQL or return an error ";$content  =  "$conn =\ mysql_connect("$dbhost", "$dbuser", "$dbpass") ";$content  =  "or die('Could not connect: ' . mysql_error());  ";$content  =  "//set database name ";$content  =  "$dbname =\ "some database"; ";$content  =  "//select database or return an error ";$content  =  "$dbselect =\ mysql_select_db("$dbname") or die ('Could not select database'); ";$content  =  "//select all records from the characters table where that character is currently online ";$content  =  "$chars =\ mysql_query("SELECT online FROM characters where online='1'") or die ('Query failed: ' . mysql_error()); "; $content  =  "//count how many online characters there are ";$content  =  "$rows =\ mysql_num_rows($chars); ";$content  =  "//convert the number of online characters to a string ";$content  =  "$count =\(string)$rows; ";$content  =  "//convert each digit in the string to a graphic ";$content  =  "for ($i=0; $i < strlen($count); $i++) { echo('<img src="' . $count{$i} . '.jpg">'); } ";$content  =  "//close MySQL connection ";$content  =  "mysql_close(); ";?>

Notice from rvalkass:
Code should be inside Code tags. Also, please try to post in the most relevant section of the forums - you'll get a quicker response. Moving to the PHP section.
Edited by rvalkass (see edit history)

Share this post


Link to post
Share on other sites

OMG im very lucky.No one want help me?
Im format the code a bit.Here is the new code just is show only the code inside the block!

<?php/****************************************************************************//*  Generated by Block Creator - By Disipal Designs (disipal.net;	   *//*  PHP-Nuke Tools v4.00													*//****************************************************************************/if (eregi("block-Block_Creator.php",$PHP_SELF)) {	Header("Location: index.php");	die();} $content  .=  "include(\"data.php\");";$content  .= "$game = @fsockopen(\"$server\", $portg, $errno, $errstr, $timeout);";$content  .= "$login = @fsockopen(\"$server\", $portl, $errno, $errstr, $timeout);"; $content  .= "echo $game ? \"<img src=\\\"gameonline.jpg\\\">\" : \"<img src=\\\"gameoffline.jpg\\\">\";";$content  .= "echo $login ? \"<img src=\\\"loginonline.jpg\\\">\" : \"<img src=\\\"loginoffline.jpg\\\">\";"; $content  .= "echo '<img src=\"online.jpg\" width=\"50\" height=\"30\">';";$content  .= "$conn = mysql_connect(\"$dbhost\", \"$dbuser\", \"$dbpass\")";$content  .= "or die('Could not connect: ' . mysql_error());"; $content  .= "$dbselect = mysql_select_db(\"$dbname\") or die ('Could not select database');"; $content  .= "$chars = mysql_query(\"SELECT online FROM characters where online='1'\") or die ('Query failed: ' . mysql_error());";$content  .= "$rows = mysql_num_rows($chars);"; $content  .= "$count =(string)$rows;"; $content  .= "for ($i=0; $i < strlen($count); $i++) { echo('<img src=\"' . $count{$i} . '.jpg\">'); }"; $content  .= "mysql_close(); "; ?>

Edited by motili (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.