Guest User

Untitled

a guest
Apr 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. <?PHP
  2. class parse {
  3.  
  4. var $raw = null;
  5. var $pkts = array();
  6. var $s = "=";
  7.  
  8. function pkt($packet) {
  9. global $config;
  10.  
  11. $raw = $this->tablumps($packet);
  12. $parr = split("\n\n", $raw);
  13. $pac = split(" ", $parr[0]); $pac=$pac[0];
  14. $pkts['cmd'] = $pac;
  15. $pkts['raw'] = $raw;
  16.  
  17. if(strstr($parr[0], "chat:")) {
  18. $chat = split("chat:", $parr[0]); $chat=$chat[1];
  19. $pkts['chat'] = $chat;
  20. }
  21. foreach($parr as $p) {
  22. if(strstr($p, $this->s)) {
  23. $rel = split($this->s, $p);
  24. if(strlen($rel[0])==1) {
  25. $rel = $rel[1];
  26. $pkts['er'] = $rel;
  27. }
  28. }
  29. if(strstr($p, " ")) {
  30. $arr = split(" ", $p);
  31. $arr = $arr[0];
  32. switch($arr) {
  33. case "msg":
  34. case "npmsg":
  35. case "action":
  36. $pkts['type'] = $arr;
  37. $from = split("from=", $raw); $from = split("\n", $from[1]); $from=$from[0];
  38. $msg = split("from=".$from."\n\n", $raw); $msg=$msg[1];
  39. $pkts['from'] = $from;
  40. $pkts['msg'] = $msg;
  41. if(strstr($msg, $config['trigger'])) {
  42. $carg = split($config['trigger'], $msg); $carg=$carg[1];
  43. $cargs = split(" ", $carg);
  44. $pkts['args'] = array();
  45. foreach($cargs as $c) {
  46. $pkts['args'][] = $c;
  47. }
  48. }
  49. //print_r($pkts); //ONLY UNCOMMENT FOR DEBUG USES! it shows the whole array in form.
  50. break;
  51. }
  52. }
  53. }
  54. global $handle;
  55. $handle->packet($pkts);
  56. }
  57.  
  58. //Taken AS IS from Charon since i was too lazy to write my own tablump parser =\
  59. function tablumps($text)
  60. {
  61. $search[]="/&emote\t([^\t])\t([0-9]+)\t([0-9]+)\t(.+)\t(.+)\t/U";
  62. $replace[]=":\\1:";
  63. $search[]="/&emote\t(.+)\t([0-9]+)\t([0-9]+)\t(.+)\t(.+)\t/U";
  64. $replace[]="\\1";
  65. $search[]="/&br\t/";
  66. $replace[]="\n\t";
  67. $search[]="/&(b|i|s|u|sub|sup|code|ul|ol|li|p|bcode)\t/";
  68. $replace[]="<\\1>";
  69. $search[]="/&\\/(b|i|s|u|sub|sup|code|ul|ol|li|p|bcode)\t/";
  70. $replace[]="</\\1>";
  71. $search[]="/&acro\t(.*)\t(.*)&\\/acro\t/U";
  72. $replace[]="<acronym title=\"\\1\">\\2</acronym>";
  73. $search[]="/&abbr\t(.*)\t(.*)&\\/abbr\t/U";
  74. $replace[]="<abbr title=\"\\1\">\\2</abbr>";
  75. $search[]="/&link\t([^\t]*)\t([^\t]*)\t&\t/U";
  76. $replace[]="\\1 (\\2)";
  77. $search[]="/&link\t([^\t]*)\t&\t/U";
  78. $replace[]="\\1";
  79. $search[]="/&a\t(.*)\t(.*)\t(.*)&\\/a\t/U";
  80. $replace[]="<a href=\"\\1\" title=\"\\2\">\\3</a>";
  81. $search[]="/&(iframe|embed)\t(.*)\t([0-9]*)\t([0-9]*)\t&\\/(iframe|embed)\t/U";
  82. $replace[]="<\\1 src=\"\\2\" width=\"\\3\" height=\"\\4\" />";
  83. $search[]="/&img\t(.*)\t([0-9]*)\t([0-9]*)\t/U";
  84. $replace[]="<img src=\"\\1\" width=\"\\2\" height=\"\\3\" />";
  85. $search[]="/&thumb\t([0-9]*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t/U";
  86. $replace[]=":thumb\\1:";
  87. $search[]="/&dev\t([^\t])\t([^\t]+)\t/U";
  88. $replace[]=":dev\\2:";
  89. $search[]="/&avatar\t([^\t]+)\t[01]\t/U";
  90. $replace[]=":icon\\1:";
  91. $search[]="/ width=\"\"/";
  92. $replace[]="";
  93. $search[]="/ height=\"\"/";
  94. $replace[]="";
  95. $oldtext='';
  96. while($text!=$oldtext)
  97. {
  98. $oldtext=$text;
  99. $text=preg_replace($search, $replace, $text);
  100. }
  101. return($text);
  102. }
  103. }
  104. ?>
Add Comment
Please, Sign In to add comment