Usman Nasir
2020-08-24 05:50:28 +05:00
parent 3a39e1dd7c
commit fda1749754
8 changed files with 1428 additions and 1148 deletions

View File

@@ -73,7 +73,7 @@ class secMiddleware:
or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \
or key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' \
or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' \
or key == 'fileContent' or key == 'commands' or key == 'gitHost' or key == 'ipv6':
or key == 'fileContent' or key == 'commands' or key == 'gitHost' or key == 'ipv6' or key == 'contentNow':
continue
if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1 \
or value.find("`") > -1 or value.find("$") > -1 or value.find("(") > -1 or value.find(")") > -1 \

View File

@@ -418,6 +418,47 @@ class DNSManager:
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def updateRecord(self, userID = None, data = None):
try:
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'addDeleteRecords') == 0:
return ACLManager.loadErrorJson('add_status', 0)
zoneDomain = data['selectedZone']
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
record = Records.objects.get(pk=data['id'])
if data['nameNow'] != None:
record.name = data['nameNow']
if data['ttlNow'] != None:
record.ttl = int(data['ttlNow'])
if data['priorityNow'] != None:
record.prio = int(data['priorityNow'])
if data['contentNow'] != None:
record.content = data['contentNow']
record.save()
final_dic = {'status': 1, 'error_message': "None"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def deleteDNSRecord(self, userID = None, data = None):
try:
currentACL = ACLManager.loadedACL(userID)

View File

@@ -407,10 +407,97 @@ app.controller('addModifyDNSRecords', function ($scope, $http) {
};
var globalID = null;
var nameNow = null;
var ttlNow = null;
var contentNow = null;
var priorityNow = null;
$scope.setupContent = function (id, type, content) {
if (globalID === null) {
globalID = id;
} else {
if (globalID !== id) {
globalID = id;
nameNow = null;
ttlNow = null;
contentNow = null;
priorityNow = null;
}
}
if (type === 'name') {
nameNow = content;
} else if (type === 'ttl') {
ttlNow = content;
} else if (type === 'content') {
contentNow = content;
} else if (type === 'priority') {
priorityNow = content;
}
};
$scope.saveNow = function (id) {
if (id !== globalID) {
alert('This record is not changed');
return;
}
$scope.recordsLoading = false;
url = "/dns/updateRecord";
var data = {
selectedZone: $scope.selectedZone,
id: globalID,
nameNow: nameNow,
ttlNow: ttlNow,
contentNow: contentNow,
priorityNow: priorityNow,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.recordsLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success!',
text: 'Record updated.',
type: 'success'
});
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.recordsLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.deleteRecord = function (id) {
var selectedZone = $scope.selectedZone;
url = "/dns/deleteDNSRecord";
@@ -493,7 +580,8 @@ app.controller('addModifyDNSRecords', function ($scope, $http) {
};
});
}
);
/* Java script code to delete DNS Zone */

View File

