You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 125 guest(s) and 1 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Module to Block How To [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
sskporter1
Nuke Cadet
Nuke Cadet


Joined: Nov 06, 2007
Posts: 2


PostPosted: Mon Nov 05, 2007 6:54 pm Reply with quoteBack to top

I am a trying to convert a nuke module to a nuke block and I am having a bit of difficulty getting it to work. Can someone link me to a converter that would do it for me after entering the module info? Any help would be greatly appreciated. Here is the module.


<?php
$module_name = basename(dirname(__FILE__));
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
Header("Location: ../../modules.php?name=$module_name");
}
require_once("mainfile.php");
$index = 1;

$stat = new CVentriloStatus;

//Change here only
//***************************************************************************************************************
//***************************************************************************************************************
$stat->m_cmdcode = "2"; // Detail mode. 1=General, 2=Detailed
$stat->m_cmdhost = "il1.leetvent.com"; // Hostname or IP address of target machine running the Ventrilo server.
$stat->m_cmdport = "3938"; // Port to be statused.
$stat->m_cmdpass = ""; // Server password if necessary.
$connectoption = 1; // 1= Show connection Link, 2 = Do not show connection link.
//***************************************************************************************************************
//***************************************************************************************************************





include('header.php');
OpenTable();
$rc = $stat->Request();
if ( $rc )
{
echo "<table width=\"100%\" border=\"0\"><tr><td align=\"center\" valign=\"center\" bgcolor=\"#FF8888\">";
echo "<br>CVentriloStatus->Request() failed. <strong>$stat->m_error</strong><br><br>\n";
echo "</td></tr></table>";
}

echo "<br>\n";
echo "<center><table width=\"95%\" border=\"0\">\n";
if (!$stat->m_cmdpass) {
$weblink = "ventrilo://$stat->m_cmdhost:$stat->m_cmdport/servername=$stat->m_name";
} else {
$weblink = "ventrilo://$stat->m_cmdhost:$stat->m_cmdport/servername=$stat->m_name&serverpassword=$stat->m_cmdpass";
}
if ($connectoption == 1) {
echo"<tr><td><div align=\"center\"><a href=\"$weblink\">Connect to this server.</a></div></td></tr>\n";
}
$name2 = "$stat->m_name";
VentriloDisplayEX3( $stat, $name2, 0, 0 );
echo "</table></center>\n";
CloseTable();
include('footer.php');


function VentriloDisplayEX3( &$stat, $name2, $cid, $bgidx ) {
global $module_name;
// Display channel info.

$chan = $stat->ChannelFind( $cid );

if ( $bgidx % 2 )
$bg = "#666666";
else
$bg = "#333333";

$isopen = false;

for ( $i = 0; $i < $stat->m_channelcount; $i++ )
{
if ( $stat->m_channellist[ $i ]->m_pid == $chan->m_cid )
{
$isopen = true;
break;
}
}

for ( $i = 0; $i < $stat->m_clientcount; $i++ )
{
if ( $stat->m_clientlist[ $i ]->m_cid == $chan->m_cid )
{
$isopen = true;
break;
}
}

if ( $cid == 0 )
{
$icon = "modules/$module_name/images/venticon_server.png";
}
else
{
if ( $chan->m_prot )
$icon = ($isopen) ? "modules/$module_name/images/venticon_chanpassopen.png" : "modules/$module_name/images/venticon_chanpass.png";
else
$icon = ($isopen) ? "modules/$module_name/images/venticon_chanopen.png" : "modules/$module_name/images/venticon_chan.png";
}

$fg = "#FFFFFF";

if ( $chan->m_prot )
{
if ( $bgidx %2 )
$bg = "#660000";
else
$bg = "#330000";
}

echo "<tr>";
echo "<td>";
echo "<div style=\"overflow:hidden;text-overflow:ellipsis\">";
echo "<img src=\"$icon\" align=\"absmiddle\"></img>";
echo "<strong>";
echo $name2;
echo "</strong>";
echo "</div>";

echo "<table width=\"95%\" border=\"0\" align=\"right\">\n";

// Display Client for this channel.

for ( $i = 0; $i < count( $stat->m_clientlist ); $i++ )
{
$client = $stat->m_clientlist[ $i ];

if ( $client->m_cid != $cid )
continue;

echo "<tr>";
// echo " <td bgcolor=\"#FFFFFF\">";
echo "<td>";
echo "<div style=\"overflow:hidden;text-overflow:ellipsis\">";

$icon = "modules/$module_name/images/venticon_voiceoff.png";
echo "<img src=\"$icon\" align=\"absmiddle\"></img>";

$flags = "";

if ( $client->m_admin )
$flags .= "A";

if ( $client->m_phan )
$flags .= "P";

if ( strlen( $flags ) )
echo "\"$flags\" ";

echo $client->m_name;
if ( $client->m_comm )
echo " ($client->m_comm)";

echo "</div>";
echo "</td>";
echo "</tr>\n";
}

// Display sub-channels for this channel.

for ( $i = 0; $i < count( $stat->m_channellist ); $i++ )
{
if ( $stat->m_channellist[ $i ]->m_pid == $cid )
{
$cn = $stat->m_channellist[ $i ]->m_name;
if ( strlen( $stat->m_channellist[ $i ]->m_comm ) )
{
$cn .= " (";
$cn .= $stat->m_channellist[ $i ]->m_comm;
$cn .= ")";
}

VentriloDisplayEX3( $stat, $cn, $stat->m_channellist[ $i ]->m_cid, $bgidx + 1 );
}
}

echo "</table>";
echo "</td>";
echo "</tr>\n";
}

