@@ -1129,11 +1129,15 @@ def getRewriteRules(self, userID=None, data=None):
1129
1129
try :
1130
1130
childDom = ChildDomains .objects .get (domain = self .domain )
1131
1131
filePath = childDom .path + '/.htaccess'
1132
+ externalApp = childDom .master .externalApp
1132
1133
except :
1134
+ website = Websites .objects .get (domain = self .domain )
1135
+ externalApp = website .externalApp
1133
1136
filePath = "/home/" + self .domain + "/public_html/.htaccess"
1134
1137
1135
1138
try :
1136
- rewriteRules = open (filePath , "r" ).read ()
1139
+ command = 'cat %s' % (filePath )
1140
+ rewriteRules = ProcessUtilities .outputExecutioner (command , externalApp )
1137
1141
1138
1142
if len (rewriteRules ) == 0 :
1139
1143
status = {"rewriteStatus" : 1 , "error_message" : "Rules file is currently empty" }
@@ -1145,54 +1149,59 @@ def getRewriteRules(self, userID=None, data=None):
1145
1149
final_json = json .dumps (status )
1146
1150
return HttpResponse (final_json )
1147
1151
1148
- except IOError :
1149
- status = {"rewriteStatus" : 1 , "error_message" : "none" , "rewriteRules" : "" }
1152
+ except BaseException as msg :
1153
+ status = {"rewriteStatus" : 1 , "error_message" : str ( msg ) , "rewriteRules" : "" }
1150
1154
final_json = json .dumps (status )
1151
1155
return HttpResponse (final_json )
1152
1156
1153
1157
def saveRewriteRules (self , userID = None , data = None ):
1158
+ try :
1154
1159
1155
- currentACL = ACLManager .loadedACL (userID )
1156
- admin = Administrator .objects .get (pk = userID )
1157
- self .domain = data ['virtualHost' ]
1158
- rewriteRules = data ['rewriteRules' ]
1160
+ currentACL = ACLManager .loadedACL (userID )
1161
+ admin = Administrator .objects .get (pk = userID )
1162
+ self .domain = data ['virtualHost' ]
1163
+ rewriteRules = data ['rewriteRules' ]. encode ( 'utf-8' )
1159
1164
1160
- if ACLManager .checkOwnership (self .domain , admin , currentACL ) == 1 :
1161
- pass
1162
- else :
1163
- return ACLManager .loadErrorJson ('rewriteStatus' , 0 )
1165
+ if ACLManager .checkOwnership (self .domain , admin , currentACL ) == 1 :
1166
+ pass
1167
+ else :
1168
+ return ACLManager .loadErrorJson ('rewriteStatus' , 0 )
1164
1169
1165
- ## writing data temporary to file
1170
+ ## writing data temporary to file
1166
1171
1167
- mailUtilities .checkHome ()
1168
- tempPath = "/tmp/" + str (randint (1000 , 9999 ))
1169
- vhost = open (tempPath , "w " )
1170
- vhost .write (rewriteRules )
1171
- vhost .close ()
1172
+ mailUtilities .checkHome ()
1173
+ tempPath = "/tmp/" + str (randint (1000 , 9999 ))
1174
+ vhost = open (tempPath , "wb " )
1175
+ vhost .write (rewriteRules )
1176
+ vhost .close ()
1172
1177
1173
- ## writing data temporary to file
1178
+ ## writing data temporary to file
1174
1179
1175
- try :
1176
- childDomain = ChildDomains .objects .get (domain = self .domain )
1177
- filePath = childDomain .path + '/.htaccess'
1178
- externalApp = childDomain .master .externalApp
1179
- except :
1180
- filePath = "/home/" + self .domain + "/public_html/.htaccess"
1181
- website = Websites .objects .get (domain = self .domain )
1182
- externalApp = website .externalApp
1180
+ try :
1181
+ childDomain = ChildDomains .objects .get (domain = self .domain )
1182
+ filePath = childDomain .path + '/.htaccess'
1183
+ externalApp = childDomain .master .externalApp
1184
+ except :
1185
+ filePath = "/home/" + self .domain + "/public_html/.htaccess"
1186
+ website = Websites .objects .get (domain = self .domain )
1187
+ externalApp = website .externalApp
1183
1188
1184
- ## save configuration data
1189
+ ## save configuration data
1185
1190
1186
- command = 'cp %s %s' % (tempPath , filePath )
1187
- ProcessUtilities .executioner (command , externalApp )
1191
+ command = 'cp %s %s' % (tempPath , filePath )
1192
+ ProcessUtilities .executioner (command , externalApp )
1188
1193
1189
- command = 'rm -f %s' % (tempPath )
1190
- ProcessUtilities .executioner (command , 'cyberpanel' )
1194
+ command = 'rm -f %s' % (tempPath )
1195
+ ProcessUtilities .executioner (command , 'cyberpanel' )
1191
1196
1192
- installUtilities .reStartLiteSpeedSocket ()
1193
- status = {"rewriteStatus" : 1 , 'error_message' : 'None' }
1194
- final_json = json .dumps (status )
1195
- return HttpResponse (final_json )
1197
+ installUtilities .reStartLiteSpeedSocket ()
1198
+ status = {"rewriteStatus" : 1 , 'error_message' : 'None' }
1199
+ final_json = json .dumps (status )
1200
+ return HttpResponse (final_json )
1201
+ except BaseException as msg :
1202
+ status = {"rewriteStatus" : 0 , 'error_message' : str (msg )}
1203
+ final_json = json .dumps (status )
1204
+ return HttpResponse (final_json )
1196
1205
1197
1206
def saveSSL (self , userID = None , data = None ):
1198
1207
0 commit comments