示例#1
0
文件: views.py 项目: qtwrk/cyberpanel
def fetchDomains(request):
    try:
        userID = request.session['userID']
        wm = WebsiteManager()
        return wm.fetchDomains(userID, json.loads(request.body))
    except KeyError:
        return redirect(loadLoginPage)
示例#2
0
def submitWebsiteStatus(request):
    try:
        if request.method == 'POST':
            data = json.loads(request.body)
            adminUser = data['adminUser']
            adminPass = data['adminPass']

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

            if admin.api == 0:
                data_ret = {
                    "websiteStatus": 0,
                    'error_message': "API Access Disabled."
                }
                json_data = json.dumps(data_ret)
                return HttpResponse(json_data)

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

            wm = WebsiteManager()
            return wm.submitWebsiteStatus(admin.pk, json.loads(request.body))

    except BaseException, msg:
        data_ret = {'websiteStatus': 0, 'error_message': str(msg)}
        json_data = json.dumps(data_ret)
        return HttpResponse(json_data)
示例#3
0
文件: views.py 项目: qtwrk/cyberpanel
def submitWebsiteModify(request):
    try:

        userID = request.session['userID']
        wm = WebsiteManager()
        return wm.submitWebsiteModify(userID, json.loads(request.body))

    except KeyError:
        return redirect(loadLoginPage)
示例#4
0
def deleteWebsite(request):
    try:
        if request.method == 'POST':
            data = json.loads(request.body)

            adminUser = data['adminUser']
            adminPass = data['adminPass']

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

            if admin.api == 0:
                data_ret = {
                    "websiteDeleteStatus": 0,
                    'error_message': "API Access Disabled."
                }
                json_data = json.dumps(data_ret)
                return HttpResponse(json_data)

            data['websiteName'] = data['domainName']

            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)

            website = Websites.objects.get(domain=data['websiteName'])
            websiteOwner = website.admin

            try:
                if admin.websites_set.all().count() == 0:
                    websiteOwner.delete()
            except:
                pass

            ## Deleting master domain

            wm = WebsiteManager()
            return wm.submitWebsiteDeletion(admin.pk, data)

    except BaseException, msg:
        data_ret = {'websiteDeleteStatus': 0, 'error_message': str(msg)}
        json_data = json.dumps(data_ret)
        return HttpResponse(json_data)
示例#5
0
def createWebsite(request):
    data = json.loads(request.body)
    adminUser = data['adminUser']
    admin = Administrator.objects.get(userName=adminUser)

    if admin.api == 0:
        data_ret = {
            "existsStatus": 0,
            'createWebSiteStatus': 0,
            'error_message': "API Access Disabled."
        }
        json_data = json.dumps(data_ret)
        return HttpResponse(json_data)

    wm = WebsiteManager()
    return wm.createWebsiteAPI(json.loads(request.body))
示例#6
0
文件: views.py 项目: qtwrk/cyberpanel
def submitDomainCreation(request):
    try:
        userID = request.session['userID']

        result = pluginManager.preDomainCreation(request)
        if result != 200:
            return result

        wm = WebsiteManager()
        coreResult = wm.submitDomainCreation(userID, json.loads(request.body))

        result = pluginManager.postDomainCreation(request, coreResult)
        if result != 200:
            return result

        return coreResult
    except KeyError:
        return redirect(loadLoginPage)
示例#7
0
文件: views.py 项目: qtwrk/cyberpanel
def delateAlias(request):
    try:
        userID = request.session['userID']

        result = pluginManager.preDelateAlias(request)
        if result != 200:
            return result

        wm = WebsiteManager()
        coreResult = wm.delateAlias(userID, json.loads(request.body))

        result = pluginManager.postDelateAlias(request, coreResult)
        if result != 200:
            return result

        return coreResult
    except KeyError:
        return redirect(loadLoginPage)
示例#8
0
文件: views.py 项目: qtwrk/cyberpanel
def changeOpenBasedir(request):
    try:

        userID = request.session['userID']

        result = pluginManager.preChangeOpenBasedir(request)
        if result != 200:
            return result

        wm = WebsiteManager()
        coreResult = wm.changeOpenBasedir(userID, json.loads(request.body))

        result = pluginManager.postChangeOpenBasedir(request, coreResult)
        if result != 200:
            return result

        return coreResult

    except KeyError:
        return redirect(loadLoginPage)
示例#9
0
文件: views.py 项目: qtwrk/cyberpanel
def saveConfigsToFile(request):
    try:

        userID = request.session['userID']

        result = pluginManager.preSaveConfigsToFile(request)
        if result != 200:
            return result

        wm = WebsiteManager()
        coreResult = wm.saveConfigsToFile(userID, json.loads(request.body))

        result = pluginManager.postSaveConfigsToFile(request, coreResult)
        if result != 200:
            return result

        return coreResult

    except KeyError:
        return redirect(loadLoginPage)
示例#10
0
文件: views.py 项目: qtwrk/cyberpanel
def saveWebsiteChanges(request):
    try:

        userID = request.session['userID']

        result = pluginManager.preWebsiteModification(request)
        if result != 200:
            return result

        wm = WebsiteManager()
        coreResult = wm.saveWebsiteChanges(userID, json.loads(request.body))

        result = pluginManager.postWebsiteModification(request, coreResult)
        if result != 200:
            return result

        return coreResult

    except KeyError:
        return redirect(loadLoginPage)
示例#11
0
文件: views.py 项目: qtwrk/cyberpanel
def domain(request, domain):
    try:

        if not request.GET._mutable:
            request.GET._mutable = True
        request.GET['domain'] = domain

        result = pluginManager.preDomain(request)
        if result != 200:
            return result

        userID = request.session['userID']
        wm = WebsiteManager(domain)
        coreResult = wm.loadDomainHome(request, userID)

        result = pluginManager.postDomain(request, coreResult)
        if result != 200:
            return result

        return coreResult

    except KeyError:
        return redirect(loadLoginPage)
示例#12
0
文件: views.py 项目: qtwrk/cyberpanel
def gitNotify(request, domain):
    try:
        wm = WebsiteManager(domain)
        return wm.gitNotify()
    except KeyError:
        return redirect(loadLoginPage)