&1", $cloudlinuxCli, base64_encode(json_encode($requestData)) ); $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("pipe", "w") // stderr is a pipe that the child will write to ); $pipes = array(); $process = proc_open($fullCommandStr, $descriptorspec, $pipes); if (is_resource($process)) { while ($s = fgets($pipes[1])) { print $s; flush(); } } exit(); } /** * Prepares response with JAVASCRIPT header. * * @param $response * @return string */ public static function asJS($response) { return self::prepareHeader('application/javascript').$response; } /** * Prepares response with CSS header. * * @param $response * @return string */ public static function asCSS($response) { return self::prepareHeader('text/css').$response; } /** * Prepares response with HTML header. * * @param $response * @return string */ public static function asHTML($response) { return self::prepareHeader('text/html').$response; } /** * Prepares response with Fonts header. * * @param $response * @return string */ public static function asFont($response) { return self::prepareHeader('application/font-otf').$response; } /** * Prepares correct response header. * * @param $contentType * @param int $statusCode * @param string $description * @param array $additionalHeaders * @return string */ public static function prepareHeader( $contentType, $statusCode = 200, $description = 'OK', $additionalHeaders = array() ) { $header = "HTTP/1.1 $statusCode $description\n"; if (!empty($additionalHeaders)) { foreach ($additionalHeaders as $_header) { $header .= $_header."\n"; } } $header .= "Content-type: $contentType\n\n"; return $header; } /** * Extends response with error message. * * @param $response * @param $errorMessage * * @return mixed */ public static function extendResultByBilling($response, $errorMessage) { switch (Base::load()->getBilling()) { case 'Spa': $response->result = $errorMessage; break; } return $response; } }