mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
Download files via Filemanager, post_max_size added to PHP Basic!
This commit is contained in:
@@ -350,7 +350,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
<td>26KB</td>
|
||||
<td>26 Oct</td>
|
||||
<td>775</td>
|
||||
<td>Folder/File</td>
|
||||
</tr>
|
||||
|
||||
*/
|
||||
|
||||
function createTR(fileName,fileSize,lastModified,permissions,dirCheck){
|
||||
@@ -381,6 +383,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
var secondTDNode = document.createElement('td');
|
||||
var thirdTDNode = document.createElement('td');
|
||||
var forthTDNode = document.createElement('td');
|
||||
var fifthTDNode = document.createElement('td');
|
||||
|
||||
fifthTDNode.style.display = "none";
|
||||
|
||||
//
|
||||
|
||||
@@ -405,18 +410,29 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
trNode.addEventListener("dblclick", function(){ $scope.fetchForTableSecondary(firstTDNode,"doubleClick");});
|
||||
trNode.addEventListener("click", function(){ addFileOrFolderToList(trNode);});
|
||||
trNode.addEventListener("contextmenu", function(event){$scope.rightClickCallBack(event,trNode);});
|
||||
|
||||
// Hidden td to represent file or folder
|
||||
|
||||
var fileOrFolderNode = document.createTextNode("Folder");
|
||||
fifthTDNode.appendChild(fileOrFolderNode)
|
||||
}
|
||||
else{
|
||||
thNode.appendChild(iNodeFile);
|
||||
trNode.appendChild(thNode);
|
||||
trNode.addEventListener("click", function(){ addFileOrFolderToList(trNode);});
|
||||
trNode.addEventListener("contextmenu", function(event){ $scope.rightClickCallBack(event,trNode); });
|
||||
|
||||
// Hidden td to represent file or folder
|
||||
|
||||
var fileOrFolderNode = document.createTextNode("File");
|
||||
fifthTDNode.appendChild(fileOrFolderNode)
|
||||
}
|
||||
|
||||
trNode.appendChild(firstTDNode);
|
||||
trNode.appendChild(secondTDNode);
|
||||
trNode.appendChild(thirdTDNode);
|
||||
trNode.appendChild(forthTDNode);
|
||||
trNode.appendChild(fifthTDNode);
|
||||
|
||||
return trNode;
|
||||
|
||||
@@ -1131,7 +1147,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
|
||||
// right click settings
|
||||
|
||||
var rightClickNode = document.getElementById("rightClick")
|
||||
var rightClickNode = document.getElementById("rightClick");
|
||||
rightClickNode.style.display = "none";
|
||||
|
||||
$scope.rightClickCallBack = function (event,trNode) {
|
||||
@@ -1146,6 +1162,19 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
'left': event.pageX
|
||||
});
|
||||
|
||||
// If we want to enable download for this node
|
||||
|
||||
var downloadOnRight = document.getElementById("downloadOnRight");
|
||||
|
||||
if(trNode.lastChild.innerHTML === "File"){
|
||||
downloadOnRight.style.display = "Block";
|
||||
}else{
|
||||
downloadOnRight.style.display = "none";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$scope.addFileOrFolderToListForRightClick(trNode);
|
||||
}
|
||||
|
||||
@@ -1154,7 +1183,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
var check = 1;
|
||||
var getFileName = nodeName.getElementsByTagName('td')[0].innerHTML;
|
||||
|
||||
if(nodeName.style.backgroundColor == "aliceblue") {
|
||||
if(nodeName.style.backgroundColor === "aliceblue") {
|
||||
|
||||
var tempArray = [];
|
||||
nodeName.style.background = "None";
|
||||
@@ -1236,7 +1265,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
};
|
||||
|
||||
|
||||
// fix permissions
|
||||
// Fix permissions
|
||||
|
||||
$scope.fixPermissions = function() {
|
||||
|
||||
@@ -1248,7 +1277,6 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
@@ -1270,6 +1298,50 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
|
||||
};
|
||||
|
||||
// Download files
|
||||
|
||||
$scope.downloadFile = function() {
|
||||
|
||||
url = "/filemanager/downloadFile";
|
||||
|
||||
var data = {
|
||||
fileToDownload: $scope.currentPath + "/" + allFilesAndFolders[0]
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
var blob = new Blob([response.data]);
|
||||
|
||||
//IE case
|
||||
if (!!window.navigator.msSaveBlob){
|
||||
window.navigator.msSaveBlob(blob, allFilesAndFolders[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
//create blob and url
|
||||
var url = URL.createObjectURL(blob);
|
||||
|
||||
//create invisible acnhor, to specify the file name
|
||||
var a = document.createElement('a');
|
||||
document.body.appendChild(a);
|
||||
a.style = "display: none";
|
||||
a.href = url;
|
||||
a.download = allFilesAndFolders[0];
|
||||
a.click();
|
||||
|
||||
setTimeout(function(){
|
||||
URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -634,6 +634,7 @@
|
||||
<div style="position: absolute;top: 0;left: 0;" id="rightClick" class="card" style="width: 20rem;">
|
||||
<ul class="list-group list-group-flush">
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showMoveModal()" href="#"><li class="list-group-item"><i class="fa fa-arrows-alt" aria-hidden="true"></i> Move</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" id="downloadOnRight" onclick="return false;" ng-click="downloadFile()" href="#"><li class="list-group-item"><i class="fa fa-download" aria-hidden="true"></i> Download</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showCopyModal()" href="#"><li class="list-group-item"><i class="fa fa-files-o" aria-hidden="true"></i> Copy</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showRenameModal()" href="#"><li class="list-group-item"><i class="fa fa-file-text-o" aria-hidden="true"></i> Rename</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showDeleteModal()" href="#"><li class="list-group-item"><i class="fa fa-trash" aria-hidden="true"></i> Delete</li></a>
|
||||
|
||||
@@ -4,6 +4,7 @@ import views
|
||||
urlpatterns = [
|
||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)$', views.loadFileManagerHome, name='loadFileManagerHome'),
|
||||
url(r'^changePermissions',views.changePermissions, name='changePermissions'),
|
||||
url(r'^downloadFile',views.downloadFile, name='downloadFile'),
|
||||
|
||||
]
|
||||
|
||||
|
||||
@@ -5,11 +5,12 @@ from django.shortcuts import render,redirect
|
||||
from loginSystem.models import Administrator
|
||||
from loginSystem.views import loadLoginPage
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponse,Http404
|
||||
import json
|
||||
from websiteFunctions.models import Websites
|
||||
import subprocess
|
||||
import shlex
|
||||
import os
|
||||
|
||||
# Create your views here.
|
||||
|
||||
@@ -59,3 +60,18 @@ def changePermissions(request):
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def downloadFile(request):
|
||||
data = json.loads(request.body)
|
||||
fileToDownload = data['fileToDownload']
|
||||
|
||||
response = ''
|
||||
if os.path.isfile(fileToDownload):
|
||||
try:
|
||||
with open(fileToDownload, 'rb') as f:
|
||||
response = HttpResponse(f.read(), content_type="application/octet-stream")
|
||||
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(fileToDownload)
|
||||
except Exception as e:
|
||||
raise Http404
|
||||
|
||||
return response
|
||||
@@ -362,6 +362,7 @@ app.controller('editPHPConfig', function($scope,$http,$timeout) {
|
||||
$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;
|
||||
|
||||
$scope.phpDetailsBox = false;
|
||||
|
||||
@@ -407,6 +408,7 @@ app.controller('editPHPConfig', function($scope,$http,$timeout) {
|
||||
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,
|
||||
};
|
||||
|
||||
var config = {
|
||||
@@ -423,7 +425,7 @@ app.controller('editPHPConfig', function($scope,$http,$timeout) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.saveStatus == 1){
|
||||
if(response.data.saveStatus === 1){
|
||||
|
||||
$scope.detailsSaved = false;
|
||||
$scope.loadingPHP = true;
|
||||
|
||||
@@ -114,6 +114,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="phpDetailsBox" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "post_max_size" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input ng-model="post_max_size" type="text" class="form-control" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="phpDetailsBox" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "max_input_time" %}</label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
@@ -2000,6 +2000,8 @@ def getCurrentPHPConfig(request):
|
||||
upload_max_filesize = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("max_input_time")>-1 and items.find("=")>-1:
|
||||
max_input_time = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("post_max_size") > -1 and items.find("=") > -1:
|
||||
post_max_size = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
|
||||
|
||||
|
||||
@@ -2011,7 +2013,8 @@ def getCurrentPHPConfig(request):
|
||||
'memory_limit': memory_limit,
|
||||
'max_execution_time': max_execution_time,
|
||||
'upload_max_filesize': upload_max_filesize,
|
||||
'max_input_time': max_input_time}
|
||||
'max_input_time': max_input_time,
|
||||
'post_max_size':post_max_size}
|
||||
|
||||
final_json = json.dumps(final_dic)
|
||||
|
||||
@@ -2046,6 +2049,7 @@ def savePHPConfigBasic(request):
|
||||
max_execution_time = data['max_execution_time']
|
||||
upload_max_filesize = data['upload_max_filesize']
|
||||
max_input_time = data['max_input_time']
|
||||
post_max_size = data['post_max_size']
|
||||
|
||||
if allow_url_fopen == True:
|
||||
allow_url_fopen = "allow_url_fopen = On"
|
||||
@@ -2086,7 +2090,7 @@ def savePHPConfigBasic(request):
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
|
||||
execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen + "' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" + allow_url_include + "' --memory_limit " + memory_limit+ " --max_execution_time " + max_execution_time + " --upload_max_filesize " + upload_max_filesize + " --max_input_time " + max_input_time
|
||||
execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen + "' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" + allow_url_include + "' --memory_limit " + memory_limit+ " --max_execution_time " + max_execution_time + " --upload_max_filesize " + upload_max_filesize + " --max_input_time " + max_input_time + " --post_max_size " + post_max_size
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class phpUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]")
|
||||
|
||||
@staticmethod
|
||||
def savePHPConfigBasic(phpVers,allow_url_fopen,display_errors,file_uploads,allow_url_include,memory_limit,max_execution_time,upload_max_filesize,max_input_time):
|
||||
def savePHPConfigBasic(phpVers,allow_url_fopen,display_errors,file_uploads,allow_url_include,memory_limit,max_execution_time,upload_max_filesize,max_input_time,post_max_size):
|
||||
try:
|
||||
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
@@ -109,6 +109,8 @@ class phpUtilities:
|
||||
|
||||
elif items.find("max_input_time") > -1 and items.find("=") > -1:
|
||||
writeToFile.writelines("max_input_time = " + max_input_time + "\n")
|
||||
elif items.find("post_max_size") > -1 and items.find("=") > -1:
|
||||
writeToFile.writelines("post_max_size = " + post_max_size + "\n")
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
@@ -155,6 +157,7 @@ def main():
|
||||
parser.add_argument("--max_execution_time", help="Memory Hard Limit (bytes) for PHP!")
|
||||
parser.add_argument("--upload_max_filesize", help="Process Soft Limit for PHP!")
|
||||
parser.add_argument("--max_input_time", help="Process Hard Limit for PHP!")
|
||||
parser.add_argument("--post_max_size", help="Process Hard Limit for PHP!")
|
||||
|
||||
## Litespeed Tuning Arguments
|
||||
|
||||
@@ -165,7 +168,7 @@ def main():
|
||||
|
||||
if args.function == "savePHPConfigBasic":
|
||||
phpUtilities.savePHPConfigBasic(args.phpVers, args.allow_url_fopen, args.display_errors, args.file_uploads, args.allow_url_include, args.memory_limit,
|
||||
args.max_execution_time, args.upload_max_filesize, args.max_input_time)
|
||||
args.max_execution_time, args.upload_max_filesize, args.max_input_time, args.post_max_size)
|
||||
elif args.function == "savePHPConfigAdvance":
|
||||
phpUtilities.savePHPConfigAdvance(args.phpVers, args.tempPath)
|
||||
|
||||
|
||||
@@ -350,7 +350,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
<td>26KB</td>
|
||||
<td>26 Oct</td>
|
||||
<td>775</td>
|
||||
<td>Folder/File</td>
|
||||
</tr>
|
||||
|
||||
*/
|
||||
|
||||
function createTR(fileName,fileSize,lastModified,permissions,dirCheck){
|
||||
@@ -381,6 +383,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
var secondTDNode = document.createElement('td');
|
||||
var thirdTDNode = document.createElement('td');
|
||||
var forthTDNode = document.createElement('td');
|
||||
var fifthTDNode = document.createElement('td');
|
||||
|
||||
fifthTDNode.style.display = "none";
|
||||
|
||||
//
|
||||
|
||||
@@ -405,18 +410,29 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
trNode.addEventListener("dblclick", function(){ $scope.fetchForTableSecondary(firstTDNode,"doubleClick");});
|
||||
trNode.addEventListener("click", function(){ addFileOrFolderToList(trNode);});
|
||||
trNode.addEventListener("contextmenu", function(event){$scope.rightClickCallBack(event,trNode);});
|
||||
|
||||
// Hidden td to represent file or folder
|
||||
|
||||
var fileOrFolderNode = document.createTextNode("Folder");
|
||||
fifthTDNode.appendChild(fileOrFolderNode)
|
||||
}
|
||||
else{
|
||||
thNode.appendChild(iNodeFile);
|
||||
trNode.appendChild(thNode);
|
||||
trNode.addEventListener("click", function(){ addFileOrFolderToList(trNode);});
|
||||
trNode.addEventListener("contextmenu", function(event){ $scope.rightClickCallBack(event,trNode); });
|
||||
|
||||
// Hidden td to represent file or folder
|
||||
|
||||
var fileOrFolderNode = document.createTextNode("File");
|
||||
fifthTDNode.appendChild(fileOrFolderNode)
|
||||
}
|
||||
|
||||
trNode.appendChild(firstTDNode);
|
||||
trNode.appendChild(secondTDNode);
|
||||
trNode.appendChild(thirdTDNode);
|
||||
trNode.appendChild(forthTDNode);
|
||||
trNode.appendChild(fifthTDNode);
|
||||
|
||||
return trNode;
|
||||
|
||||
@@ -1131,7 +1147,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
|
||||
// right click settings
|
||||
|
||||
var rightClickNode = document.getElementById("rightClick")
|
||||
var rightClickNode = document.getElementById("rightClick");
|
||||
rightClickNode.style.display = "none";
|
||||
|
||||
$scope.rightClickCallBack = function (event,trNode) {
|
||||
@@ -1146,6 +1162,19 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
'left': event.pageX
|
||||
});
|
||||
|
||||
// If we want to enable download for this node
|
||||
|
||||
var downloadOnRight = document.getElementById("downloadOnRight");
|
||||
|
||||
if(trNode.lastChild.innerHTML === "File"){
|
||||
downloadOnRight.style.display = "Block";
|
||||
}else{
|
||||
downloadOnRight.style.display = "none";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$scope.addFileOrFolderToListForRightClick(trNode);
|
||||
}
|
||||
|
||||
@@ -1154,7 +1183,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
var check = 1;
|
||||
var getFileName = nodeName.getElementsByTagName('td')[0].innerHTML;
|
||||
|
||||
if(nodeName.style.backgroundColor == "aliceblue") {
|
||||
if(nodeName.style.backgroundColor === "aliceblue") {
|
||||
|
||||
var tempArray = [];
|
||||
nodeName.style.background = "None";
|
||||
@@ -1236,7 +1265,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
};
|
||||
|
||||
|
||||
// fix permissions
|
||||
// Fix permissions
|
||||
|
||||
$scope.fixPermissions = function() {
|
||||
|
||||
@@ -1248,7 +1277,6 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
@@ -1270,6 +1298,50 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
|
||||
|
||||
};
|
||||
|
||||
// Download files
|
||||
|
||||
$scope.downloadFile = function() {
|
||||
|
||||
url = "/filemanager/downloadFile";
|
||||
|
||||
var data = {
|
||||
fileToDownload: $scope.currentPath + "/" + allFilesAndFolders[0]
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
var blob = new Blob([response.data]);
|
||||
|
||||
//IE case
|
||||
if (!!window.navigator.msSaveBlob){
|
||||
window.navigator.msSaveBlob(blob, allFilesAndFolders[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
//create blob and url
|
||||
var url = URL.createObjectURL(blob);
|
||||
|
||||
//create invisible acnhor, to specify the file name
|
||||
var a = document.createElement('a');
|
||||
document.body.appendChild(a);
|
||||
a.style = "display: none";
|
||||
a.href = url;
|
||||
a.download = allFilesAndFolders[0];
|
||||
a.click();
|
||||
|
||||
setTimeout(function(){
|
||||
URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -362,6 +362,7 @@ app.controller('editPHPConfig', function($scope,$http,$timeout) {
|
||||
$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;
|
||||
|
||||
$scope.phpDetailsBox = false;
|
||||
|
||||
@@ -407,6 +408,7 @@ app.controller('editPHPConfig', function($scope,$http,$timeout) {
|
||||
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,
|
||||
};
|
||||
|
||||
var config = {
|
||||
@@ -423,7 +425,7 @@ app.controller('editPHPConfig', function($scope,$http,$timeout) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.saveStatus == 1){
|
||||
if(response.data.saveStatus === 1){
|
||||
|
||||
$scope.detailsSaved = false;
|
||||
$scope.loadingPHP = true;
|
||||
|
||||
Reference in New Issue
Block a user