php code compiled with bcompiler not working - php

I don't do a huge amount of php work and I've never used bcompiler before but I'm migrating a php site to a new server and I can't get this working.
There seems to be a class compiled with bcompiler 'class.viewimage.php' - it contains bz compressed code 'BZh91AY&SY;iu...'
There is then a regular php file that is calling this class:
require('class.viewimage.php');
$my_image = NEW ViewImage ($MEDIALIB->Filestore);
When this code is run it just spits the text contents of the compiled class into the browser ('BZh91AY&SY;iu...'). It's the require line which is causing this. Seems to me like php doesn't magically know that this is compiled code.
To the best of my knowledge I've installed Bcompiler on the system as this code is no longer crashing (and it was crashing when I first did the migration):
if (!extension_loaded('bcompiler')) {
$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
dl($prefix . 'bcompiler.' . PHP_SHLIB_SUFFIX);
}
Any help appreciated.

While I've had my own troubles with PHP bcompiler, using include() or require() to access compiled code (compiled using bcompiler_write_file()) on a machine with the bcompiler module installed and enabled should work.
http://us2.php.net/manual/en/function.bcompiler-read.php:
Note:
Please use include or require
statements to parse bytecodes, it's
more portable and convenient way than
using this function.
Not only are there a multitude of bugs, but versions are incompatible with one another, which is what I'm guessing is your problem.
For example, my two (incompatible) machines:
CentOS 5.5, PHP 5.2.10, Apache 2.2.3, x86_64
----
bcompiler version 0.9.3-devs
current bytecode version 0.21
can parse bytecode version 0.7, 0.9, 0.11, 0.12, 0.14,
0.18, 0.21
Mac OS X 10.6, PHP 5.3.3, Apache 2.2.15, i386
----
bcompiler version 0.9.3-devs
current bytecode version 0.22
can parse bytecode version 0.20, 0.22
I submitted it as a bug to the PECL package.

PHP considers all require/include files to be plain text, and will treat them as such until it spots either the <? (shorttag), <?php (regular tag), or <% (ASP tag) character sequences in the stream, after which it switches into PHP mode, until it hits the end of the script or the corresponding closing tag (?>, %>). As such, there's no way to have PHP treat a compiled input as program code. Even an EVAL won't help, since that just invokes the same parser that didn't trigger off the binary input in the first place.
BZipped code itself isn't executable either, unless it's been wrapped by an auto-extractor stub.
Since it would appear to be BZipped, why not try un-bzipping the file and see what you get? Maybe the class file was downloaded as a .bz2 distribution and simply got renamed. The uncompressed copy may contain the appropriate wrappers to allow execution.

I have been struggling since a long time to work with bcompiler but surprisingly i found a very easy solution where you can compile you whole website with one click. you can follow the bellow steps:-
Download and install Wampserver (any edition).
Download and install Wampserver PHP Addons Version php 5.2.5
click on Wampserver -> PHP -> Version -> 5.2.5 from Task bar (it will change your current version of php to 5.2.5).
Select Wampserver -> PHP -> extension -> php_bcompiler (it will enable bcompiler on your computer).
Above steps are enough if you can compiler the script your own but to make it easy you can continue with next steps.
Download bcompiler GUI.
Select the Folder on the Bcompiler GUI and this will compiler your whole website with one click.
enjoy PHP | Enjoy Open Source

Related

Is cURL in PHP tied to the local install of cURL?

IE, does PHP use its own, internal version of cURL or does it use whatever it finds in the local OS (Windows 10)? I'm in the unfortunate position of trying to make scripts written in 7.4 work on a permanent home that's saddled with 7.1. Before I force an update of PHP, I want to make sure chasing the right problem. I've searched php.ini and don't see a path to the local file system.
Thanks!
The curl functions in PHP do not call out to a command-line version of curl, but rather to a library which can be integrated into a C program.
This version may be included "statically" when PHP is compiled, be a separate file installed alongside PHP, or use a shared file installed centrally on the server and used by multiple programs. This will be determined by the distribution package of PHP.
To determine the library version used, use the phpinfo() function, or run php -i on the command line (which just runs that function for you) and search for "curl", which will show the version.
I'm not sure what your question is.
IE is not an issue here.
I always keep a script that gives me the current state of PHP.
PHP Manual, phpinfo()
<?php
phpinfo();
?>
phpinfo will return something like this if curl is (likely) installed.
I learned through the process of installing PHP 8.1 in my dev env and configuring it to use curl (and a comment), that PHP does call it's own curl executable, in the case of windows 10: php_curl.dll, and does not make an external call to curl in the operating system.
My fear was I'd go through the process of getting someone to upgrade PHP then have to have ask, again, to have curl upgraded.
Thanks to all who offered input!
yes, but curl is an extension, you need to enable it in php.ini file

Not able to import XML data

