make access log fetch compatible with Michael commit

This commit is contained in:
Usman Nasir
2020-02-03 17:30:24 +05:00
parent 0d6b7a9c4c
commit 829c8c8b59
4 changed files with 12 additions and 12 deletions

View File

@@ -297,10 +297,10 @@ class virtualHostUtilities:
print("0, %s file is symlinked." % (fileName)) print("0, %s file is symlinked." % (fileName))
return 0 return 0
numberOfTotalLines = int(ProcessUtilities.outputExecutioner('wc -l %s' % (fileName), externalApp).split(" ")[0]) numberOfTotalLines = int(ProcessUtilities.outputExecutioner('wc -l %s' % (fileName), 'nobody').split(" ")[0])
if numberOfTotalLines < 25: if numberOfTotalLines < 25:
data = ProcessUtilities.outputExecutioner('cat %s' % (fileName), externalApp) data = ProcessUtilities.outputExecutioner('cat %s' % (fileName), 'nobody')
else: else:
if page == 1: if page == 1:
end = numberOfTotalLines end = numberOfTotalLines
@@ -309,7 +309,7 @@ class virtualHostUtilities:
start = 1 start = 1
startingAndEnding = "'" + str(start) + "," + str(end) + "p'" startingAndEnding = "'" + str(start) + "," + str(end) + "p'"
command = "sed -n " + startingAndEnding + " " + fileName command = "sed -n " + startingAndEnding + " " + fileName
data = ProcessUtilities.outputExecutioner(command, externalApp) data = ProcessUtilities.outputExecutioner(command, 'nobody')
else: else:
end = numberOfTotalLines - ((page - 1) * 25) end = numberOfTotalLines - ((page - 1) * 25)
start = end - 24 start = end - 24
@@ -317,7 +317,7 @@ class virtualHostUtilities:
start = 1 start = 1
startingAndEnding = "'" + str(start) + "," + str(end) + "p'" startingAndEnding = "'" + str(start) + "," + str(end) + "p'"
command = "sed -n " + startingAndEnding + " " + fileName command = "sed -n " + startingAndEnding + " " + fileName
data = ProcessUtilities.outputExecutioner(command, externalApp) data = ProcessUtilities.outputExecutioner(command, 'nobody')
print(data) print(data)
return data return data
except BaseException as msg: except BaseException as msg:

View File

@@ -194,7 +194,7 @@
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th>Domain</th> <th>Type</th>
<th>IP Address</th> <th>IP Address</th>
<th>Time</th> <th>Time</th>
<th>Resource</th> <th>Resource</th>

View File

@@ -176,7 +176,7 @@
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th>Domain</th> <th>Type</th>
<th>IP Address</th> <th>IP Address</th>
<th>Time</th> <th>Time</th>
<th>Resource</th> <th>Resource</th>

View File

@@ -1004,7 +1004,7 @@ class WebsiteManager:
if output.find("1,None") > -1: if output.find("1,None") > -1:
final_json = json.dumps( final_json = json.dumps(
{'status': 0, 'logstatus': 0, 'error_message': "Not able to fetch logs, see CyberPanel main log file!"}) {'status': 0, 'logstatus': 0, 'error_message': "Not able to fetch logs, see CyberPanel main log file, Error: %s" % (output)})
return HttpResponse(final_json) return HttpResponse(final_json)
## get log ends here. ## get log ends here.
@@ -1017,11 +1017,11 @@ class WebsiteManager:
for items in reversed(data): for items in reversed(data):
if len(items) > 10: if len(items) > 10:
logData = items.split(" ") logData = items.split(" ")
domain = logData[0].strip('"') domain = logData[5].strip('"')
ipAddress = logData[1] ipAddress = logData[0].strip('"')
time = (logData[4]).strip("[").strip("]") time = (logData[3]).strip("[").strip("]")
resource = logData[7].strip('"') resource = logData[6].strip('"')
size = logData[10].replace('"', '') size = logData[9].replace('"', '')
dic = {'domain': domain, dic = {'domain': domain,
'ipAddress': ipAddress, 'ipAddress': ipAddress,