/**
  * {@inheritdoc}
  */
 public function handle(\Input $input)
 {
     $configFile = new \File($this->configPathname);
     if ($input->post('save')) {
         $tempPathname = $this->configPathname . '~';
         $tempFile = new \File($tempPathname);
         $config = $input->postRaw('config');
         $config = html_entity_decode($config, ENT_QUOTES, 'UTF-8');
         $tempFile->write($config);
         $tempFile->close();
         $validator = new ConfigValidator($this->io);
         list($errors, $publishErrors, $warnings) = $validator->validate(TL_ROOT . '/' . $tempPathname);
         if (!$errors && !$publishErrors) {
             Messages::addConfirmation($GLOBALS['TL_LANG']['composer_client']['configValid']);
             $this->import('Files');
             $this->Files->rename($tempPathname, $this->configPathname);
         } else {
             $tempFile->delete();
             $_SESSION['COMPOSER_EDIT_CONFIG'] = $config;
             if ($errors) {
                 foreach ($errors as $message) {
                     Messages::addError('Error: ' . $message);
                 }
             }
             if ($publishErrors) {
                 foreach ($publishErrors as $message) {
                     Messages::addError('Publish error: ' . $message);
                 }
             }
         }
         if ($warnings) {
             foreach ($warnings as $message) {
                 Messages::addWarning('Warning: ' . $message);
             }
         }
         $this->reload();
     }
     if (isset($_SESSION['COMPOSER_EDIT_CONFIG'])) {
         $config = $_SESSION['COMPOSER_EDIT_CONFIG'];
         unset($_SESSION['COMPOSER_EDIT_CONFIG']);
     } else {
         $config = $configFile->getContent();
     }
     $template = new \BackendTemplate('be_composer_client_editor');
     $template->composer = $this->composer;
     $template->config = $config;
     return $template->parse();
 }
 /**
  * Check if SNI is available and disable remote host checking if not.
  *
  * @param string   $url  The url.
  *
  * @param resource $curl The curl resource.
  *
  * @return void
  */
 private static function checkSNI($url, $curl)
 {
     if ('https' !== substr($url, 0, 5)) {
         return;
     }
     $curlVersion = curl_version();
     // Curl 7.18.1 - March 30 2008 supports server name indication (RFC 4366), aka SNI
     // (http://curl.haxx.se/changes.html)
     if (version_compare(trim($curlVersion['version']), '7.18.1', '<')) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
         Messages::addWarning('SNI support not available, curl version too old. Host verification has been deactivated.');
         return;
     }
     // We only check for OpenSSL.
     $ssl = explode('/', trim($curlVersion['ssl_version']));
     if (count($ssl) !== 2 || $ssl[0] !== 'OpenSSL') {
         return;
     }
     // OpenSSL 0.9.8f support SNI, 0.9.8k and later has this enabled by default
     // (https://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI)
     if (version_compare($ssl[1], '0.9.8f', '<')) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
         Messages::addWarning('SNI support not available, OpenSSL version too old. Host verification has been deactivated.');
     }
 }
 /**
  * Determine the runtime mode to use depending on the availability of functions.
  *
  * @return mixed
  */
 private function determineRuntimeMode()
 {
     $mode = $GLOBALS['TL_CONFIG']['composerExecutionMode'];
     if ('inline' === $mode) {
         return $mode;
     }
     $functions = array();
     if ($mode === 'process') {
         $functions = array('proc_open', 'proc_close');
     }
     if ($mode === 'detached') {
         $functions = array('shell_exec');
         if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
             $functions[] = 'posix_kill';
         }
     }
     foreach ($functions as $function) {
         if (!FunctionAvailabilityCheck::isFunctionEnabled($function)) {
             Messages::addWarning($function . ' is disabled, reverting from ' . $mode . ' to inline execution');
             return 'inline';
         }
     }
     return $mode;
 }