Run PHP script encoded using ZendGuard via command line

I need to run from the command line (PHP CLI) some files that were encrypted by Zend Guard, and php just closes as soon as it reaches the encoded file without any error message. Is it possible to execute PHP scripts that are encoded by Zend Guard from the command line?

More details

In the application I'm working on now, some tasks need to be run periodically. First, we implemented controllers for some URLs that are used only for tasks. Then we completed the cron job using wget on these pages. The problem is that some of these tasks require parameters to run. Using wget to execute a POST request does not work, because the first thing that Zend Guard does is assign a cookie and then redirect to the same URL. On the second request, since he is now in GET, all parameters have been lost.

Then we decided to go to the script command line to fix the problem. We really like this approach because it solves the problems that we had using the URL. First, it does not support an open Apache connection for a long period of time. In addition, it does not provide some internal logic for public URLs. As I said earlier, when we try to run these command-line scripts, nothing happens, the application just quits.

We use Ubuntu 12.04 LTS, PHP 5.4.25 and Apache 2.2.22. I made sure that the Zend Guard extension was loaded correctly on the command line. In addition, it works correctly when pages are accessible through a web browser.

If anyone can help me with this problem, it will be very appreciated. Thanks!

+7
php apache zend-guard
source share
2 answers

I am going to make an assumption here. When you guys moved the script to run from the command line, you did not actually overwrite the script. You just simply php -f in the file instead of wget in the url.

If so, you probably have logic in the script that requires authentication, or web server logic with / die output if the parameter is not found. You mentioned that some scripts require running POST, so I assume that there will be $ _ POST , where, obviously, it will not work on the command line.

Just a guess.

EDIT: Just read the part in which you said that it works when accessed by the URL. Almost definitely $ _POST or something like that.

+2
source share

You should wrap any logic you want to run from the command line in a php script inside something like

 $cli = isset($_ENV['SSH_CLIENT']); if($cli) { // Code to run from command line here } else { // Code for the Web here } 

This will allow you to run the same file from the Internet and from the command line. As tazer84 , make sure that in CLI mode you do not enable Web Only logic (such as header('location: ...'); $_COOKIE , $_POST , etc.) and vice versa.

0
source share

All Articles