function StrKey( $src, $key, &$res )
{
$key .= " ";
if ( strncasecmp( $src, $key, strlen( $key ) ) )
return false;

$res = substr( $src, strlen( $key ) );
return true;
}




function StrSplit( $src, $sep, &$d1, &$d2 )
{
$pos = strpos( $src, $sep );
if ( $pos === false )
{
$d1 = $src;
return;
}

$d1 = substr( $src, 0, $pos );
$d2 = substr( $src, $pos + 1 );
}





function StrDecode( &$src )
{
$res = "";

for ( $i = 0; $i < strlen( $src ); )
{
if ( $src[ $i ] == '%' )
{
$res .= sprintf( "%c", intval( substr( $src, $i + 1, 2 ), 16 ) );
$i += 3;
continue;
}

$res .= $src[ $i ];
$i += 1;
}

return( $res );
}




class CVentriloClient
{
var $m_uid; // User ID.
var $m_admin; // Admin flag.
var $m_phan; // Phantom flag.
var $m_cid; // Channel ID.
var $m_ping; // Ping.
var $m_sec; // Connect time in seconds.
var $m_name; // Login name.
var $m_comm; // Comment.

function Parse( $str )
{
$ary = explode( ",", $str );

for ( $i = 0; $i < count( $ary ); $i++ )
{
StrSplit( $ary[ $i ], "=", $field, $val );

if ( strcasecmp( $field, "UID" ) == 0 )
{
$this->m_uid = $val;
continue;
}

if ( strcasecmp( $field, "ADMIN" ) == 0 )
{
$this->m_admin = $val;
continue;
}

if ( strcasecmp( $field, "CID" ) == 0 )
{
$this->m_cid = $val;
continue;
}

if ( strcasecmp( $field, "PHAN" ) == 0 )
{
$this->m_phan = $val;
continue;
}

if ( strcasecmp( $field, "PING" ) == 0 )
{
$this->m_ping = $val;
continue;
}

if ( strcasecmp( $field, "SEC" ) == 0 )
{
$this->m_sec = $val;
continue;
}

if ( strcasecmp( $field, "NAME" ) == 0 )
{
$this->m_name = StrDecode( $val );
continue;
}

if ( strcasecmp( $field, "COMM" ) == 0 )
{
$this->m_comm = StrDecode( $val );
continue;
}
}
}
}

class CVentriloChannel
{
var $m_cid; // Channel ID.
var $m_pid; // Parent channel ID.
var $m_prot; // Password protected flag.
var $m_name; // Channel name.
var $m_comm; // Channel comment.

function Parse( $str )
{
$ary = explode( ",", $str );

for ( $i = 0; $i < count( $ary ); $i++ )
{
StrSplit( $ary[ $i ], "=", $field, $val );

if ( strcasecmp( $field, "CID" ) == 0 )
{
$this->m_cid = $val;
continue;
}

if ( strcasecmp( $field, "PID" ) == 0 )
{
$this->m_pid = $val;
continue;
}

if ( strcasecmp( $field, "PROT" ) == 0 )
{
$this->m_prot = $val;
continue;
}

if ( strcasecmp( $field, "NAME" ) == 0 )
{
$this->m_name = StrDecode( $val );
continue;
}

if ( strcasecmp( $field, "COMM" ) == 0 )
{
$this->m_comm = StrDecode( $val );
continue;
}
}
}
}


