| | |
| | | $crt_file = $ssl_dir.'/'.$domain.'.crt'; |
| | | |
| | | //* Create a SSL Certificate |
| | | if($data['new']['ssl_action'] == 'create') { |
| | | if($data['new']['ssl_action'] == 'create' && $conf['mirror_server_id'] == 0) { |
| | | |
| | | $this->ssl_certificate_changed = true; |
| | | |
| | |
| | | switch($data['new']['subdomain']) { |
| | | case 'www': |
| | | if(substr($data['new']['redirect_path'],0,1) == '/'){ // relative path |
| | | $rewrite_exclude = '(?!'.substr($data['new']['redirect_path'],0,-1).')'; |
| | | $rewrite_exclude = '((?!'.substr($data['new']['redirect_path'],0,-1).'))'; |
| | | } else { // URL - check if URL is local |
| | | $tmp_redirect_path = $data['new']['redirect_path']; |
| | | if(substr($tmp_redirect_path,0,7) == '$scheme') $tmp_redirect_path = 'http'.substr($tmp_redirect_path,7); |
| | |
| | | if($tmp_redirect_path_parts['host'] == $data['new']['domain'] && ($tmp_redirect_path_parts['port'] == '80' || $tmp_redirect_path_parts['port'] == '443' || !isset($tmp_redirect_path_parts['port']))){ |
| | | if(substr($tmp_redirect_path_parts['path'],-1) == '/') $tmp_redirect_path_parts['path'] = substr($tmp_redirect_path_parts['path'],0,-1); |
| | | if(substr($tmp_redirect_path_parts['path'],0,1) != '/') $tmp_redirect_path_parts['path'] = '/'.$tmp_redirect_path_parts['path']; |
| | | $rewrite_exclude = '(?!'.$tmp_redirect_path_parts['path'].')'; |
| | | $rewrite_exclude = '((?!'.$tmp_redirect_path_parts['path'].'))'; |
| | | } else { |
| | | $rewrite_exclude = '(.?)'; |
| | | } |
| | | unset($tmp_redirect_path); |
| | | unset($tmp_redirect_path_parts); |
| | | } |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^'.$data['new']['domain'], |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^'.$this->_rewrite_quote($data['new']['domain']), |
| | | 'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':$data['new']['redirect_type'], |
| | | 'rewrite_target' => $data['new']['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude); |
| | | |
| | | if(substr($data['new']['redirect_path'],0,1) == '/'){ // relative path |
| | | $rewrite_exclude = '(?!'.substr($data['new']['redirect_path'],0,-1).')'; |
| | | $rewrite_exclude = '((?!'.substr($data['new']['redirect_path'],0,-1).'))'; |
| | | } else { // URL - check if URL is local |
| | | $tmp_redirect_path = $data['new']['redirect_path']; |
| | | if(substr($tmp_redirect_path,0,7) == '$scheme') $tmp_redirect_path = 'http'.substr($tmp_redirect_path,7); |
| | |
| | | if($tmp_redirect_path_parts['host'] == 'www.'.$data['new']['domain'] && ($tmp_redirect_path_parts['port'] == '80' || $tmp_redirect_path_parts['port'] == '443' || !isset($tmp_redirect_path_parts['port']))){ |
| | | if(substr($tmp_redirect_path_parts['path'],-1) == '/') $tmp_redirect_path_parts['path'] = substr($tmp_redirect_path_parts['path'],0,-1); |
| | | if(substr($tmp_redirect_path_parts['path'],0,1) != '/') $tmp_redirect_path_parts['path'] = '/'.$tmp_redirect_path_parts['path']; |
| | | $rewrite_exclude = '(?!'.$tmp_redirect_path_parts['path'].')'; |
| | | $rewrite_exclude = '((?!'.$tmp_redirect_path_parts['path'].'))'; |
| | | } else { |
| | | $rewrite_exclude = '(.?)'; |
| | | } |
| | | unset($tmp_redirect_path); |
| | | unset($tmp_redirect_path_parts); |
| | | } |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^www.'.$data['new']['domain'], |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^' . $this->_rewrite_quote('www.'.$data['new']['domain']), |
| | | 'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':$data['new']['redirect_type'], |
| | | 'rewrite_target' => $data['new']['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude); |
| | | break; |
| | | case '*': |
| | | if(substr($data['new']['redirect_path'],0,1) == '/'){ // relative path |
| | | $rewrite_exclude = '(?!'.substr($data['new']['redirect_path'],0,-1).')'; |
| | | $rewrite_exclude = '((?!'.substr($data['new']['redirect_path'],0,-1).'))'; |
| | | } else { // URL - check if URL is local |
| | | $tmp_redirect_path = $data['new']['redirect_path']; |
| | | if(substr($tmp_redirect_path,0,7) == '$scheme') $tmp_redirect_path = 'http'.substr($tmp_redirect_path,7); |
| | |
| | | if(substr($tmp_redirect_path_parts['host'],-strlen($data['new']['domain'])) == $data['new']['domain'] && ($tmp_redirect_path_parts['port'] == '80' || $tmp_redirect_path_parts['port'] == '443' || !isset($tmp_redirect_path_parts['port']))){ |
| | | if(substr($tmp_redirect_path_parts['path'],-1) == '/') $tmp_redirect_path_parts['path'] = substr($tmp_redirect_path_parts['path'],0,-1); |
| | | if(substr($tmp_redirect_path_parts['path'],0,1) != '/') $tmp_redirect_path_parts['path'] = '/'.$tmp_redirect_path_parts['path']; |
| | | $rewrite_exclude = '(?!'.$tmp_redirect_path_parts['path'].')'; |
| | | $rewrite_exclude = '((?!'.$tmp_redirect_path_parts['path'].'))'; |
| | | } else { |
| | | $rewrite_exclude = '(.?)'; |
| | | } |
| | | unset($tmp_redirect_path); |
| | | unset($tmp_redirect_path_parts); |
| | | } |
| | | $rewrite_rules[] = array( 'rewrite_domain' => $data['new']['domain'], |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '(^|\.)'.$this->_rewrite_quote($data['new']['domain']), |
| | | 'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':$data['new']['redirect_type'], |
| | | 'rewrite_target' => $data['new']['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude); |
| | | break; |
| | | default: |
| | | if(substr($data['new']['redirect_path'],0,1) == '/'){ // relative path |
| | | $rewrite_exclude = '(?!'.substr($data['new']['redirect_path'],0,-1).')'; |
| | | $rewrite_exclude = '((?!'.substr($data['new']['redirect_path'],0,-1).'))'; |
| | | } else { // URL - check if URL is local |
| | | $tmp_redirect_path = $data['new']['redirect_path']; |
| | | if(substr($tmp_redirect_path,0,7) == '$scheme') $tmp_redirect_path = 'http'.substr($tmp_redirect_path,7); |
| | |
| | | if($tmp_redirect_path_parts['host'] == $data['new']['domain'] && ($tmp_redirect_path_parts['port'] == '80' || $tmp_redirect_path_parts['port'] == '443' || !isset($tmp_redirect_path_parts['port']))){ |
| | | if(substr($tmp_redirect_path_parts['path'],-1) == '/') $tmp_redirect_path_parts['path'] = substr($tmp_redirect_path_parts['path'],0,-1); |
| | | if(substr($tmp_redirect_path_parts['path'],0,1) != '/') $tmp_redirect_path_parts['path'] = '/'.$tmp_redirect_path_parts['path']; |
| | | $rewrite_exclude = '(?!'.$tmp_redirect_path_parts['path'].')'; |
| | | $rewrite_exclude = '((?!'.$tmp_redirect_path_parts['path'].'))'; |
| | | } else { |
| | | $rewrite_exclude = '(.?)'; |
| | | } |
| | | unset($tmp_redirect_path); |
| | | unset($tmp_redirect_path_parts); |
| | | } |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^'.$data['new']['domain'], |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^'.$this->_rewrite_quote($data['new']['domain']), |
| | | 'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':$data['new']['redirect_type'], |
| | | 'rewrite_target' => $data['new']['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude); |
| | |
| | | unset($client); |
| | | unset($aa_search); |
| | | unset($aa_replace); |
| | | $server_alias[] .= $auto_alias; |
| | | $server_alias[] .= $auto_alias.' '; |
| | | } |
| | | |
| | | // get alias domains (co-domains and subdomains) |
| | |
| | | switch($alias['subdomain']) { |
| | | case 'www': |
| | | if(substr($alias['redirect_path'],0,1) == '/'){ // relative path |
| | | $rewrite_exclude = '(?!'.substr($alias['redirect_path'],0,-1).')'; |
| | | $rewrite_exclude = '((?!'.substr($alias['redirect_path'],0,-1).'))'; |
| | | } else { // URL - check if URL is local |
| | | $tmp_redirect_path = $alias['redirect_path']; |
| | | if(substr($tmp_redirect_path,0,7) == '$scheme') $tmp_redirect_path = 'http'.substr($tmp_redirect_path,7); |
| | |
| | | if($tmp_redirect_path_parts['host'] == $alias['domain'] && ($tmp_redirect_path_parts['port'] == '80' || $tmp_redirect_path_parts['port'] == '443' || !isset($tmp_redirect_path_parts['port']))){ |
| | | if(substr($tmp_redirect_path_parts['path'],-1) == '/') $tmp_redirect_path_parts['path'] = substr($tmp_redirect_path_parts['path'],0,-1); |
| | | if(substr($tmp_redirect_path_parts['path'],0,1) != '/') $tmp_redirect_path_parts['path'] = '/'.$tmp_redirect_path_parts['path']; |
| | | $rewrite_exclude = '(?!'.$tmp_redirect_path_parts['path'].')'; |
| | | $rewrite_exclude = '((?!'.$tmp_redirect_path_parts['path'].'))'; |
| | | } else { |
| | | $rewrite_exclude = '(.?)'; |
| | | } |
| | | unset($tmp_redirect_path); |
| | | unset($tmp_redirect_path_parts); |
| | | } |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^'.$alias['domain'], |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^'.$this->_rewrite_quote($alias['domain']), |
| | | 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'], |
| | | 'rewrite_target' => $alias['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude); |
| | | |
| | | if(substr($alias['redirect_path'],0,1) == '/'){ // relative path |
| | | $rewrite_exclude = '(?!'.substr($alias['redirect_path'],0,-1).')'; |
| | | $rewrite_exclude = '((?!'.substr($alias['redirect_path'],0,-1).'))'; |
| | | } else { // URL - check if URL is local |
| | | $tmp_redirect_path = $alias['redirect_path']; |
| | | if(substr($tmp_redirect_path,0,7) == '$scheme') $tmp_redirect_path = 'http'.substr($tmp_redirect_path,7); |
| | |
| | | if($tmp_redirect_path_parts['host'] == 'www.'.$alias['domain'] && ($tmp_redirect_path_parts['port'] == '80' || $tmp_redirect_path_parts['port'] == '443' || !isset($tmp_redirect_path_parts['port']))){ |
| | | if(substr($tmp_redirect_path_parts['path'],-1) == '/') $tmp_redirect_path_parts['path'] = substr($tmp_redirect_path_parts['path'],0,-1); |
| | | if(substr($tmp_redirect_path_parts['path'],0,1) != '/') $tmp_redirect_path_parts['path'] = '/'.$tmp_redirect_path_parts['path']; |
| | | $rewrite_exclude = '(?!'.$tmp_redirect_path_parts['path'].')'; |
| | | $rewrite_exclude = '((?!'.$tmp_redirect_path_parts['path'].'))'; |
| | | } else { |
| | | $rewrite_exclude = '(.?)'; |
| | | } |
| | | unset($tmp_redirect_path); |
| | | unset($tmp_redirect_path_parts); |
| | | } |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^www.'.$alias['domain'], |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^' . $this->_rewrite_quote('www.'.$alias['domain']), |
| | | 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'], |
| | | 'rewrite_target' => $alias['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude); |
| | | break; |
| | | case '*': |
| | | if(substr($alias['redirect_path'],0,1) == '/'){ // relative path |
| | | $rewrite_exclude = '(?!'.substr($alias['redirect_path'],0,-1).')'; |
| | | $rewrite_exclude = '((?!'.substr($alias['redirect_path'],0,-1).'))'; |
| | | } else { // URL - check if URL is local |
| | | $tmp_redirect_path = $alias['redirect_path']; |
| | | if(substr($tmp_redirect_path,0,7) == '$scheme') $tmp_redirect_path = 'http'.substr($tmp_redirect_path,7); |
| | |
| | | if(substr($tmp_redirect_path_parts['host'],-strlen($alias['domain'])) == $alias['domain'] && ($tmp_redirect_path_parts['port'] == '80' || $tmp_redirect_path_parts['port'] == '443' || !isset($tmp_redirect_path_parts['port']))){ |
| | | if(substr($tmp_redirect_path_parts['path'],-1) == '/') $tmp_redirect_path_parts['path'] = substr($tmp_redirect_path_parts['path'],0,-1); |
| | | if(substr($tmp_redirect_path_parts['path'],0,1) != '/') $tmp_redirect_path_parts['path'] = '/'.$tmp_redirect_path_parts['path']; |
| | | $rewrite_exclude = '(?!'.$tmp_redirect_path_parts['path'].')'; |
| | | $rewrite_exclude = '((?!'.$tmp_redirect_path_parts['path'].'))'; |
| | | } else { |
| | | $rewrite_exclude = '(.?)'; |
| | | } |
| | | unset($tmp_redirect_path); |
| | | unset($tmp_redirect_path_parts); |
| | | } |
| | | $rewrite_rules[] = array( 'rewrite_domain' => $alias['domain'], |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '(^|\.)' . $this->_rewrite_quote($alias['domain']), |
| | | 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'], |
| | | 'rewrite_target' => $alias['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude); |
| | | break; |
| | | default: |
| | | if(substr($alias['redirect_path'],0,1) == '/'){ // relative path |
| | | $rewrite_exclude = '(?!'.substr($alias['redirect_path'],0,-1).')'; |
| | | $rewrite_exclude = '((?!'.substr($alias['redirect_path'],0,-1).'))'; |
| | | } else { // URL - check if URL is local |
| | | $tmp_redirect_path = $alias['redirect_path']; |
| | | if(substr($tmp_redirect_path,0,7) == '$scheme') $tmp_redirect_path = 'http'.substr($tmp_redirect_path,7); |
| | |
| | | if($tmp_redirect_path_parts['host'] == $alias['domain'] && ($tmp_redirect_path_parts['port'] == '80' || $tmp_redirect_path_parts['port'] == '443' || !isset($tmp_redirect_path_parts['port']))){ |
| | | if(substr($tmp_redirect_path_parts['path'],-1) == '/') $tmp_redirect_path_parts['path'] = substr($tmp_redirect_path_parts['path'],0,-1); |
| | | if(substr($tmp_redirect_path_parts['path'],0,1) != '/') $tmp_redirect_path_parts['path'] = '/'.$tmp_redirect_path_parts['path']; |
| | | $rewrite_exclude = '(?!'.$tmp_redirect_path_parts['path'].')'; |
| | | $rewrite_exclude = '((?!'.$tmp_redirect_path_parts['path'].'))'; |
| | | } else { |
| | | $rewrite_exclude = '(.?)'; |
| | | } |
| | | unset($tmp_redirect_path); |
| | | unset($tmp_redirect_path_parts); |
| | | } |
| | | $rewrite_rules[] = array( 'rewrite_domain' => '^'.$alias['domain'], |
| | | if(substr($alias['domain'], 0, 2) === '*.') $domain_rule = '(^|\.)'.$this->_rewrite_quote(substr($alias['domain'], 2)); |
| | | else $domain_rule = '^'.$this->_rewrite_quote($alias['domain']); |
| | | $rewrite_rules[] = array( 'rewrite_domain' => $domain_rule, |
| | | 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'], |
| | | 'rewrite_target' => $alias['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude); |
| | |
| | | } |
| | | |
| | | if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html"); |
| | | $app->system->copy("/usr/local/ispconfig/server/conf/awstats_index.php.master",$data['new']['document_root']."/" . $web_folder . "/stats/index.php"); |
| | | if(file_exists("/usr/local/ispconfig/server/conf-custom/awstats_index.php.master")) { |
| | | $app->system->copy("/usr/local/ispconfig/server/conf-custom/awstats_index.php.master",$data['new']['document_root']."/" . $web_folder . "/stats/index.php"); |
| | | } else { |
| | | $app->system->copy("/usr/local/ispconfig/server/conf/awstats_index.php.master",$data['new']['document_root']."/" . $web_folder . "/stats/index.php"); |
| | | } |
| | | } |
| | | |
| | | //* Delete the awstats configuration file |
| | |
| | | $ini_settings = explode("\n", $custom_php_ini_settings); |
| | | if(is_array($ini_settings) && !empty($ini_settings)){ |
| | | foreach($ini_settings as $ini_setting){ |
| | | list($key, $value) = explode('=', $ini_setting); |
| | | if($value){ |
| | | $value = escapeshellcmd(trim($value)); |
| | | $key = escapeshellcmd(trim($key)); |
| | | switch (strtolower($value)) { |
| | | case '0': |
| | | // PHP-FPM might complain about invalid boolean value if you use 0 |
| | | $value = 'off'; |
| | | case '1': |
| | | case 'on': |
| | | case 'off': |
| | | case 'true': |
| | | case 'false': |
| | | case 'yes': |
| | | case 'no': |
| | | $final_php_ini_settings[] = array('ini_setting' => 'php_admin_flag['.$key.'] = '.$value); |
| | | break; |
| | | default: |
| | | $final_php_ini_settings[] = array('ini_setting' => 'php_admin_value['.$key.'] = '.$value); |
| | | } |
| | | $ini_setting = trim($ini_setting); |
| | | if(substr($ini_setting,0,1) == ';') continue; |
| | | if(substr($ini_setting,0,1) == '#') continue; |
| | | if(substr($ini_setting,0,2) == '//') continue; |
| | | list($key, $value) = explode('=', $ini_setting); |
| | | if($value){ |
| | | $value = trim($value); |
| | | $key = trim($key); |
| | | switch (strtolower($value)) { |
| | | case '0': |
| | | // PHP-FPM might complain about invalid boolean value if you use 0 |
| | | $value = 'off'; |
| | | case '1': |
| | | case 'on': |
| | | case 'off': |
| | | case 'true': |
| | | case 'false': |
| | | case 'yes': |
| | | case 'no': |
| | | $final_php_ini_settings[] = array('ini_setting' => 'php_admin_flag['.$key.'] = '.$value); |
| | | break; |
| | | default: |
| | | $final_php_ini_settings[] = array('ini_setting' => 'php_admin_value['.$key.'] = '.$value); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | return symlink($cfrom, $to); |
| | | } |
| | | |
| | | |
| | | private function _rewrite_quote($string) { |
| | | return str_replace(array('.', '*', '?', '+'), array('\\.', '\\*', '\\?', '\\+'), $string); |
| | | } |
| | | |
| | | } // end class |
| | | |