Advertisement
Eeems

Untitled

May 19th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.58 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3.     function strip_php_comments($str){
  4.         $str = str_replace("<?php", '<?php ', $str);
  5.         $str = str_replace("\r", '', $str);
  6.         $str = ereg_replace("/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/", '', $str);
  7.         $str = ereg_replace("//[\x20-\x7E]*\n",'', $str);
  8.         $str = preg_replace('/^([^#"\']*?)#.*/','',$str);
  9.         $str = ereg_replace("\t|\n", '', $str);
  10.         return $str;
  11.     }
  12.     function buildFile($in,$out){
  13.         if(is_file($in)){
  14.             echo "Building: $in\n";
  15.             $name = $in;
  16.             $out = fopen($out, 'w');
  17.             $in = strip_php_comments(parseInclude($in));
  18.             fwrite($out,"#!/usr/bin/php\n".$in);
  19.             echo "Build of {$name} Complete\n";
  20.         }else{
  21.             echo "File {$in} does not exist\n";
  22.         }
  23.     }
  24.     function parseInclude($in){
  25.         $in = fopen($in, "r");
  26.         $out = '';
  27.         if ($in) {
  28.             while (($buff = fgets($in, 4096)) !== false) {
  29.                 if($i = strpos(strtolower($buff),'include(')){
  30.                     $i += 9;
  31.                     $d = substr($buff,$i-1,1);
  32.                     $t = $i;
  33.                     while(substr($buff,++$t,1)!=$d){}
  34.                     $f = substr($buff,$i,($t-$i));
  35.                     echo "Including: {$f}\n";
  36.                     $buff = substr_replace($buff,strip_php_comments(parseInclude($f)),$i-9,$t+2-$i);
  37.                 }
  38.                 if($i = strpos(strtolower($buff),'<?php')){
  39.                     $buff = substr_replace($buff,'',$i,5);
  40.                 }
  41.                 if($i = strpos(strtolower($buff),'?>')){
  42.                     $buff = substr_replace($buff,'',$i,2);
  43.                 }
  44.             $out = $out.$buff;
  45.             }
  46.             if (!feof($in)) {
  47.             echo "Error: unexpected fgets() fail\n";
  48.             }
  49.             fclose($in);
  50.             return $out;
  51.         }
  52.     }
  53.     buildFile('bot.php','EeeZorBot.php');
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement