mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 14:26:16 +01:00
bug fix: rewrite rules: encoding
This commit is contained in:
@@ -292,8 +292,8 @@ class FileManager:
|
|||||||
domainName = self.data['domainName']
|
domainName = self.data['domainName']
|
||||||
website = Websites.objects.get(domain=domainName)
|
website = Websites.objects.get(domain=domainName)
|
||||||
|
|
||||||
writeToFile = open(tempPath, 'w')
|
writeToFile = open(tempPath, 'wb')
|
||||||
writeToFile.write(self.data['fileContent'])
|
writeToFile.write(self.data['fileContent'].encode('utf-8'))
|
||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
if os.path.islink(self.data['fileName']):
|
if os.path.islink(self.data['fileName']):
|
||||||
|
|||||||
@@ -1129,11 +1129,15 @@ class WebsiteManager:
|
|||||||
try:
|
try:
|
||||||
childDom = ChildDomains.objects.get(domain=self.domain)
|
childDom = ChildDomains.objects.get(domain=self.domain)
|
||||||
filePath = childDom.path + '/.htaccess'
|
filePath = childDom.path + '/.htaccess'
|
||||||
|
externalApp = childDom.master.externalApp
|
||||||
except:
|
except:
|
||||||
|
website = Websites.objects.get(domain=self.domain)
|
||||||
|
externalApp = website.externalApp
|
||||||
filePath = "/home/" + self.domain + "/public_html/.htaccess"
|
filePath = "/home/" + self.domain + "/public_html/.htaccess"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rewriteRules = open(filePath, "r").read()
|
command = 'cat %s' % (filePath)
|
||||||
|
rewriteRules = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||||
|
|
||||||
if len(rewriteRules) == 0:
|
if len(rewriteRules) == 0:
|
||||||
status = {"rewriteStatus": 1, "error_message": "Rules file is currently empty"}
|
status = {"rewriteStatus": 1, "error_message": "Rules file is currently empty"}
|
||||||
@@ -1145,17 +1149,18 @@ class WebsiteManager:
|
|||||||
final_json = json.dumps(status)
|
final_json = json.dumps(status)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except IOError:
|
except BaseException as msg:
|
||||||
status = {"rewriteStatus": 1, "error_message": "none", "rewriteRules": ""}
|
status = {"rewriteStatus": 1, "error_message": str(msg), "rewriteRules": ""}
|
||||||
final_json = json.dumps(status)
|
final_json = json.dumps(status)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
def saveRewriteRules(self, userID=None, data=None):
|
def saveRewriteRules(self, userID=None, data=None):
|
||||||
|
try:
|
||||||
|
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
admin = Administrator.objects.get(pk=userID)
|
admin = Administrator.objects.get(pk=userID)
|
||||||
self.domain = data['virtualHost']
|
self.domain = data['virtualHost']
|
||||||
rewriteRules = data['rewriteRules']
|
rewriteRules = data['rewriteRules'].encode('utf-8')
|
||||||
|
|
||||||
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||||
pass
|
pass
|
||||||
@@ -1166,7 +1171,7 @@ class WebsiteManager:
|
|||||||
|
|
||||||
mailUtilities.checkHome()
|
mailUtilities.checkHome()
|
||||||
tempPath = "/tmp/" + str(randint(1000, 9999))
|
tempPath = "/tmp/" + str(randint(1000, 9999))
|
||||||
vhost = open(tempPath, "w")
|
vhost = open(tempPath, "wb")
|
||||||
vhost.write(rewriteRules)
|
vhost.write(rewriteRules)
|
||||||
vhost.close()
|
vhost.close()
|
||||||
|
|
||||||
@@ -1193,6 +1198,10 @@ class WebsiteManager:
|
|||||||
status = {"rewriteStatus": 1, 'error_message': 'None'}
|
status = {"rewriteStatus": 1, 'error_message': 'None'}
|
||||||
final_json = json.dumps(status)
|
final_json = json.dumps(status)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
except BaseException as msg:
|
||||||
|
status = {"rewriteStatus": 0, 'error_message': str(msg)}
|
||||||
|
final_json = json.dumps(status)
|
||||||
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
def saveSSL(self, userID=None, data=None):
|
def saveSSL(self, userID=None, data=None):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user