| | |
| | | $tpl->setVar('stats_auth_passwd_file', $data['new']['document_root']."/.htpasswd_stats"); |
| | | |
| | | // Create basic http auth for other directories |
| | | $tpl->setLoop('basic_auth_locations', $this->_create_web_folder_auth_configuration($data['new'])); |
| | | $basic_auth_locations = $this->_create_web_folder_auth_configuration($data['new']); |
| | | if(is_array($basic_auth_locations) && !empty($basic_auth_locations)) $tpl->setLoop('basic_auth_locations', $basic_auth_locations); |
| | | |
| | | $vhost_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/'.$data['new']['domain'].'.vhost'); |
| | | //* Make a backup copy of vhost file |
| | |
| | | if(substr($folder['path'],0,1) == '/') $folder['path'] = substr($folder['path'],1); |
| | | if(substr($folder['path'],-1) == '/') $folder['path'] = substr($folder['path'],0,-1); |
| | | $folder_path = escapeshellcmd($website['document_root'].'/web/'.$folder['path']); |
| | | if(substr($folder_path,-1 != '/')) $folder_path .= '/'; |
| | | if(substr($folder_path,-1) != '/' && $folder['path'] != '') $folder_path .= '/'; |
| | | |
| | | //* Check if the resulting path is inside the docroot |
| | | if(stristr($folder_path,'..') || stristr($folder_path,'./') || stristr($folder_path,'\\')) { |
| | |
| | | $app->log('Created file'.$folder_path.'.htpasswd',LOGLEVEL_DEBUG); |
| | | } |
| | | |
| | | /* |
| | | $auth_users = $app->db->queryAllRecords("SELECT * FROM web_folder_user WHERE active = 'y' AND web_folder_id = ".intval($folder_id)); |
| | | $htpasswd_content = ''; |
| | | if(is_array($auth_users) && !empty($auth_users)){ |
| | |
| | | $htpasswd_content = trim($htpasswd_content); |
| | | @file_put_contents($folder_path.'.htpasswd', $htpasswd_content); |
| | | $app->log('Changed .htpasswd file: '.$folder_path.'.htpasswd',LOGLEVEL_DEBUG); |
| | | */ |
| | | |
| | | /* |
| | | if($data['new']['username'] != $data['old']['username'] || $data['new']['active'] == 'n') { |
| | | if(($data['new']['username'] != $data['old']['username'] || $data['new']['active'] == 'n') && $data['old']['username'] != '') { |
| | | $app->system->removeLine($folder_path.'.htpasswd',$data['old']['username'].':'); |
| | | $app->log('Removed user: '.$data['old']['username'],LOGLEVEL_DEBUG); |
| | | } |
| | |
| | | $app->log('Added or updated user: '.$data['new']['username'],LOGLEVEL_DEBUG); |
| | | } |
| | | } |
| | | */ |
| | | |
| | | // write basic auth configuration to vhost file because nginx does not support .htaccess |
| | | $webdata['new'] = $webdata['old'] = $website; |
| | |
| | | if(substr($folder['path'],0,1) == '/') $folder['path'] = substr($folder['path'],1); |
| | | if(substr($folder['path'],-1) == '/') $folder['path'] = substr($folder['path'],0,-1); |
| | | $folder_path = realpath($website['document_root'].'/web/'.$folder['path']); |
| | | if(substr($folder_path,-1 != '/')) $folder_path .= '/'; |
| | | if(substr($folder_path,-1) != '/' && $folder['path'] != '') $folder_path .= '/'; |
| | | |
| | | //* Check if the resulting path is inside the docroot |
| | | if(substr($folder_path,0,strlen($website['document_root'])) != $website['document_root']) { |
| | |
| | | //* Get the folder path. |
| | | if(substr($data['old']['path'],0,1) == '/') $data['old']['path'] = substr($data['old']['path'],1); |
| | | if(substr($data['old']['path'],-1) == '/') $data['old']['path'] = substr($data['old']['path'],0,-1); |
| | | $old_folder_path = escapeshellcmd($website['document_root'].'/web/'.$data['old']['path']); |
| | | if(substr($old_folder_path,-1 != '/')) $old_folder_path .= '/'; |
| | | $old_folder_path = realpath($website['document_root'].'/web/'.$data['old']['path']); |
| | | if(substr($old_folder_path,-1) != '/' && $data['old']['path'] != '') $old_folder_path .= '/'; |
| | | |
| | | if(substr($data['new']['path'],0,1) == '/') $data['new']['path'] = substr($data['new']['path'],1); |
| | | if(substr($data['new']['path'],-1) == '/') $data['new']['path'] = substr($data['new']['path'],0,-1); |
| | | $new_folder_path = escapeshellcmd($website['document_root'].'/web/'.$data['new']['path']); |
| | | if(substr($new_folder_path,-1 != '/')) $new_folder_path .= '/'; |
| | | if(substr($new_folder_path,-1) != '/' && $data['new']['path'] != '') $new_folder_path .= '/'; |
| | | |
| | | //* Check if the resulting path is inside the docroot |
| | | if(stristr($new_folder_path,'..') || stristr($new_folder_path,'./') || stristr($new_folder_path,'\\')) { |
| | |
| | | //* move .htpasswd file |
| | | if(is_file($old_folder_path.'.htpasswd')) { |
| | | rename($old_folder_path.'.htpasswd',$new_folder_path.'.htpasswd'); |
| | | $app->log('Moved file '.$new_folder_path.'.htpasswd',LOGLEVEL_DEBUG); |
| | | $app->log('Moved file '.$old_folder_path.'.htpasswd to '.$new_folder_path.'.htpasswd',LOGLEVEL_DEBUG); |
| | | } |
| | | |
| | | } |