使用 bcompiler 编译的 php 代码不起作用

发布于 2024-09-06 22:28:43 字数 658 浏览 12 评论 0原文

我没有做大量的 php 工作,而且以​​前从未使用过 bcompiler,但我正在将 php 站点迁移到新服务器,但我无法让它工作。

似乎有一个用 bcompiler 'class.viewimage.php' 编译的类 - 它包含 bz 压缩代码 'BZh91AY&SY;iu...'

然后有一个常规 php 文件正在调用此类:

require('class.viewimage.php');
$my_image = NEW ViewImage ($MEDIALIB->Filestore);

运行此代码时它只是将编译类的文本内容吐入浏览器('BZh91AY&SY;iu...')。这是导致此问题的 require 行。在我看来,php 并没有神奇地知道这是编译后的代码。

据我所知,我已经在系统上安装了 Bcompiler,因为此代码不再崩溃(当我第一次进行迁移时它就崩溃了):

if (!extension_loaded('bcompiler')) {
    $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
    dl($prefix . 'bcompiler.' . PHP_SHLIB_SUFFIX);
}

感谢任何帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦归所梦 2024-09-13 22:28:43

虽然我在使用 PHP bcompiler 时遇到了麻烦,但使用 include()require() 来访问编译后的代码(使用 bcompiler_write_file() 编译的) >) 在安装并启用 bcompiler 模块的机器上应该可以工作。

https://www.php.net/manual/en/function。 bcompiler-read.php:

注意:

请使用包含或要求
解析字节码的语句,它是

使用此功能。

不仅存在大量错误,而且版本彼此不兼容,这就是我猜你的问题。

例如,我的两台(不兼容)机器:

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

我将其作为错误提交给 PECL 包。

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.

https://www.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.

复古式 2024-09-13 22:28:43

PHP 认为所有 require/include 文件都是纯文本,并将如此对待它们,直到它发现 (短标签)、(常规标签),或流中的 <% (ASP 标签)字符序列,之后切换到 PHP 模式,直到到达脚本末尾或相应的结束标签(? >, %>)。因此,PHP 无法将编译后的输入视为程序代码。即使 EVAL 也无济于事,因为它只会调用最初没有触发二进制输入的同一个解析器。

BZipped 代码本身也不可执行,除非它被自动提取器存根包装。

既然它看起来是 BZipped,为什么不尝试解压缩该文件并看看会得到什么?也许类文件是作为 .bz2 发行版下载的,只是被重命名了。未压缩的副本可能包含适当的包装器以允许执行。

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.

淡淡離愁欲言轉身 2024-09-13 22:28:43

很长一段时间以来,我一直在努力使用 bcompiler,但令人惊讶的是,我找到了一个非常简单的解决方案,您只需单击一下即可编译整个网站。您可以按照以下步骤操作:-

  1. 下载并安装 Wampserver(任何版本)。

  2. 下载并安装 Wampserver PHP Addons 版本 php 5.2.5

  3. 点击 Wampserver -> PHP->版本-> 5.2.5 从任务栏(它将更改您当前的 php 版本为 5.2.5)。

  4. 选择 Wampserver -> PHP->扩展名-> php_bcompiler(它将在您的计算机上启用 bcompiler)。

    如果您可以自己编译脚本,上述步骤就足够了,但为了方便起见,您可以继续后续步骤。

  5. 下载bcompiler GUI

  6. 在 Bcompiler GUI 上选择文件夹,即可一键编译整个网站。

享受 PHP |享受开源

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:-

  1. Download and install Wampserver (any edition).

  2. Download and install Wampserver PHP Addons Version php 5.2.5

  3. click on Wampserver -> PHP -> Version -> 5.2.5 from Task bar (it will change your current version of php to 5.2.5).

  4. 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.

  5. Download bcompiler GUI.

  6. Select the Folder on the Bcompiler GUI and this will compiler your whole website with one click.

enjoy PHP | Enjoy Open Source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文