Last year, I deployed a project in client server by encoding all the files using Zend Guard Loader PHP extension and after the deployment we have done some quick changes / fixes as per the client emails and deployed the files without encoding on live server as a matter of urgency which we have done so many times after the deployment so now I am on a stage that I don't have a list of files which deployed without encoding on live server.
Now Client is coming this year for upgrading the solution by further integrating new modules which require major impact on the current solution. So before moving ahead with the new modules integration i would like to generate one report that what are the files currently deployed on live server without encoded.
Now coming to the technical discussion, I have searched in Google and came to one solution that we can able to check whether the file is encoded or not using the Zend Guard Loader - PHP API. (http://files.zend.com/help/Zend-Server-5/zend_guard_loader_-_php_api.htm)
API provide one function boolean zend_loader_file_encoded (void) but actually this function doesn't accept any argument as it always checks the current file whether the current file is encrypted or not using Zend guard.
Basically I would like to go through each folder and further files inside it on the server for checking whether it's encoded or not.
Looking forward for your further direction path.
You need to recursively check for php files that don't begin with <?php @Zend;
:
$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();
}
}
}