From e40c7d89127f8170a3709c08cd3199571d332adf Mon Sep 17 00:00:00 2001 From: usmannasir <01-134132-158@student.bahria.edu.pk> Date: Wed, 13 Mar 2019 18:22:12 +0500 Subject: [PATCH] minor changes to backup manager --- .../templates/databases/listDataBases.html | 6 ++-- ftp/templates/ftp/listFTPAccounts.html | 6 ++-- plogical/backupManager.py | 8 +++-- plogical/backupSchedule.py | 2 +- plogical/backupUtilities.py | 14 ++++---- .../baseTemplate/custom-js/system-status.js | 10 ++++++ static/databases/databases.js | 28 ++++++++++++--- static/ftp/ftp.js | 34 +++++++++++++++---- static/loginSystem/login-systen.js | 4 --- static/mailServer/mailServer.js | 33 ++++++++++++++---- static/userManagment/userManagment.js | 28 +++++++++++++-- 11 files changed, 133 insertions(+), 40 deletions(-) diff --git a/databases/templates/databases/listDataBases.html b/databases/templates/databases/listDataBases.html index 8cfb6f880..d1ba45ccf 100644 --- a/databases/templates/databases/listDataBases.html +++ b/databases/templates/databases/listDataBases.html @@ -74,12 +74,12 @@ class="btn btn-primary">{% trans "Generate" %} - -
+ +
-
+
diff --git a/ftp/templates/ftp/listFTPAccounts.html b/ftp/templates/ftp/listFTPAccounts.html index dae50eb87..d231092f0 100644 --- a/ftp/templates/ftp/listFTPAccounts.html +++ b/ftp/templates/ftp/listFTPAccounts.html @@ -92,13 +92,13 @@ class="btn btn-primary">{% trans "Generate" %}
- -
+
-
+
diff --git a/plogical/backupManager.py b/plogical/backupManager.py index 649220a8b..cff44f583 100644 --- a/plogical/backupManager.py +++ b/plogical/backupManager.py @@ -207,10 +207,12 @@ class BackupManager: try: command = 'sudo rm -f ' + status cmd = shlex.split(command) - res = subprocess.call(cmd) + subprocess.call(cmd) + + backupObs = Backups.objects.filter(fileName=fileName) + for items in backupObs: + items.delete() - backupOb = Backups.objects.get(fileName=fileName) - backupOb.delete() except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupStatus]") diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index 332a14a94..22679de33 100644 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -93,7 +93,7 @@ class backupSchedule: backupSchedule.remoteBackupLogging(backupLogPath, "") except BaseException,msg: - logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createBackup]") + logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]") @staticmethod def sendBackup(backupPath, IPAddress, backupLogPath , port): diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index 5d6f94450..f51559115 100644 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -125,6 +125,7 @@ class backupUtilities: ## DNS Records XML try: + dnsRecordsXML = Element("dnsrecords") dnsRecords = DNS.getDNSRecords(backupDomain) @@ -144,8 +145,8 @@ class backupUtilities: metaFileXML.append(dnsRecordsXML) - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile(str(msg)) + except: + pass ## Email accounts XML @@ -166,8 +167,8 @@ class backupUtilities: metaFileXML.append(emailRecordsXML) - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile(str(msg)) + except: + pass ## Email meta generated! @@ -309,8 +310,8 @@ class backupUtilities: except: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]") - status = open(os.path.join(backupPath,'status'), "w") - logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, please check CyberPanel main log file. [5009]") + status = os.path.join(backupPath,'status'), "w" + logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, "+ str(msg) + ". [5009]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]") @staticmethod @@ -624,6 +625,7 @@ class backupUtilities: subprocess.call(cmd) except BaseException, msg: + status = os.path.join(completPath, 'status') logging.CyberCPLogFileWriter.statusWriter(status, str(msg) + " [5009]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]") diff --git a/static/baseTemplate/custom-js/system-status.js b/static/baseTemplate/custom-js/system-status.js index 58b2c634e..0200129db 100644 --- a/static/baseTemplate/custom-js/system-status.js +++ b/static/baseTemplate/custom-js/system-status.js @@ -22,6 +22,16 @@ function getCookie(name) { return cookieValue; } +function randomPassword(length) { + var chars = "abcdefghijklmnopqrstuvwxyz!@#$%^*()-+<>ABCDEFGHIJKLMNOP1234567890"; + var pass = ""; + for (var x = 0; x < length; x++) { + var i = Math.floor(Math.random() * chars.length); + pass += chars.charAt(i); + } + return pass; +} + /* Utilities ends here */ diff --git a/static/databases/databases.js b/static/databases/databases.js index 15095effa..22f246d91 100644 --- a/static/databases/databases.js +++ b/static/databases/databases.js @@ -11,13 +11,13 @@ app.controller('createDatabase', function($scope,$http) { $scope.databaseCreationFailed = true; $scope.databaseCreated = true; $scope.couldNotConnect = true; + $scope.generatedPasswordView = true; $scope.showDetailsBoxes = function(){ $scope.dbDetails = false; }; - $scope.createDatabase = function(){ $scope.createDatabaseLoading = false; @@ -106,6 +106,15 @@ app.controller('createDatabase', function($scope,$http) { + }; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.dbPassword = randomPassword(12); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; }; }); @@ -365,8 +374,6 @@ app.controller('listDBs', function($scope,$http) { }; - - function populateCurrentRecords(){ $scope.recordsFetched = true; $scope.passwordChanged = true; @@ -442,7 +449,20 @@ app.controller('listDBs', function($scope,$http) { } - }; + } + + //// + + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.dbPassword = randomPassword(12); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; }); diff --git a/static/ftp/ftp.js b/static/ftp/ftp.js index 27b0e7c88..88a7c3806 100644 --- a/static/ftp/ftp.js +++ b/static/ftp/ftp.js @@ -23,8 +23,6 @@ app.controller('createFTPAccount', function($scope,$http) { }; - - $scope.createFTPAccount = function(){ $scope.ftpLoading = false; @@ -116,6 +114,19 @@ app.controller('createFTPAccount', function($scope,$http) { }; + /// + + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.ftpPassword = randomPassword(12); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; + }); /* Java script code to create account ends here */ @@ -142,8 +153,6 @@ app.controller('deleteFTPAccount', function($scope,$http) { $scope.deleteFTPButtonInit = true; - - var url = "/ftp/fetchFTPAccounts"; @@ -382,8 +391,6 @@ app.controller('listFTPAccounts', function($scope,$http) { }; - - function populateCurrentRecords(){ $scope.recordsFetched = true; $scope.passwordChanged = true; @@ -459,6 +466,19 @@ app.controller('listFTPAccounts', function($scope,$http) { } - }; + } + + //// + + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.ftpPassword = randomPassword(12); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; }); \ No newline at end of file diff --git a/static/loginSystem/login-systen.js b/static/loginSystem/login-systen.js index 30a56f0fe..6aad70b6f 100644 --- a/static/loginSystem/login-systen.js +++ b/static/loginSystem/login-systen.js @@ -39,9 +39,6 @@ application.config(['$interpolateProvider', } ]); - - - application.controller('loginSystem', function($scope,$http,$window) { @@ -98,4 +95,3 @@ application.controller('loginSystem', function($scope,$http,$window) { /* Java script code to to Check Login status ends here */ - diff --git a/static/mailServer/mailServer.js b/static/mailServer/mailServer.js index eabb4acf5..c5d8e512d 100644 --- a/static/mailServer/mailServer.js +++ b/static/mailServer/mailServer.js @@ -26,8 +26,6 @@ app.controller('createEmailAccount', function($scope,$http) { }; - - $scope.createEmailAccount = function(){ $scope.emailDetails = false; @@ -117,11 +115,21 @@ app.controller('createEmailAccount', function($scope,$http) { }; + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.emailPassword = randomPassword(12); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; + }); /* Java script code to create account ends here */ - /* Java script code to create account */ app.controller('deleteEmailAccount', function($scope,$http) { @@ -318,7 +326,6 @@ app.controller('deleteEmailAccount', function($scope,$http) { /* Java script code to create account ends here */ - /* Java script code to create account */ app.controller('changeEmailPassword', function($scope,$http) { @@ -408,7 +415,6 @@ app.controller('changeEmailPassword', function($scope,$http) { }; - $scope.changePassword = function(){ $scope.emailLoading = false; @@ -493,8 +499,6 @@ app.controller('changeEmailPassword', function($scope,$http) { }; - - $scope.deleteEmailAccount = function(){ var domain = $scope.selectedEmail; @@ -505,6 +509,21 @@ app.controller('changeEmailPassword', function($scope,$http) { }; + /// + + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.emailPassword = randomPassword(12); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; + + + }); /* Java script code to create account ends here */ diff --git a/static/userManagment/userManagment.js b/static/userManagment/userManagment.js index 9b47283a5..e2685095e 100644 --- a/static/userManagment/userManagment.js +++ b/static/userManagment/userManagment.js @@ -108,7 +108,6 @@ app.controller('createUserCtr', function($scope,$http) { }; - $scope.hideSomeThings = function(){ $scope.userCreated = true; @@ -117,6 +116,19 @@ app.controller('createUserCtr', function($scope,$http) { }; + /// + + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.password = randomPassword(12); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; + }); /* Java script code to create account ends here */ @@ -333,7 +345,6 @@ app.controller('modifyUser', function($scope,$http) { }; - $scope.showLimitsBox = function () { if ($scope.accountType == "Normal User"){ @@ -353,6 +364,19 @@ app.controller('modifyUser', function($scope,$http) { }; + /// + + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.password = randomPassword(12); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; + }); /* Java script code to modify user account ends here */