PHP Classes
elePHPant
Icontem

File: begin.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marcin Sznyra  >  Turtle Muddler  >  begin.php  >  Download  
File: begin.php
Role: Application script
Content type: text/plain
Description: Begin file
Class: Turtle Muddler
Obfuscate PHP code to make it unreadable to humans
Author: By
Last change:
Date: 9 years ago
Size: 8,473 bytes
 

Contents

Class file image Download
<?php
/**
* Run file.
*
* @package Turtle
* @access public
* @desc Run file.
* @copyright Marcin Sznyra (c) 2005 <marcin@marcinsznyra.info>
* @author Marcin Sznyra <marcin@marcinsznyra.info>
* @version $Id: _file.class.php,v 1.0 2005/12/29 11:39:23 MarcinSznyra Exp $;
* @since Version 1.0
*/
class ObfRunMe
{


var
$_i = 0;

    function
ObfRunMe( )
    {
       
error_reporting( E_ALL );
   
        include(
realpath( dirname( __FILE__ ) ).'/_obfuscator.class.php' );
        include(
realpath( dirname( __FILE__ ) ).'/_file.class.php' );
       
       
$this -> _Obfuscator = Obfuscator::instance( );

       
$_FILE = new File( );
       
$_FILE -> open( realpath( dirname( __FILE__ ) ).'/config.dat' );
       
$_CONFIG = unserialize( $_FILE -> read( ) );
       
$_FILE -> close( );
       
       
$this -> _Obfuscator -> _CONFIG = $_CONFIG;

       
set_time_limit( 3600 * $_CONFIG['time'] );
       
       
$this -> _source =& $_CONFIG['source'];
       
$this -> _destin =& $_CONFIG['target'];
       
       
        if( isset(
$_CONFIG['smarty'] ) && $_CONFIG['smarty'] == true )
        {
           
$this -> _Obfuscator -> _NOCHANGE[] = 'smarty';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'append';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'append_by_ref';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'assign';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'assign_by_ref';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'lear_all_assign';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'clear_all_cache';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'clear_assign';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'clear_cache';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'clear_compiled_tpl';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'clear_config';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'config_load';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'display';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'fetch';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'get_config_vars';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'get_registered_object';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'get_template_vars';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'is_cached';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'load_filter';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_block';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_compiler_function';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_function';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_modifier';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_object';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_outputfilter';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_postfilter';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_prefilter';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'register_resource';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'trigger_error';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'template_exists';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_block';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_compiler_function';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_function';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_modifier';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_object';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_outputfilter';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_postfilter';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_prefilter';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'unregister_resource';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'capture';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'config_load';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'foreach';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'foreachelse';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'include';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'include_php';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'insert';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'if';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'elseif';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'else';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'ldelim';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'rdelim';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'literal';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'php';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'section';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'sectionelse';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'strip';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'assign';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'counter';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'cycle';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'debug';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'eval';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'fetch';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'html_checkboxes';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'html_image';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'html_options';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'html_radios';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'html_select_date';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'html_select_time';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'html_table';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'math';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'mailto';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'popup_init';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'popup';
           
$this -> _Obfuscator -> _NOCHANGE[] = 'textformat';
        }
       
        if( isset(
$_CONFIG['nochange'] ) && !empty( $_CONFIG['nochange'] ) )
        {

           
$exp = explode( ',', $_CONFIG['nochange'] );
           
            if(
sizeof( $exp ) >= 1 )
            {
                foreach(
$exp as $key => $value )
                {
                   
$this -> _Obfuscator -> _NOCHANGE[] = preg_replace( '/\s/', '' , strtolower( $value ) );
                }
            }
           
        }
       
    }
   
    function
run( )
    {
       
$this -> readFiles( $this -> _source , $this -> _destin );
       
       
$this -> _Obfuscator -> ObfSaveRandomsFile( );
       
$this -> _Obfuscator -> ObfSaveFunctionsFile( );
       
$this -> _Obfuscator -> ObfSaveClassesFile( );
       
$this -> _Obfuscator -> ObfSaveVariablesFile( );
       
       
$this -> procesFiles( $this -> _source , $this -> _destin );
       
       
        echo
'<script>this.window.location.href(\'finish.php\')</script>';
    }
   
    function
readFiles( $_dir , $_dest )
    {
       
$_files = $this -> _getDirectory( $_dir );
       
       
        if(
is_array( $_files ) )
        {
            foreach(
$_files AS $value )
            {
                if(
is_dir( $_dir.'/'.$value ) )
                {
                   
                   
$this -> readFiles( $_dir.'/'.$value , $_dest.'/'.$value );
           
                } else if(
eregi( '.php', $value ) && file_exists( $_dir.'/'.$value) ) {
               
   
                   
$this -> runObfuscatorSearch( $_dir.'/'.$value , $_dest.'/'.$value );
           
                }
            }
        }
    }
   
    function
procesFiles( $_dir , $_dest )
    {
       
$this -> _i++;
       
       
$_files = $this -> _getDirectory( $_dir );
       
        if(
is_array( $_files ) )
        {

            foreach(
$_files AS $value )
            {

                if(
is_dir( $_dir.'/'.$value ) )
                {
                    if(
$this -> _i == 1 ) { echo '<b>'.$value.'</b>';$this -> _Obfuscator -> ObfSetDir( $value ); }

                   
$this -> makeDir( $_dest.'/'.$value );
                   
$this -> procesFiles( $_dir.'/'.$value , $_dest.'/'.$value );
           
                } else if(
eregi( '.php', $value ) && file_exists( $_dir.'/'.$value) ) {
                   
                   
$this -> runObfuscatorReplace( $_dir.'/'.$value , $_dest.'/'.$value );
           
                } else {
           
                   
copy( $_dir.'/'.$value , $_dest.'/'.$value );
           
                }
            }
        }
       
       
$this -> _i--;
    }
   
    function
runObfuscatorSearch( $_addr = null , $_dest )
    {
        echo
"Process File :: ".realpath( $_addr )." <BR>\n";
       
       
$this -> _Obfuscator -> ObfSetSource( $_addr );
       
$this -> _Obfuscator -> ObfSetDestination( $_dest );
       
$this -> _Obfuscator -> ObfSearch( );
    }
   
    function
runObfuscatorReplace( $_addr = null , $_dest )
    {
       
$this -> _Obfuscator -> ObfSetSource( $_addr );
       
$this -> _Obfuscator -> ObfSetDestination( $_dest );
       
$this -> _Obfuscator -> ObfReplace( );

        echo
"Creates File :: ".realpath( $_dest )." <BR>\n";
    }
   
    function
makeDir( $_addr )
    {
        if( !
is_dir( $_addr ) )
        {
           
mkdir ( $_addr , 0777 );
        }
    }

   
    function
_getDirectory( $directory )
    {
       
$array = null;
   
       
$dir = $directory;
       
        if (
is_dir( $dir ) )
        {
           if (
$dh = opendir( $dir ) )
           {
              while ( (
$file = readdir( $dh ) ) !== false)
              {

                if(
$file != '.' && $file != '..' )
                {

                   
$array[] = $file;
                }
                
               }
             
              
closedir($dh);
             
           }
        }

        return
$array;
    }

   
}

$obj = new ObfRunMe( );
$obj -> run( );
?>