0

I have been using PECL bcompiler extension for a long time. All is good. However, I have found that the moving the working script to another linux system (CentOS -> FreeBSD) causes a problem with include of the bcompiled program part to the basic script (trash appears on the screen on running). The versions of PHP (5.2.10) and bcompiler extension (the latest) are the same. All sources were installed without errors in both linux systems. Bcompiler is loaded correctly using dl() function: no errors, all bcompiler's functions are working.

I tried to devide the task into two parts:

  1. CentOS: Compile only content without header and footer:

    function bc($ext = "b") { global $SCRIPT_DIR, $INCLUDES; echo "Bcompiler is loaded. Compiling modules ... \n"; foreach($INCLUDES as $inc_file){ echo "$inc_file.php "; $php_file = "$SCRIPT_DIR/include/$inc_file.php"; if(!file_exists($php_file)){ echo "not found!\n"; continue; } else echo "=> $inc_file.$ext\n"; $fh = fopen("$SCRIPT_DIR/modules/b/$inc_file.$ext", "w"); bcompiler_write_file($fh, $php_file); fclose($fh); } return; }

  2. FreeBSD: Addition of the header and footer to the compiled modules:

    function b2bin() { global $SCRIPT_DIR, $INCLUDES; echo "Bcompiler is loaded. Processing modules ... \n"; foreach($INCLUDES as $inc_file){ echo "$inc_file.b "; $b_file = "$SCRIPT_DIR/modules/$inc_file.b"; // without header and footer if(!file_exists($b_file)){ echo "not found!\n"; continue; } else echo "=> $inc_file.bin\n"; $content = file_get_contents($b_file); $target_bin_file="$SCRIPT_DIR/modules/$inc_file.bin"; // with header and footer $fh = fopen($target_bin_file, "w"); bcompiler_write_header($fh); fwrite($fh,$content); bcompiler_write_footer($fh); fclose($fh); } return; }

  3. Starting main program on FreeBSD [filename.php]:

    if(!extension_loaded('bcompiler')) dl('bcompiler.so'); if(!function_exists("bcompiler_read")){ exit("error: PHP Bcompiler module not loaded. Install Bcompiler from https://pecl.php.net/package/bcompiler.\n"); } /*line 40*/ foreach( $INCLUDES as $inc_file) include_once ("$SCRIPT_DIR/modules/$inc_file.bin");
    shedule_run(); ...and so on...

Trash disappears, but PHP informs: Fatal error: unable to inherit in [filename.php on line 40]. At the same time the full compilation with header and footer on both systems gives the positive result.

The question arises: Is the Bcompiled bytecode unique to the parent system and how I can get around the problem. My significant task is free transfer of the compiled modules to various Linux systems where PHP and Bcompiler were installed.

  • 1
    PHP 5.2? That was end-of-lifed *six years ago*. Stop using it. http://php.net/eol.php – ceejayoz Jun 30 '17 at 17:51
  • I need in Bcompiler, and it works up to 5.3. version of PHP. – Alexander Jun 30 '17 at 18:23
  • I'd treat that as a hint that you should stop using that, too. Last update in 2011? – ceejayoz Jun 30 '17 at 18:27
  • ok, how to protect PHP scripts? Obfuscation does not fit. Coverting to C++ is difficult. I tried phc for this purpose. The compiled c++ works only on the master machine and is not always (sigstop and other errors appear). – Alexander Jun 30 '17 at 18:50
  • https://stackoverflow.com/questions/18203112/is-it-possible-to-hide-encode-encrypt-php-source-code-and-let-others-have-the-sy – ceejayoz Jun 30 '17 at 20:17
  • many thanks, but I use cli PHP and need to have a protection of source code (only included files), with the decoding not have to being depended on the system. Since the bcompiled bytecode is depended on the Linux system (whether correctly I understand from my experience?), I need in the analogous feature which is based on the encryption/decryption rocedure. Thus, the similar extension is required. – Alexander Jun 30 '17 at 22:13

0 Answers0