mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-07 20:35:57 +02:00
push changes
This commit is contained in:
@@ -12,42 +12,37 @@
|
||||
|
||||
<div class="container">
|
||||
|
||||
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Access Logs" %}</h2>
|
||||
<p>{% trans "Access Logs for main web server." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="readAccessLogs" class="row">
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Last 50 Lines" %} <img ng-hide="logFileLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="col-md-12">
|
||||
|
||||
<form class="form-horizontal bordered-row">
|
||||
<form class="form-horizontal bordered-row panel-body">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="logsData" rows="30" class="form-control">{{ logs }}</textarea>
|
||||
<textarea ng-model="logsData" class="form-control" rows="30">{{ logs }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg my-10">{% trans "Refresh" %}</button>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg my-10">{% trans "Clear Logs" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="logsFeteched" class="alert alert-success">
|
||||
<p>{% trans "Last 50 Lines Fetched" %}</p>
|
||||
</div>
|
||||
@@ -57,14 +52,8 @@
|
||||
<p>{% trans "Could not fetch logs. Use the command line to view the log file." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -74,4 +63,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
<div ng-controller="readEmailLogs" class="row">
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Last 50 Lines" %} <img ng-hide="logFileLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="col-md-12">
|
||||
|
||||
<form class="form-horizontal bordered-row">
|
||||
<form class="form-horizontal bordered-row panel-body">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="logsData" rows="30" class="form-control">{{ logs }}</textarea>
|
||||
<textarea ng-model="logsData" class="form-control" rows="30">{{ logs }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -35,11 +35,11 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg my-10">{% trans "Refresh" %}</button>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg my-10">{% trans "Clear Logs" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,4 +71,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -9,37 +9,33 @@
|
||||
|
||||
<div class="container">
|
||||
|
||||
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Error Logs" %}</h2>
|
||||
<p>{% trans "Error Logs for main web server." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="readErrorLogs" class="row">
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Last 50 Lines" %} <img ng-hide="logFileLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="col-md-12">
|
||||
|
||||
<form class="form-horizontal bordered-row">
|
||||
<form class="form-horizontal bordered-row panel-body">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="logsData" rows="30" class="form-control">{{ logs }}</textarea>
|
||||
<textarea ng-model="logsData" class="form-control" rows="30">{{ logs }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg my-10">{% trans "Refresh" %}</button>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg my-10">{% trans "Clear Logs" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,4 +67,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -9,42 +9,37 @@
|
||||
|
||||
<div class="container">
|
||||
|
||||
|
||||
<div id="page-title">
|
||||
<h2>{% trans "FTP Logs" %}</h2>
|
||||
<p>{% trans "FTP Logs for main web server." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="readFTPLogs" class="row">
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Last 50 Lines" %} <img ng-hide="logFileLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="col-md-12">
|
||||
|
||||
<form class="form-horizontal bordered-row">
|
||||
<form class="form-horizontal bordered-row panel-body">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="logsData" rows="30" class="form-control">{{ logs }}</textarea>
|
||||
<textarea ng-model="logsData" class="form-control" rows="30">{{ logs }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg my-10">{% trans "Refresh" %}</button>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg my-10">{% trans "Clear Logs" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="logsFeteched" class="alert alert-success">
|
||||
<p>{% trans "Last 50 Lines Fetched" %}</p>
|
||||
</div>
|
||||
@@ -68,4 +63,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -3,80 +3,78 @@
|
||||
{% block title %}{% trans "Server Logs - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Server Logs" %}</h2>
|
||||
<p>{% trans "These are the logs from main server, to see logs for your website navigate to: Websites -> List Websites -> Select Website -> View Logs." %}</p>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Available Functions" %}
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Server Logs" %}</h2>
|
||||
<p>{% trans "These are the logs from main server, to see logs for your website navigate to: Websites -> List Websites -> Select Website -> View Logs." %}</p>
|
||||
</div>
|
||||
<div class="panel col-md-12">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Available Functions" %}
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<a href="{% url 'accessLogs' %}" title="{% trans 'Access Logs' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Access Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="glyph-icon icon-dashboard"></i>
|
||||
</div>
|
||||
</a>
|
||||
<div class="row">
|
||||
<div class="col-md-3 btn-min-width">
|
||||
<a href="{% url 'accessLogs' %}" title="{% trans 'Access Logs' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Access Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-key"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-6">
|
||||
<a href="{% url 'errorLogs' %}" title="{% trans 'Error Logs' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Error Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="glyph-icon icon-dashboard"></i>
|
||||
</div>
|
||||
</a>
|
||||
<div class="col-md-3 btn-min-width">
|
||||
<a href="{% url 'errorLogs' %}" title="{% trans 'Error Logs' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Error Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-exclamation"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 btn-min-width">
|
||||
<a href="{% url 'emaillogs' %}" title="{% trans 'Email Logs' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Email Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-envelope"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 btn-min-width">
|
||||
<a href="{% url 'ftplogs' %}" title="{% trans 'FTP Logs' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "FTP Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-upload"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<a href="{% url 'emaillogs' %}" title="{% trans 'Email Logs' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Email Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="glyph-icon icon-dashboard"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-6">
|
||||
<a href="{% url 'ftplogs' %}" title="{% trans 'FTP Logs' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "FTP Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="glyph-icon icon-dashboard"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -15,51 +15,42 @@
|
||||
<p>{% trans "ModSecurity Audit logs" %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="modSecAuditLogs" class="row">
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Last 50 Lines" %} <img ng-hide="logFileLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="col-md-12">
|
||||
|
||||
<form class="form-horizontal bordered-row">
|
||||
<form class="form-horizontal bordered-row panel-body">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="logsData" rows="30" class="form-control">{{ logs }}</textarea>
|
||||
<textarea ng-model="logsData" class="form-control" rows="30">{{ logs }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg my-10">{% trans "Refresh" %}</button>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg my-10">{% trans "Clear Logs" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div ng-hide="logsFeteched" class="alert alert-success">
|
||||
<p>{% trans "Last 50 Lines Fetched" %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="couldNotFetchLogs" class="alert alert-danger">
|
||||
<p>{% trans "Could not fetch logs. Use the command line to view the log file." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -69,4 +60,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -7,33 +7,38 @@ from django.http import HttpResponse
|
||||
import json
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.installUtilities import installUtilities
|
||||
from loginSystem.models import Administrator
|
||||
import subprocess
|
||||
import shlex
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
# Create your views here.
|
||||
|
||||
|
||||
def logsHome(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
return render(request,'serverLogs/index.html')
|
||||
|
||||
|
||||
def accessLogs(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'serverLogs/accessLogs.html')
|
||||
|
||||
@@ -41,15 +46,15 @@ def accessLogs(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def errorLogs(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
|
||||
return render(request,'serverLogs/errorLogs.html')
|
||||
@@ -60,13 +65,13 @@ def errorLogs(request):
|
||||
|
||||
def ftplogs(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'serverLogs/ftplogs.html')
|
||||
|
||||
@@ -76,12 +81,13 @@ def ftplogs(request):
|
||||
|
||||
def emailLogs(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
|
||||
return render(request,'serverLogs/emailLogs.html')
|
||||
@@ -92,13 +98,13 @@ def emailLogs(request):
|
||||
|
||||
def modSecAuditLogs(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'serverLogs/modSecAuditLog.html')
|
||||
|
||||
@@ -106,78 +112,79 @@ def modSecAuditLogs(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getLogsFromFile(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
|
||||
admin = Administrator.objects.get(id=val)
|
||||
|
||||
if admin.type == 1:
|
||||
data = json.loads(request.body)
|
||||
type = data['type']
|
||||
|
||||
if type=="access":
|
||||
fileName = installUtilities.Server_root_path+"/logs/access.log"
|
||||
elif type=="error":
|
||||
fileName = installUtilities.Server_root_path + "/logs/error.log"
|
||||
elif type=="email":
|
||||
fileName="/var/log/maillog"
|
||||
elif type=="ftp":
|
||||
fileName="/var/log/messages"
|
||||
elif type == "modSec":
|
||||
fileName = "/usr/local/lsws/logs/auditmodsec.log"
|
||||
|
||||
|
||||
command = "sudo tail -50 " + fileName
|
||||
|
||||
fewLinesOfLogFile = subprocess.check_output(shlex.split(command))
|
||||
|
||||
status = {"logstatus":1,"logsdata":fewLinesOfLogFile}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
status = {"logstatus": 0, 'error': "You don't have enough privileges to access this page."}
|
||||
return ACLManager.loadErrorJson('logstatus', 0)
|
||||
|
||||
data = json.loads(request.body)
|
||||
type = data['type']
|
||||
|
||||
if type == "access":
|
||||
fileName = installUtilities.Server_root_path + "/logs/access.log"
|
||||
elif type == "error":
|
||||
fileName = installUtilities.Server_root_path + "/logs/error.log"
|
||||
elif type == "email":
|
||||
fileName = "/var/log/maillog"
|
||||
elif type == "ftp":
|
||||
fileName = "/var/log/messages"
|
||||
elif type == "modSec":
|
||||
fileName = "/usr/local/lsws/logs/auditmodsec.log"
|
||||
elif type == "cyberpanel":
|
||||
fileName = "/home/cyberpanel/error-logs.txt"
|
||||
|
||||
try:
|
||||
command = "sudo tail -50 " + fileName
|
||||
fewLinesOfLogFile = ProcessUtilities.outputExecutioner(command)
|
||||
status = {"status": 1, "logstatus": 1, "logsdata": fewLinesOfLogFile}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
except:
|
||||
status = {"status": 1, "logstatus": 1, "logsdata": 'Emtpy File.'}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
except KeyError, msg:
|
||||
status = {"logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."}
|
||||
status = {"status": 0, "logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getLogsFromFile]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def clearLogFile(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('cleanStatus', 0)
|
||||
|
||||
try:
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
if request.method == 'POST':
|
||||
|
||||
data = json.loads(request.body)
|
||||
data = json.loads(request.body)
|
||||
|
||||
fileName = data['fileName']
|
||||
fileName = data['fileName']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/serverLogs.py"
|
||||
execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/serverLogs.py"
|
||||
execPath = execPath + " cleanLogFile --fileName " + fileName
|
||||
|
||||
execPath = execPath + " cleanLogFile --fileName " + fileName
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'cleanStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'cleanStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'cleanStatus': 0, 'error_message': 'Not enough privileges.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'cleanStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'cleanStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'cleanStatus': 0, 'error_message': str(msg)}
|
||||
|
||||
Reference in New Issue
Block a user