| | |
| | | } |
| | | */ |
| | | |
| | | //* Create the domain.auth file which is included in the vhost configuration file |
| | | $app->uses('getconf'); |
| | | $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); |
| | | $basic_auth_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/'.$website['domain'].'.auth'); |
| | | $app->load('tpl'); |
| | | $tpl = new tpl(); |
| | | $tpl->newTemplate('nginx_http_authentication.auth.master'); |
| | | $website_auth_locations = $app->db->queryAllRecords("SELECT * FROM web_folder WHERE active = 'y' AND parent_domain_id = ".intval($website['domain_id'])); |
| | | $basic_auth_locations = array(); |
| | | if(is_array($website_auth_locations) && !empty($website_auth_locations)){ |
| | | foreach($website_auth_locations as $website_auth_location){ |
| | | if(substr($website_auth_location['path'],0,1) == '/') $website_auth_location['path'] = substr($website_auth_location['path'],1); |
| | | if(substr($website_auth_location['path'],-1) == '/') $website_auth_location['path'] = substr($website_auth_location['path'],0,-1); |
| | | $basic_auth_locations[] = array('htpasswd_location' => $website_auth_location['path'], |
| | | 'htpasswd_path' => $website['document_root'].'/web/'.$website_auth_location['path']); |
| | | } |
| | | } |
| | | $tpl->setLoop('basic_auth_locations', $basic_auth_locations); |
| | | file_put_contents($basic_auth_file,$tpl->grab()); |
| | | $app->log('Writing the http basic authentication file: '.$basic_auth_file,LOGLEVEL_DEBUG); |
| | | unset($tpl); |
| | | $app->services->restartServiceDelayed('httpd','reload'); |
| | | $this->_create_web_folder_auth_configuration($website); |
| | | } |
| | | |
| | | //* Remove .htpasswd file, when folder protection is removed |
| | |
| | | $app->log('Removed file '.$folder_path.'.htpasswd',LOGLEVEL_DEBUG); |
| | | } |
| | | |
| | | //* Create the domain.auth file which is included in the vhost configuration file |
| | | $app->uses('getconf'); |
| | | $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); |
| | | $basic_auth_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/'.$website['domain'].'.auth'); |
| | | $app->load('tpl'); |
| | | $tpl = new tpl(); |
| | | $tpl->newTemplate('nginx_http_authentication.auth.master'); |
| | | $website_auth_locations = $app->db->queryAllRecords("SELECT * FROM web_folder WHERE active = 'y' AND parent_domain_id = ".intval($website['domain_id'])); |
| | | $basic_auth_locations = array(); |
| | | if(is_array($website_auth_locations) && !empty($website_auth_locations)){ |
| | | foreach($website_auth_locations as $website_auth_location){ |
| | | if(substr($website_auth_location['path'],0,1) == '/') $website_auth_location['path'] = substr($website_auth_location['path'],1); |
| | | if(substr($website_auth_location['path'],-1) == '/') $website_auth_location['path'] = substr($website_auth_location['path'],0,-1); |
| | | $basic_auth_locations[] = array('htpasswd_location' => $website_auth_location['path'], |
| | | 'htpasswd_path' => $website['document_root'].'/web/'.$website_auth_location['path']); |
| | | } |
| | | } |
| | | $tpl->setLoop('basic_auth_locations', $basic_auth_locations); |
| | | file_put_contents($basic_auth_file,$tpl->grab()); |
| | | $app->log('Writing the http basic authentication file: '.$basic_auth_file,LOGLEVEL_DEBUG); |
| | | unset($tpl); |
| | | $app->services->restartServiceDelayed('httpd','reload'); |
| | | $this->_create_web_folder_auth_configuration($website); |
| | | } |
| | | |
| | | //* Update folder protection, when path has been changed |
| | |
| | | |
| | | } |
| | | |
| | | $this->_create_web_folder_auth_configuration($website); |
| | | } |
| | | |
| | | function _create_web_folder_auth_configuration($website){ |
| | | global $app, $conf; |
| | | //* Create the domain.auth file which is included in the vhost configuration file |
| | | $app->uses('getconf'); |
| | | $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); |
| | |
| | | file_put_contents($basic_auth_file,$tpl->grab()); |
| | | $app->log('Writing the http basic authentication file: '.$basic_auth_file,LOGLEVEL_DEBUG); |
| | | unset($tpl); |
| | | $app->services->restartServiceDelayed('httpd','reload'); |
| | | $app->services->restartServiceDelayed('httpd','reload'); |
| | | } |
| | | |
| | | //* Update the awstats configuration file |