TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 141
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 136
  • Total: 136

Convert a PHP-Nuke Block to TP

Started by stik, November 21, 2007, 05:41:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

stik

Is there an easy way to convert a PHP-Nuke Block to a TP block.

PHP -Nuke Blocks tend to use Fucntions defined by PHP Nuke.

or is it a rewrite of the block ?

IchBin

Depends on the block.  Some are easy, and others would be a re-write. Post it and we can take a look.

stik

#2
The block is to display server status and stats of a BHD gaming server.

you can see it in action here

Here is the block:

<?php

######################################################################
# Block module for PHP-Nuke 6.x
#-------------------------
# BABSTATS online status check
#-------------------------
# Version: 2.0
#
# Copyright (c) 2003 by:
#
# Andy
# (http://www.422nd.com)
# (andy@422nd.com)
#
# modified for CHRONOS by
#  Wetworks*Claymore
#  http://www.teamwetworks.com/
#  April 2003
#
# modified to a Monthly Stats Block & Extras
#  By Stik
#  http://www.guywitha.com stik@guywitha.com
#  April 2006
#
# This block can only be used for ONE server!!!
#
######################################################################

$dbhost     "localhost"; // Database host
$dbname     ""; // Database name
$dbusername ""; // Database user name
$dbuserpw   ""; // Database password


mysql_connect($dbhost$dbusername$dbuserpw) or die ("Unable to connect to mysql server");
$db=mysql_select_db($dbname) or die ("Unable to select database");


if (
eregi("block-BabstatsCHRONOS.php"$_SERVER['PHP_SELF'])) {
    
Header("Location: index.php");
    die();
}

require_once(
"mainfile.php");
global 
$prefix$dbi$bgcolor2$bgcolor3;

$time time();
$offline $time 120;

$sql sql_query("SELECT * FROM chronos_servers WHERE time>$offline ORDER BY name"$dbi);
$content1 "";


