如何使用 Zend Guard 加载程序识别 PHP 文件是否已编码

How to identify whether the PHP file is Encoded or not using the Zend Guard loader

去年,我通过使用 Zend Guard Loader PHP 扩展对所有文件进行编码,在客户端服务器中部署了一个项目,在部署之后,我们根据客户端电子邮件进行了一些快速更改/修复,并部署了作为紧急事项,我们在实时服务器上没有编码的文件在部署后已经做了很多次,所以现在我处于一个阶段,我没有在实时服务器上没有编码部署的文件列表。

现在客户今年来升级解决方案,通过进一步集成需要对当前解决方案产生重大影响的新模块。因此,在继续进行新模块集成之前,我想生成一份报告,说明当前部署在实时服务器上的文件是什么,没有编码。

现在开始技术讨论,我在 Google 中进行了搜索,找到了一种解决方案,我们可以使用 Zend Guard Loader 检查文件是否已编码 - PHP API。 (http://files.zend.com/help/Zend-Server-5/zend_guard_loader_-_php_api.htm)

API 提供一个函数 boolean zend_loader_file_encoded (void) 但实际上这个函数不接受任何参数,因为它总是检查当前文件是否当前文件是否已使用 Zend guard 加密。

基本上我想遍历服务器上的每个文件夹和其中的其他文件,以检查它是否已编码。

期待您进一步的方向。

您需要递归检查不以 <?php @Zend;:

开头的 php 个文件
$directory = new \RecursiveDirectoryIterator($path);
$iterator = new \RecursiveIteratorIterator($directory);
$files = array();
foreach ($iterator as $info) {
  if (substr($info->getPathname(), -4) === '.php') {
    $f = fopen($info->getPathname(), 'r');
    $bytes = fgets($f, 12);
    fclose($f);
    if($bytes !== '<?php @Zend;') {
      $files[] = $info->getPathname();
    }
  }
}