Beispiel #1
0
 /**
  * Writes the environmental variables to the Nginx configuration file.
  * @param Collection $envars
  * @return boolean
  */
 private function writeToVhostConf(Collection $envars)
 {
     $vhost_conf = NginxHandler::VHOST_AVAILABLE_DIR . DIRECTORY_SEPARATOR . $this->identifier . '.conf';
     $configuration = '';
     foreach ($envars->all()->toArray() as $key => $value) {
         $configuration .= '    fastcgi_param               ' . $key . ' ' . $value . ';' . PHP_EOL;
     }
     if (!@file_put_contents($vhost_conf, replace_between(file_get_contents($vhost_conf), '# [[ENVARS]]', '# [[!ENVARS]]', PHP_EOL . $configuration))) {
         return false;
     }
     return true;
 }
Beispiel #2
0
 /**
  * Removes HTTP redirection configuration from a specified VHOST.
  * @return void
  */
 public function removeHttpRedirection()
 {
     $this->domain = $this->arguments()->getOption('domain', false);
     $this->identifier = fqdn_to_directory($this->domain);
     if (!$this->domain) {
         $this->writeln("No domain specified, use --domain to specify the domain!")->exitWithError();
     }
     $vhost_conf = NginxHandler::VHOST_AVAILABLE_DIR . DIRECTORY_SEPARATOR . $this->identifier . '.conf';
     if (!@file_put_contents($vhost_conf, replace_between(file_get_contents($vhost_conf), '# [[HTTPS-REDIR]]', '# [[!HTTPS-REDIR]]', PHP_EOL))) {
         $this->writeln(SpringoAgent::TAG_ERROR . "Unable to update virtual host configuration file in {$vhost_conf}");
         return;
     }
     $this->writeln('Done!');
 }
 $gtab = [];
 $translationJson = cURL("https://trustpilot.zendesk.com/api/v2/help_center/articles/" . $article['id'] . "/translations.json?locale=en-us,da,de,es,fr,it,nl,sv");
 //echo '*****************' . $articleID;
 //var_dump($translationJson['translations']);
 foreach ($translationJson['translations'] as $translation) {
     $sectionID = $translation['id'];
     $locale = $translation['locale'];
     $lastUpdate = $translation['updated_at'];
     $sectionTitle = $translation['title'];
     $sectionContent = $translation['body'];
     if (strlen(get_string_between($sectionContent, '<script>', '</script>')) > 0) {
         $scriptBody = '<script>' . get_string_between($sectionContent, '<script>', '</script>') . '</script>';
     } else {
         $scriptBody = '';
     }
     $sectionContent = replace_between($sectionContent, '<script>', '</script>', '');
     //echo "--> Article " . $articleID . " being imported now ";
     $sectionUL = $sectionTitle . $sectionID;
     // Sequence is : English, DK, DE, NL, FR, IT, ES, SE
     //echo $locale . "\\\\\\\\\\\\\\\\\\\ \n";
     $link_article = "<a href='https://support.trustpilot.com/hc/" . $locale . "/articles/" . $articleID . "' target='_blank'\\>https://support.trustpilot.com/hc/" . $locale . "/articles/" . $articleID . "</a>";
     if (strcmp($locale, "en-us") == 0) {
         $config[0]->elements[1]->microcopy = $link_article;
         $config[0]->elements[1]->value = $sectionTitle;
         $config[0]->elements[2]->value = $scriptBody;
         $config[0]->elements[3]->value = $sectionContent;
     } else {
         if (strcmp($locale, "da") == 0) {
             $config[1]->elements[1]->microcopy = $link_article;
             $config[1]->elements[1]->value = $sectionTitle;
             $config[1]->elements[2]->value = $scriptBody;
Beispiel #4
0
 /**
  * Removes the SSL configuration in the Nginx virtualhost configuration file.
  * @return void
  */
 private function removeConfigFromVhost()
 {
     $vhost_config = NginxHandler::VHOST_AVAILABLE_DIR . DIRECTORY_SEPARATOR . $this->identifier . '.conf';
     file_put_contents($vhost_config, replace_between(file_get_contents($vhost_config), '# [[LESSL]]', '# [[!LESSL]]', PHP_EOL));
     file_put_contents($vhost_config, replace_between(file_get_contents($vhost_config), '# [[SERVER-PORT]]', '# [[!SERVER-PORT]]', PHP_EOL . 'listen 80;' . PHP_EOL));
 }