コード例 #1
0
def submitDatabaseDeletion(request):
    try:
        val = request.session['userID']
        try:
            if request.method == 'POST':


                data = json.loads(request.body)
                dbName = data['dbName']


                databaseToBeDeleted = Databases.objects.get(dbName=dbName)
                result = mysqlUtilities.deleteDatabase(dbName,databaseToBeDeleted.dbUser)

                if  result == 1:
                    data_ret = {'deleteStatus': 1, 'error_message': "None"}
                    databaseToBeDeleted.delete()
                    json_data = json.dumps(data_ret)
                    return HttpResponse(json_data)
                else:
                    data_ret = {'deleteStatus': 0, 'error_message': result}
                    json_data = json.dumps(data_ret)
                    return HttpResponse(json_data)


        except BaseException,msg:
            data_ret = {'deleteStatus': 0, 'error_message': str(msg)}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)
    except KeyError,msg:
        data_ret = {'deleteStatus': 0, 'error_message': str(msg)}
        json_data = json.dumps(data_ret)
        return HttpResponse(json_data)
コード例 #2
0
def deleteWebsite(request):
    try:
        if request.method == 'POST':
            data = json.loads(request.body)
            websiteName = data['domainName']
            adminUser = data['adminUser']
            adminPass = data['adminPass']

            admin = Administrator.objects.get(userName=adminUser)

            if hashPassword.check_password(admin.password, adminPass):
                pass
            else:
                data_ret = {
                    "websiteDeleteStatus": 0,
                    'error_message': "Could not authorize access to API"
                }
                json_data = json.dumps(data_ret)
                return HttpResponse(json_data)

            numberOfWebsites = Websites.objects.count()

            virtualHostUtilities.deleteVirtualHostConfigurations(
                websiteName, numberOfWebsites)

            delWebsite = Websites.objects.get(domain=websiteName)
            databases = Databases.objects.filter(website=delWebsite)

            for items in databases:
                mysqlUtilities.deleteDatabase(items.dbName, items.dbUser)

            delWebsite.delete()

            installUtilities.reStartLiteSpeed()

            data_ret = {'websiteDeleteStatus': 1, 'error_message': "None"}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)

    except BaseException, msg:
        data_ret = {'websiteDeleteStatus': 0, 'error_message': str(msg)}
        json_data = json.dumps(data_ret)
        return HttpResponse(json_data)
コード例 #3
0
ファイル: views.py プロジェクト: iamrahulsethi/cyberpanel
def deleteWebsite(request):
    try:
        if request.method == 'POST':
            data = json.loads(request.body)
            websiteName = data['domainName']
            adminUser = data['adminUser']
            adminPass = data['adminPass']

            admin = Administrator.objects.get(userName=adminUser)

            if hashPassword.check_password(admin.password, adminPass):
                pass
            else:
                data_ret = {"websiteDeleteStatus": 0,
                            'error_message': "Could not authorize access to API"}
                json_data = json.dumps(data_ret)
                return HttpResponse(json_data)

            numberOfWebsites = Websites.objects.count()

            virtualHostUtilities.deleteVirtualHostConfigurations(websiteName, numberOfWebsites)

            delWebsite = Websites.objects.get(domain=websiteName)
            databases = Databases.objects.filter(website=delWebsite)

            for items in databases:
                mysqlUtilities.deleteDatabase(items.dbName, items.dbUser)

            delWebsite.delete()

            installUtilities.reStartLiteSpeed()

            data_ret = {'websiteDeleteStatus': 1, 'error_message': "None"}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)

    except BaseException, msg:
        data_ret = {'websiteDeleteStatus': 0, 'error_message': str(msg)}
        json_data = json.dumps(data_ret)
        return HttpResponse(json_data)
コード例 #4
0
ファイル: views.py プロジェクト: minhnkt/cyberpanel-1
def deleteWebsite(request):
    try:
        if request.method == 'POST':
            data = json.loads(request.body)
            websiteName = data['domainName']
            adminUser = data['adminUser']
            adminPass = data['adminPass']

            admin = Administrator.objects.get(userName=adminUser)

            if hashPassword.check_password(admin.password, adminPass):
                pass
            else:
                data_ret = {
                    "websiteDeleteStatus": 0,
                    'error_message': "Could not authorize access to API"
                }
                json_data = json.dumps(data_ret)
                return HttpResponse(json_data)

            numberOfWebsites = str(Websites.objects.count() +
                                   ChildDomains.objects.count())

            ## Deleting master domain

            execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"

            execPath = execPath + " deleteVirtualHostConfigurations --virtualHostName " + websiteName + " --numberOfSites " + numberOfWebsites

            subprocess.check_output(shlex.split(execPath))

            delWebsite = Websites.objects.get(domain=websiteName)
            databases = Databases.objects.filter(website=delWebsite)

            childDomains = delWebsite.childdomains_set.all()

            ## Deleting child domains

            for items in childDomains:
                numberOfWebsites = str(Websites.objects.count() +
                                       ChildDomains.objects.count())
                execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
                execPath = execPath + " deleteVirtualHostConfigurations --virtualHostName " + items.domain + " --numberOfSites " + numberOfWebsites

                subprocess.check_output(shlex.split(execPath))

            for items in databases:
                mysqlUtilities.deleteDatabase(items.dbName, items.dbUser)

            delWebsite.delete()

            try:
                delZone = Domains.objects.get(name=websiteName)
                delZone.delete()
            except:
                pass

            installUtilities.reStartLiteSpeed()

            data_ret = {'websiteDeleteStatus': 1, 'error_message': "None"}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)

    except BaseException, msg:
        data_ret = {'websiteDeleteStatus': 0, 'error_message': str(msg)}
        json_data = json.dumps(data_ret)
        return HttpResponse(json_data)