def zoneCreation(self, userID=None, data=None): try: admin = Administrator.objects.get(pk=userID) currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'createDNSZone') == 0: return ACLManager.loadErrorJson('zoneCreation', 0) zoneDomain = data['zoneDomain'] newZone = Domains(admin=admin, name=zoneDomain, type="NATIVE") newZone.save() content = "ns1." + zoneDomain + " hostmaster." + zoneDomain + " 1 10800 3600 604800 3600" soaRecord = Records(domainOwner=newZone, domain_id=newZone.id, name=zoneDomain, type="SOA", content=content, ttl=3600, prio=0, disabled=0, auth=1) soaRecord.save() final_dic = {'zoneCreation': 1} final_json = json.dumps(final_dic) return HttpResponse(final_json) except BaseException, msg: final_dic = {'zoneCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json)
def zoneCreation(request): try: val = request.session['userID'] try: if request.method == 'POST': admin = Administrator.objects.get(pk=val) data = json.loads(request.body) zoneDomain = data['zoneDomain'] newZone = Domains(admin=admin, name=zoneDomain, type="NATIVE") newZone.save() content = "ns1." + zoneDomain + " hostmaster." + zoneDomain + " 1 10800 3600 604800 3600" soaRecord = Records(domainOwner=newZone, domain_id=newZone.id, name=zoneDomain, type="SOA", content=content, ttl=3600, prio=0, disabled=0, auth=1) soaRecord.save() final_dic = {'zoneCreation': 1} final_json = json.dumps(final_dic) return HttpResponse(final_json) except BaseException,msg: final_dic = {'zoneCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) except KeyError,msg: final_dic = {'zoneCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json)
def zoneCreation(request): try: val = request.session['userID'] try: if request.method == 'POST': admin = Administrator.objects.get(pk=val) data = json.loads(request.body) zoneDomain = data['zoneDomain'] newZone = Domains(admin=admin, name=zoneDomain, type="NATIVE") newZone.save() content = "ns1." + zoneDomain + " hostmaster." + zoneDomain + " 1 10800 3600 604800 3600" soaRecord = Records(domainOwner=newZone, domain_id=newZone.id, name=zoneDomain, type="SOA", content=content, ttl=3600, prio=0, disabled=0, auth=1) soaRecord.save() final_dic = {'zoneCreation': 1} final_json = json.dumps(final_dic) return HttpResponse(final_json) except BaseException, msg: final_dic = {'zoneCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) except KeyError, msg: final_dic = {'zoneCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json)
def submitEmailCreation(request): try: if request.method == 'POST': data = json.loads(request.body) domain = data['domain'] userName = data['username'] password = data['password'] ## Check if already exists finalEmailUsername = userName + "@" + domain if EUsers.objects.filter(email=finalEmailUsername).exists(): data_ret = { 'createEmailStatus': 0, 'error_message': "This account already exists!" } json_data = json.dumps(data_ret) return HttpResponse(json_data) ## Check for email limits. website = Websites.objects.get(domain=domain) try: newEmailDomain = Domains(domainOwner=website, domain=domain) newEmailDomain.save() if website.package.emailAccounts == 0 or ( newEmailDomain.eusers_set.all().count() < website.package.emailAccounts): pass else: data_ret = { 'createEmailStatus': 0, 'error_message': "Exceeded maximum amount of email accounts allowed for the package." } json_data = json.dumps(data_ret) return HttpResponse(json_data) except: emailDomain = Domains.objects.get(domain=domain) if website.package.emailAccounts == 0 or ( emailDomain.eusers_set.all().count() < website.package.emailAccounts): pass else: data_ret = { 'createEmailStatus': 0, 'error_message': "Exceeded maximum amount of email accounts allowed for the package." } json_data = json.dumps(data_ret) return HttpResponse(json_data) ## Create email entry execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " createEmailAccount --domain " + domain output = subprocess.check_output(shlex.split(execPath)) if output.find("1,None") > -1: emailDomain = Domains.objects.get(domain=domain) emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password) emailAcct.save() data_ret = {'createEmailStatus': 1, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) else: data_ret = {'createEmailStatus': 0, 'error_message': output} json_data = json.dumps(data_ret) return HttpResponse(json_data) ## create email entry ends except BaseException, msg: data_ret = {'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data)
def submitEmailCreation(request): try: val = request.session['userID'] try: if request.method == 'POST': data = json.loads(request.body) domain = data['domain'] userName = data['username'] password = data['password'] ## create email entry execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " createEmailAccount --domain " + domain output = subprocess.check_output(shlex.split(execPath)) if output.find("1,None") > -1: pass else: data_ret = {'createEmailStatus': 0, 'error_message': output} json_data = json.dumps(data_ret) return HttpResponse(json_data) ## create email entry ends finalEmailUsername = userName+"@"+domain website = Websites.objects.get(domain=domain) if EUsers.objects.filter(email=finalEmailUsername).exists(): data_ret = {'createEmailStatus': 0, 'error_message': "This account already exists"} json_data = json.dumps(data_ret) return HttpResponse(json_data) if not Domains.objects.filter(domain=domain).exists(): newEmailDomain = Domains(domainOwner=website,domain=domain) newEmailDomain.save() emailAcct = EUsers(emailOwner=newEmailDomain,email=finalEmailUsername,password=password) emailAcct.save() data_ret = {'createEmailStatus': 1, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) else: emailDomain = Domains.objects.get(domain=domain) emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password) emailAcct.save() data_ret = {'createEmailStatus': 1, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) except BaseException,msg: data_ret = {'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) except KeyError,msg: data_ret = {'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data)
def NSCreation(request): try: val = request.session['userID'] try: if request.method == 'POST': admin = Administrator.objects.get(pk=val) if admin.type != 1: dic = { 'NSCreation': 0, 'error_message': "Only administrator can view this page." } json_data = json.dumps(dic) return HttpResponse(json_data) data = json.loads(request.body) domainForNS = data['domainForNS'] ns1 = data['ns1'] ns2 = data['ns2'] firstNSIP = data['firstNSIP'] secondNSIP = data['secondNSIP'] if Domains.objects.filter(name=domainForNS).count() == 0: newZone = Domains(admin=admin, name=domainForNS, type="NATIVE") newZone.save() content = "ns1." + domainForNS + " hostmaster." + domainForNS + " 1 10800 3600 604800 3600" soaRecord = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="SOA", content=content, ttl=3600, prio=0, disabled=0, auth=1) soaRecord.save() ## NS1 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns1, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns1, type="A", content=firstNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() ## NS2 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns2, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns2, type="A", content=secondNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() final_dic = {'NSCreation': 1, 'error_message': "None"} final_json = json.dumps(final_dic) return HttpResponse(final_json) else: newZone = Domains.objects.get(name=domainForNS) ## NS1 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns1, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns1, type="A", content=firstNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() ## NS2 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns2, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns2, type="A", content=secondNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() final_dic = {'NSCreation': 1, 'error_message': "None"} final_json = json.dumps(final_dic) return HttpResponse(final_json) except BaseException, msg: final_dic = {'NSCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) except KeyError, msg: final_dic = {'NSCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json)
def NSCreation(self, userID=None, data=None): try: admin = Administrator.objects.get(pk=userID) currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'createNameServer') == 0: return ACLManager.loadErrorJson('NSCreation', 0) domainForNS = data['domainForNS'] ns1 = data['ns1'] ns2 = data['ns2'] firstNSIP = data['firstNSIP'] secondNSIP = data['secondNSIP'] if Domains.objects.filter(name=domainForNS).count() == 0: newZone = Domains(admin=admin, name=domainForNS, type="NATIVE") newZone.save() content = "ns1." + domainForNS + " hostmaster." + domainForNS + " 1 10800 3600 604800 3600" soaRecord = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="SOA", content=content, ttl=3600, prio=0, disabled=0, auth=1) soaRecord.save() ## NS1 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns1, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns1, type="A", content=firstNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() ## NS2 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns2, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns2, type="A", content=secondNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() final_dic = {'NSCreation': 1, 'error_message': "None"} final_json = json.dumps(final_dic) return HttpResponse(final_json) else: newZone = Domains.objects.get(name=domainForNS) ## NS1 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns1, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns1, type="A", content=firstNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() ## NS2 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns2, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns2, type="A", content=secondNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() final_dic = {'NSCreation': 1, 'error_message': "None"} final_json = json.dumps(final_dic) return HttpResponse(final_json) except BaseException, msg: final_dic = {'NSCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json)
def submitEmailCreation(request): try: val = request.session['userID'] try: if request.method == 'POST': data = json.loads(request.body) domain = data['domain'] userName = data['username'] password = data['password'] path = "/usr/local/CyberCP/install/rainloop/cyberpanel.net.ini" if not os.path.exists( "/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains/" ): command = 'sudo mkdir -p /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains' cmd = shlex.split(command) res = subprocess.call(cmd) finalPath = "/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains/" + domain + ".ini" if not os.path.exists(finalPath): command = 'sudo cp ' + path + " " + finalPath cmd = shlex.split(command) res = subprocess.call(cmd) command = 'sudo chown -R nobody:nobody /usr/local/lscp/rainloop' cmd = shlex.split(command) res = subprocess.call(cmd) command = 'sudo chown -R nobody:nobody /usr/local/lscp/cyberpanel/rainloop/data/_data_' cmd = shlex.split(command) res = subprocess.call(cmd) command = 'sudo chown -R vmail:vmail /home/vmail' cmd = shlex.split(command) res = subprocess.call(cmd) finalEmailUsername = userName + "@" + domain website = Websites.objects.get(domain=domain) if EUsers.objects.filter(email=finalEmailUsername).exists(): data_ret = { 'createEmailStatus': 0, 'error_message': "This account already exists" } json_data = json.dumps(data_ret) return HttpResponse(json_data) if not Domains.objects.filter(domain=domain).exists(): newEmailDomain = Domains(domainOwner=website, domain=domain) newEmailDomain.save() emailAcct = EUsers(emailOwner=newEmailDomain, email=finalEmailUsername, password=password) emailAcct.save() data_ret = { 'createEmailStatus': 1, 'error_message': "None" } json_data = json.dumps(data_ret) return HttpResponse(json_data) else: emailDomain = Domains.objects.get(domain=domain) emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password) emailAcct.save() data_ret = { 'createEmailStatus': 1, 'error_message': "None" } json_data = json.dumps(data_ret) return HttpResponse(json_data) except BaseException, msg: data_ret = {'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) except KeyError, msg: data_ret = {'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data)
def submitEmailCreation(request): try: val = request.session['userID'] try: if request.method == 'POST': data = json.loads(request.body) domain = data['domain'] userName = data['username'] password = data['password'] ## create email entry execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " createEmailAccount --domain " + domain output = subprocess.check_output(shlex.split(execPath)) if output.find("1,None") > -1: pass else: data_ret = { 'createEmailStatus': 0, 'error_message': output } json_data = json.dumps(data_ret) return HttpResponse(json_data) ## create email entry ends finalEmailUsername = userName + "@" + domain website = Websites.objects.get(domain=domain) if EUsers.objects.filter(email=finalEmailUsername).exists(): data_ret = { 'createEmailStatus': 0, 'error_message': "This account already exists" } json_data = json.dumps(data_ret) return HttpResponse(json_data) if not Domains.objects.filter(domain=domain).exists(): newEmailDomain = Domains(domainOwner=website, domain=domain) newEmailDomain.save() emailAcct = EUsers(emailOwner=newEmailDomain, email=finalEmailUsername, password=password) emailAcct.save() data_ret = { 'createEmailStatus': 1, 'error_message': "None" } json_data = json.dumps(data_ret) return HttpResponse(json_data) else: emailDomain = Domains.objects.get(domain=domain) emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password) emailAcct.save() data_ret = { 'createEmailStatus': 1, 'error_message': "None" } json_data = json.dumps(data_ret) return HttpResponse(json_data) except BaseException, msg: data_ret = {'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) except KeyError, msg: data_ret = {'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data)
def NSCreation(request): try: val = request.session['userID'] try: if request.method == 'POST': admin = Administrator.objects.get(pk=val) data = json.loads(request.body) domainForNS = data['domainForNS'] ns1 = data['ns1'] ns2 = data['ns2'] firstNSIP = data['firstNSIP'] secondNSIP = data['secondNSIP'] if Domains.objects.filter(name=domainForNS).count() == 0: newZone = Domains(admin=admin,name=domainForNS, type="NATIVE") newZone.save() content = "ns1." + domainForNS + " hostmaster." + domainForNS + " 1 10800 3600 604800 3600" soaRecord = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="SOA", content=content, ttl=3600, prio=0, disabled=0, auth=1) soaRecord.save() ## NS1 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns1, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns1, type="A", content=firstNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() ## NS2 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns2, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=ns2, type="A", content=secondNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() final_dic = {'NSCreation': 1, 'error_message': "None"} final_json = json.dumps(final_dic) return HttpResponse(final_json) else: newZone = Domains.objects.get(name=domainForNS) ## NS1 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns1, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="A", content=firstNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() ## NS2 record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="NS", content=ns2, ttl=3600, prio=0, disabled=0, auth=1) record.save() record = Records(domainOwner=newZone, domain_id=newZone.id, name=domainForNS, type="A", content=secondNSIP, ttl=3600, prio=0, disabled=0, auth=1) record.save() final_dic = {'NSCreation': 1, 'error_message': "None"} final_json = json.dumps(final_dic) return HttpResponse(final_json) except BaseException, msg: final_dic = {'NSCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) except KeyError, msg: final_dic = {'NSCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json)