ftimme
2011-10-10 7e586d92ad871fee9f974d026b26bf59335bd210

1 files modified
53 ■■■■ changed files
server/plugins-available/nginx_plugin.inc.php 53 ●●●● patch | view | raw | blame | history
server/plugins-available/nginx_plugin.inc.php
@@ -1147,28 +1147,7 @@
        }
        */
        
        //* 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 @@
            $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 @@
        
        }
        $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 @@
        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