Commit 7e586d92 authored by Falko Timme's avatar Falko Timme

No commit message

No commit message
parent 900a38d8
......@@ -1147,28 +1147,7 @@ class nginx_plugin {
}
*/
//* 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
......@@ -1203,28 +1182,7 @@ class nginx_plugin {
$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
......@@ -1283,6 +1241,11 @@ class nginx_plugin {
}
$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');
......@@ -1304,7 +1267,7 @@ class nginx_plugin {
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment