def restoreRemoteBackups(request): try: userID = request.session['userID'] currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'createBackup') == 0: return ACLManager.loadError() websitesName = ACLManager.findAllSites(currentACL, userID) destinations = [] path = '/home/cyberpanel/sftp' if os.path.exists(path): for items in os.listdir(path): destinations.append('sftp:%s' % (items)) path = '/home/cyberpanel/aws' if os.path.exists(path): for items in os.listdir(path): destinations.append('s3:s3.amazonaws.com/%s' % (items)) return defRenderer(request, 'IncBackups/restoreRemoteBackups.html', { 'websiteList': websitesName, 'destinations': destinations }) except BaseException, msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage)
def createFTPAccount(sender, **kwargs): from loginSystem.models import Administrator from plogical.acl import ACLManager try: request = kwargs['request'] userID = request.session['userID'] currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'createFTPAccount') == 0: return ACLManager.loadError() admin = Administrator.objects.get(pk=userID) if not os.path.exists('/home/cyberpanel/pureftpd'): return render(request, "ftp/createFTPAccount.html", {"status": 0}) websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'beautifulNames/createFTPAccount.html', { 'websiteList': websitesName, 'admin': admin.userName, "status": 1 }) except BaseException, msg: return HttpResponse(str(msg))
def backupSite(self, request = None, userID = None, data = None): try: currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'createBackup') == 0: return ACLManager.loadError() websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'backup/backup.html', {'websiteList': websitesName}) except BaseException, msg: return HttpResponse(str(msg))
def listDBs(self, request=None, userID=None): try: currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'listDatabases') == 0: return ACLManager.loadError() websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'databases/listDataBases.html', {'websiteList': websitesName}) except BaseException, msg: return HttpResponse(str(msg))
def deleteDatabase(self, request=None, userID=None): try: currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'deleteDatabase') == 0: return ACLManager.loadError() websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'databases/deleteDatabase.html', {'websitesList': websitesName}) except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg))
def createDatabase(sender, **kwargs): from plogical.acl import ACLManager try: request = kwargs['request'] userID = request.session['userID'] currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'createDatabase') == 0: return ACLManager.loadError() websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'beautifulNames/createDatabase.html', {'websitesList': websitesName}) except BaseException, msg: return HttpResponse(str(msg))
def listFTPAccounts(self): try: userID = self.request.session['userID'] currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'listFTPAccounts') == 0: return ACLManager.loadError() if not os.path.exists('/home/cyberpanel/pureftpd'): return render(self.request, "ftp/listFTPAccounts.html", {"status": 0}) websitesName = ACLManager.findAllSites(currentACL, userID) return render(self.request, 'ftp/listFTPAccounts.html', {'websiteList': websitesName, "status": 1}) except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg))
def emailForwarding(self): try: userID = self.request.session['userID'] currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'emailForwarding') == 0: return ACLManager.loadError() if not os.path.exists('/home/cyberpanel/postfix'): return render(self.request, "mailServer/emailForwarding.html", {"status": 0}) websitesName = ACLManager.findAllSites(currentACL, userID) websitesName = websitesName + ACLManager.findChildDomains(websitesName) return render(self.request, 'mailServer/emailForwarding.html', {'websiteList': websitesName, "status": 1}) except BaseException, msg: return redirect(loadLoginPage)
def websitePagination(self, currentACL, userID): websites = ACLManager.findAllSites(currentACL, userID) pages = float(len(websites)) / float(10) pagination = [] if pages <= 1.0: pages = 1 pagination.append('<li><a href="\#"></a></li>') else: pages = ceil(pages) finalPages = int(pages) + 1 for i in range(1, finalPages): pagination.append('<li><a href="\#">' + str(i) + '</a></li>') return pagination
def dkimManager(self): try: userID = self.request.session['userID'] currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0: return ACLManager.loadError() openDKIMInstalled = 1 websitesName = ACLManager.findAllSites(currentACL, userID) websitesName = websitesName + ACLManager.findChildDomains(websitesName) return render(self.request, 'mailServer/dkimManager.html', {'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled}) except BaseException, msg: return redirect(loadLoginPage)
def manageSSL(request): try: userID = request.session['userID'] currentACL = ACLManager.loadedACL(userID) if currentACL['admin'] == 1: pass elif currentACL['manageSSL'] == 1: pass else: return ACLManager.loadError() websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'manageSSL/manageSSL.html', {'websiteList': websitesName}) except KeyError: return redirect(loadLoginPage)
def phpTuning(self, request, userID): try: userID = request.session['userID'] currentACL = ACLManager.loadedACL(userID) if currentACL['admin'] == 1: pass else: return ACLManager.loadError() if ProcessUtilities.decideServer() == ProcessUtilities.OLS: websitesName = ACLManager.findAllSites(currentACL, userID) OLS = 1 return render(request, 'tuning/phpTuning.html', { 'websiteList': websitesName, 'OLS': OLS }) else: OLS = 0 return render(request, 'tuning/phpTuning.html', {'OLS': OLS}) except KeyError: return redirect(loadLoginPage)