class CVentriloStatus
{
// These need to be filled in before issuing the request.

var $m_cmdcode; // Specific status request code. 1=General, 2=Detail.
var $m_cmdhost; // Hostname or IP address to perform status of.
var $m_cmdport; // Port number of server to status.
var $m_cmdpass; // Remote status password. Not used any more but included for legacy reference.

// Optional

var $m_connTimeout; // Integer timeout value in seconds when trying to connect to the status server.
var $m_streamTimeout; // Integer timeout value in seconds when waiting for the reply from status server.

// These are the result variables that are filled in when the request is performed.

var $m_error; // If the ERROR: keyword is found then this is the reason following it.
var $m_statserver; // Name of the status server that we connected to.

var $m_name; // Server name.
var $m_phonetic; // Phonetic spelling of server name.
var $m_comment; // Server comment.
var $m_maxclients; // Maximum number of clients.
var $m_voicecodec_code; // Voice codec code.
var $m_voicecodec_desc; // Voice codec description.
var $m_voiceformat_code; // Voice format code.
var $m_voiceformat_desc; // Voice format description.
var $m_uptime; // Server uptime in seconds.
var $m_platform; // Platform description.
var $m_version; // Version string.

var $m_channelcount; // Number of channels as specified by the server.
var $m_channelfields; // Channel field names.
var $m_channellist; // Array of CVentriloChannel's.

var $m_clientcount; // Number of clients as specified by the server.
var $m_clientfields; // Client field names.
var $m_clientlist; // Array of CVentriloClient's.

function Parse( $str, &$fndend )
{
// Remove trailing newline.

$pos = strpos( $str, "\n" );
if ( $pos === false )
{
}
else
{
$str = substr( $str, 0, $pos );
}

// Begin parsing for keywords.

if ( StrKey( $str, "END:", $val ) )
{
$fndend = true;
return 0;
}

if ( StrKey( $str, "ERROR:", $val ) )
{
$this->m_error = $val;
return -100;
}

if ( StrKey( $str, "NAME:", $val ) )
{
$this->m_name = StrDecode( $val );
return 0;
}

if ( StrKey( $str, "PHONETIC:", $val ) )
{
$this->m_phonetic = StrDecode( $val );
return 0;
}

if ( StrKey( $str, "COMMENT:", $val ) )
{
$this->m_comment = StrDecode( $val );
return 0;
}

if ( StrKey( $str, "AUTH:", $this->m_auth ) )
return 0;

if ( StrKey( $str, "MAXCLIENTS:", $this->m_maxclients ) )
return 0;

if ( StrKey( $str, "VOICECODEC:", $val ) )
{
StrSplit( $val, ",", $this->m_voicecodec_code, $desc );
$this->m_voicecodec_desc = StrDecode( $desc );
return 0;
}

if ( StrKey( $str, "VOICEFORMAT:", $val ) )
{
StrSplit( $val, ",", $this->m_voiceformat_code, $desc );
$this->m_voiceformat_desc = StrDecode( $desc );
return 0;
}

if ( StrKey( $str, "UPTIME:", $val ) )
{
$this->m_uptime = $val;
return 0;
}

if ( StrKey( $str, "PLATFORM:", $val ) )
{
$this->m_platform = StrDecode( $val );
return 0;
}

if ( StrKey( $str, "VERSION:", $val ) )
{
$this->m_version = StrDecode( $val );
return 0;
}

if ( StrKey( $str, "CHANNELCOUNT:", $this->m_channelcount ) )
return 0;

if ( StrKey( $str, "CHANNELFIELDS:", $this->m_channelfields ) )
return 0;

if ( StrKey( $str, "CHANNEL:", $val ) )
{
$chan = new CVentriloChannel;
$chan->Parse( $val );

$this->m_channellist[ count( $this->m_channellist ) ] = $chan;
return 0;
}

if ( StrKey( $str, "CLIENTCOUNT:", $this->m_clientcount ) )
return 0;

if ( StrKey( $str, "CLIENTFIELDS:", $this->m_clientfields ) )
return 0;

if ( StrKey( $str, "CLIENT:", $val ) )
{
$client = new CVentriloClient;
$client->Parse( $val );

$this->m_clientlist[ count( $this->m_clientlist ) ] = $client;
return 0;
}

// Unknown key word. Could be a new keyword from a newer server.

return 1;
}

function ChannelFind( $cid )
{
for ( $i = 0; $i < count( $this->m_channellist ); $i++ )
if ( $this->m_channellist[ $i ]->m_cid == $cid )
return( $this->m_channellist[ $i ] );

return NULL;
}

function ChannelPathName( $idx )
{
$chan = $this->m_channellist[ $idx ];
$pathname = $chan->m_name;

for(;Wink
{
$chan = $this->ChannelFind( $chan->m_pid );
if ( $chan == NULL )
break;

$pathname = $chan->m_name . "/" . $pathname;
}

return( $pathname );
}

function Request()
{
if ( $this->m_connTimeout == 0 )
$this->m_connTimeout = 10;

if ( $this->m_streamTimeout == 0 )
$this->m_streamTimeout = 30;

for ( $srv = 0; $srv < 3; $srv++ )
{
$srvname = sprintf( "status%d.ventrilo.com", $srv + 1 );

$pipe = fsockopen( $srvname, 5100, $errno[ $srv ], $errstr[ $srv ], $this->m_connTimeout );
if ( !$pipe )
{
if ( $errno[ $srv ] == 0 )
{
// If connection fails but errno is 0 then error string is wrong
// by default. Set it to a value that is most likely the cause.

$errstr[ $srv ] = "Could not resolve the status server name.";
}
}
else
{
$this->m_statserver = $srvname;
break;
}
}

if ( !$pipe )
{
$this->m_error = "PHP: Unable to connect to a Ventrilo Status server.";

for ( $srv = 0; $srv < 3; $srv++ )
{
$temp = sprintf( " S%d=", $srv + 1 );
$this->m_error .= $temp;
$this->m_error .= $errstr[ $srv ];
}

return -2;
}

$req = sprintf( "Code=%s,Host=%s,Port=%s,Pass=%s\n", $this->m_cmdcode, $this->m_cmdhost, $this->m_cmdport, $this->m_cmdpass );

if ( fwrite( $pipe, $req ) == FALSE )
{
fclose( $pipe );

$this->m_error = "PHP: Failed sending request to Ventrilo Status server.";
return -3;
}

// Process the results coming from the stream.

$cnt = 0;
$fndend = false;

while( !feof( $pipe ) )
{
stream_set_timeout( $pipe, $this->m_streamTimeout );

$s = fgets( $pipe, 1024 );

$info = stream_get_meta_data( $pipe );
if ( $info[ 'timed_out' ] )
{
fclose( $pipe );

$this->m_error = "PHP: Status server stream timed out.";
return -4;
}

if ( strlen( $s ) == 0 )
continue;

$rc = $this->Parse( $s, $fndend );
if ( $rc < 0 )
{
fclose( $pipe );
return( $rc );
}

if ( $fndend )
break;

$cnt += 1;
}

fclose( $pipe );

if ( $fndend == false )
{
$this->m_error = "PHP: Incomplete data from Ventrilo Status server.";
return -5;
}

if ( $cnt == 0 )
{
// This should not happen because of the fndend test. But we'll check
// for it anyway just to be sure.

$this->m_error = "PHP: Nothing received from Ventrilo Status server.";
return -6;
}

// Everything is OK and data is valid.

return 0;
}
};
Find all posts by sskporter1View user's profileSend private messageVisit poster's website
simrin
Support Mod
Support Mod


Joined: Jul 17, 2003
Posts: 508

Location: In front of a computer, who wants to know

PostPosted: Sat Nov 10, 2007 2:20 am Reply with quoteBack to top

Well its been a long time since I have done this but this is what used to work. Granted this was back maybe in the 6.x days.

I snagged this from another forum floating around someplace.

Quote:

This should work generally enough:

Normally, the module's output is between the calls of OpenTable() and CloseTable() functions:

Code:


OpenTable();

MODULE CODE

CloseTable();



Of course, if there is PHP code above OpenTable(), like declarations, assignments etc, you must include it in "MODULE CODE" in what follows.

Write a block that contains:

Code:


<?php
if (eregi("block-YOUR_BLOCK_NAME.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

ob_start();

MODULE CODE here!   <---- put your module code here!

$output = ob_get_contents();
ob_end_clean();
$content = $output;

?>


_________________
NC Support Mod

Are you there? No I am a figment of your imagination.

www.hostileguild.net
Find all posts by simrinView user's profileSend private messageSend e-mailVisit poster's website
sskporter1
Nuke Cadet
Nuke Cadet


Joined: Nov 06, 2007
Posts: 2


PostPosted: Sat Nov 10, 2007 3:27 am Reply with quoteBack to top

Thanks alot. I will give it a try.
Find all posts by sskporter1View user's profileSend private messageVisit poster's website
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.210 Seconds - 396 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::