add rest ftp and dns code
This commit is contained in:
parent
4aba2b9d30
commit
65a49c023e
|
|
@ -549,6 +549,11 @@
|
|||
title="{% trans 'CloudFlare' %}"><span>{% trans "CloudFlare" %}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if admin or addDeleteRecords %}
|
||||
<li><a href="{% url 'ResetDNSConfigurations' %}"
|
||||
title="{% trans 'Reset DNS Configurations' %}"><span>{% trans "Reset DNS Configurations" %}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
|
|
@ -634,6 +639,11 @@
|
|||
title="{% trans 'List FTP Accounts' %}"><span>{% trans "List FTP Accounts" %}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if admin or listFTPAccounts %}
|
||||
<li><a href="{% url 'ResetFTPConfigurations' %}"
|
||||
title="{% trans 'Reset FTP Configurations' %}"><span>{% trans "Reset FTP Configurations" %}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
|
|
@ -1088,6 +1098,7 @@
|
|||
<li><a href="{% url 'managePureFtpd' %}"
|
||||
title="{% trans 'Manage FTP' %}"><span>{% trans "Manage FTP" %}</span></a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
</div>
|
||||
|
||||
<div ng-hide="modSecSuccessfullyInstalled" class="alert alert-success">
|
||||
<p>{% trans "CSF successfully installed, refreshing page in 3 seconds.." %}</p>
|
||||
<p>{% trans "Upgrading Done successfully." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@
|
|||
<a style="display: inline-block;" href="{% url 'OptimizeMySQL' %}" class="btn btn-primary">
|
||||
<i class="glyph-icon icon-database"></i> Optimize MySQL
|
||||
</a>
|
||||
{# <a style="display: inline-block;" href="{% url 'UpgradeMySQL' %}" class="btn btn-primary">#}
|
||||
{# <i class="glyph-icon icon-database"></i> Upgrade MySQL#}
|
||||
{# </a>#}
|
||||
<a style="display: inline-block;" href="{% url 'UpgradeMySQL' %}" class="btn btn-primary">
|
||||
<i class="glyph-icon icon-database"></i> Upgrade MySQL
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="content-box-header">
|
||||
|
|
|
|||
|
|
@ -1308,4 +1308,154 @@ app.controller('addModifyDNSRecordsCloudFlare', function ($scope, $http, $window
|
|||
|
||||
});
|
||||
|
||||
/* Java script code for CloudFlare */
|
||||
/* Java script code for CloudFlare */
|
||||
|
||||
|
||||
app.controller('ResetDNSconf', function ($scope, $http, $timeout){
|
||||
$scope.Loading = true;
|
||||
$scope.NotifyBox = true;
|
||||
$scope.InstallBox = true;
|
||||
|
||||
|
||||
$scope.resetDNS = function () {
|
||||
$scope.Loading = false;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.InstallBox = false;
|
||||
|
||||
|
||||
|
||||
url = "/dns/resetDNSnow";
|
||||
|
||||
var data = {
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
$scope.NotifyBox = true;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.statusfile = response.data.tempStatusPath
|
||||
|
||||
$timeout(getRequestStatus, 1000);
|
||||
|
||||
} else {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.NotifyBox = false;
|
||||
$scope.InstallBox = true;
|
||||
$scope.Loading = true;
|
||||
$scope.failedToStartInallation = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberhosting = true;
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getRequestStatus() {
|
||||
|
||||
$scope.NotifyBox = true;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
url = "/dns/getresetstatus";
|
||||
|
||||
var data = {
|
||||
statusfile: $scope.statusfile
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.abort === 0) {
|
||||
|
||||
$scope.NotifyBox = true;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$timeout.cancel();
|
||||
$scope.NotifyBox = false;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
|
||||
if (response.data.installed === 0) {
|
||||
$scope.installationFailed = false;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
} else {
|
||||
$scope.modSecSuccessfullyInstalled = false;
|
||||
$timeout(function () {
|
||||
$window.location.reload();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.NotifyBox = false;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Reset DNS Configurations - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Reset DNS Configurations" %}</h2>
|
||||
<p>{% trans "Reset your DNS Configurations here." %}</p>
|
||||
</div>
|
||||
<div ng-controller="ResetDNSconf">
|
||||
<div class="panel-body">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div class="col-sm-4">
|
||||
<button
|
||||
type="button" ng-click="resetDNS()"
|
||||
class="btn btn-primary btn-lg">{% trans "Reset Configuration" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="NotifyBox" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<div ng-hide="failedToStartInallation" class="alert alert-danger">
|
||||
<p>{% trans "Failed to start installation, Error message: " %} {$ errorMessage
|
||||
$}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect. Please refresh this page." %} </p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Installation failed." %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="modSecSuccessfullyInstalled" class="alert alert-success">
|
||||
<p>{% trans "successfully Completed Reset Process." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="InstallBox" class="col-md-12">
|
||||
|
||||
<form action="/dns/static" id="" class="form-horizontal bordered-row">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 text-center">
|
||||
<h3> {% trans "Reseting...." %}
|
||||
<img ng-hide="Loading" src="/images/loading.gif"></h3>
|
||||
</div>
|
||||
<div style="margin-top: 2%;" class="col-sm-12">
|
||||
<textarea ng-model="requestData" rows="15"
|
||||
class="form-control">{$ requestData $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -8,6 +8,9 @@ urlpatterns = [
|
|||
url(r'^createDNSZone', views.createDNSZone, name='createDNSZone'),
|
||||
url(r'^addDeleteDNSRecords$', views.addDeleteDNSRecords, name='addDeleteDNSRecords'),
|
||||
url(r'^addDeleteDNSRecordsCloudFlare$', views.addDeleteDNSRecordsCloudFlare, name='addDeleteDNSRecordsCloudFlare'),
|
||||
url(r'^ResetDNSConfigurations$', views.ResetDNSConfigurations, name='ResetDNSConfigurations'),
|
||||
url(r'^resetDNSnow$', views.resetDNSnow, name='resetDNSnow'),
|
||||
url(r'^getresetstatus', views.getresetstatus, name='getresetstatus'),
|
||||
|
||||
# JS Functions
|
||||
url(r'^NSCreation',views.NSCreation,name="NSCreation"),
|
||||
|
|
|
|||
119
dns/views.py
119
dns/views.py
|
|
@ -1,11 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
from random import randint
|
||||
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import redirect, HttpResponse
|
||||
from loginSystem.views import loadLoginPage
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.httpProc import httpProc
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from .dnsManager import DNSManager
|
||||
from .pluginManager import pluginManager
|
||||
import json
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def loadDNSHome(request):
|
||||
|
|
@ -16,6 +22,7 @@ def loadDNSHome(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def createNameserver(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -24,6 +31,7 @@ def createNameserver(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def NSCreation(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -43,6 +51,7 @@ def NSCreation(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def createDNSZone(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -51,6 +60,7 @@ def createDNSZone(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def zoneCreation(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -60,7 +70,7 @@ def zoneCreation(request):
|
|||
return result
|
||||
|
||||
dm = DNSManager()
|
||||
coreResult = dm.zoneCreation(userID, json.loads(request.body))
|
||||
coreResult = dm.zoneCreation(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postZoneCreation(request, coreResult)
|
||||
if result != 200:
|
||||
|
|
@ -70,6 +80,7 @@ def zoneCreation(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def addDeleteDNSRecords(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -78,6 +89,7 @@ def addDeleteDNSRecords(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def updateRecord(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -86,6 +98,7 @@ def updateRecord(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getCurrentRecordsForDomain(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -94,6 +107,7 @@ def getCurrentRecordsForDomain(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def addDNSRecord(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -103,7 +117,7 @@ def addDNSRecord(request):
|
|||
return result
|
||||
|
||||
dm = DNSManager()
|
||||
coreResult = dm.addDNSRecord(userID, json.loads(request.body))
|
||||
coreResult = dm.addDNSRecord(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postAddDNSRecord(request, coreResult)
|
||||
if result != 200:
|
||||
|
|
@ -114,6 +128,7 @@ def addDNSRecord(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def deleteDNSRecord(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -123,7 +138,7 @@ def deleteDNSRecord(request):
|
|||
return result
|
||||
|
||||
dm = DNSManager()
|
||||
coreResult = dm.deleteDNSRecord(userID, json.loads(request.body))
|
||||
coreResult = dm.deleteDNSRecord(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postDeleteDNSRecord(request, coreResult)
|
||||
if result != 200:
|
||||
|
|
@ -133,6 +148,7 @@ def deleteDNSRecord(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def deleteDNSZone(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -141,6 +157,7 @@ def deleteDNSZone(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def submitZoneDeletion(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -177,6 +194,7 @@ def saveNSConfigurations(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def addDeleteDNSRecordsCloudFlare(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -185,6 +203,86 @@ def addDeleteDNSRecordsCloudFlare(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def ResetDNSConfigurations(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
proc = httpProc(request, 'dns/resetdnsconf.html')
|
||||
return proc.render()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def resetDNSnow(request):
|
||||
try:
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
userID = request.session['userID']
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('FilemanagerAdmin', 0)
|
||||
|
||||
data = json.loads(request.body)
|
||||
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
execPath = f"/usr/local/CyberCP/bin/python /usr/local/CyberCP/dns/dnsManager.py ResetDNSConfigurations --tempStatusPath {tempStatusPath}"
|
||||
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': "None",
|
||||
'tempStatusPath': tempStatusPath}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getresetstatus(request):
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
statusfile = data['statusfile']
|
||||
installStatus = ProcessUtilities.outputExecutioner("sudo cat " + statusfile)
|
||||
|
||||
if installStatus.find("[200]") > -1:
|
||||
|
||||
command = 'sudo rm -f ' + statusfile
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
final_json = json.dumps({
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
'abort': 1,
|
||||
'installed': 1,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
elif installStatus.find("[404]") > -1:
|
||||
command = 'sudo rm -f ' + statusfile
|
||||
ProcessUtilities.executioner(command)
|
||||
final_json = json.dumps({
|
||||
'abort': 1,
|
||||
'installed': 0,
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
final_json = json.dumps({
|
||||
'abort': 0,
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def saveCFConfigs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -197,7 +295,6 @@ def saveCFConfigs(request):
|
|||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
def getCurrentRecordsForDomainCloudFlare(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -206,47 +303,51 @@ def getCurrentRecordsForDomainCloudFlare(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def deleteDNSRecordCloudFlare(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
dm = DNSManager()
|
||||
coreResult = dm.deleteDNSRecordCloudFlare(userID, json.loads(request.body))
|
||||
coreResult = dm.deleteDNSRecordCloudFlare(userID, json.loads(request.body))
|
||||
|
||||
return coreResult
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def addDNSRecordCloudFlare(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
dm = DNSManager()
|
||||
coreResult = dm.addDNSRecordCloudFlare(userID, json.loads(request.body))
|
||||
coreResult = dm.addDNSRecordCloudFlare(userID, json.loads(request.body))
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def syncCF(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
dm = DNSManager()
|
||||
coreResult = dm.syncCF(userID, json.loads(request.body))
|
||||
coreResult = dm.syncCF(userID, json.loads(request.body))
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def enableProxy(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
dm = DNSManager()
|
||||
coreResult = dm.enableProxy(userID, json.loads(request.body))
|
||||
coreResult = dm.enableProxy(userID, json.loads(request.body))
|
||||
|
||||
return coreResult
|
||||
except KeyError:
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ app.controller('deleteFTPAccount', function ($scope, $http) {
|
|||
/* Java script code to delete ftp account ends here */
|
||||
|
||||
|
||||
app.controller('listFTPAccounts', function ($scope, $http) {
|
||||
app.controller('listFTPAccounts', function ($scope, $http, ) {
|
||||
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
|
|
@ -455,3 +455,154 @@ app.controller('listFTPAccounts', function ($scope, $http) {
|
|||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.controller('Resetftpconf', function ($scope, $http, $timeout){
|
||||
$scope.Loading = true;
|
||||
$scope.NotifyBox = true;
|
||||
$scope.InstallBox = true;
|
||||
|
||||
|
||||
$scope.resetftp = function () {
|
||||
$scope.Loading = false;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.InstallBox = false;
|
||||
|
||||
|
||||
|
||||
url = "/ftp/resetftpnow";
|
||||
|
||||
var data = {
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
$scope.NotifyBox = true;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.statusfile = response.data.tempStatusPath
|
||||
|
||||
$timeout(getRequestStatus, 1000);
|
||||
|
||||
} else {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.NotifyBox = false;
|
||||
$scope.InstallBox = true;
|
||||
$scope.Loading = true;
|
||||
$scope.failedToStartInallation = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberhosting = true;
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getRequestStatus() {
|
||||
|
||||
$scope.NotifyBox = true;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
url = "/ftp/getresetstatus";
|
||||
|
||||
var data = {
|
||||
statusfile: $scope.statusfile
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.abort === 0) {
|
||||
|
||||
$scope.NotifyBox = true;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$timeout.cancel();
|
||||
$scope.NotifyBox = false;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
|
||||
if (response.data.installed === 0) {
|
||||
$scope.installationFailed = false;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
} else {
|
||||
$scope.modSecSuccessfullyInstalled = false;
|
||||
$timeout(function () {
|
||||
$window.location.reload();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.NotifyBox = false;
|
||||
$scope.InstallBox = false;
|
||||
$scope.Loading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Reset FTP Configurations - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Reset FTP Configurations" %}</h2>
|
||||
<p>{% trans "Reset your FTP Configurations here." %}</p>
|
||||
</div>
|
||||
<div ng-controller="Resetftpconf">
|
||||
<div class="panel-body">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div class="col-sm-4">
|
||||
<button
|
||||
type="button" ng-click="resetftp()"
|
||||
class="btn btn-primary btn-lg">{% trans "Reset Configuration" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="NotifyBox" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<div ng-hide="failedToStartInallation" class="alert alert-danger">
|
||||
<p>{% trans "Failed to start installation, Error message: " %} {$ errorMessage
|
||||
$}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect. Please refresh this page." %} </p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Installation failed." %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="modSecSuccessfullyInstalled" class="alert alert-success">
|
||||
<p>{% trans "successfully Completed Reset Process." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="InstallBox" class="col-md-12">
|
||||
|
||||
<form action="/" id="" class="form-horizontal bordered-row">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 text-center">
|
||||
<h3> {% trans "Reseting...." %}
|
||||
<img ng-hide="Loading" src="/static/images/loading.gif"></h3>
|
||||
</div>
|
||||
<div style="margin-top: 2%;" class="col-sm-12">
|
||||
<textarea ng-model="requestData" rows="15"
|
||||
class="form-control">{$ requestData $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -5,6 +5,9 @@ urlpatterns = [
|
|||
url(r'^$', views.loadFTPHome, name='loadFTPHome'),
|
||||
url(r'^createFTPAccount', views.createFTPAccount, name='createFTPAccount'),
|
||||
url(r'^submitFTPCreation', views.submitFTPCreation, name='ftpHome'),
|
||||
url(r'^ResetFTPConfigurations', views.ResetFTPConfigurations, name='ResetFTPConfigurations'),
|
||||
url(r'^resetftpnow', views.resetftpnow, name='resetftpnow'),
|
||||
url(r'^getresetstatus', views.getresetstatus, name='getresetstatus'),
|
||||
|
||||
url(r'^deleteFTPAccount', views.deleteFTPAccount, name='deleteFTPAccount'),
|
||||
|
||||
|
|
@ -16,5 +19,5 @@ urlpatterns = [
|
|||
url(r'^getAllFTPAccounts', views.getAllFTPAccounts, name='getAllFTPAccounts'),
|
||||
|
||||
url(r'^changePassword', views.changePassword, name='changePassword'),
|
||||
]
|
||||
|
||||
]
|
||||
|
|
|
|||
90
ftp/views.py
90
ftp/views.py
|
|
@ -1,6 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import json
|
||||
import time
|
||||
from random import randint
|
||||
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import redirect, HttpResponse
|
||||
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.httpProc import httpProc
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from .ftpManager import FTPManager
|
||||
from loginSystem.views import loadLoginPage
|
||||
from .pluginManager import pluginManager
|
||||
|
|
@ -91,6 +98,87 @@ def listFTPAccounts(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def ResetFTPConfigurations(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
|
||||
proc = httpProc(request, 'ftp/ResetFTPconf.html')
|
||||
return proc.render()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def resetftpnow(request):
|
||||
try:
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
userID = request.session['userID']
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('FilemanagerAdmin', 0)
|
||||
|
||||
data = json.loads(request.body)
|
||||
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
execPath = f"/usr/local/CyberCP/bin/python /usr/local/CyberCP/ftp/ftpManager.py ResetFTPConfigurations --tempStatusPath {tempStatusPath}"
|
||||
|
||||
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': "None",
|
||||
'tempStatusPath': tempStatusPath}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getresetstatus(request):
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
statusfile = data['statusfile']
|
||||
installStatus = ProcessUtilities.outputExecutioner("sudo cat " + statusfile)
|
||||
|
||||
if installStatus.find("[200]") > -1:
|
||||
|
||||
command = 'sudo rm -f ' + statusfile
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
final_json = json.dumps({
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
'abort': 1,
|
||||
'installed': 1,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
elif installStatus.find("[404]") > -1:
|
||||
command = 'sudo rm -f ' + statusfile
|
||||
ProcessUtilities.executioner(command)
|
||||
final_json = json.dumps({
|
||||
'abort': 1,
|
||||
'installed': 0,
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
final_json = json.dumps({
|
||||
'abort': 0,
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def getAllFTPAccounts(request):
|
||||
try:
|
||||
fm = FTPManager(request)
|
||||
|
|
|
|||
Loading…
Reference in New Issue