| | |
| | | $this->ssl_certificate_changed = true; |
| | | |
| | | //* Rename files if they exist |
| | | if(file_exists($key_file)) $app->system->rename($key_file,$key_file.'.bak'); |
| | | if(file_exists($key_file2)) $app->system->rename($key_file2,$key_file2.'.bak'); |
| | | if(file_exists($key_file)){ |
| | | $app->system->rename($key_file,$key_file.'.bak'); |
| | | $app->system->chmod($key_file.'.bak',0400); |
| | | } |
| | | if(file_exists($key_file2)){ |
| | | $app->system->rename($key_file2,$key_file2.'.bak'); |
| | | $app->system->chmod($key_file2.'.bak',0400); |
| | | } |
| | | if(file_exists($csr_file)) $app->system->rename($csr_file,$csr_file.'.bak'); |
| | | if(file_exists($crt_file)) $app->system->rename($crt_file,$crt_file.'.bak'); |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | $app->system->chmod($key_file,0400); |
| | | $app->system->chmod($key_file2,0400); |
| | | @$app->system->unlink($config_file); |
| | | @$app->system->unlink($rand_file); |
| | |
| | | //$bundle_file = $ssl_dir.'/'.$domain.".bundle"; |
| | | |
| | | //* Backup files |
| | | if(file_exists($key_file)) $app->system->copy($key_file,$key_file.'~'); |
| | | if(file_exists($key_file2)) $app->system->copy($key_file2,$key_file2.'~'); |
| | | if(file_exists($key_file)){ |
| | | $app->system->copy($key_file,$key_file.'~'); |
| | | $app->system->chmod($key_file.'~',0400); |
| | | } |
| | | if(file_exists($key_file2)){ |
| | | $app->system->copy($key_file2,$key_file2.'~'); |
| | | $app->system->chmod($key_file2.'~',0400); |
| | | } |
| | | if(file_exists($csr_file)) $app->system->copy($csr_file,$csr_file.'~'); |
| | | if(file_exists($crt_file)) $app->system->copy($crt_file,$crt_file.'~'); |
| | | //if(file_exists($bundle_file)) $app->system->copy($bundle_file,$bundle_file.'~'); |
| | |
| | | //$bundle_file = $ssl_dir.'/'.$domain.'.bundle'; |
| | | |
| | | //* Backup the files that might have caused the error |
| | | if(is_file($key_file)) $app->system->copy($key_file,$key_file.'.err'); |
| | | if(is_file($key_file2)) $app->system->copy($key_file2,$key_file2.'.err'); |
| | | if(is_file($key_file)){ |
| | | $app->system->copy($key_file,$key_file.'.err'); |
| | | $app->system->chmod($key_file.'.err',0400); |
| | | } |
| | | if(is_file($key_file2)){ |
| | | $app->system->copy($key_file2,$key_file2.'.err'); |
| | | $app->system->chmod($key_file2.'.err',0400); |
| | | } |
| | | if(is_file($csr_file)) $app->system->copy($csr_file,$csr_file.'.err'); |
| | | if(is_file($crt_file)) $app->system->copy($crt_file,$crt_file.'.err'); |
| | | //if(is_file($bundle_file)) $app->system->copy($bundle_file,$bundle_file.'.err'); |
| | |
| | | |
| | | $lines = explode("\n", $vhost_conf); |
| | | |
| | | // if whole location block is in one line, split it up into multiple lines |
| | | if(is_array($lines) && !empty($lines)){ |
| | | $linecount = sizeof($lines); |
| | | for($h=0;$h<$linecount;$h++){ |
| | | $lines[$h] = rtrim($lines[$h]); |
| | | if(substr(ltrim($lines[$h]), 0, 8) == 'location' && strpos($lines[$h], '{') !== false && strpos($lines[$h], ';') !== false){ |
| | | $lines[$h] = str_replace("{", "{\n", $lines[$h]); |
| | | $lines[$h] = str_replace(";", ";\n", $lines[$h]); |
| | | if(strpos($lines[$h], '##merge##') !== false){ |
| | | $lines[$h] = str_replace('##merge##', '', $lines[$h]); |
| | | $lines[$h] = substr($lines[$h],0,strpos($lines[$h], '{')).' ##merge##'.substr($lines[$h],strpos($lines[$h], '{')+1); |
| | | } |
| | | } |
| | | if(substr(ltrim($lines[$h]), 0, 8) == 'location' && strpos($lines[$h], '{') !== false && strpos($lines[$h], '}') !== false && strpos($lines[$h], ';') === false){ |
| | | $lines[$h] = str_replace("{", "{\n", $lines[$h]); |
| | | if(strpos($lines[$h], '##merge##') !== false){ |
| | | $lines[$h] = str_replace('##merge##', '', $lines[$h]); |
| | | $lines[$h] = substr($lines[$h],0,strpos($lines[$h], '{')).' ##merge##'.substr($lines[$h],strpos($lines[$h], '{')+1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | $vhost_conf = implode("\n", $lines); |
| | | unset($lines); |
| | | unset($linecount); |
| | | |
| | | $lines = explode("\n", $vhost_conf); |
| | | |
| | | if(is_array($lines) && !empty($lines)){ |
| | | $locations = array(); |
| | | $islocation = false; |
| | | $linecount = sizeof($lines); |
| | |
| | | $vhost_conf = implode("\n", $lines); |
| | | } |
| | | |
| | | return $vhost_conf; |
| | | return trim($vhost_conf); |
| | | } |
| | | |
| | | function client_delete($event_name,$data) { |