Marius Cramer
2014-03-07 bed72531bfb1ca225bb2c009dfbacf8f09fcd128
install/lib/install.lib.php
@@ -637,6 +637,11 @@
               $out .= $line;
            }
         }
         if (!$found) {
            if (trim($line) == $new_line) {
               $found = 1;
            }
         }
      }
      if($found == 0) {
         //* add \n if the last line does not end with \n or \r
@@ -719,6 +724,32 @@
}
/*
* Get the port number of the ISPConfig apps vhost
*/
function get_apps_vhost_port_number() {
   global $conf;
   if($conf['nginx']['installed'] == true){
      $ispconfig_vhost_file = $conf['nginx']['vhost_conf_dir'].'/apps.vhost';
      $regex = '/listen (\d+)/';
   } else {
      $ispconfig_vhost_file = $conf['apache']['vhost_conf_dir'].'/apps.vhost';
      $regex = '/\<VirtualHost.*\:(\d{1,})\>/';
   }
   if(is_file($ispconfig_vhost_file)) {
      $tmp = file_get_contents($ispconfig_vhost_file);
      preg_match($regex, $tmp, $matches);
      $port_number = @intval($matches[1]);
      if($port_number > 0) {
         return $port_number;
      } else {
         return '8081';
      }
   }
}
/*
* Get the port number of the ISPConfig controlpanel vhost
*/
@@ -797,5 +828,30 @@
   return $timezone;
}
function getapacheversion($get_minor = false) {
      global $app;
      $cmd = '';
      if(is_installed('apache2ctl')) $cmd = 'apache2ctl -v';
      elseif(is_installed('apachectl')) $cmd = 'apachectl -v';
      else {
         $app->log("Could not check apache version, apachectl not found.", LOGLEVEL_WARN);
         return '2.2';
      }
      exec($cmd, $output, $return_var);
      if($return_var != 0 || !$output[0]) {
         $app->log("Could not check apache version, apachectl did not return any data.", LOGLEVEL_WARN);
         return '2.2';
      }
      if(preg_match('/version:\s*Apache\/(\d+)(\.(\d+)(\.(\d+))*)?(\D|$)/i', $output[0], $matches)) {
         return $matches[1] . (isset($matches[3]) ? '.' . $matches[3] : '') . (isset($matches[5]) && $get_minor == true ? '.' . $matches[5] : '');
      } else {
         $app->log("Could not check apache version, did not find version string in apachectl output.", LOGLEVEL_WARN);
         return '2.2';
      }
   }
?>