@@ -10,7 +10,10 @@
<div class="container">
<div id="page-title">
<h2>{% trans "Add/Modify DNS Zone" %} - <a target="_blank" href="http://go.cyberpanel.net/dns-records" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "DNS Docs" %}</span></a></h2>
<h2>{% trans "Add/Modify DNS Zone" %} - <a target="_blank" href="http://go.cyberpanel.net/dns-records"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "DNS Docs" %}</span></a></h2>
<p>{% trans "On this page you can add/modify dns records for domains whose dns zone is already created." %}</p>
</div>
<div ng-controller="addModifyDNSRecords" class="panel">
@@ -25,10 +28,12 @@
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "PowerDNS is disabled." %}
<a href="{% url 'managePowerDNS' %}"><button class="btn btn-alt btn-hover btn-blue-alt">
<a href="{% url 'managePowerDNS' %}">
<button class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Enable Now" %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button></a></h3>
</button>
</a></h3>
</div>
@@ -55,15 +60,22 @@
<div class="example-box-wrapper">
<ul class="nav nav-tabs">
<li ng-click="fetchRecordsTabs('aRecord')" id="aRecord"><a href="">A</a></li>
<li ng-click="fetchRecordsTabs('aaaaRecord')" id="aaaaRecord" ><a href="">AAAA</a></li>
<li ng-click="fetchRecordsTabs('cNameRecord')" id="cNameRecord"><a href="">CNAME</a></li>
<li ng-click="fetchRecordsTabs('aaaaRecord')" id="aaaaRecord"><a
href="">AAAA</a></li>
<li ng-click="fetchRecordsTabs('cNameRecord')" id="cNameRecord"><a
href="">CNAME</a></li>
<li ng-click="fetchRecordsTabs('mxRecord')" id="mxRecord"><a href="">MX</a></li>
<li ng-click="fetchRecordsTabs('txtRecord')" id="txtRecord"><a href="">TXT</a></li>
<li ng-click="fetchRecordsTabs('spfRecord')" id="spfRecord"><a href="">SPF</a></li>
<li ng-click="fetchRecordsTabs('txtRecord')" id="txtRecord"><a href="">TXT</a>
</li>
<li ng-click="fetchRecordsTabs('spfRecord')" id="spfRecord"><a href="">SPF</a>
</li>
<li ng-click="fetchRecordsTabs('nsRecord')" id="nsRecord"><a href="">NS</a></li>
<li ng-click="fetchRecordsTabs('soaRecord')" id="soaRecord" ><a href="">SOA</a></li>
<li ng-click="fetchRecordsTabs('srvRecord')" id="srvRecord" ><a href="">SRV</a></li>
<li ng-click="fetchRecordsTabs('caaRecord')" id="caaRecord" ><a href="">CAA</a></li>
<li ng-click="fetchRecordsTabs('soaRecord')" id="soaRecord"><a href="">SOA</a>
</li>
<li ng-click="fetchRecordsTabs('srvRecord')" id="srvRecord"><a href="">SRV</a>
</li>
<li ng-click="fetchRecordsTabs('caaRecord')" id="caaRecord"><a href="">CAA</a>
</li>
</ul>
</div>
@@ -71,21 +83,24 @@
<div class="col-sm-3 aRecord">
<input placeholder="{% trans 'Name' %}" name="dom" type="text" class="form-control" ng-model="recordName" required>
<input placeholder="{% trans 'Name' %}" name="dom" type="text" class="form-control"
ng-model="recordName" required>
</div>
<div class="col-sm-3 aRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 aRecord">
<input placeholder="{% trans 'IP Address' %}" name="dom" type="text" class="form-control" ng-model="recordContentA" required>
<input placeholder="{% trans 'IP Address' %}" name="dom" type="text"
class="form-control" ng-model="recordContentA" required>
</div>
<div class="col-sm-3 aRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('A')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('A')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- A Record box ------------->
@@ -94,21 +109,24 @@
<div class="col-sm-3 aaaaRecord">
<input placeholder="{% trans 'Name' %}" name="dom" type="text" class="form-control" ng-model="recordName" required>
<input placeholder="{% trans 'Name' %}" name="dom" type="text" class="form-control"
ng-model="recordName" required>
</div>
<div class="col-sm-3 aaaaRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 aaaaRecord">
<input placeholder="{% trans 'IPV6 Address' %}" name="dom" type="text" class="form-control" ng-model="recordContentAAAA" required>
<input placeholder="{% trans 'IPV6 Address' %}" name="dom" type="text"
class="form-control" ng-model="recordContentAAAA" required>
</div>
<div class="col-sm-3 aaaaRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('AAAA')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('AAAA')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- AAAA Record box ------------->
@@ -118,21 +136,24 @@
<div class="col-sm-3 cNameRecord">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName" required>
<input placeholder="{% trans 'Name' %}" type="text" class="form-control"
ng-model="recordName" required>
</div>
<div class="col-sm-3 cNameRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 cNameRecord">
<input placeholder="{% trans 'Domain Name' %}" type="text" class="form-control" ng-model="recordContentCNAME" required>
<input placeholder="{% trans 'Domain Name' %}" type="text" class="form-control"
ng-model="recordContentCNAME" required>
</div>
<div class="col-sm-3 cNameRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('CNAME')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('CNAME')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- CNAME Record box ------------->
@@ -141,25 +162,29 @@
<div class="col-sm-3 mxRecord">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName" required>
<input placeholder="{% trans 'Name' %}" type="text" class="form-control"
ng-model="recordName" required>
</div>
<div class="col-sm-2 mxRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-2 mxRecord">
<input placeholder="{% trans 'Priority' %}" type="number" class="form-control" ng-model="priority" required>
<input placeholder="{% trans 'Priority' %}" type="number" class="form-control"
ng-model="priority" required>
</div>
<div class="col-sm-3 mxRecord">
<input placeholder="{% trans 'Domain Name' %}" type="text" class="form-control" ng-model="recordContentMX" required>
<input placeholder="{% trans 'Domain Name' %}" type="text" class="form-control"
ng-model="recordContentMX" required>
</div>
<div class="col-sm-2 mxRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('MX')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('MX')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- CNAME Record box ------------->
@@ -169,22 +194,25 @@
<div class="col-sm-3 spfRecord">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName" required>
<input placeholder="{% trans 'Name' %}" type="text" class="form-control"
ng-model="recordName" required>
</div>
<div class="col-sm-3 spfRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 spfRecord">
<input placeholder="{% trans 'Policy' %}" type="text" class="form-control" ng-model="recordContentSPF" required>
<input placeholder="{% trans 'Policy' %}" type="text" class="form-control"
ng-model="recordContentSPF" required>
</div>
<div class="col-sm-3 spfRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SPF')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SPF')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- SPF Record box ------------->
@@ -193,22 +221,25 @@
<div class="col-sm-3 txtRecord">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName" required>
<input placeholder="{% trans 'Name' %}" type="text" class="form-control"
ng-model="recordName" required>
</div>
<div class="col-sm-3 txtRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 txtRecord">
<input placeholder="{% trans 'Text' %}" type="text" class="form-control" ng-model="recordContentTXT" required>
<input placeholder="{% trans 'Text' %}" type="text" class="form-control"
ng-model="recordContentTXT" required>
</div>
<div class="col-sm-3 txtRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('TXT')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('TXT')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- TXT Record box ------------->
@@ -217,22 +248,25 @@
<div class="col-sm-3 soaRecord">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="selectedZone" disabled>
<input placeholder="{% trans 'Name' %}" type="text" class="form-control"
ng-model="selectedZone" disabled>
</div>
<div class="col-sm-3 soaRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 soaRecord">
<input placeholder="{% trans 'SOA Value' %}" type="text" class="form-control" ng-model="recordContentSOA" required>
<input placeholder="{% trans 'SOA Value' %}" type="text" class="form-control"
ng-model="recordContentSOA" required>
</div>
<div class="col-sm-3 soaRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SOA')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SOA')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- SOA Record box ------------->
@@ -241,22 +275,25 @@
<div class="col-sm-3 nsRecord">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="selectedZone" disabled>
<input placeholder="{% trans 'Name' %}" type="text" class="form-control"
ng-model="selectedZone" disabled>
</div>
<div class="col-sm-3 nsRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 nsRecord">
<input placeholder="{% trans 'Name server' %}" type="text" class="form-control" ng-model="recordContentNS" required>
<input placeholder="{% trans 'Name server' %}" type="text" class="form-control"
ng-model="recordContentNS" required>
</div>
<div class="col-sm-3 nsRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('NS')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('NS')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- NS Record box ------------->
@@ -265,26 +302,30 @@
<div class="col-sm-3 srvRecord">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control"
ng-model="recordName">
</div>
<div class="col-sm-2 srvRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-2 srvRecord">
<input placeholder="{% trans 'Prioirty' %}" type="number" class="form-control" ng-model="priority" required>
<input placeholder="{% trans 'Prioirty' %}" type="number" class="form-control"
ng-model="priority" required>
</div>
<div class="col-sm-3 srvRecord">
<input placeholder="{% trans 'Content' %}" type="text" class="form-control" ng-model="recordContentSRV" required>
<input placeholder="{% trans 'Content' %}" type="text" class="form-control"
ng-model="recordContentSRV" required>
</div>
<div class="col-sm-2 srvRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SRV')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SRV')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- SRV Record box ------------->
@@ -292,55 +333,69 @@
<!------------- CAA Record box ------------->
<div class="col-sm-3 caaRecord">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName">
<input placeholder="{% trans 'Name' %}" type="text" class="form-control"
ng-model="recordName">
</div>
<div class="col-sm-3 caaRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 caaRecord">
<input placeholder='Value e.g: 0 issue "letsencrypt.org"' type="text" class="form-control" ng-model="recordContentCAA" required>
<input placeholder='Value e.g: 0 issue "letsencrypt.org"' type="text"
class="form-control" ng-model="recordContentCAA" required>
</div>
<div class="col-sm-3 caaRecord">
<button style="width: 100%;" type="button" ng-click="addDNSRecord('CAA')" class="btn btn-primary">{% trans "Add" %}</button>
<button style="width: 100%;" type="button" ng-click="addDNSRecord('CAA')"
class="btn btn-primary">{% trans "Add" %}</button>
</div>
<!------------- CAA Record box ------------->
</div>
<!------ List of records --------------->
<div ng-hide="currentRecords" class="form-group">
<div class="col-sm-12">
<table class="table">
<table style="margin: 0px; padding: 0px" class="table">
<thead>
<tr>
<th>{% trans "ID" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Name" %}</th>
<th>{% trans "TTL" %}</th>
<th style="width: 100px;">{% trans "TTL" %}</th>
<th>{% trans "Value" %}</th>
<th>{% trans "Priority" %}</th>
<th style="width: 87px;">{% trans "Priority" %}</th>
<th>{% trans "Delete" %}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in records track by $index">
<td ng-bind="record.id"></td>
<td ng-bind="record.type"></td>
<td ng-bind="record.name"></td>
<td ng-bind="record.ttl"></td>
<td ng-bind="record.content"></td>
<td ng-bind="record.priority"></td>
<td ng-click="deleteRecord(record.id)"><img src="{% static 'images/delete.png' %}"></td>
<td><input ng-change="setupContent(record.id, 'name', nameNow)"
ng-model="nameNow" type="text" class="form-control"
ng-value="record.name">
</td>
<td><input ng-change="setupContent(record.id, 'ttl', ttlNow)"
ng-model="ttlNow" type="number" class="form-control"
ng-value="record.ttl"></td>
<td><input ng-change="setupContent(record.id, 'content', contentNow)"
ng-model="contentNow" type="text" class="form-control"
ng-value="record.content"></td>
<td><input ng-change="setupContent(record.id, 'priority', priorityNow)"
type="number" class="form-control" ng-model="priorityNow"
ng-value="record.priority"></td>
<td>
<button type="button" ng-click="saveNow(record.id)"
class="btn btn-round btn-blue-alt">
<i class="glyph-icon icon-save"></i>
</button>
<img ng-click="deleteRecord(record.id)"
src="{% static 'images/delete.png' %}">
</td>
</tr>
</tbody>
</table>
@@ -364,7 +419,8 @@
</div>
<div ng-hide="recordsFetched" class="alert alert-success">
<p>{% trans "Records successfully fetched for" %} <strong>{$ domainFeteched $}</strong></p>
<p>{% trans "Records successfully fetched for" %} <strong>{$ domainFeteched
$}</strong></p>
</div>
<div ng-hide="recordDeleted" class="alert alert-success">
@@ -388,14 +444,11 @@
</div>
</form>
{% endif %}
</div>
</div>
</div>

View File

@@ -19,6 +19,7 @@ urlpatterns = [
url(r'^submitZoneDeletion',views.submitZoneDeletion,name='submitZoneDeletion'),
url(r'^saveNSConfigurations$', views.saveNSConfigurations, name='saveNSConfigurations'),
url(r'^saveCFConfigs$', views.saveCFConfigs, name='saveCFConfigs'),
url(r'^updateRecord$', views.updateRecord, name='updateRecord'),
url(r'^getCurrentRecordsForDomainCloudFlare$', views.getCurrentRecordsForDomainCloudFlare, name='getCurrentRecordsForDomainCloudFlare'),
url(r'^deleteDNSRecordCloudFlare$', views.deleteDNSRecordCloudFlare, name='deleteDNSRecordCloudFlare'),

View File

@@ -78,6 +78,14 @@ def addDeleteDNSRecords(request):
except KeyError:
return redirect(loadLoginPage)
def updateRecord(request):
try:
userID = request.session['userID']
dm = DNSManager()
return dm.updateRecord(userID, json.loads(request.body))
except KeyError:
return redirect(loadLoginPage)
def getCurrentRecordsForDomain(request):
try:
userID = request.session['userID']

View File

@@ -814,175 +814,176 @@ class ApplicationInstaller(multi.Thread):
logging.writeToFile(str(msg))
return 0
def installMagento(self):
try:
username = self.extraArgs['username']
domainName = self.extraArgs['domainName']
home = self.extraArgs['home']
firstName = self.extraArgs['firstName']
lastName = self.extraArgs['lastName']
email = self.extraArgs['email']
password = self.extraArgs['password']
tempStatusPath = self.extraArgs['tempStatusPath']
sampleData = self.extraArgs['sampleData']
self.tempStatusPath = tempStatusPath
FNULL = open(os.devnull, 'w')
## Open Status File
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Setting up paths,0')
statusFile.close()
finalPath = ''
self.premPath = ''
try:
website = ChildDomains.objects.get(domain=domainName)
externalApp = website.master.externalApp
self.masterDomain = website.master.domain
if home == '0':
path = self.extraArgs['path']
finalPath = website.path.rstrip('/') + "/" + path + "/"
else:
finalPath = website.path + "/"
if website.master.package.dataBases > website.master.databases_set.all().count():
pass
else:
raise BaseException( "Maximum database limit reached for this website.")
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Setting up Database,20')
statusFile.close()
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
self.permPath = website.path
except:
website = Websites.objects.get(domain=domainName)
externalApp = website.externalApp
self.masterDomain = website.domain
if home == '0':
path = self.extraArgs['path']
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
else:
finalPath = "/home/" + domainName + "/public_html/"
if website.package.dataBases > website.databases_set.all().count():
pass
else:
raise BaseException( "Maximum database limit reached for this website.")
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Setting up Database,20')
statusFile.close()
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
self.permPath = '/home/%s/public_html' % (website.domain)
## Security Check
if finalPath.find("..") > -1:
raise BaseException( "Specified path must be inside virtual host home.")
command = 'chmod 755 %s' % (self.permPath)
ProcessUtilities.executioner(command)
if not os.path.exists(finalPath):
command = 'mkdir -p ' + finalPath
ProcessUtilities.executioner(command, externalApp)
## checking for directories/files
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
raise BaseException('Directory not empty.')
# def installMagento(self):
# try:
#
# username = self.extraArgs['username']
# domainName = self.extraArgs['domainName']
# home = self.extraArgs['home']
# firstName = self.extraArgs['firstName']
# lastName = self.extraArgs['lastName']
# email = self.extraArgs['email']
# password = self.extraArgs['password']
# tempStatusPath = self.extraArgs['tempStatusPath']
# sampleData = self.extraArgs['sampleData']
# self.tempStatusPath = tempStatusPath
#
# FNULL = open(os.devnull, 'w')
#
# ## Open Status File
#
# statusFile = open(tempStatusPath, 'w')
# statusFile.writelines('Setting up paths,0')
# statusFile.close()
#
# finalPath = ''
# self.premPath = ''
#
# try:
# website = ChildDomains.objects.get(domain=domainName)
# externalApp = website.master.externalApp
# self.masterDomain = website.master.domain
#
# if home == '0':
# path = self.extraArgs['path']
# finalPath = website.path.rstrip('/') + "/" + path + "/"
# else:
# finalPath = website.path + "/"
#
# if website.master.package.dataBases > website.master.databases_set.all().count():
# pass
# else:
# raise BaseException( "Maximum database limit reached for this website.")
#
# statusFile = open(tempStatusPath, 'w')
# statusFile.writelines('Setting up Database,20')
# statusFile.close()
#
# dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
# self.permPath = website.path
#
# except:
# website = Websites.objects.get(domain=domainName)
# externalApp = website.externalApp
# self.masterDomain = website.domain
#
# if home == '0':
# path = self.extraArgs['path']
# finalPath = "/home/" + domainName + "/public_html/" + path + "/"
# else:
# finalPath = "/home/" + domainName + "/public_html/"
#
# if website.package.dataBases > website.databases_set.all().count():
# pass
# else:
# raise BaseException( "Maximum database limit reached for this website.")
#
# statusFile = open(tempStatusPath, 'w')
# statusFile.writelines('Setting up Database,20')
# statusFile.close()
#
# dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
# self.permPath = '/home/%s/public_html' % (website.domain)
#
# ## Security Check
#
# if finalPath.find("..") > -1:
# raise BaseException( "Specified path must be inside virtual host home.")
#
# command = 'chmod 755 %s' % (self.permPath)
# ProcessUtilities.executioner(command)
#
# if not os.path.exists(finalPath):
# command = 'mkdir -p ' + finalPath
# ProcessUtilities.executioner(command, externalApp)
#
# ## checking for directories/files
#
# if self.dataLossCheck(finalPath, tempStatusPath) == 0:
# raise BaseException('Directory not empty.')
#
# ####
#
# statusFile = open(tempStatusPath, 'w')
# statusFile.writelines('Downloading Magento Community Core via composer to document root ..,30')
# statusFile.close()
#
# command = 'composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition %s' % (finalPath)
#
# ProcessUtilities.executioner(command, externalApp)
#
# ###
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Downloading Magento Community Core via composer to document root ..,30')
statusFile.close()
command = 'composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition %s' % (finalPath)
ProcessUtilities.executioner(command, externalApp)
#
# statusFile = open(tempStatusPath, 'w')
# statusFile.writelines('Configuring the installation,40')
# statusFile.close()
#
# if home == '0':
# path = self.extraArgs['path']
# # finalURL = domainName + '/' + path
# finalURL = domainName
# else:
# finalURL = domainName
#
# statusFile = open(tempStatusPath, 'w')
# statusFile.writelines('Installing and configuring Magento..,60')
# statusFile.close()
#
# command = '/usr/local/lsws/lsphp73/bin/php -d memory_limit=512M %sbin/magento setup:install --base-url="http://%s" ' \
# ' --db-host="localhost" --db-name="%s" --db-user="%s" --db-password="%s" --admin-firstname="%s" ' \
# ' --admin-lastname="%s" --admin-email="%s" --admin-user="%s" --admin-password="%s" --language="%s" --timezone="%s" ' \
# ' --use-rewrites=1 --search-engine="elasticsearch7" --elasticsearch-host="localhost" --elasticsearch-port="9200" ' \
# ' --elasticsearch-index-prefix="%s"' \
# % (finalPath, finalURL, dbName, dbUser, dbPassword, firstName, lastName, email, username, password, 'language', 'timezone', dbName )
#
# result = ProcessUtilities.outputExecutioner(command, externalApp)
# logging.writeToFile(result)
#
# ##
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Configuring the installation,40')
statusFile.close()
if home == '0':
path = self.extraArgs['path']
# finalURL = domainName + '/' + path
finalURL = domainName
else:
finalURL = domainName
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Installing and configuring Magento..,60')
statusFile.close()
command = '/usr/local/lsws/lsphp73/bin/php -d memory_limit=512M %sbin/magento setup:install --base-url="http://%s" ' \
' --db-host="localhost" --db-name="%s" --db-user="%s" --db-password="%s" --admin-firstname="%s" ' \
' --admin-lastname="%s" --admin-email="%s" --admin-user="%s" --admin-password="%s" --language="%s" --timezone="%s" ' \
' --use-rewrites=1 --search-engine="elasticsearch7" --elasticsearch-host="localhost" --elasticsearch-port="9200" ' \
' --elasticsearch-index-prefix="%s"' \
% (finalPath, finalURL, dbName, dbUser, dbPassword, firstName, lastName, email, username, password, language, timezone, dbName )
result = ProcessUtilities.outputExecutioner(command, externalApp)
logging.writeToFile(result)
##
ProcessUtilities.executioner(command, externalApp)
##
from filemanager.filemanager import FileManager
fm = FileManager(None, None)
fm.fixPermissions(self.masterDomain)
installUtilities.reStartLiteSpeed()
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Successfully Installed. [200]")
statusFile.close()
return 0
except BaseException as msg:
# remove the downloaded files
homeDir = "/home/" + domainName + "/public_html"
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
groupName = 'nobody'
else:
groupName = 'nogroup'
if not os.path.exists(homeDir):
command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
ProcessUtilities.executioner(command, externalApp)
try:
mysqlUtilities.deleteDatabase(dbName, dbUser)
db = Databases.objects.get(dbName=dbName)
db.delete()
except:
pass
permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)
statusFile = open(self.tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
return 0
#
# ProcessUtilities.executioner(command, externalApp)
#
# ##
#
# from filemanager.filemanager import FileManager
#
# fm = FileManager(None, None)
# fm.fixPermissions(self.masterDomain)
#
# installUtilities.reStartLiteSpeed()
#
# statusFile = open(tempStatusPath, 'w')
# statusFile.writelines("Successfully Installed. [200]")
# statusFile.close()
# return 0
#
#
# except BaseException as msg:
# # remove the downloaded files
#
# homeDir = "/home/" + domainName + "/public_html"
#
# if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
# groupName = 'nobody'
# else:
# groupName = 'nogroup'
#
# if not os.path.exists(homeDir):
# command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
# ProcessUtilities.executioner(command, externalApp)
#
# try:
# mysqlUtilities.deleteDatabase(dbName, dbUser)
# db = Databases.objects.get(dbName=dbName)
# db.delete()
# except:
# pass
#
# permPath = '/home/%s/public_html' % (domainName)
# command = 'chmod 750 %s' % (permPath)
# ProcessUtilities.executioner(command)
#
# statusFile = open(self.tempStatusPath, 'w')
# statusFile.writelines(str(msg) + " [404]")
# statusFile.close()
# return 0

View File

@@ -407,10 +407,97 @@ app.controller('addModifyDNSRecords', function ($scope, $http) {
};
var globalID = null;
var nameNow = null;
var ttlNow = null;
var contentNow = null;
var priorityNow = null;
$scope.setupContent = function (id, type, content) {
if (globalID === null) {
globalID = id;
} else {
if (globalID !== id) {
globalID = id;
nameNow = null;
ttlNow = null;
contentNow = null;
priorityNow = null;
}
}
if (type === 'name') {
nameNow = content;
} else if (type === 'ttl') {
ttlNow = content;
} else if (type === 'content') {
contentNow = content;
} else if (type === 'priority') {
priorityNow = content;
}
};
$scope.saveNow = function (id) {
if (id !== globalID) {
alert('This record is not changed');
return;
}
$scope.recordsLoading = false;
url = "/dns/updateRecord";
var data = {
selectedZone: $scope.selectedZone,
id: globalID,
nameNow: nameNow,
ttlNow: ttlNow,
contentNow: contentNow,
priorityNow: priorityNow,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.recordsLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success!',
text: 'Record updated.',
type: 'success'
});
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.recordsLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.deleteRecord = function (id) {
var selectedZone = $scope.selectedZone;
url = "/dns/deleteDNSRecord";
@@ -493,7 +580,8 @@ app.controller('addModifyDNSRecords', function ($scope, $http) {
};
});
}
);
/* Java script code to delete DNS Zone */