| | |
| | | function onInstall() { |
| | | global $conf; |
| | | |
| | | if($conf['services']['proxy'] == true && $conf['nginx']['installed'] == true) { |
| | | if(isset($conf['services']['proxy']) && $conf['services']['proxy'] == true && isset($conf['nginx']['installed']) && $conf['nginx']['installed'] == true) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | |
| | | |
| | | if($this->action != 'insert') $this->action = 'update'; |
| | | |
| | | if($data['new']['type'] != 'vhost' && $data['new']['parent_domain_id'] > 0) { |
| | | if($data['new']['type'] != 'vhost' && $data['new']['type'] != 'vhostsubdomain' && $data['new']['parent_domain_id'] > 0) { |
| | | |
| | | $old_parent_domain_id = intval($data['old']['parent_domain_id']); |
| | | $new_parent_domain_id = intval($data['new']['parent_domain_id']); |
| | |
| | | |
| | | // load the server configuration options |
| | | $app->uses('getconf'); |
| | | $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); |
| | | $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'web'); |
| | | |
| | | // Create group and user, if not exist |
| | | $app->uses('system'); |
| | |
| | | |
| | | |
| | | // get alias domains (co-domains and subdomains) |
| | | $aliases = $app->dbmaster->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'"); |
| | | $aliases = $app->dbmaster->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND type != 'vhostsubdomain' AND active = 'y'"); |
| | | $server_alias = array(); |
| | | switch($data['new']['subdomain']) { |
| | | case 'www': |
| | |
| | | } |
| | | |
| | | |
| | | $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['new']['domain'].'.vhost'); |
| | | $vhost_file = escapeshellcmd($nginx_config['nginx_vhost_conf_dir'].'/'.$data['new']['domain'].'.vhost'); |
| | | //* Make a backup copy of vhost file |
| | | copy($vhost_file,$vhost_file.'~'); |
| | | |
| | |
| | | |
| | | |
| | | // Set the symlink to enable the vhost |
| | | $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['new']['domain'].'.vhost'); |
| | | $vhost_symlink = escapeshellcmd($nginx_config['nginx_vhost_conf_enabled_dir'].'/'.$data['new']['domain'].'.vhost'); |
| | | if($data['new']['active'] == 'y' && !is_link($vhost_symlink)) { |
| | | symlink($vhost_file,$vhost_symlink); |
| | | $app->log('Creating symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); |
| | |
| | | |
| | | // remove old symlink and vhost file, if domain name of the site has changed |
| | | if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) { |
| | | $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); |
| | | $vhost_symlink = escapeshellcmd($nginx_config['nginx_vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); |
| | | unlink($vhost_symlink); |
| | | $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); |
| | | $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); |
| | | $vhost_file = escapeshellcmd($nginx_config['nginx_vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); |
| | | unlink($vhost_file); |
| | | $app->log('Removing file: '.$vhost_file,LOGLEVEL_DEBUG); |
| | | |
| | |
| | | |
| | | // load the server configuration options |
| | | $app->uses('getconf'); |
| | | $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); |
| | | $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'web'); |
| | | |
| | | |
| | | if($data['old']['type'] == 'vhost') { |
| | | if($data['old']['type'] == 'vhost' || $data['old']['type'] == 'vhostsubdomain') { |
| | | |
| | | //* This is a website |
| | | // Deleting the vhost file, symlink and the data directory |
| | | $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); |
| | | $vhost_symlink = escapeshellcmd($nginx_config['nginx_vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); |
| | | unlink($vhost_symlink); |
| | | $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); |
| | | |
| | | $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); |
| | | $vhost_file = escapeshellcmd($nginx_config['nginx_vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); |
| | | unlink($vhost_file); |
| | | $app->log('Removing vhost file: '.$vhost_file,LOGLEVEL_DEBUG); |
| | | |
| | |
| | | $rules = $this->_getRewriteRules($app); |
| | | |
| | | $app->uses('getconf'); |
| | | $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); |
| | | $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'web'); |
| | | |
| | | $app->load('tpl'); |
| | | $tpl = new tpl(); |
| | | $tpl->newTemplate("nginx_reverseproxy_rewrites.conf.master"); |
| | | if (!empty($rules))$tpl->setLoop('nginx_rewrite_rules',$rules); |
| | | |
| | | $rewrites_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/default.rewrites.conf'); |
| | | $rewrites_file = escapeshellcmd($nginx_config['nginx_vhost_conf_dir'].'/default.rewrites.conf'); |
| | | //* Make a backup copy of vhost file |
| | | copy($rewrites_file,$rewrites_file.'~'); |
| | | |
| | |
| | | |
| | | |
| | | // Set the symlink to enable the vhost |
| | | $rewrite_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/default.rewrites.conf'); |
| | | $rewrite_symlink = escapeshellcmd($nginx_config['nginx_vhost_conf_enabled_dir'].'/default.rewrites.conf'); |
| | | |
| | | if(!is_link($rewrite_symlink)) { |
| | | symlink($rewrites_file,$rewrite_symlink); |