Files
CyberPanel/static/managePHP/managePHP.js

562 lines
13 KiB
JavaScript
Raw Normal View History

2017-10-24 19:16:36 +05:00
/**
* Created by usman on 9/20/17.
*/
2019-06-08 21:41:43 +00:00
app.controller('installExtensions', function ($scope, $http, $timeout) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var size = 0;
var extName = '';
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.availableExtensions = true;
$scope.loadingExtensions = true;
$scope.canNotFetch = true;
$scope.couldNotConnect = true;
$scope.phpSelectionDisabled = false;
$scope.request = true;
$scope.canNotPerform = true;
$scope.goback = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.fetchPHPDetails = function () {
$scope.loadingExtensions = false;
$scope.phpSelectionDisabled = false;
populateCurrentRecords();
$scope.request = true;
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.installExt = function (extensionName) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
extName = extensionName;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.phpSelectionDisabled = true;
$scope.requestData = "";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.loadingExtensions = false;
$scope.availableExtensions = true;
$scope.request = false;
$scope.goback = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
url = "/managephp/submitExtensionRequest";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var data = {
extensionName: extensionName,
type: "install"
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.extensionRequestStatus === 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
getRequestStatus();
$scope.canNotPerform = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
else {
$scope.canNotPerform = false;
$scope.errorMessage = response.data.error_message;
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.canNotFetch = true;
$scope.couldNotConnect = false;
$scope.canNotPerform = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.uninstallExt = function (extensionName) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
extName = extensionName;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.phpSelectionDisabled = true;
$scope.requestData = "";
$scope.goback = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.loadingExtensions = false;
$scope.availableExtensions = true;
$scope.request = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
url = "/managephp/submitExtensionRequest";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var data = {
extensionName: extensionName,
type: "uninstall"
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.extensionRequestStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
getRequestStatus();
$scope.canNotPerform = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
else {
$scope.canNotPerform = false;
$scope.errorMessage = response.data.error_message;
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.canNotFetch = true;
$scope.couldNotConnect = false;
$scope.canNotPerform = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function populateCurrentRecords() {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var phpSelection = $scope.phpSelection;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
url = "/managephp/getExtensionsInformation";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var data = {
phpSelection: phpSelection,
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.fetchStatus === 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.records = JSON.parse(response.data.data);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.availableExtensions = false;
$scope.loadingExtensions = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.canNotFetch = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
else {
$scope.errorMessage = response.data.error_message;
$scope.canNotFetch = false;
$scope.couldNotConnect = true;
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.canNotFetch = true;
$scope.couldNotConnect = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function getRequestStatus() {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
url = "/managephp/getRequestStatus";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var data = {
size: size,
extensionName: extName,
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.extensionRequestStatus === 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.finished === 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.loadingExtensions = true;
$scope.phpSelectionDisabled = false;
$scope.requestData = response.data.requestStatus;
$scope.goback = false;
$timeout.cancel();
2017-10-24 19:16:36 +05:00
}
2019-06-08 21:41:43 +00:00
else {
size = Number(response.data.size);
$scope.requestData = response.data.requestStatus;
$timeout(getRequestStatus, 1000);
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
else {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.canNotFetch = true;
$scope.couldNotConnect = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
});
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
app.controller('editPHPConfig', function ($scope, $http, $timeout) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.loadingPHP = true;
$scope.canNotFetch = true;
$scope.phpDetailsBox = true;
$scope.couldNotConnect = true;
$scope.detailsSaved = true;
$scope.savebtn = true;
$scope.configDataView = true;
$scope.canNotFetchAdvanced = true;
$scope.detailsSavedAdvanced = true;
$scope.savebtnAdvance = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var allow_url_fopen = false;
var display_errors = false;
var file_uploads = false;
var allow_url_include = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$('#allow_url_fopen').change(function () {
allow_url_fopen = $(this).prop('checked');
});
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$('#display_errors').change(function () {
display_errors = $(this).prop('checked');
});
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$('#file_uploads').change(function () {
file_uploads = $(this).prop('checked');
});
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$('#allow_url_include').change(function () {
allow_url_include = $(this).prop('checked');
});
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.fetchPHPDetails = function () {
$scope.loadingPHP = false;
$scope.canNotFetch = true;
$scope.detailsSaved = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$('#allow_url_fopen').bootstrapToggle('off');
$('#display_errors').bootstrapToggle('off');
$('#file_uploads').bootstrapToggle('off');
$('#allow_url_include').bootstrapToggle('off');
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
url = "/managephp/getCurrentPHPConfig";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var phpSelection = $scope.phpSelection;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var data = {
phpSelection: phpSelection,
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.fetchStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.savebtn = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.allow_url_fopen === "1") {
$('#allow_url_fopen').bootstrapToggle('on');
}
if (response.data.display_errors === "1") {
$('#display_errors').bootstrapToggle('on');
}
if (response.data.file_uploads === "1") {
$('#file_uploads').bootstrapToggle('on');
}
if (response.data.allow_url_include === "1") {
$('#allow_url_include').bootstrapToggle('on');
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.loadingPHP = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.memory_limit = response.data.memory_limit;
$scope.max_execution_time = response.data.max_execution_time;
$scope.upload_max_filesize = response.data.upload_max_filesize;
$scope.max_input_time = response.data.max_input_time;
$scope.post_max_size = response.data.post_max_size;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.phpDetailsBox = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
else {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.errorMessage = response.data.error_message;
$scope.canNotFetch = false;
$scope.loadingPHP = true;
$scope.phpDetailsBox = true;
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.couldNotConnect = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.saveChanges = function () {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.loadingPHP = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var phpSelection = $scope.phpSelection;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
url = "/managephp/savePHPConfigBasic";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var data = {
phpSelection: phpSelection,
allow_url_fopen: allow_url_fopen,
display_errors: display_errors,
file_uploads: file_uploads,
allow_url_include: allow_url_include,
memory_limit: $scope.memory_limit,
max_execution_time: $scope.max_execution_time,
upload_max_filesize: $scope.upload_max_filesize,
max_input_time: $scope.max_input_time,
post_max_size: $scope.post_max_size,
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.saveStatus === 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.detailsSaved = false;
$scope.loadingPHP = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
else {
$scope.errorMessage = response.data.error_message;
$scope.canNotFetch = false;
$scope.couldNotConnect = true;
$scope.loadingPHP = true;
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.canNotFetch = true;
$scope.couldNotConnect = false;
$scope.loadingPHP = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.fetchAdvancePHPDetails = function () {
$scope.loadingPHP = false;
$scope.savebtnAdvance = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
url = "/managephp/getCurrentAdvancedPHPConfig";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var phpSelection = $scope.phpSelection;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var data = {
phpSelection: phpSelection,
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.fetchStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.configDataView = false;
$scope.configData = response.data.configData;
$scope.loadingPHP = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.canNotFetchAdvanced = true;
$scope.detailsSavedAdvanced = true;
$scope.savebtnAdvance = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
else {
$scope.canNotFetchAdvanced = false;
$scope.detailsSavedAdvanced = true;
$scope.loadingPHP = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.errorMessage = response.data.error_message;
$scope.configDataView = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.couldNotConnect = false;
$scope.loadingPHP = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.saveChangesAdvance = function () {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.loadingPHP = false;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var phpSelection = $scope.phpSelection;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
url = "/managephp/savePHPConfigAdvance";
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var data = {
phpSelection: phpSelection,
configData: $scope.configData,
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
if (response.data.saveStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
$scope.detailsSavedAdvanced = false;
$scope.loadingPHP = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
else {
$scope.errorMessage = response.data.error_message;
$scope.canNotFetchAdvanced = false;
$scope.couldNotConnect = true;
$scope.loadingPHP = true;
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = false;
$scope.canNotFetchAdvanced = true;
$scope.couldNotConnect = true;
$scope.loadingPHP = true;
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
}
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
};
2017-10-24 19:16:36 +05:00
});