FTP Quota System
@@ -112,22 +130,35 @@ function enableFTPQuota() {
'csrfmiddlewaretoken': '{{ csrf_token }}'
}, function(data) {
if (data.status === 1) {
- showNotification('success', data.message);
+ showNotification('success', (data && (data.message || data.error_message)) || 'Success');
refreshQuotas();
} else {
- showNotification('error', data.message);
+ showNotification('error', (data && (data.error_message || data.message)) || 'Unknown error');
}
});
}
function refreshQuotas() {
- $.post('{% url "getFTPQuotas" %}', {
- 'csrfmiddlewaretoken': '{{ csrf_token }}'
- }, function(data) {
- if (data.status === 1) {
- displayQuotas(data.quotas);
- } else {
- showNotification('error', data.message);
+ var tbody = document.getElementById('quotasTableBody');
+ if (tbody) tbody.innerHTML = '| Loading... |
';
+ $.ajax({
+ url: '{% url "getFTPQuotas" %}',
+ type: 'POST',
+ data: { 'csrfmiddlewaretoken': '{{ csrf_token }}' },
+ dataType: 'json',
+ success: function(data) {
+ if (data && data.status === 1) {
+ displayQuotas(data.quotas || []);
+ } else {
+ var msg = (data && (data.error_message || data.message)) || 'Unknown error';
+ showNotification('error', msg);
+ if (tbody) tbody.innerHTML = '| ' + msg + ' |
';
+ }
+ },
+ error: function(xhr) {
+ var msg = (xhr.responseJSON && (xhr.responseJSON.error_message || xhr.responseJSON.message)) || (xhr.statusText || 'Request failed');
+ showNotification('error', msg);
+ if (tbody) tbody.innerHTML = '| ' + msg + ' |
';
}
});
}
@@ -190,11 +221,11 @@ function saveQuota() {
$.post('{% url "updateFTPQuota" %}', formData, function(data) {
if (data.status === 1) {
- showNotification('success', data.message);
+ showNotification('success', (data && (data.message || data.error_message)) || 'Success');
$('#editQuotaModal').modal('hide');
refreshQuotas();
} else {
- showNotification('error', data.message);
+ showNotification('error', (data && (data.error_message || data.message)) || 'Unknown error');
}
});
}
diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py
index b6dce054f..74e2cb674 100644
--- a/websiteFunctions/urls.py
+++ b/websiteFunctions/urls.py
@@ -201,31 +201,33 @@ urlpatterns = [
path('resetVHostConfigToDefault', views.resetVHostConfigToDefault, name='resetVHostConfigToDefault'),
path('getTerminalJWT', views.get_terminal_jwt, name='get_terminal_jwt'),
- # Catch all for domains
- path('/', views.launchChild, name='launchChild'),
- path('', views.domain, name='domain'),
-
path('get_website_resources/', views.get_website_resources, name='get_website_resources'),
# Subdomain Log Fix
path('fixSubdomainLogs', views.fixSubdomainLogs, name='fixSubdomainLogs'),
path('fixSubdomainLogsAction', views.fixSubdomainLogsAction, name='fixSubdomainLogsAction'),
- # FTP Quota Management
+ # FTP Quota Management (API endpoints only; page is at /ftp/quotaManagement)
path('enableFTPQuota', views.enableFTPQuota, name='enableFTPQuota'),
path('getFTPQuotas', views.getFTPQuotas, name='getFTPQuotas'),
path('updateFTPQuota', views.updateFTPQuota, name='updateFTPQuota'),
# Bandwidth Management
+ path('bandwidthManagement', views.bandwidthManagementPage, name='bandwidthManagementPage'),
path('resetBandwidth', views.resetBandwidth, name='resetBandwidth'),
path('getBandwidthResetLogs', views.getBandwidthResetLogs, name='getBandwidthResetLogs'),
path('scheduleBandwidthReset', views.scheduleBandwidthReset, name='scheduleBandwidthReset'),
+ # Security Management
+ path('securityManagement', views.securityManagementPage, name='securityManagementPage'),
+
# IP Blocking
path('blockIPAddress', views.blockIPAddress, name='blockIPAddress'),
path('unblockIPAddress', views.unblockIPAddress, name='unblockIPAddress'),
path('getBlockedIPs', views.getBlockedIPs, name='getBlockedIPs'),
path('checkIPStatus', views.checkIPStatus, name='checkIPStatus'),
-
+ # Catch all for domains (must be last)
+ path('/', views.launchChild, name='launchChild'),
+ path('', views.domain, name='domain'),
]
diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py
index 0b123b770..5c65f6d85 100644
--- a/websiteFunctions/views.py
+++ b/websiteFunctions/views.py
@@ -2236,6 +2236,33 @@ def fixSubdomainLogsAction(request):
return redirect(loadLoginPage)
# FTP Quota Management Views
+def ftpQuotaManagementPage(request):
+ """Render the FTP Quota Management page."""
+ try:
+ userID = request.session['userID']
+ proc = httpProc(request, 'websiteFunctions/ftpQuotaManagement.html', {}, 'admin')
+ return proc.render()
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def bandwidthManagementPage(request):
+ """Render the Bandwidth Management page."""
+ try:
+ userID = request.session['userID']
+ proc = httpProc(request, 'websiteFunctions/bandwidthManagement.html', {}, 'admin')
+ return proc.render()
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def securityManagementPage(request):
+ """Render the Security Management page."""
+ try:
+ userID = request.session['userID']
+ proc = httpProc(request, 'websiteFunctions/securityManagement.html', {}, 'admin')
+ return proc.render()
+ except KeyError:
+ return redirect(loadLoginPage)
+
def enableFTPQuota(request):
try:
userID = request.session['userID']
diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py
index 576c272c6..d2bcfee56 100644
--- a/websiteFunctions/website.py
+++ b/websiteFunctions/website.py
@@ -8744,7 +8744,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
# Backup existing configurations
@@ -8811,7 +8811,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
quotas = FTPQuota.objects.all().order_by('-created_at')
@@ -8856,7 +8856,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
quota_id = data.get('quota_id')
@@ -8899,7 +8899,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
reset_type = data.get('reset_type', 'manual')
@@ -8970,7 +8970,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
logs = BandwidthResetLog.objects.all().order_by('-reset_at')[:50] # Last 50 entries
@@ -9013,7 +9013,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
schedule_type = data.get('schedule_type', 'monthly') # monthly, weekly, daily
@@ -9068,7 +9068,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
ip_address = data.get('ip_address')
@@ -9119,7 +9119,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
ip_address = data.get('ip_address')
@@ -9169,7 +9169,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
# Import firewall utilities
@@ -9203,7 +9203,7 @@ StrictHostKeyChecking no
admin = Administrator.objects.get(pk=userID)
# Check if user has permission
- if not ACLManager.checkIfUserIsAdmin(currentACL):
+ if not (currentACL.get('admin', 0) == 1):
return ACLManager.loadErrorJson('status', 0)
ip_address = data.get('ip_address')