Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- class parse {
- var $raw = null;
- var $pkts = array();
- var $s = "=";
- function pkt($packet) {
- global $config;
- $raw = $this->tablumps($packet);
- $parr = split("\n\n", $raw);
- $pac = split(" ", $parr[0]); $pac=$pac[0];
- $pkts['cmd'] = $pac;
- $pkts['raw'] = $raw;
- if(strstr($parr[0], "chat:")) {
- $chat = split("chat:", $parr[0]); $chat=$chat[1];
- $pkts['chat'] = $chat;
- }
- foreach($parr as $p) {
- if(strstr($p, $this->s)) {
- $rel = split($this->s, $p);
- if(strlen($rel[0])==1) {
- $rel = $rel[1];
- $pkts['er'] = $rel;
- }
- }
- if(strstr($p, " ")) {
- $arr = split(" ", $p);
- $arr = $arr[0];
- switch($arr) {
- case "msg":
- case "npmsg":
- case "action":
- $pkts['type'] = $arr;
- $from = split("from=", $raw); $from = split("\n", $from[1]); $from=$from[0];
- $msg = split("from=".$from."\n\n", $raw); $msg=$msg[1];
- $pkts['from'] = $from;
- $pkts['msg'] = $msg;
- if(strstr($msg, $config['trigger'])) {
- $carg = split($config['trigger'], $msg); $carg=$carg[1];
- $cargs = split(" ", $carg);
- $pkts['args'] = array();
- foreach($cargs as $c) {
- $pkts['args'][] = $c;
- }
- }
- //print_r($pkts); //ONLY UNCOMMENT FOR DEBUG USES! it shows the whole array in form.
- break;
- }
- }
- }
- global $handle;
- $handle->packet($pkts);
- }
- //Taken AS IS from Charon since i was too lazy to write my own tablump parser =\
- function tablumps($text)
- {
- $search[]="/&emote\t([^\t])\t([0-9]+)\t([0-9]+)\t(.+)\t(.+)\t/U";
- $replace[]=":\\1:";
- $search[]="/&emote\t(.+)\t([0-9]+)\t([0-9]+)\t(.+)\t(.+)\t/U";
- $replace[]="\\1";
- $search[]="/&br\t/";
- $replace[]="\n\t";
- $search[]="/&(b|i|s|u|sub|sup|code|ul|ol|li|p|bcode)\t/";
- $replace[]="<\\1>";
- $search[]="/&\\/(b|i|s|u|sub|sup|code|ul|ol|li|p|bcode)\t/";
- $replace[]="</\\1>";
- $search[]="/&acro\t(.*)\t(.*)&\\/acro\t/U";
- $replace[]="<acronym title=\"\\1\">\\2</acronym>";
- $search[]="/&abbr\t(.*)\t(.*)&\\/abbr\t/U";
- $replace[]="<abbr title=\"\\1\">\\2</abbr>";
- $search[]="/&link\t([^\t]*)\t([^\t]*)\t&\t/U";
- $replace[]="\\1 (\\2)";
- $search[]="/&link\t([^\t]*)\t&\t/U";
- $replace[]="\\1";
- $search[]="/&a\t(.*)\t(.*)\t(.*)&\\/a\t/U";
- $replace[]="<a href=\"\\1\" title=\"\\2\">\\3</a>";
- $search[]="/&(iframe|embed)\t(.*)\t([0-9]*)\t([0-9]*)\t&\\/(iframe|embed)\t/U";
- $replace[]="<\\1 src=\"\\2\" width=\"\\3\" height=\"\\4\" />";
- $search[]="/&img\t(.*)\t([0-9]*)\t([0-9]*)\t/U";
- $replace[]="<img src=\"\\1\" width=\"\\2\" height=\"\\3\" />";
- $search[]="/&thumb\t([0-9]*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t/U";
- $replace[]=":thumb\\1:";
- $search[]="/&dev\t([^\t])\t([^\t]+)\t/U";
- $replace[]=":dev\\2:";
- $search[]="/&avatar\t([^\t]+)\t[01]\t/U";
- $replace[]=":icon\\1:";
- $search[]="/ width=\"\"/";
- $replace[]="";
- $search[]="/ height=\"\"/";
- $replace[]="";
- $oldtext='';
- while($text!=$oldtext)
- {
- $oldtext=$text;
- $text=preg_replace($search, $replace, $text);
- }
- return($text);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment