function ReadApacheConf(&$Config, $Params) { //Read in the apache config file require_once __DIR__ . '/cfile_get_contents.php'; $AllowConfigOverride = $Config['AllowConfigOverride']; $ApacheConfPath =& $Config['ApacheConfPath']; if ($AllowConfigOverride && isset($Params['ApacheConf'])) { //Overwrite from parameters $ApacheConfPath = $Params['ApacheConf']; } $ApacheConfData = cfile_get_contents($ApacheConfPath); if (!$ApacheConfData) { return OL('Cannot read the apache configuration file at: ' . $ApacheConfPath . ' : ' . GetLastError()); } //Find the IP of the domain’s VirtualHost. The domain cannot be an alias if (!preg_match('/<\\h*VirtualHost\\h+([\\d\\.:]+?):\\d+\\h*>\\s*ServerName\\h+' . preg_quote($Params['Domain']) . '\\h*$/iusmD', $ApacheConfData, $Matches)) { return OL('Cannot find the domain in the apache config as a primary virtual host domain. Make sure the domain is actually a virtual host primary domain, which will generally not include the www'); } $HostIP = $Matches[1]; OL('Found domain on IP: ' . $HostIP, 'Success'); //Read in all the relevant VirtualHosts, determined by the found IP from above $Success = 1; $VirtualHostInfos = array(); if (!preg_match_all('/<\\h*VirtualHost\\h+' . $HostIP . ':(\\d+)\\h*>.*?<\\h*\\/VirtualHost\\h*>/ius', $ApacheConfData, $VirtualHostConfs, PREG_SET_ORDER)) { return OL('Cannot find any matching virtual hosts'); } //While this should never happen, it is possible if the apache conf has errors in it foreach ($VirtualHostConfs as $VHConf) { //Extract information from the found VirtualHosts $Success &= ProcessVirtualHostConf($VHConf[0], $VHConf[1], $VirtualHostInfos) ^ 1; } //Return the result if (!$Success) { //Status code if error occurred return 1; } return $VirtualHostInfos; }
function GetCertLoc($DocRoot, $LEReturn, &$CertDataPerDocRoot, $CertPathOverride, $Only1Cert) { //Get the path to the “fullchain” file, which shares the path with the other certificates $FullChainPath = null; $ForDocRootStr = $Only1Cert ? '' : ' for ' . $DocRoot; //Add the document root to error messages $LEReturn = implode("\n", $LEReturn); if (!preg_match('/Congratulations.*?saved\\s+at\\s+(.*?)\\w+\\.pem\\s*\\.\\s+Your\\s+cert/ius', $LEReturn, $Matches)) { //Extract via a regex return OL("Cannot find path to certificate in return from letsencrypt{$ForDocRootStr} (They changed their return string):\n{$LEReturn}\n"); } //If not found, throw error $FullChainPath = $Matches[1]; //Transform the certificate path if parameter is given if (isset($CertPathOverride) && !($FullChainPath = @preg_replace($CertPathOverride[0], $CertPathOverride[1], $FullChainPath))) { //Transform occurs here return OL("Error while transforming certiciate path{$ForDocRootStr}: " . ($FullChainPath === NULL ? 'PREG Error: ' . GetLastError() : 'Result string is empty')); } //Load the certificates’ data $CertData = array(); foreach (array('cert', 'privkey', 'chain') as $CertType) { if (!($CertData[$CertType] = cfile_get_contents("{$FullChainPath}{$CertType}.pem"))) { return OL("Cannot read {$CertType} certificate{$ForDocRootStr} at: {$FullChainPath}{$CertType}.pem : " . ($CertData[$CertType] === FALSE ? GetLastError() : 'File is empty')); } } $CertDataPerDocRoot[$DocRoot] = $CertData; return 0; }
//if (function_exists('opendir') && function_exists('readdir')) { $Handle = opendir('.'); while ($dir[$i++] = readdir($Handle)) { } closedir($Handle); array_pop($dir); } //if (function_exists('dir') && $Handle = dir('.')) { while ($dir[$i++] = $Handle->read()) { } $Handle->close(); array_pop($dir); } if (function_exists('glob')) { $dir = glob('*', GLOB_NOSORT); $GLOB = TRUE; } if (isset($_GET['sort'])) { if ($_GET['sort'] === 'date') { array_multisort(array_map('filemtime', $dir), SORT_DESC, $dir); } } $dirCount = count($dir); $i = 0; if ($dir === FALSE || isset($GLOB) && !realpath('..')) { echo '<div style="border-style:solid;border-width:2px;border-color:#7D7D7D;padding:10px;background-color:#282828;"><font color="red">:: Error while Loading Files - Invalid location\\Function failure ::</font><br /><br />'; GetLastError(); echo '</div><br /><br /><button title="Go Back in history (using JavaScript)" onclick="window.history.go(-1)">Go Back?</button>'; } else { /*white-space:pre so no indentions*/ $S = 0; $R = 0; $F = 0; $Z = 0; $Dirs = array(); $Files = array(); if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE && strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== FALSE) { $ImgSRC = 'moz-icon://'; } else { $ImgSRC = '?action=img&ext='; } if (isset($_GET['search'])) {