mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 14:26:16 +01:00
switchoff security DOne Frontend
This commit is contained in:
@@ -204,19 +204,19 @@
|
|||||||
|
|
||||||
<div ng-controller="loadAvg" id="header-nav-right">
|
<div ng-controller="loadAvg" id="header-nav-right">
|
||||||
{% comment %}<a class="hide-on-phone hdr-btn" style="background-color: unset;width: 33px" href="#"
|
{% comment %}<a class="hide-on-phone hdr-btn" style="background-color: unset;width: 33px" href="#"
|
||||||
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
||||||
<span class="badge bg-red" id="load1">{$ one $}</span>
|
<span class="badge bg-red" id="load1">{$ one $}</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="hide-on-phone hdr-btn" style="background-color: unset;width: 33px" href="#"
|
<a class="hide-on-phone hdr-btn" style="background-color: unset;width: 33px" href="#"
|
||||||
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
||||||
<span class="badge bg-red" id="load2">{$ two $}</span>
|
<span class="badge bg-red" id="load2">{$ two $}</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="hide-on-phone hdr-btn" style="background-color: unset;width: 33px" href="#"
|
<a class="hide-on-phone hdr-btn" style="background-color: unset;width: 33px" href="#"
|
||||||
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
||||||
<span class="badge bg-red" id="load3">{$ three $}</span>
|
<span class="badge bg-red" id="load3">{$ three $}</span>
|
||||||
</a>{% endcomment %}
|
</a>{% endcomment %}
|
||||||
<a class="header-btn" target="_blank"
|
<a class="header-btn" target="_blank"
|
||||||
href="https://www.youtube.com/channel/UCS6sgUWEhaFl1TO238Ck0xw?sub_confirmation=1"
|
href="https://www.youtube.com/channel/UCS6sgUWEhaFl1TO238Ck0xw?sub_confirmation=1"
|
||||||
title="{% trans 'Youtube Channel' %}">
|
title="{% trans 'Youtube Channel' %}">
|
||||||
@@ -947,6 +947,9 @@
|
|||||||
<li><a href="{% url 'packageManager' %}"
|
<li><a href="{% url 'packageManager' %}"
|
||||||
title="{% trans 'Package Manager' %}"><span>{% trans "Package Manager" %}</span></a>
|
title="{% trans 'Package Manager' %}"><span>{% trans "Package Manager" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
|
<li><a href="{% url 'Switchoffsecurity' %}"
|
||||||
|
title="{% trans 'Switch off security' %}"><span>{% trans "Switch off security" %}</span></a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div><!-- .sidebar-submenu -->
|
</div><!-- .sidebar-submenu -->
|
||||||
@@ -1057,12 +1060,12 @@
|
|||||||
<li><a href="{% url 'mailQueue' %}"
|
<li><a href="{% url 'mailQueue' %}"
|
||||||
title="{% trans 'Mail Queue' %}"><span>{% trans "Mail Queue" %}</span></a>
|
title="{% trans 'Mail Queue' %}"><span>{% trans "Mail Queue" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
{# <li><a href="{% url 'emailPolicyServer' %}"#}
|
{# <li><a href="{% url 'emailPolicyServer' %}"#}
|
||||||
{# title="{% trans 'Email Policy Server' %}"><span>{% trans "Email Policy Server" %}</span></a>#}
|
{# title="{% trans 'Email Policy Server' %}"><span>{% trans "Email Policy Server" %}</span></a>#}
|
||||||
{# </li>#}
|
{# </li>#}
|
||||||
{# <li><a href="{% url 'listDomains' %}"#}
|
{# <li><a href="{% url 'listDomains' %}"#}
|
||||||
{# title="{% trans 'Email Limits' %}"><span>{% trans "Email Limits" %}</span></a>#}
|
{# title="{% trans 'Email Limits' %}"><span>{% trans "Email Limits" %}</span></a>#}
|
||||||
{# </li>#}
|
{# </li>#}
|
||||||
<li><a href="{% url 'SpamAssassin' %}"
|
<li><a href="{% url 'SpamAssassin' %}"
|
||||||
title="{% trans 'SpamAssassin Configurations' %}"><span>{% trans "SpamAssassin" %}</span></a>
|
title="{% trans 'SpamAssassin Configurations' %}"><span>{% trans "SpamAssassin" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Java script code to start/stop litespeed */
|
/* Java script code to start/stop litespeed */
|
||||||
app.controller('litespeedStatus', function ($scope, $http) {
|
app.controller('litespeedStatus', function ($scope, $http) {
|
||||||
|
|
||||||
@@ -424,6 +423,87 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
|
|||||||
|
|
||||||
/* Services */
|
/* Services */
|
||||||
|
|
||||||
|
|
||||||
|
app.controller('securityrule', function ($scope, $http) {
|
||||||
|
|
||||||
|
$scope.securityruleLoading = true;
|
||||||
|
|
||||||
|
|
||||||
|
$scope.ActivateTags = ['Agents', 'AppsInitialization', 'Backdoor', 'Bruteforce', 'CWAF', 'Domains', 'Drupal', 'FilterASP',
|
||||||
|
'FilterGen', 'FilterInFarme', 'FilterOther', 'FilterPHP', 'FiltersEnd', 'FilterSQL', 'Generic', 'HTTP', 'HTTPDoS',
|
||||||
|
'Incoming', 'Initialzation', 'JComponent', 'Joomla', 'Other', 'OtherApps', 'PHPGen', 'Protocol', 'Request', 'RoRGen',
|
||||||
|
'SQLi', 'WHMCS', 'WordPress', 'WPPlugin', 'XSS']
|
||||||
|
|
||||||
|
$scope.DeactivatedTags = []
|
||||||
|
|
||||||
|
|
||||||
|
$scope.toggleActivation = function (tag) {
|
||||||
|
var index = $scope.ActivateTags.indexOf(tag);
|
||||||
|
if (index > -1) {
|
||||||
|
$scope.ActivateTags.splice(index, 1);
|
||||||
|
$scope.DeactivatedTags.push(tag);
|
||||||
|
} else {
|
||||||
|
index = $scope.DeactivatedTags.indexOf(tag);
|
||||||
|
if (index > -1) {
|
||||||
|
$scope.DeactivatedTags.splice(index, 1);
|
||||||
|
$scope.ActivateTags.push(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$scope.applychanges = function () {
|
||||||
|
|
||||||
|
$scope.securityruleLoading = false;
|
||||||
|
url = "/serverstatus/securityruleUpdate";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
ActivateTags: $scope.ActivateTags,
|
||||||
|
DeactivatedTags: $scope.DeactivatedTags,
|
||||||
|
RuleID: $scope.ruleID,
|
||||||
|
Regular_expressions: $scope.Regular_expressions
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
|
||||||
|
function ListInitialDatas(response) {
|
||||||
|
$scope.securityruleLoading = true;
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Done',
|
||||||
|
text: "Changes Applied",
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: response.data.error_message,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cantLoadInitialDatas(response) {
|
||||||
|
$scope.securityruleLoading = true;
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: 'Could not connect to server, please refresh this page',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.controller('servicesManager', function ($scope, $http) {
|
app.controller('servicesManager', function ($scope, $http) {
|
||||||
|
|
||||||
$scope.services = false;
|
$scope.services = false;
|
||||||
|
|||||||
170
serverStatus/templates/serverStatus/Switchoffsecurity.html
Normal file
170
serverStatus/templates/serverStatus/Switchoffsecurity.html
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
{% extends "baseTemplate/index.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{% trans "Switch off security - CyberPanel" %}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.tagcontainer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-container {
|
||||||
|
width: 200px;
|
||||||
|
height: 300px;
|
||||||
|
overflow-y: auto;
|
||||||
|
margin-right: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-label {
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags {
|
||||||
|
width: calc(100% - 20px); /* Adjusted width to accommodate the icon */
|
||||||
|
justify-content: space-between;
|
||||||
|
margin: 5px 0; /* Added margin top and bottom */
|
||||||
|
display: flex; /* Added to ensure icon and text are aligned */
|
||||||
|
align-items: center; /* Added to vertically center the icon */
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags:hover {
|
||||||
|
background-color: lightblue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-icon {
|
||||||
|
display: none; /* Initially hide the SVG icon */
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags:hover .tag-icon {
|
||||||
|
display: inline-block; /* Show the SVG icon on hover */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Adjusted SVG styling */
|
||||||
|
svg {
|
||||||
|
flex-shrink: 0; /* Prevent SVG from shrinking */
|
||||||
|
margin-left: 5px; /* Added space between text and icon */
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><g fill="none" stroke="currentColor"><circle cx="11" cy="11" r="5.5"/><path stroke-linecap="round" stroke-linejoin="round" d="m15 15l4 4"/></g></svg>');
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: calc(100% - 10px) center;
|
||||||
|
padding-right: 30px; /* Adjust based on the size of your SVG icon */
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input:focus {
|
||||||
|
outline: none; /* Optional: Remove outline on focus */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div id="page-title">
|
||||||
|
<h2>{% trans "Switch off security rules" %} <img src="{% static 'images/lsON.png' %}"
|
||||||
|
style="margin-bottom: 5px;"></h2>
|
||||||
|
<p>{% trans "Here you can switch off security rules. It is handy if you find out that a security rule is too restrictive for some websites. To deactivate security rules, specify their IDs (for example, 340003 or 340005-340007), tags (for example, CVE-2011-4898), or regular expressions used in rule messages (for example, XSS)." %}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-controller="securityrule" class="panel">
|
||||||
|
<div class="panel-body">
|
||||||
|
<h3 class="content-box-header">
|
||||||
|
{% trans "Security Rules" %} <img ng-hide="securityruleLoading"
|
||||||
|
src="{% static 'images/loading.gif' %}">
|
||||||
|
</h3>
|
||||||
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
|
<form action="/" id="createPackages"
|
||||||
|
class="form-horizontal bordered-row panel-body">
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Security Rule IDs" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input name="dom" type="text" class="form-control" ng-model="ruleID"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group tagcontainer">
|
||||||
|
<div>
|
||||||
|
<div class="tags-label">Activate Tags</div>
|
||||||
|
<div class="tags-container">
|
||||||
|
<input type="text" ng-model="tagFilter" placeholder="Search tags"
|
||||||
|
class="search-input">
|
||||||
|
<div ng-repeat="tag in ActivateTags | filter:tagFilter"
|
||||||
|
ng-click="toggleActivation(tag)">
|
||||||
|
<span class="tags">{$ tag $}
|
||||||
|
<svg class="tag-icon" xmlns="http://www.w3.org/2000/svg" width="1em"
|
||||||
|
height="1em"
|
||||||
|
viewBox="0 0 24 24">
|
||||||
|
<path fill="none" stroke="currentColor" stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2" d="m10 17l5-5-5-5"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="tags-label">Deactivated Tags</div>
|
||||||
|
<div class="tags-container">
|
||||||
|
<input type="text" ng-model="deactivatedTagFilter" placeholder="Search tags"
|
||||||
|
class="search-input">
|
||||||
|
<div ng-repeat="tag in DeactivatedTags | filter:deactivatedTagFilter"
|
||||||
|
ng-click="toggleActivation(tag)">
|
||||||
|
<span class="tags">{$ tag $}
|
||||||
|
<svg class="tag-icon" xmlns="http://www.w3.org/2000/svg" width="1em"
|
||||||
|
height="1em"
|
||||||
|
viewBox="0 0 24 24">
|
||||||
|
<path fill="none" stroke="currentColor" stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2" d="m14 7l-5 5 5 5"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Regular expressions in rule messages " %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<textarea name="dom" type="text" class="form-control" ng-model="Regular_expressions"
|
||||||
|
rows="5"
|
||||||
|
required> </textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"></label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<button
|
||||||
|
type="button" ng-click="applychanges()"
|
||||||
|
class="btn btn-primary btn-lg">{% trans "Save Changes" %}</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -27,4 +27,8 @@ urlpatterns = [
|
|||||||
url(r'^CyberPanelPort$', views.CyberPanelPort, name='CyberPanelPort'),
|
url(r'^CyberPanelPort$', views.CyberPanelPort, name='CyberPanelPort'),
|
||||||
url(r'^submitPortChange$', views.submitPortChange, name='submitPortChange'),
|
url(r'^submitPortChange$', views.submitPortChange, name='submitPortChange'),
|
||||||
|
|
||||||
|
|
||||||
|
url(r'^Switchoffsecurity$', views.Switchoffsecurity, name='Switchoffsecurity'),
|
||||||
|
url(r'^securityruleUpdate$', views.securityruleUpdate, name='securityruleUpdate'),
|
||||||
|
|
||||||
]
|
]
|
||||||
@@ -28,11 +28,19 @@ EXPIRE = 3
|
|||||||
VERSION = '2.3'
|
VERSION = '2.3'
|
||||||
BUILD = 5
|
BUILD = 5
|
||||||
|
|
||||||
|
|
||||||
def serverStatusHome(request):
|
def serverStatusHome(request):
|
||||||
proc = httpProc(request, 'serverStatus/index.html',
|
proc = httpProc(request, 'serverStatus/index.html',
|
||||||
None, 'admin')
|
None, 'admin')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
|
def Switchoffsecurity(request):
|
||||||
|
proc = httpProc(request, 'serverStatus/Switchoffsecurity.html',
|
||||||
|
None, 'admin')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
def litespeedStatus(request):
|
def litespeedStatus(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -91,6 +99,7 @@ def litespeedStatus(request):
|
|||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def stopOrRestartLitespeed(request):
|
def stopOrRestartLitespeed(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -124,10 +133,12 @@ def stopOrRestartLitespeed(request):
|
|||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]")
|
||||||
return HttpResponse("Not Logged in as admin")
|
return HttpResponse("Not Logged in as admin")
|
||||||
|
|
||||||
|
|
||||||
def cyberCPMainLogFile(request):
|
def cyberCPMainLogFile(request):
|
||||||
proc = httpProc(request, 'serverStatus/cybercpmainlogfile.html', None, 'admin')
|
proc = httpProc(request, 'serverStatus/cybercpmainlogfile.html', None, 'admin')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
def getFurtherDataFromLogFile(request):
|
def getFurtherDataFromLogFile(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -151,6 +162,7 @@ def getFurtherDataFromLogFile(request):
|
|||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]")
|
||||||
return HttpResponse("Not Logged in as admin")
|
return HttpResponse("Not Logged in as admin")
|
||||||
|
|
||||||
|
|
||||||
def services(request):
|
def services(request):
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
@@ -168,6 +180,7 @@ def services(request):
|
|||||||
proc = httpProc(request, 'serverStatus/services.html', data, 'admin')
|
proc = httpProc(request, 'serverStatus/services.html', data, 'admin')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
def servicesStatus(request):
|
def servicesStatus(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -276,6 +289,7 @@ def servicesStatus(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def servicesAction(request):
|
def servicesAction(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -328,6 +342,7 @@ def servicesAction(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
def switchTOLSWS(request):
|
def switchTOLSWS(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -361,6 +376,35 @@ def switchTOLSWS(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
def securityruleUpdate(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson('status', 0)
|
||||||
|
|
||||||
|
data = json.loads(request.body)
|
||||||
|
|
||||||
|
ActivateTags = data['ActivateTags']
|
||||||
|
DeactivatedTags = data['DeactivatedTags']
|
||||||
|
RuleID = data['RuleID']
|
||||||
|
Regular_expressions = data['Regular_expressions']
|
||||||
|
|
||||||
|
data_ret = {'status': 1, 'error_message': "None", }
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def switchTOLSWSStatus(request):
|
def switchTOLSWSStatus(request):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -387,10 +431,11 @@ def switchTOLSWSStatus(request):
|
|||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
command = "sudo rm -f " + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath
|
command = "sudo rm -f " + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath
|
||||||
ProcessUtilities.popenExecutioner(command)
|
ProcessUtilities.popenExecutioner(command)
|
||||||
data_ret = {'status': 0,'abort': 1, 'requestStatus': str(msg), 'installed': 0}
|
data_ret = {'status': 0, 'abort': 1, 'requestStatus': str(msg), 'installed': 0}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def licenseStatus(request):
|
def licenseStatus(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -407,7 +452,8 @@ def licenseStatus(request):
|
|||||||
serial = ProcessUtilities.outputExecutioner(command)
|
serial = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
if serial.find('No such file or directory') > -1:
|
if serial.find('No such file or directory') > -1:
|
||||||
final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': 'Trial License in use.', 'lsexpiration': 'Trial license expires 15 days after activation.'}
|
final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': 'Trial License in use.',
|
||||||
|
'lsexpiration': 'Trial license expires 15 days after activation.'}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
@@ -427,6 +473,7 @@ def licenseStatus(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
def refreshLicense(request):
|
def refreshLicense(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -439,7 +486,6 @@ def refreshLicense(request):
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson('status', 0)
|
return ACLManager.loadErrorJson('status', 0)
|
||||||
|
|
||||||
|
|
||||||
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
|
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
|
||||||
ProcessUtilities.outputExecutioner(command)
|
ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
@@ -512,6 +558,7 @@ def topProcesses(request):
|
|||||||
proc = httpProc(request, "serverStatus/topProcesses.html", None, 'admin')
|
proc = httpProc(request, "serverStatus/topProcesses.html", None, 'admin')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
def topProcessesStatus(request):
|
def topProcessesStatus(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -586,7 +633,6 @@ def topProcessesStatus(request):
|
|||||||
memoryInf0[1] = list(filter(None, memoryInf0[1].split(' ')))
|
memoryInf0[1] = list(filter(None, memoryInf0[1].split(' ')))
|
||||||
memoryInf0[2] = list(filter(None, memoryInf0[2].split(' ')))
|
memoryInf0[2] = list(filter(None, memoryInf0[2].split(' ')))
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data['totalMemory'] = '%sMB' % (memoryInf0[1][1])
|
data['totalMemory'] = '%sMB' % (memoryInf0[1][1])
|
||||||
except:
|
except:
|
||||||
@@ -606,7 +652,6 @@ def topProcessesStatus(request):
|
|||||||
except:
|
except:
|
||||||
data['buffCache'] = '%sMB' % ('0')
|
data['buffCache'] = '%sMB' % ('0')
|
||||||
|
|
||||||
|
|
||||||
## Swap
|
## Swap
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -681,8 +726,8 @@ def topProcessesStatus(request):
|
|||||||
total, used, free = shutil.disk_usage("/")
|
total, used, free = shutil.disk_usage("/")
|
||||||
|
|
||||||
data['TotalDisk'] = '%s GB' % (total // (2 ** 30))
|
data['TotalDisk'] = '%s GB' % (total // (2 ** 30))
|
||||||
data['TotalDiskUsed'] = '%s GB' % (used // (2 ** 30))
|
data['TotalDiskUsed'] = '%s GB' % (used // (2 ** 30))
|
||||||
data['TotalDiskFree'] =' %s GB' % (free // (2 ** 30))
|
data['TotalDiskFree'] = ' %s GB' % (free // (2 ** 30))
|
||||||
|
|
||||||
final_json = json.dumps(data)
|
final_json = json.dumps(data)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
@@ -692,6 +737,7 @@ def topProcessesStatus(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def killProcess(request):
|
def killProcess(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -721,10 +767,12 @@ def killProcess(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
def packageManager(request):
|
def packageManager(request):
|
||||||
proc = httpProc(request, "serverStatus/packageManager.html", None, 'admin')
|
proc = httpProc(request, "serverStatus/packageManager.html", None, 'admin')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
def fetchPackages(request):
|
def fetchPackages(request):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -842,8 +890,7 @@ def fetchPackages(request):
|
|||||||
|
|
||||||
## make list of packages that need update
|
## make list of packages that need update
|
||||||
|
|
||||||
|
# if os.path.exists(ProcessUtilities.debugPath):
|
||||||
#if os.path.exists(ProcessUtilities.debugPath):
|
|
||||||
# logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages)))
|
# logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages)))
|
||||||
|
|
||||||
from s3Backups.s3Backups import S3Backups
|
from s3Backups.s3Backups import S3Backups
|
||||||
@@ -857,7 +904,7 @@ def fetchPackages(request):
|
|||||||
counter = 0
|
counter = 0
|
||||||
|
|
||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
|
logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
|
||||||
|
|
||||||
import re
|
import re
|
||||||
for items in finalPackages:
|
for items in finalPackages:
|
||||||
@@ -896,7 +943,9 @@ def fetchPackages(request):
|
|||||||
else:
|
else:
|
||||||
lock = 0
|
lock = 0
|
||||||
|
|
||||||
dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade, 'lock': lock}
|
dic = {'package': nowSplitted[0].split('/')[0],
|
||||||
|
'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]),
|
||||||
|
'upgrade': upgrade, 'lock': lock}
|
||||||
|
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
if checker == 0:
|
if checker == 0:
|
||||||
@@ -923,7 +972,6 @@ def fetchPackages(request):
|
|||||||
else:
|
else:
|
||||||
upgrade = 'Upgrade available'
|
upgrade = 'Upgrade available'
|
||||||
|
|
||||||
|
|
||||||
if details[0].split('.')[0] in locked:
|
if details[0].split('.')[0] in locked:
|
||||||
lock = 1
|
lock = 1
|
||||||
else:
|
else:
|
||||||
@@ -965,7 +1013,8 @@ def fetchPackages(request):
|
|||||||
|
|
||||||
json_data = json_data + ']'
|
json_data = json_data + ']'
|
||||||
|
|
||||||
data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination, 'fetchedPackages': counter, 'totalPackages': len(packages)}
|
data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination, 'fetchedPackages': counter,
|
||||||
|
'totalPackages': len(packages)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -974,6 +1023,7 @@ def fetchPackages(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def fetchPackageDetails(request):
|
def fetchPackageDetails(request):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -1004,6 +1054,7 @@ def fetchPackageDetails(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def updatePackage(request):
|
def updatePackage(request):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -1027,7 +1078,7 @@ def updatePackage(request):
|
|||||||
extraArgs = {}
|
extraArgs = {}
|
||||||
extraArgs['package'] = package
|
extraArgs['package'] = package
|
||||||
|
|
||||||
from plogical.applicationInstaller import ApplicationInstaller
|
from plogical.applicationInstaller import ApplicationInstaller
|
||||||
|
|
||||||
background = ApplicationInstaller('updatePackage', extraArgs)
|
background = ApplicationInstaller('updatePackage', extraArgs)
|
||||||
background.start()
|
background.start()
|
||||||
@@ -1043,6 +1094,7 @@ def updatePackage(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def lockStatus(request):
|
def lockStatus(request):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -1179,11 +1231,11 @@ def submitPortChange(request):
|
|||||||
|
|
||||||
ProcessUtilities.executioner('systemctl restart lscpd')
|
ProcessUtilities.executioner('systemctl restart lscpd')
|
||||||
|
|
||||||
data_ret = {'status': 1,}
|
data_ret = {'status': 1, }
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user