Allow normal user to change PHP Version.

This commit is contained in:
usmannasir
2018-03-02 01:20:16 +05:00
parent 58ea325b09
commit 26eb4ce6b3
4 changed files with 470 additions and 218 deletions

View File

@@ -265,9 +265,14 @@ def addDeleteDNSRecords(request):
for items in domains:
domainsList.append(items.name)
else:
domains = admin.domains_set.all()
for items in domains:
domainsList.append(items.name)
websites = admin.websites_set.all()
for web in websites:
try:
tempDomain = Domains.objects.get(name = web.domain)
domainsList.append(web.domain)
except:
pass
return render(request, 'dns/addDeleteDNSRecords.html',{"domainsList":domainsList})

View File

@@ -672,6 +672,7 @@ app.controller('websitePages', function($scope,$http) {
$scope.hidsslconfigs = true;
$scope.configurationsBoxRewrite = true;
$scope.changePHPView = true;
//Rewrite rules
@@ -898,6 +899,7 @@ app.controller('websitePages', function($scope,$http) {
$scope.hidsslconfigs = true;
$scope.configurationsBox = true;
$scope.changePHPView = true;
$scope.configurationsBox = true;
@@ -1124,8 +1126,6 @@ app.controller('websitePages', function($scope,$http) {
//////// Application Installation part
$scope.installationDetailsForm = true;
@@ -1340,9 +1340,12 @@ app.controller('websitePages', function($scope,$http) {
$scope.hidsslconfigs = false;
$scope.configurationsBox = true;
$scope.configurationsBoxRewrite = true;
$scope.changePHPView = true;
};
$scope.saveSSL = function(){
@@ -1412,6 +1415,98 @@ app.controller('websitePages', function($scope,$http) {
};
//// Change PHP Master
$scope.failedToChangePHPMaster = true;
$scope.phpChangedMaster = true;
$scope.couldNotConnect = true;
$scope.changePHPView = true;
$scope.hideChangePHPMaster = function(){
$scope.changePHPView = true;
};
$scope.changePHPMaster = function(){
$scope.hidsslconfigs = true;
$scope.configurationsBox = true;
$scope.configurationsBoxRewrite = true;
$scope.changePHPView = false;
};
$scope.changePHPVersionMaster = function(childDomain,phpSelection){
// notifcations
$scope.configFileLoading = false;
var url = "/websites/changePHP";
var data = {
childDomain:$("#domainNamePage").text(),
phpSelection:$scope.phpSelectionMaster,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.changePHP === 1){
$scope.configFileLoading = true;
$scope.websiteDomain = $("#domainNamePage").text();
// notifcations
$scope.failedToChangePHPMaster = true;
$scope.phpChangedMaster = false;
$scope.couldNotConnect = true;
}
else{
$scope.configFileLoading = true;
$scope.errorMessage = response.data.error_message;
// notifcations
$scope.failedToChangePHPMaster = false;
$scope.phpChangedMaster = true;
$scope.couldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.configFileLoading = true;
// notifcations
$scope.failedToChangePHPMaster = true;
$scope.phpChangedMaster = true;
$scope.couldNotConnect = false;
}
}
////// create domain part
$("#domainCreationForm").hide();

View File

@@ -672,6 +672,7 @@ app.controller('websitePages', function($scope,$http) {
$scope.hidsslconfigs = true;
$scope.configurationsBoxRewrite = true;
$scope.changePHPView = true;
//Rewrite rules
@@ -898,6 +899,7 @@ app.controller('websitePages', function($scope,$http) {
$scope.hidsslconfigs = true;
$scope.configurationsBox = true;
$scope.changePHPView = true;
$scope.configurationsBox = true;
@@ -1124,8 +1126,6 @@ app.controller('websitePages', function($scope,$http) {
//////// Application Installation part
$scope.installationDetailsForm = true;
@@ -1340,9 +1340,12 @@ app.controller('websitePages', function($scope,$http) {
$scope.hidsslconfigs = false;
$scope.configurationsBox = true;
$scope.configurationsBoxRewrite = true;
$scope.changePHPView = true;
};
$scope.saveSSL = function(){
@@ -1412,6 +1415,98 @@ app.controller('websitePages', function($scope,$http) {
};
//// Change PHP Master
$scope.failedToChangePHPMaster = true;
$scope.phpChangedMaster = true;
$scope.couldNotConnect = true;
$scope.changePHPView = true;
$scope.hideChangePHPMaster = function(){
$scope.changePHPView = true;
};
$scope.changePHPMaster = function(){
$scope.hidsslconfigs = true;
$scope.configurationsBox = true;
$scope.configurationsBoxRewrite = true;
$scope.changePHPView = false;
};
$scope.changePHPVersionMaster = function(childDomain,phpSelection){
// notifcations
$scope.configFileLoading = false;
var url = "/websites/changePHP";
var data = {
childDomain:$("#domainNamePage").text(),
phpSelection:$scope.phpSelectionMaster,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.changePHP === 1){
$scope.configFileLoading = true;
$scope.websiteDomain = $("#domainNamePage").text();
// notifcations
$scope.failedToChangePHPMaster = true;
$scope.phpChangedMaster = false;
$scope.couldNotConnect = true;
}
else{
$scope.configFileLoading = true;
$scope.errorMessage = response.data.error_message;
// notifcations
$scope.failedToChangePHPMaster = false;
$scope.phpChangedMaster = true;
$scope.couldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.configFileLoading = true;
// notifcations
$scope.failedToChangePHPMaster = true;
$scope.phpChangedMaster = true;
$scope.couldNotConnect = false;
}
}
////// create domain part
$("#domainCreationForm").hide();

View File

@@ -241,44 +241,43 @@
<div class="example-box-wrapper">
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
<h3 class="content-box-header bg-blue">
<h3 class="content-box-header bg-blue">
{% trans "Domains" %} <img ng-hide="domainLoading" src="/static/images/loading.gif">
</h3>
<div class="content-box-wrapper">
<div class="row">
<div class="content-box-wrapper">
<div class="row">
<div class="col-md-6" style="margin-bottom: 2%;">
<a href="" ng-click="showCreateDomainForm()" title="{% trans 'Add Domains' %}" href="" >
<img src="{% static 'images/icons/domains.png' %}">
</a>
<a ng-click="showCreateDomainForm()" title="{% trans 'Add Domains' %}" href="" title="{% trans 'Add Domains' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Add Domains" %}</span>
</a>
<div class="col-md-6" style="margin-bottom: 2%;">
<a href="" ng-click="showCreateDomainForm()" title="{% trans 'Add Domains' %}" href="" >
<img src="{% static 'images/icons/domains.png' %}">
</a>
<a ng-click="showCreateDomainForm()" title="{% trans 'Add Domains' %}" href="" title="{% trans 'Add Domains' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Add Domains" %}</span>
</a>
</div>
</div>
<div class="col-md-6" style="margin-bottom: 2%;">
<a href="" ng-click="showListDomains()" title="{% trans 'List Domains' %}" href="" title="{% trans 'List Domains' %}">
<img src="{% static 'images/icons/sort.png' %}">
</a>
<a ng-click="showListDomains()" title="{% trans 'List Domains' %}" href="" title="{% trans 'List Domains' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "List Domains" %}</span>
</a>
<div class="col-md-6" style="margin-bottom: 2%;">
<a href="" ng-click="showListDomains()" title="{% trans 'List Domains' %}" href="" title="{% trans 'List Domains' %}">
<img src="{% static 'images/icons/sort.png' %}">
</a>
<a ng-click="showListDomains()" title="{% trans 'List Domains' %}" href="" title="{% trans 'List Domains' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "List Domains" %}</span>
</a>
</div>
</div>
</div>
</div>
<!---------- HTML For creating domains --------------->
<form id="domainCreationForm" name="websiteCreationForm" action="/" class="form-horizontal bordered-row">
<form id="domainCreationForm" name="websiteCreationForm" action="/" class="form-horizontal bordered-row">
@@ -367,13 +366,11 @@
</form>
<!---------- HTML For creating domains --------------->
<!---------- HTML For Listing domains --------------->
<div id="listDomains" class="col-md-12">
<div id="listDomains" class="col-md-12">
<form ng-hide="" class="form-horizontal bordered-row">
@@ -460,10 +457,12 @@
</div>
<!---------- HTML For Listing domains --------------->
</div>
</div>
</div>
</div>
</div>
</div>
<div class="example-box-wrapper">
@@ -475,222 +474,280 @@
<div class="content-box-wrapper">
<div class="row">
<div class="row">
<div class="col-md-3" style="margin-bottom: 2%;">
<div class="col-md-3" style="margin-bottom: 2%;">
<a ng-click="fetchConfigurations()" href="" title="{% trans 'Edit vHost Main Configurations' %}">
<img src="{% static 'images/icons/file.png' %}">
</a>
<a ng-click="fetchConfigurations()" href="" title="{% trans 'Edit vHost Main Configurations' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "vHost Conf" %}</span>
</a>
<a ng-click="fetchConfigurations()" href="" title="{% trans 'Edit vHost Main Configurations' %}">
<img src="{% static 'images/icons/file.png' %}">
</a>
<a ng-click="fetchConfigurations()" href="" title="{% trans 'Edit vHost Main Configurations' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "vHost Conf" %}</span>
</a>
</div>
</div>
<div class="col-md-3" style="margin-bottom: 2%;">
<div class="col-md-3" style="margin-bottom: 2%;">
<a ng-click="fetchRewriteFules()" href="" title="{% trans 'Add Rewrite Rules (.htaccess)' %}">
<img src="{% static 'images/icons/pencilcase.png' %}">
</a>
<a ng-click="fetchRewriteFules()" href="" title="{% trans 'Rewrite Rules (.htaccess)' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Rewrite Rules" %}</span>
</a>
<a ng-click="fetchRewriteFules()" href="" title="{% trans 'Add Rewrite Rules (.htaccess)' %}">
<img src="{% static 'images/icons/pencilcase.png' %}">
</a>
<a ng-click="fetchRewriteFules()" href="" title="{% trans 'Rewrite Rules (.htaccess)' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Rewrite Rules" %}</span>
</a>
</div>
</div>
<div class="col-md-3" style="margin-bottom: 2%;">
<div class="col-md-3" style="margin-bottom: 2%;">
<a ng-click="addSSL()" href="" title="{% trans 'Add Your Own SSL' %}">
<img src="{% static 'images/icons/locked.png' %}">
</a>
<a ng-click="addSSL()" href="" title="{% trans 'Add Your Own SSL' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Add SSL" %}</span>
</a>
<a ng-click="addSSL()" href="" title="{% trans 'Add Your Own SSL' %}">
<img src="{% static 'images/icons/locked.png' %}">
</a>
<a ng-click="addSSL()" href="" title="{% trans 'Add Your Own SSL' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Add SSL" %}</span>
</a>
</div>
</div>
<div class="col-md-3" style="margin-bottom: 2%;">
<div class="col-md-3" style="margin-bottom: 2%;">
<a ng-click="changePHPVersion()" href="" title="{% trans 'Change PHP Version' %}">
<img src="{% static 'images/icons/laptop.png' %}">
</a>
<a ng-click="changePHPVersion()" href="" title="{% trans 'Change PHP Version' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Change PHP" %}</span>
</a>
<a ng-click="changePHPMaster()" href="" title="{% trans 'Change PHP Version' %}">
<img src="{% static 'images/icons/laptop.png' %}">
</a>
<a ng-click="changePHPMaster()" href="" title="{% trans 'Change PHP Version' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Change PHP" %}</span>
</a>
</div>
</div>
<!---- HTML for main ssl file ---->
<!---- HTML for main ssl file ---->
<div class="col-md-12">
<div class="col-md-12">
<form ng-hide="hidsslconfigs" class="form-horizontal bordered-row">
<form ng-hide="hidsslconfigs" class="form-horizontal bordered-row">
<div ng-hide="sslSaved" class="alert alert-success">
<p>{% trans "SSL Saved" %}</p>
<div ng-hide="sslSaved" class="alert alert-success">
<p>{% trans "SSL Saved" %}</p>
</div>
<div ng-hide="couldNotSaveSSL" class="alert alert-danger">
<p>{% trans "Could not save SSL. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hidesslbtn()" href=""><img src="/static/images/close-32.png"></a>
</div>
<div class="col-sm-6">
<textarea placeholder="Paste Your Cert" ng-model="cert" rows="10" class="form-control"></textarea>
</div>
<div class="col-sm-6">
<textarea placeholder="Paste Your Key" ng-model="key" rows="10" class="form-control"></textarea>
</div>
</div>
<div ng-hide="" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveSSL()" class="btn btn-primary btn-lg btn-block">{% trans "Save" %}</button>
</div>
</div>
<div ng-hide="couldNotSaveSSL" class="alert alert-danger">
<p>{% trans "Could not save SSL. Error message:" %} {$ errorMessage $}</p>
</form>
</div>
<!----- HTML For SSL ---->
<!---- HTML for main conf file ---->
<div class="col-md-12">
<form ng-hide="configurationsBox" class="form-horizontal bordered-row">
<div ng-hide="configsFetched" class="alert alert-success">
<p>{% trans "Current configuration in the file fetched." %}</p>
</div>
<div ng-hide="couldNotFetchConfigs" class="alert alert-danger">
<p>{% trans "Could not fetch current configuration. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="configSaved" class="alert alert-success">
<p>{% trans "Configurations saved." %}</p>
</div>
<div ng-hide="couldNotSaveConfigurations" class="alert alert-danger">
<p>{% trans "Could not fetch current configuration. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="fetchedConfigsData" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hideconfigbtn()" href=""><img src="/static/images/close-32.png"></a>
</div>
<div class="col-sm-12">
<textarea ng-model="configData" rows="20" class="form-control"></textarea>
</div>
</div>
<div ng-hide="saveConfigBtn" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveCongiruations()" class="btn btn-primary btn-lg btn-block">{% trans "Save" %}</button>
</div>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</form>
</div>
<!-- HTML For rewrite rules-->
<div class="col-md-12">
<form ng-hide="configurationsBoxRewrite" class="form-horizontal bordered-row">
<div ng-hide="rewriteRulesFetched" class="alert alert-success">
<p>{% trans "Current rewrite rules in the file fetched." %}</p>
</div>
<div ng-hide="couldNotFetchRewriteRules" class="alert alert-danger">
<p>{% trans "Could not fetch current rewrite rules. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="rewriteRulesSaved" class="alert alert-success">
<p>{% trans "Configurations saved." %}</p>
</div>
<div ng-hide="couldNotSaveRewriteRules" class="alert alert-danger">
<p>{% trans "Could not save rewrite rules. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="fetchedRewriteRules" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hideRewriteRulesbtn()" href=""><img src="/static/images/close-32.png"></a>
</div>
<div class="col-sm-12">
<textarea ng-model="rewriteRules" rows="10" class="form-control"></textarea>
</div>
</div>
<div ng-hide="saveRewriteRulesBTN" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveRewriteRules()" class="btn btn-primary btn-lg btn-block">{% trans "Save Rewrite Rules" %}</button>
</div>
</div>
<div ng-hide="" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hidesslbtn()" href=""><img src="/static/images/close-32.png"></a>
</div>
<div class="col-sm-6">
<textarea placeholder="Paste Your Cert" ng-model="cert" rows="10" class="form-control"></textarea>
</div>
<div class="col-sm-6">
<textarea placeholder="Paste Your Key" ng-model="key" rows="10" class="form-control"></textarea>
</div>
</div>
</form>
</div>
<!--- HTML To change PHP --->
<div class="col-md-12">
<form ng-hide="changePHPView" name="" action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select PHP" %}</label>
<div class="col-sm-6">
<select ng-model="phpSelectionMaster" class="form-control">
<option>PHP 5.3</option>
<option>PHP 5.4</option>
<option>PHP 5.5</option>
<option>PHP 5.6</option>
<option>PHP 7.0</option>
<option>PHP 7.1</option>
</select>
</div>
<div style="margin-bottom: 1%;" class=" col-sm-1">
<a title="{% trans 'Cancel' %}" ng-click="hideChangePHPMaster()" href=""><img src="/static/images/close-32.png"></a>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="changePHPVersionMaster()" class="btn btn-primary btn-lg btn-block">{% trans "Change PHP" %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="failedToChangePHPMaster" class="alert alert-danger">
<p>{% trans "Failed to change PHP version. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="phpChangedMaster" class="alert alert-success">
<p>{% trans "PHP successfully changed for: " %} <strong>{$ websiteDomain $}</strong></p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
<div ng-hide="" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveSSL()" class="btn btn-primary btn-lg btn-block">{% trans "Save" %}</button>
</div>
</div>
</form>
</div>
</div>
<!----- HTML For SSL
<!---- HTML for main conf file ---->
<div class="col-md-12">
<form ng-hide="configurationsBox" class="form-horizontal bordered-row">
<div ng-hide="configsFetched" class="alert alert-success">
<p>{% trans "Current configuration in the file fetched." %}</p>
</div>
<div ng-hide="couldNotFetchConfigs" class="alert alert-danger">
<p>{% trans "Could not fetch current configuration. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="configSaved" class="alert alert-success">
<p>{% trans "Configurations saved." %}</p>
</div>
<div ng-hide="couldNotSaveConfigurations" class="alert alert-danger">
<p>{% trans "Could not fetch current configuration. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="fetchedConfigsData" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hideconfigbtn()" href=""><img src="/static/images/close-32.png"></a>
</div>
<div class="col-sm-12">
<textarea ng-model="configData" rows="20" class="form-control"></textarea>
</div>
</div>
<div ng-hide="saveConfigBtn" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveCongiruations()" class="btn btn-primary btn-lg btn-block">{% trans "Save" %}</button>
</div>
</div>
</form>
</div>
<!-- HTML For rewrite rules-->
<div class="col-md-12">
<form ng-hide="configurationsBoxRewrite" class="form-horizontal bordered-row">
<div ng-hide="rewriteRulesFetched" class="alert alert-success">
<p>{% trans "Current rewrite rules in the file fetched." %}</p>
</div>
<div ng-hide="couldNotFetchRewriteRules" class="alert alert-danger">
<p>{% trans "Could not fetch current rewrite rules. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="rewriteRulesSaved" class="alert alert-success">
<p>{% trans "Configurations saved." %}</p>
</div>
<div ng-hide="couldNotSaveRewriteRules" class="alert alert-danger">
<p>{% trans "Could not save rewrite rules. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="fetchedRewriteRules" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hideRewriteRulesbtn()" href=""><img src="/static/images/close-32.png"></a>
</div>
<div class="col-sm-12">
<textarea ng-model="rewriteRules" rows="10" class="form-control"></textarea>
</div>
</div>
<div ng-hide="saveRewriteRulesBTN" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveRewriteRules()" class="btn btn-primary btn-lg btn-block">{% trans "Save Rewrite Rules" %}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@@ -920,7 +977,7 @@
{% else %}
<div class="alert alert-danger">
<div class="alert alert-danger">
<p>{{ domain }}</p>
</div>