diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 887036790..0766e95b6 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -549,6 +549,11 @@ title="{% trans 'CloudFlare' %}">{% trans "CloudFlare" %} {% endif %} + {% if admin or addDeleteRecords %} +
  • {% trans "Reset DNS Configurations" %} +
  • + {% endif %} @@ -634,6 +639,11 @@ title="{% trans 'List FTP Accounts' %}">{% trans "List FTP Accounts" %} {% endif %} + {% if admin or listFTPAccounts %} +
  • {% trans "Reset FTP Configurations" %} +
  • + {% endif %} @@ -1088,6 +1098,7 @@
  • {% trans "Manage FTP" %}
  • + diff --git a/databases/templates/databases/Updatemysql.html b/databases/templates/databases/Updatemysql.html index 91dcf2ff1..362525ccd 100644 --- a/databases/templates/databases/Updatemysql.html +++ b/databases/templates/databases/Updatemysql.html @@ -64,7 +64,7 @@
    -

    {% trans "CSF successfully installed, refreshing page in 3 seconds.." %}

    +

    {% trans "Upgrading Done successfully." %}

    diff --git a/databases/templates/databases/mysqlmanager.html b/databases/templates/databases/mysqlmanager.html index 10894fa12..2fb55c533 100644 --- a/databases/templates/databases/mysqlmanager.html +++ b/databases/templates/databases/mysqlmanager.html @@ -21,9 +21,9 @@ Optimize MySQL -{# #} -{# Upgrade MySQL#} -{# #} + + Upgrade MySQL +
    diff --git a/dns/static/dns/dns.js b/dns/static/dns/dns.js index 18cc88645..0767bb30d 100755 --- a/dns/static/dns/dns.js +++ b/dns/static/dns/dns.js @@ -1308,4 +1308,154 @@ app.controller('addModifyDNSRecordsCloudFlare', function ($scope, $http, $window }); -/* Java script code for CloudFlare */ \ No newline at end of file +/* 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; + + + } + + } +}); \ No newline at end of file diff --git a/dns/templates/dns/resetdnsconf.html b/dns/templates/dns/resetdnsconf.html new file mode 100644 index 000000000..74e54e6aa --- /dev/null +++ b/dns/templates/dns/resetdnsconf.html @@ -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 %} + +
    +
    +

    {% trans "Reset DNS Configurations" %}

    +

    {% trans "Reset your DNS Configurations here." %}

    +
    +
    +
    +
    +
    + +
    +
    + + +
    + +
    + +
    +

    {% trans "Failed to start installation, Error message: " %} {$ errorMessage + $}

    +
    + +
    +

    {% trans "Could not connect. Please refresh this page." %}

    +
    + +
    +

    {% trans "Installation failed." %} {$ errorMessage $}

    +
    + +
    +

    {% trans "successfully Completed Reset Process." %}

    +
    +
    +
    + + +
    + +
    +
    +
    +

    {% trans "Reseting...." %} +

    +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    + +{% endblock %} \ No newline at end of file diff --git a/dns/urls.py b/dns/urls.py index fd175330d..dcb5a3963 100755 --- a/dns/urls.py +++ b/dns/urls.py @@ -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"), diff --git a/dns/views.py b/dns/views.py index a28af54af..ebb9717a1 100755 --- a/dns/views.py +++ b/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: diff --git a/ftp/static/ftp/ftp.js b/ftp/static/ftp/ftp.js index 113845c8f..00f5b4c14 100755 --- a/ftp/static/ftp/ftp.js +++ b/ftp/static/ftp/ftp.js @@ -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; + + + } + + } +}); \ No newline at end of file diff --git a/ftp/templates/ftp/ResetFTPconf.html b/ftp/templates/ftp/ResetFTPconf.html new file mode 100644 index 000000000..103edf0f5 --- /dev/null +++ b/ftp/templates/ftp/ResetFTPconf.html @@ -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 %} + +
    +
    +

    {% trans "Reset FTP Configurations" %}

    +

    {% trans "Reset your FTP Configurations here." %}

    +
    +
    +
    +
    +
    + +
    +
    + + +
    + +
    + +
    +

    {% trans "Failed to start installation, Error message: " %} {$ errorMessage + $}

    +
    + +
    +

    {% trans "Could not connect. Please refresh this page." %}

    +
    + +
    +

    {% trans "Installation failed." %} {$ errorMessage $}

    +
    + +
    +

    {% trans "successfully Completed Reset Process." %}

    +
    +
    +
    + + +
    + +
    +
    +
    +

    {% trans "Reseting...." %} +

    +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    + +{% endblock %} \ No newline at end of file diff --git a/ftp/urls.py b/ftp/urls.py index 170bc36e2..e0392037e 100755 --- a/ftp/urls.py +++ b/ftp/urls.py @@ -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'), -] +] diff --git a/ftp/views.py b/ftp/views.py index 0eaf41284..4b85d242f 100755 --- a/ftp/views.py +++ b/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)