I tried to import data from XML file using the importDump utility...
root#aace30d9b5f3:/var/www/html/mediawiki-1.36.1# php ./maintenance/importDump.php mrwiki-latest-pages-articles-multistream.xml
Got this error:
MWException from line 2108 of /var/www/html/mediawiki-1.36.1/includes/parser/Parser.php: PCRE needs to be compiled with --enable-unicode-properties in order for MediaWiki to function
I downloaded the source code of PCRE and run make / make install but that did not work. I am using the official docker image of mediawiki if that matters.
https://hub.docker.com/_/mediawiki
update:
I need to simplify what I am trying to ask...
Is PCRE compiled using --enable-unicode-properties in this dockerfile?
https://github.com/docker-library/php/edit/master/7.3/buster/apache/Dockerfile
Is that php image being used by mediawiki official repo?
https://github.com/wikimedia/mediawiki-docker/blob/51105612d2e1168f1b0545f47951847d63fb9613/1.36/apache/Dockerfile
PHP, unfortunately, usually uses its own PCRE library (from the manual: "By default, this extension is compiled using the bundled PCRE library"), as you can also see in this other answer.
What you need to do is recompile PHP itself in order to activate the PCRE changes. To do this you need to (you can do this on a cloned machine)
check out the exact PHP version
download and install the relevant source packages
get the exact compilation options from phpinfo()
change the PCRE options appropriately
make (you don't need install as you're not going use PHP in the cloned machine)
The only file that you need to change now is the basic PHP binary (/usr/bin/php, watch out for alternatives symlinks). If you used a cloned machine with the same distro and versions, you can easily rename that one binary on the original machine and move in the new one, and it will work (I've done this dozens of times), so you'll have the option to go back at any time.
Or you can install the development packages for PCRE on the cloned machine and supply --with-pcre-regex= and --with-pcre-dir= to the compiler. The new PHP binary will now use the system PCRE, so that pcretest -C will now yield reliable results. I am not sure whether you need the same PCRE version on both machines (you probably need the same major version, but a minor version mismatch shouldn't be a showstopper). Be aware that updating the system PCRE library might break compatibility with PHP if for any reasons the library calls change.

PHP script locks up when changed and re-ran (Caused by APC)

Basic Info - Running WAMP 2.2 with PHP 5.4.3 and Apache 2.2.22 on Windows XP Pro 32 bit
My problem is that when I run a php script it will run just fine. Now if I change that script and re-run it, the page will never load and the script will become locked due to being used by another program. I have found that it is being used by the process httpd.exe, which if I use End Process (Which actually restarts it rather than stopping it) the original page will suddenly load and the new script will be ran. If I change it again it will do this same thing.
If I disable the PHP APC extension this problem doesn't happen, so it is caused by APC
I have tried using php_apc_3114_beta_php54.dll (renamed it to php_apc.dll) downloaded from http://dev.freshsite.pl/php-accelerators/apc.html "APC 3.1.14 beta for PHP 5.4" and apc_3113_beta_php54_vc9.dll (renamed it to php_apc.dll) the same place "APC 3.1.13 beta for PHP 5.4 vc9"
I would suggest to download PHP extensions from specific sites only. The extensions should be compiled for your specific PHP version and system (check for x86/x64 and thread-safe vs non-thread-safe). The best places to download correctly compiled extensions for windows are:
PHP for Windows:
http://windows.php.net/
http://downloads.php.net/pierre/
and Anindya's Blog:
http://www.anindya.com/tag/php/
http://www.mediafire.com/php-win64-extensions
EDIT: As mentioned below in my comment, have you tried using BOTH versions of APC (thread safe AND non-thread-safe) from the original site you linked to?
This does sound like some sort of threading issue...
I did myself a favor and did it all on Linux. Setting up my whole server and installing APC on Ubuntu was faster and smoother than just trying to insert APC in WAMP. After a few commands and a clean install it's working beautifully, I can't believe I didn't migrate to Linux sooner!

Mismatch between Php and Extension module

I am trying to install the following php extension. Microsoft Drivers for SQL Server for PHP.
I have tried both versions of the driver but both seem to mismatch the version of php i am running. I looked around and it appears I have to recompile the modules in order to match the php api version. But I don't have any idea how to do this.
Any ideas on how to make this work? Or maybe a simpler way to use PHP 5.4.7 to access SQL.
You can do it with some tricks, its not recommended but it will work fine and in my case, it has not crashed yet :)
Check your phpinfo() page for:
1-PHP extension API Number
2-Thread safe or non-thread safe version
3-(Windows) compiler version
1-For building your extension you need php.lib. It is in your PHP-server dev directory.
2-You need PHP header files for compiling your extension, after including PHP header files, go to PHP/Zend directory and open zend_modules.h file and change the #define ZEND_MODULE_API_NO 20060613to your PHP extension API number for example change it to #define ZEND_MODULE_API_NO 20090626.
3- If you use windows based servers the compiler version is important(VC8 - VC10), if your PHP was compiled with VC8, build the extension in VS2008 or use VC8 for building your project.
If you encounter any wired error just comment it. I spent 3 months to make this worked ;)

Suhosin for Windows

I was wondering if it is possible to install Suhosin for php without completely recompiling the php library. I've looked around a lot an all I was able to find are resources for Linux and other windows alternatives. I did stumble upon one resource for windows, but it requires re-compiling php with Suhosin enabled, is there a way to do this on an existing, compiled php library?
I tried php -f suhosin-patch-5.3.9-0.9.10.patch in the cmd which gives a console output but no actual file is compiled, so installing the extension is not possible at this point.
here is the windows resouce:
http://board.deioncube.in/showthread.php?tid=96
Thanks.
-f is a flag for the compiled interpreter that makes the interpreter execute the specified php source code. suhosin is a patch to the php interpreter, which is written in C.
Therefore, you must download the source code of the php interpreter, apply suhosin, and then recompile php.

Categories