Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Php Nuke, Create Block
motili
post Jun 27 2008, 03:33 AM
Post #1


Newbie
*

Group: Members
Posts: 3
Joined: 27-June 08
Member No.: 64,240



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

<?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.Thx



Ok im look in the other blocks and made this just block is not working.Where is the problem?
CODE

<?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.


This post has been edited by rvalkass: Jun 27 2008, 09:45 AM
Go to the top of the page
 
+Quote Post
motili
post Jun 27 2008, 08:22 PM
Post #2


Newbie
*

Group: Members
Posts: 3
Joined: 27-June 08
Member No.: 64,240



No One Can Help Me?Please....
Go to the top of the page
 
+Quote Post
motili
post Jun 28 2008, 01:12 PM
Post #3


Newbie
*

Group: Members
Posts: 3
Joined: 27-June 08
Member No.: 64,240



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!
CODE
<?php
/****************************************************************************/
/*  Generated by Block Creator - By Disipal Designs (www.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(); ";
?>


This post has been edited by motili: Jun 28 2008, 09:35 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Best Content management system?(21)
  2. Php Nuke(2)
  3. Php-nuke(20)
  4. Is The First Time I Use Php Nuke Pls Someone Help(2)
  5. Phpnuke, E107 Or Post Nuke?(13)
  6. Help Me About Post Nuke(5)
  7. Font Effects In Nuke(0)
  8. Php Nuke And Google Adsense(3)


 



- Lo-Fi Version Time is now: 12th October 2008 - 12:29 AM