$servernum sql_num_rows($sql$dbi);
if (
$servernum >= 1) {

     
$content1 .= "<center><table width='100%' celspacing='0'></center>";

    while(
$result sql_fetch_array($sql$dbi)) {

        
$player_color "";
        
$players "";

        
$players_red $result[player] ;
        
$codedmap $result["map_name"];

        
$result["server_name"] = htmlspecialchars(base64_decode($result["server_name"]));
        
$result["map_name"]    = htmlspecialchars(base64_decode($result["map_name"]));
        
$result[server_name] = ereg_replace('~[0-9]'''$result[server_name]);
        
$result[map_name] = ereg_replace('~[0-9]'''$result[map_name]);

        if (
$result["game_type"] == "Deathmatch"$game_type "DM";
        if (
$result["game_type"] == "Team Deathmatch"$game_type "TDM";
        if (
$result["game_type"] == "Team King of the Hill"$game_type "TKOTH";
        if (
$result["game_type"] == "Search and Destroy"$game_type "S&D";
        if (
$result["game_type"] == "Attack and Defend"$game_type "A&D";
        if (
$result["game_type"] == "Capture the Flag"$game_type "CTF";
        if (
$result["game_type"] == "Flagball"$game_type "FB";


        
$player_teams   explode("\n"$result["player_teams"]);
         
$player_names  explode("\n"$result["player_names"]);
        
$playercount 1;
        for(
$i 0$i count($player_names); $i++) {
            
$player_name htmlspecialchars(base64_decode($player_names[$i]));
            
$player_team $player_teams[$i];



            if (
$player_team == "Blue"$player_color "#00BFFF";
            if (
$player_team == "Red"$player_color "#FF0000";
            if (
$player_team == "Yellow"$player_color "yellow";
            if (
$player_team == "Violet"$player_color "violet";
            if (
$player_team == "Green"$player_color "#44DD44";
            if (
$player_team == "None"$player_color "#44DD44";
     if ($player_name == "Guy with a Stik"$player_color "#FF7F2A";


            if (
$player_name == "Host") {
                
$result[num_players]--;
            } else  {
$players .= "[<font color='".$player_color."'><b>".$player_name."</b></font>] ";

$playercount++;

            }


        }

        if(!
$bg) {
            
$bg $bgcolor4;
        } elseif (
$bg == $bgcolor2) {
            
$bg $bgcolor2;
        } elseif (
$bg == $bgcolor2) {
            
$bg $bgcolor2;
        }

        
$content1 .= "<tr><td align='center' bgcolor='$bg'>";
        
$content1 .= "<a href='Neos_Chronos/index.php?action=servers&id=".$result[id]."' class='special1'>" ;
        
$content1 .= "<img src='modules/Chronos/templates/online.gif' alt='Online.gif' title='Online' border='0'><br>";
        
$content1 .= "<b>".$result[server_name]."<br>";
        
$content1 .= $result[map_name]."</b><br>";
        
$sql2 sql_query("select * from chronos_maps where name='$codedmap'"$dbi);
        
$result2 sql_fetch_array($sql2$dbi);
        if (
$result2["image"] && $servernum 5) {
            
$content1 .= "<img src='Neos_Chronos/$result2[image]' alt='$result[map_name]' title='$result[map_name]' width='125' height='94' border='0'><br>";
        } else {
             
$content1.="<br><b><br></b><br>";
       }
        
$content1 .= $result[game]."&nbsp;(".$game_type.")<br>";
        
$content1 .= $result[num_players]." of ".$result[max_players]."</a><br><br><br>";
        if (
$result["player_names"] && $playercount 1) { // && $servernum == 1
            
$content1 .= "<MARQUEE behavior='scroll' align='center' direction='left' width='120' height='12' scrollamount='2'

scrolldelay='1' onmouseover='this.stop()' onmouseout='this.start()'>"

."<b>Players Online:</b> $players"

."</MARQUEE>";
        }
        
$content1 .= "</td></tr>";
    }


     
$content1 .= "</table>";
}

if (!
$content1) {
$content "<br><center><a href='modules.php?name=Chronos'><img src='modules/Chronos/templates/offline.gif' alt=\"offline.gif\" title=\"Offline\" border='0'></a></center><br>";
} else {
$content "<br>$content1<br><br>";
}

global 
$prefix$db$dbi$sitename;
$sql "SELECT name, id, m_rating FROM chronos_players WHERE m_rating > 0 ORDER BY m_rating DESC LIMIT 10";
$content .= "<br><center><B><a href='/Neos_Chronos/monthlystats/index.php?action=kill_stats'>Monthly Ratings</a></B></center><br>";
$result $db->sql_query($sql);
while (
$row $db->sql_fetchrow($result)) {
    
$rating $row[m_rating];
    
$name "".htmlspecialchars(base64_decode($row[name]))."&nbsp;&nbsp;";
    
$id $row[id];
    
$sql2 sql_query("SELECT name, thumbnail FROM chronos_ranks WHERE rating<='$rating' ORDER BY rating DESC LIMIT 0,1"$dbi);
    
$result2 sql_fetch_array($sql2$dbi);
    
$thumbnail $result2[thumbnail];
    
$rankname $result2[name];

        
$content .= "&nbsp;<img src='modules/Chronos/$thumbnail' border='0' alt='$rankname' title='$rankname' width='24' height='15'>&nbsp;<a href='Neos_Chronos/monthlystats/index.php?action=player_stats&amp;id=$id'>$name</a><br>";
    }


global 
$prefix$db$dbi$sitename;
$sql "SELECT name, id, rating FROM chronos_players ORDER BY rating DESC LIMIT 10";
$content .= "<br><br><center><B><a href='/Neos_Chronos/index.php?action=kill_stats'>Overall Ratings</a></B></center><br>";
$result $db->sql_query($sql);
while (
$row $db->sql_fetchrow($result)) {
    
$rating $row[rating];
    
$name "".htmlspecialchars(base64_decode($row[name]))."&nbsp;&nbsp;";
    
$id $row[id];
    
$sql2 sql_query("SELECT name, thumbnail FROM chronos_ranks WHERE rating<='$rating' ORDER BY rating DESC LIMIT 0,1"$dbi);
    
$result2 sql_fetch_array($sql2$dbi);
    
$thumbnail $result2[thumbnail];
    
$rankname $result2[name];

        
$content .= "&nbsp;<img src='modules/Chronos/$thumbnail' border='0' alt='$rankname' title='$rankname' width='24' height='15'>&nbsp;<a href='Neos_Chronos/index.php?action=player_stats&amp;id=$id'>$name</a><br>";
    }


?>


I do have some basic PHP skills, and have attempted to make this change myself, but am not having much luck.

Thanks.

IchBin

You can get rid of this piece of code:

if (eregi("block-BabstatsCHRONOS.php", $_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}


My only question would be, what is mainfile.php used for? If that is a nuke file it may not work.

stik

#4
Hi,
   
Thanks for taking a look. mainfile.php calls another file which holds the defined functions. I did attempt to call those functions from within
the above file, but that just opened up a whole new set of problems

The above file is the original file for you to see, in case I had totally messed up my modified version.

sounds a bit like I will need to learn some more PHP and recode the block  :)

This website is proudly hosted on Crocweb Cloud Website Hosting.