collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: help with some old code  (Read 5478 times)

0 Members and 1 Guest are viewing this topic.

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
help with some old code
« on: September 09, 2009, 02:02:00 pm »
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:
Code: [Select]
<?
/*
* 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";
}
}

}
?>

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: help with some old code
« Reply #1 on: September 09, 2009, 02:15:17 pm »
done

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
Re: help with some old code
« Reply #2 on: September 09, 2009, 02:19:47 pm »
thanks temar, fast as usual, and excellent service...hehe

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 321
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal