I need some help updating some code from a custom 4.x module to 6.x
The php file goes in fine, doesn't develop any errors, but is not pulling the associated txt or php files like it should, so have a feeling it is because of a change in 6.x's handling...
I am running 6.5 currently, I have the module in the custom/04 folder, and I've tried putting the txt folder both in the root of the bot and also under custom.
code is as follows:
<?
/*
* View.php - Renders a text file (or IGN 'plugin') to a blob and returns it to the user.
*/
$view = new View($bot);
$commands["tell"]["view"] = &$view;
if ($commands["tell2"] != null)
$commands["tell2"]["view"] = &$view;
$commands["pgmsg"]["view"] = &$view;
$commands["gc"]["view"] = &$view;
//This is only here for "compatibility" with the horrendous beast known as "IGNBot"
function send($bla1, $bla2, $bla3)
{
}
/*
The Class itself...
*/
class View
{
var $bot;
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function View (&$bot)
{
$this -> bot = &$bot;
//Comment the following out for BeBot version < 0.4
$this -> bot -> accesscontrol -> create ('tell', 'view', 'ANONYMOUS');
$this -> bot -> accesscontrol -> create ('gc', 'view', 'ANONYMOUS');
$this -> bot -> accesscontrol -> create ('pgmsg', 'view', 'ANONYMOUS');
$this -> help['description'] = 'Displays a text file, or an IGN \'plugin\'';
}
/*
This gets called on a tell with the command
*/
function tell($name, $msg)
{
$this -> bot -> send_tell($name, $this -> process($msg));
}
/*
This gets called on a tell with the command from person outside guild
*/
function tell2($name, $msg)
{
$this -> bot -> send_tell($name, $this -> process($msg));
}
/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg)
{
$this -> bot -> send_pgroup($this -> process($msg));
}
/*
This gets called on a msg in the guildchat with the command
*/
function gc($name, $msg)
{
$this -> bot -> send_gc($this -> process($msg));
}
function process($msg)
{
if((strpos($msg, './') !== false) || (strpos($msg, '.\\') !== false) || (strpos($msg, ':\\') !== false))
{
$this -> bot -> log("HELP", "SECURITY", "Possible directory traversal attempt by $name ($msg)");
return "Directory traversal attempt logged. Administrators notified.";
}
if (preg_match("/^" . $this -> bot -> commpre . "view (.+)/i", $msg, $info))
{
$file = str_replace(".txt", "", str_replace(".php", "", $info[1]));
$pfile = $file . ".php";
$tfile = $file . ".txt";
$df = ucfirst(strtolower($file));
if (file_exists("txt/$pfile"))
{
include "txt/$pfile";
if (!empty($reply) && !empty($blob))
return $this -> bot -> make_blob($reply, "<font color=CCInfoHeader>$df</font><br><br><font color=CCInfoText>$blob</font>");
if (!empty($blob))
return $this -> bot -> make_blob($df, "<font color=CCInfoHeader>$df</font><br><br><font color=CCInfoText>$blob</font>");
if (!empty($reply))
return $this -> bot -> make_blob($reply, "<font color=CCInfoHeader>$df</font><br><br><font color=CCInfoText>The file exists, but does not conform to the proper data exchange format.</font>");
}
if (file_exists("txt/$tfile"))
{
$blob = file_get_contents("txt/$tfile");
return $this -> bot -> make_blob($df, "<font color=CCInfoHeader>$df</font><br><br><font color=CCInfoText>$blob</font>");
}
if (file_exists("txt/$file"))
{
$blob = file_get_contents("txt/$file");
return $this -> bot -> make_blob($df, "<font color=CCInfoHeader>$df</font><br><br><font color=CCInfoText>$blob</font>");
}
return "Unable to locate $df, maybe it does not exist.";
}
else
{
return "I'm confused, whatcha wanna view? Try /tell <botname> <pre>view";
}
}
}
?>