Reputation: 13
I made a simple script for our webservices (a zf2 rest application) that will receive a post request with params asking the script to call a C program via PHP exec() with those params in order to send a sms via a modem and return a json response success = true;
<?php
$phoneNumber = "5145551234";
$message = "Sample sms text";
$smsAgentPath = "C:\installpath\smsagent.exe"; //install path to smsAgent
$optionA = 40; //Request Type (int)
$optionB = $phoneNumber; //Cellphone number to send the SMS to
$optionC = 1; //Auto update flag 1 = true
$optionD = 1; //Confirm delivery flag 1 = true;
$optionE = strlen($message); //Length of the message
$optionF = $message; //Message to send
$optionG = 1; //Message delivery request reference number
$cmd = $smsAgentPath . " [A:" . $optionA . "][B:" . $optionB . "][C:" . $optionC . "][D:" . $optionD . "][E:" . $optionE . "][F:" . $optionF . "][G:" . $optionG . "]";
$out = exec($cmd);
This script runs perfect on easyPHP and sends and sms the the given number as expected. However once inside ZF2, on a zend server install, all latest stable version, the page stays on waiting for localhost to response, and launches a download of an empty file after 30 seconds or more.
Reading the web, found out about the php.ini disable_functions, string is empty in zend server config, also found about apache safe_mode, could not find any mention of it inside apache config on zend server nor its php.ini. Adding the safe_mode = Off to php.ini did not change anything.
Am I missing something?
<?php
namespace Sms\Controller;
use Zend\Mvc\Controller\AbstractRestfulController;
use Zend\View\Model\JsonModel;
use BaseApi\V1\Model\Log;
use Sms\Model\SmsBase;
class SendController extends AbstractRestfulController
{
protected $smsTable;
protected $logTable;
public function create()
{
$phoneNumber = "5145551234";
$message = "Sample message";
$smsAgentPath = "C:\\installpath\\smsagent.exe";
$optionA = 40;
$optionB = trim($phoneNumber);
$optionC = 1;
$optionD = 1;
$optionE = strlen($message);
$optionF = $message;
$optionG = 1;
$cmd = $smsAgentPath . " [A:" . $optionA . "][B:" . $optionB . "][C:" . $optionC . "][D:" . $optionD . "][E:" . $optionE . "][F:" . $optionF . "][G:" . $optionG . "]";
exec($cmd);
return new JsonModel(array('success' => true, 'cmd' => $cmd));
}
}
Upvotes: 0
Views: 318
Reputation: 13
After more than 8 hours on it, turns out to be because zendServer starts Apache as a service. Stop the service, start Apache manualy and on windows startup and php exec will work...
Upvotes: 0