lsws switch

This commit is contained in:
usmannasir
2018-11-09 22:01:28 +05:00
parent 7f72c84bb1
commit 1c3df3d361
50 changed files with 8430 additions and 1747 deletions

View File

@@ -567,8 +567,9 @@ def changeAdminPassword(request):
'error_message': "None"} 'error_message': "None"}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)
os.remove(randomFile) os.remove(randomFile)
admin = Administrator.objects.get(pk="admin") admin = Administrator.objects.get(userName="admin")
admin.password = hashPassword.hash_password(adminPass) admin.password = hashPassword.hash_password(adminPass)
admin.save() admin.save()
data_ret = {"changed": 1, data_ret = {"changed": 1,

View File

@@ -13,16 +13,15 @@ from plogical.virtualHostUtilities import virtualHostUtilities
import subprocess import subprocess
import shlex import shlex
from plogical.installUtilities import installUtilities from plogical.installUtilities import installUtilities
from django.shortcuts import HttpResponse, render, redirect from django.shortcuts import HttpResponse, render
from loginSystem.models import Administrator
from random import randint from random import randint
import time import time
from loginSystem.views import loadLoginPage
from plogical.firewallUtilities import FirewallUtilities from plogical.firewallUtilities import FirewallUtilities
from firewall.models import FirewallRules from firewall.models import FirewallRules
import thread import thread
from plogical.modSec import modSec from plogical.modSec import modSec
from plogical.csf import CSF from plogical.csf import CSF
from plogical.processUtilities import ProcessUtilities
class FirewallManager: class FirewallManager:
@@ -604,6 +603,8 @@ class FirewallManager:
else: else:
return ACLManager.loadError() return ACLManager.loadError()
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
OLS = 1
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath command = "sudo cat " + confPath
@@ -615,7 +616,11 @@ class FirewallManager:
if items.find('module mod_security') > -1: if items.find('module mod_security') > -1:
modSecInstalled = 1 modSecInstalled = 1
break break
return render(request, 'firewall/modSecurity.html', {'modSecInstalled': modSecInstalled}) else:
OLS = 0
modSecInstalled = 1
return render(request, 'firewall/modSecurity.html', {'modSecInstalled': modSecInstalled, 'OLS': OLS})
except BaseException, msg: except BaseException, msg:
return HttpResponse(str(msg)) return HttpResponse(str(msg))
@@ -702,6 +707,8 @@ class FirewallManager:
else: else:
return ACLManager.loadErrorJson('fetchStatus', 0) return ACLManager.loadErrorJson('fetchStatus', 0)
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
modsecurity = 0 modsecurity = 0
SecAuditEngine = 0 SecAuditEngine = 0
SecRuleEngine = 0 SecRuleEngine = 0
@@ -714,9 +721,7 @@ class FirewallManager:
modSecPath = os.path.join(virtualHostUtilities.Server_root, 'modules', 'mod_security.so') modSecPath = os.path.join(virtualHostUtilities.Server_root, 'modules', 'mod_security.so')
if os.path.exists(modSecPath): if os.path.exists(modSecPath):
command = "sudo cat " + confPath command = "sudo cat " + confPath
data = subprocess.check_output(shlex.split(command)).splitlines() data = subprocess.check_output(shlex.split(command)).splitlines()
for items in data: for items in data:
@@ -770,6 +775,61 @@ class FirewallManager:
else: else:
final_dic = {'fetchStatus': 1, final_dic = {'fetchStatus': 1,
'installed': 0} 'installed': 0}
else:
SecAuditEngine = 0
SecRuleEngine = 0
SecDebugLogLevel = "9"
SecAuditLogRelevantStatus = '^(?:5|4(?!04))'
SecAuditLogParts = 'ABIJDEFHZ'
SecAuditLogType = 'Serial'
confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/modsec.conf')
command = "sudo cat " + confPath
data = subprocess.check_output(shlex.split(command)).splitlines()
for items in data:
if items.find('SecAuditEngine ') > -1:
if items.find('on') > -1 or items.find('On') > -1:
SecAuditEngine = 1
continue
if items.find('SecRuleEngine ') > -1:
if items.find('on') > -1 or items.find('On') > -1:
SecRuleEngine = 1
continue
if items.find('SecDebugLogLevel') > -1:
result = items.split(' ')
if result[0] == 'SecDebugLogLevel':
SecDebugLogLevel = result[1]
continue
if items.find('SecAuditLogRelevantStatus') > -1:
result = items.split(' ')
if result[0] == 'SecAuditLogRelevantStatus':
SecAuditLogRelevantStatus = result[1]
continue
if items.find('SecAuditLogParts') > -1:
result = items.split(' ')
if result[0] == 'SecAuditLogParts':
SecAuditLogParts = result[1]
continue
if items.find('SecAuditLogType') > -1:
result = items.split(' ')
if result[0] == 'SecAuditLogType':
SecAuditLogType = result[1]
continue
final_dic = {'fetchStatus': 1,
'installed': 1,
'SecRuleEngine': SecRuleEngine,
'SecAuditEngine': SecAuditEngine,
'SecDebugLogLevel': SecDebugLogLevel,
'SecAuditLogParts': SecAuditLogParts,
'SecAuditLogRelevantStatus': SecAuditLogRelevantStatus,
'SecAuditLogType': SecAuditLogType,
}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
@@ -788,6 +848,8 @@ class FirewallManager:
else: else:
return ACLManager.loadErrorJson('saveStatus', 0) return ACLManager.loadErrorJson('saveStatus', 0)
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
modsecurity = data['modsecurity_status'] modsecurity = data['modsecurity_status']
SecAuditEngine = data['SecAuditEngine'] SecAuditEngine = data['SecAuditEngine']
SecRuleEngine = data['SecRuleEngine'] SecRuleEngine = data['SecRuleEngine']
@@ -841,6 +903,62 @@ class FirewallManager:
output = subprocess.check_output(shlex.split(execPath)) output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
data_ret = {'saveStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'saveStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
SecAuditEngine = data['SecAuditEngine']
SecRuleEngine = data['SecRuleEngine']
SecDebugLogLevel = data['SecDebugLogLevel']
SecAuditLogParts = data['SecAuditLogParts']
SecAuditLogRelevantStatus = data['SecAuditLogRelevantStatus']
SecAuditLogType = data['SecAuditLogType']
if SecAuditEngine == True:
SecAuditEngine = "SecAuditEngine on"
else:
SecAuditEngine = "SecAuditEngine off"
if SecRuleEngine == True:
SecRuleEngine = "SecRuleEngine On"
else:
SecRuleEngine = "SecRuleEngine off"
SecDebugLogLevel = "SecDebugLogLevel " + str(SecDebugLogLevel)
SecAuditLogParts = "SecAuditLogParts " + str(SecAuditLogParts)
SecAuditLogRelevantStatus = "SecAuditLogRelevantStatus " + SecAuditLogRelevantStatus
SecAuditLogType = "SecAuditLogType " + SecAuditLogType
## writing data temporary to file
tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999))
confPath = open(tempConfigPath, "w")
confPath.writelines(SecAuditEngine + "\n")
confPath.writelines(SecRuleEngine + "\n")
confPath.writelines(SecDebugLogLevel + "\n")
confPath.writelines(SecAuditLogParts + "\n")
confPath.writelines(SecAuditLogRelevantStatus + "\n")
confPath.writelines(SecAuditLogType + "\n")
confPath.close()
## save configuration data
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1: if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed() installUtilities.reStartLiteSpeed()
data_ret = {'saveStatus': 1, 'error_message': "None"} data_ret = {'saveStatus': 1, 'error_message': "None"}
@@ -866,6 +984,7 @@ class FirewallManager:
else: else:
return ACLManager.loadError() return ACLManager.loadError()
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath command = "sudo cat " + confPath
@@ -877,6 +996,8 @@ class FirewallManager:
if items.find('module mod_security') > -1: if items.find('module mod_security') > -1:
modSecInstalled = 1 modSecInstalled = 1
break break
else:
modSecInstalled = 1
return render(request, 'firewall/modSecurityRules.html', {'modSecInstalled': modSecInstalled}) return render(request, 'firewall/modSecurityRules.html', {'modSecInstalled': modSecInstalled})
@@ -892,6 +1013,8 @@ class FirewallManager:
else: else:
return ACLManager.loadErrorJson('modSecInstalled', 0) return ACLManager.loadErrorJson('modSecInstalled', 0)
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath command = "sudo cat " + confPath
@@ -920,6 +1043,17 @@ class FirewallManager:
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
else:
rulesPath = os.path.join(virtualHostUtilities.Server_root + "/conf/rules.conf")
command = "sudo cat " + rulesPath
currentModSecRules = subprocess.check_output(shlex.split(command))
final_dic = {'modSecInstalled': 1,
'currentModSecRules': currentModSecRules}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg: except BaseException, msg:
final_dic = {'modSecInstalled': 0, final_dic = {'modSecInstalled': 0,
@@ -941,17 +1075,13 @@ class FirewallManager:
## writing data temporary to file ## writing data temporary to file
rulesPath = open(modSec.tempRulesFile, "w") rulesPath = open(modSec.tempRulesFile, "w")
rulesPath.write(newModSecRules) rulesPath.write(newModSecRules)
rulesPath.close() rulesPath.close()
## save configuration data ## save configuration data
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " saveModSecRules" execPath = execPath + " saveModSecRules"
output = subprocess.check_output(shlex.split(execPath)) output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1: if output.find("1,None") > -1:
@@ -979,6 +1109,8 @@ class FirewallManager:
else: else:
return ACLManager.loadError() return ACLManager.loadError()
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath command = "sudo cat " + confPath
@@ -990,6 +1122,8 @@ class FirewallManager:
if items.find('module mod_security') > -1: if items.find('module mod_security') > -1:
modSecInstalled = 1 modSecInstalled = 1
break break
else:
modSecInstalled = 1
return render(request, 'firewall/modSecurityRulesPacks.html', {'modSecInstalled': modSecInstalled}) return render(request, 'firewall/modSecurityRulesPacks.html', {'modSecInstalled': modSecInstalled})
@@ -1006,6 +1140,7 @@ class FirewallManager:
else: else:
return ACLManager.loadErrorJson('modSecInstalled', 0) return ACLManager.loadErrorJson('modSecInstalled', 0)
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath command = "sudo cat " + confPath
@@ -1047,6 +1182,28 @@ class FirewallManager:
final_dic = {'modSecInstalled': 0} final_dic = {'modSecInstalled': 0}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
else:
comodoInstalled = 0
owaspInstalled = 0
try:
command = 'sudo cat /usr/local/lsws/conf/comodo_litespeed/rules.conf.main'
res = subprocess.call(shlex.split(command))
if res == 0:
comodoInstalled = 1
except subprocess.CalledProcessError:
pass
final_dic = {
'modSecInstalled': 1,
'owaspInstalled': owaspInstalled,
'comodoInstalled': comodoInstalled
}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg: except BaseException, msg:
final_dic = {'modSecInstalled': 0, 'error_message': str(msg)} final_dic = {'modSecInstalled': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
@@ -1064,12 +1221,31 @@ class FirewallManager:
packName = data['packName'] packName = data['packName']
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " " + packName execPath = execPath + " " + packName
output = subprocess.check_output(shlex.split(execPath)) output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
data_ret = {'installStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'installStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
if packName == 'disableOWASP' or packName == 'installOWASP':
final_json = json.dumps({'installStatus': 0, 'error_message': "OWASP will be available later.", })
return HttpResponse(final_json)
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " " + packName
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1: if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed() installUtilities.reStartLiteSpeed()
data_ret = {'installStatus': 1, 'error_message': "None"} data_ret = {'installStatus': 1, 'error_message': "None"}
@@ -1096,6 +1272,7 @@ class FirewallManager:
packName = data['packName'] packName = data['packName']
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf') confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf')
command = "sudo cat " + confPath command = "sudo cat " + confPath
@@ -1134,6 +1311,54 @@ class FirewallManager:
json_data = json_data + ']' json_data = json_data + ']'
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json) return HttpResponse(final_json)
else:
if packName == 'owasp':
final_json = json.dumps({'fetchStatus': 0, 'error_message': "OWASP will be available later.", })
return HttpResponse(final_json)
comodoPath = '/usr/local/lsws/conf/comodo_litespeed'
command = 'sudo chown -R cyberpanel:cyberpanel /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
json_data = "["
counter = 0
checker = 0
for fileName in os.listdir(comodoPath):
if fileName == 'categories.conf':
continue
if fileName.endswith('dis'):
status = 0
fileName = fileName.rstrip('.dis')
elif fileName.endswith('conf'):
status = 1
else:
continue
dic = {
'id': counter,
'fileName': fileName,
'packName': packName,
'status': status,
}
counter = counter + 1
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
json_data = json_data + ']'
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
except BaseException, msg: except BaseException, msg:
final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_dic = {'fetchStatus': 0, 'error_message': str(msg)}

View File

@@ -3,10 +3,6 @@
*/ */
/* Java script code to ADD Firewall Rules */ /* Java script code to ADD Firewall Rules */
app.controller('firewallController', function($scope,$http) { app.controller('firewallController', function($scope,$http) {
@@ -548,8 +544,6 @@ app.controller('firewallController', function($scope,$http) {
/* Java script code to ADD Firewall Rules */ /* Java script code to ADD Firewall Rules */
/* Java script code to Secure SSH */ /* Java script code to Secure SSH */
app.controller('secureSSHCTRL', function($scope,$http) { app.controller('secureSSHCTRL', function($scope,$http) {

View File

@@ -3,18 +3,24 @@
{% block title %}{% trans "ModSecurity - CyberPanel" %}{% endblock %} {% block title %}{% trans "ModSecurity - CyberPanel" %}{% endblock %}
{% block content %} {% block content %}
{% load static %} {% load static %}
{% get_current_language as LANGUAGE_CODE %} {% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} --> <!-- Current language: {{ LANGUAGE_CODE }} -->
{% if OLS %}
<div class="container"> <div class="container">
<div id="page-title"> <div id="page-title">
<h2>{% trans "ModSecurity Configurations!" %} - <a target="_blank" href="http://go.cyberpanel.net/modsec-docs" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "ModSec Docs" %}</span></a> </h2> <h2>{% trans "ModSecurity Configurations!" %} - <a target="_blank"
href="http://go.cyberpanel.net/modsec-docs"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "ModSec Docs" %}</span></a>
</h2>
<p>{% trans "On this page you can configure ModSecurity settings." %}</p> <p>{% trans "On this page you can configure ModSecurity settings." %}</p>
</div> </div>
<div ng-controller="modSec" class="example-box-wrapper"> <div ng-controller="modSec" class="example-box-wrapper">
<div style="border-radius: 25px;border-color:#3498db" class="content-box"> <div style="border-radius: 25px;border-color:#3498db" class="content-box">
<h3 class="content-box-header bg-blue"> <h3 class="content-box-header bg-blue">
{% trans "ModSecurity" %} <img ng-hide="modsecLoading" src="/static/images/loading.gif"> {% trans "ModSecurity" %} <img ng-hide="modsecLoading" src="/static/images/loading.gif">
@@ -30,7 +36,8 @@
<button ng-click="installModSec()" class="btn btn-alt btn-hover btn-blue-alt"> <button ng-click="installModSec()" class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Install Now." %}</span> <span>{% trans "Install Now." %}</span>
<i class="glyph-icon icon-arrow-right"></i> <i class="glyph-icon icon-arrow-right"></i>
</button></h3> </button>
</h3>
</div> </div>
<!------ ModeSec Install Log box -----------------> <!------ ModeSec Install Log box ----------------->
@@ -40,7 +47,9 @@
<div class="col-sm-6"> <div class="col-sm-6">
<div ng-hide="failedToStartInallation" class="alert alert-danger"> <div ng-hide="failedToStartInallation" class="alert alert-danger">
<p>{% trans "Failed to start installation, Error message: " %} {$ errorMessage $}</p> <p>{% trans "Failed to start installation, Error message: " %} {$
errorMessage
$}</p>
</div> </div>
<div ng-hide="couldNotConnect" class="alert alert-danger"> <div ng-hide="couldNotConnect" class="alert alert-danger">
@@ -63,10 +72,13 @@
<form action="/" id="" class="form-horizontal bordered-row"> <form action="/" id="" class="form-horizontal bordered-row">
<div class="form-group"> <div class="form-group">
<div class="col-sm-12 text-center"> <div class="col-sm-12 text-center">
<h3><img src="{% static 'firewall/icons/firewall.png' %}"> {% trans "Winter is coming, but so is ModSecurity." %} <img ng-hide="modsecLoading" src="/static/images/loading.gif"></h3> <h3><img
src="{% static 'firewall/icons/firewall.png' %}"> {% trans "Winter is coming, but so is ModSecurity." %}
<img ng-hide="modsecLoading" src="/static/images/loading.gif"></h3>
</div> </div>
<div style="margin-top: 2%;" class="col-sm-12"> <div style="margin-top: 2%;" class="col-sm-12">
<textarea ng-model="requestData" rows="15" class="form-control">{{ requestData }}</textarea> <textarea ng-model="requestData" rows="15"
class="form-control">{{ requestData }}</textarea>
</div> </div>
</div> </div>
</form> </form>
@@ -103,7 +115,9 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">SecDebugLogLevel</label> <label class="col-sm-4 control-label">SecDebugLogLevel</label>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="selector" style="width: 79px;"><span style="width: 57px; -moz-user-select: none;">{$ SecDebugLogLevel $}</span><select ng-model="SecDebugLogLevel" class="custom-select"> <div class="selector" style="width: 79px;"><span
style="width: 57px; -moz-user-select: none;">{$ SecDebugLogLevel $}</span><select
ng-model="SecDebugLogLevel" class="custom-select">
<option>0</option> <option>0</option>
<option>1</option> <option>1</option>
<option>2</option> <option>2</option>
@@ -121,7 +135,8 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogParts</label> <label class="col-sm-4 control-label">SecAuditLogParts</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input placeholder="ABIJDEFHZ" type="text" class="form-control" ng-model="SecAuditLogParts" required> <input placeholder="ABIJDEFHZ" type="text" class="form-control"
ng-model="SecAuditLogParts" required>
</div> </div>
</div> </div>
@@ -129,35 +144,38 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogRelevantStatus</label> <label class="col-sm-4 control-label">SecAuditLogRelevantStatus</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input type="text" class="form-control" ng-model="SecAuditLogRelevantStatus" required> <input type="text" class="form-control"
ng-model="SecAuditLogRelevantStatus"
required>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogType</label> <label class="col-sm-4 control-label">SecAuditLogType</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input type="text" class="form-control" ng-model="SecAuditLogType" required> <input type="text" class="form-control" ng-model="SecAuditLogType"
required>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-3 control-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
<button type="button" ng-click="saveModSecConfigurations()" class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button> <button type="button" ng-click="saveModSecConfigurations()"
class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-3 control-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
<div ng-hide="failedToSave" class="alert alert-danger"> <div ng-hide="failedToSave" class="alert alert-danger">
<p>{% trans "Failed to save ModSecurity configurations. Error message: " %} {$ errorMessage $}</p> <p>{% trans "Failed to save ModSecurity configurations. Error message: " %}
{$ errorMessage $}</p>
</div> </div>
<div ng-hide="successfullySaved" class="alert alert-success"> <div ng-hide="successfullySaved" class="alert alert-success">
@@ -178,6 +196,193 @@
{% endif %} {% endif %}
</div>
</div>
</div>
</div>
</div>
{% else %}
<div class="container">
<div id="page-title">
<h2>{% trans "ModSecurity Configurations!" %} - <a target="_blank"
href="http://go.cyberpanel.net/modsec-docs"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "ModSec Docs" %}</span></a>
</h2>
<p>{% trans "On this page you can configure ModSecurity settings." %}</p>
</div>
<div ng-controller="modSec" class="example-box-wrapper">
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
<h3 class="content-box-header bg-blue">
{% trans "ModSecurity" %} <img ng-hide="modsecLoading" src="/static/images/loading.gif">
</h3>
<div class="content-box-wrapper">
<div class="row">
{% if modSecInstalled == 0 %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "ModSecurity is not installed " %}
<button ng-click="installModSec()" class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Install Now." %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
</h3>
</div>
<!------ ModeSec Install Log box ----------------->
<div ng-hide="modSecNotifyBox" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-6">
<div ng-hide="failedToStartInallation" class="alert alert-danger">
<p>{% trans "Failed to start installation, Error message: " %} {$
errorMessage $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
<div ng-hide="installationFailed" class="alert alert-danger">
<p>{% trans "Installation failed." %} {$ errorMessage $}</p>
</div>
<div ng-hide="modSecSuccessfullyInstalled" class="alert alert-success">
<p>{% trans "ModSecurity successfully installed, refreshing page in 3 seconds.." %}</p>
</div>
</div>
</div>
<div ng-hide="modeSecInstallBox" class="col-md-12">
<form action="/" id="" class="form-horizontal bordered-row">
<div class="form-group">
<div class="col-sm-12 text-center">
<h3><img
src="{% static 'firewall/icons/firewall.png' %}"> {% trans "Winter is coming, but so is ModSecurity." %}
<img ng-hide="modsecLoading" src="/static/images/loading.gif"></h3>
</div>
<div style="margin-top: 2%;" class="col-sm-12">
<textarea ng-model="requestData" rows="15"
class="form-control">{{ requestData }}</textarea>
</div>
</div>
</form>
</div>
<!----- ModeSec Install Log box ----------------->
{% else %}
<div style="padding: 2%" class="col-md-12">
<form action="/" id="createPackages" class="form-horizontal bordered-row">
<div ng-hide="phpDetailsBox" class="form-group">
<label class="col-sm-4 control-label">SecAuditEngine</label>
<div class="col-sm-6">
<input type="checkbox" id="SecAuditEngine" data-toggle="toggle">
</div>
</div>
<div ng-hide="phpDetailsBox" class="form-group">
<label class="col-sm-4 control-label">SecRuleEngine</label>
<div class="col-sm-6">
<input type="checkbox" id="SecRuleEngine" data-toggle="toggle">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">SecDebugLogLevel</label>
<div class="col-sm-6">
<div class="selector" style="width: 79px;"><span
style="width: 57px; -moz-user-select: none;">{$ SecDebugLogLevel $}</span><select
ng-model="SecDebugLogLevel" class="custom-select">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</select><i class="glyph-icon icon-caret-down"></i></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogParts</label>
<div class="col-sm-6">
<input placeholder="ABIJDEFHZ" type="text" class="form-control"
ng-model="SecAuditLogParts" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogRelevantStatus</label>
<div class="col-sm-6">
<input type="text" class="form-control"
ng-model="SecAuditLogRelevantStatus" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogType</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="SecAuditLogType"
required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveModSecConfigurations()"
class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="failedToSave" class="alert alert-danger">
<p>{% trans "Failed to save ModSecurity configurations. Error message: " %}
{$ errorMessage $}</p>
</div>
<div ng-hide="successfullySaved" class="alert alert-success">
<p>{% trans "ModSecurity configurations successfully saved." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
</div>
</div>
</form>
</div>
{% endif %}
</div> </div>
</div> </div>
@@ -185,7 +390,9 @@
</div> </div>
</div> </div>
{% endif %}
{% endblock %} {% endblock %}

View File

@@ -79,12 +79,9 @@ class FTPManager:
path = 'None' path = 'None'
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/ftpUtilities.py" execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/ftpUtilities.py"
execPath = execPath + " submitFTPCreation --domainName " + domainName + " --userName " + userName \ execPath = execPath + " submitFTPCreation --domainName " + domainName + " --userName " + userName \
+ " --password " + password + " --path " + path + " --owner " + admin.userName + ' --api ' + api + " --password " + password + " --path " + path + " --owner " + admin.userName + ' --api ' + api
output = subprocess.check_output(shlex.split(execPath)) output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1: if output.find("1,None") > -1:
data_ret = {'status': 1, 'creatFTPStatus': 1, 'error_message': 'None'} data_ret = {'status': 1, 'creatFTPStatus': 1, 'error_message': 'None'}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)

View File

@@ -297,7 +297,7 @@ class preFlightsChecks:
os._exit(os.EX_SOFTWARE) os._exit(os.EX_SOFTWARE)
else: else:
while(1): while (1):
cmd.append("rpm") cmd.append("rpm")
cmd.append("-ivh") cmd.append("-ivh")
cmd.append("http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm") cmd.append("http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm")
@@ -305,9 +305,11 @@ class preFlightsChecks:
if res == 1: if res == 1:
count = count + 1 count = count + 1
preFlightsChecks.stdOut("Unable to add CyberPanel official repository, trying again, try number: " + str(count) + "\n") preFlightsChecks.stdOut(
"Unable to add CyberPanel official repository, trying again, try number: " + str(count) + "\n")
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Unable to add CyberPanel official repository, exiting installer! [installCyberPanelRepo]") logging.InstallLog.writeToFile(
"Unable to add CyberPanel official repository, exiting installer! [installCyberPanelRepo]")
preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt")
os._exit(0) os._exit(0)
else: else:

View File

@@ -234,7 +234,6 @@ class InstallCyberPanel:
'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \ 'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \
'lsphp7?-sqlite3 lsphp7?-tidy' 'lsphp7?-sqlite3 lsphp7?-tidy'
res = os.system(command) res = os.system(command)
else: else:
command = 'yum -y groupinstall lsphp-all' command = 'yum -y groupinstall lsphp-all'
cmd = shlex.split(command) cmd = shlex.split(command)

View File

@@ -41,7 +41,7 @@ class CyberCPLogFileWriter:
@staticmethod @staticmethod
def statusWriter(tempStatusPath, mesg): def statusWriter(tempStatusPath, mesg):
try: try:
statusFile = open(tempStatusPath, 'w') statusFile = open(tempStatusPath, 'a')
statusFile.writelines(mesg) statusFile.writelines(mesg)
statusFile.close() statusFile.close()
except BaseException, msg: except BaseException, msg:

View File

@@ -1,12 +1,7 @@
import os.path
import shutil
import CyberCPLogFileWriter as logging import CyberCPLogFileWriter as logging
import subprocess
import argparse import argparse
import shlex
from random import randint from random import randint
class filemanager: class filemanager:
@staticmethod @staticmethod
@@ -25,7 +20,7 @@ class filemanager:
except BaseException,msg: except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile( logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [createEmailAccount]") str(msg) + " [createTemporaryFile]")
print "0," + str(msg) print "0," + str(msg)

View File

@@ -4,8 +4,8 @@ import CyberCPLogFileWriter as logging
import shutil import shutil
import pexpect import pexpect
import os import os
import thread
import shlex import shlex
from processUtilities import ProcessUtilities
class installUtilities: class installUtilities:
@@ -136,15 +136,15 @@ class installUtilities:
@staticmethod @staticmethod
def reStartLiteSpeed(): def reStartLiteSpeed():
try: try:
FNULL = open(os.devnull, 'w') FNULL = open(os.devnull, 'w')
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
command = "sudo systemctl restart lsws" command = "sudo systemctl restart lsws"
else:
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
cmd = shlex.split(command) cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except OSError, msg: except OSError, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
@@ -159,12 +159,12 @@ class installUtilities:
def reStartOpenLiteSpeed(restart,orestart): def reStartOpenLiteSpeed(restart,orestart):
try: try:
FNULL = open(os.devnull, 'w') if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
command = "sudo systemctl restart lsws" command = "sudo systemctl restart lsws"
else:
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res == 1: if res == 1:
@@ -177,7 +177,6 @@ class installUtilities:
print(" Litespeed Re-Started ") print(" Litespeed Re-Started ")
print("###############################################") print("###############################################")
except OSError, msg: except OSError, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartOpenLiteSpeed]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartOpenLiteSpeed]")
return 0 return 0
@@ -279,8 +278,6 @@ class installUtilities:
return 1 return 1
@staticmethod @staticmethod
def installMainWebServer(): def installMainWebServer():
if installUtilities.enableEPELRepo() == 1: if installUtilities.enableEPELRepo() == 1:
@@ -370,7 +367,6 @@ class installUtilities:
return 1 return 1
@staticmethod @staticmethod
def startMariaDB(): def startMariaDB():
@@ -406,7 +402,6 @@ class installUtilities:
return 1 return 1
@staticmethod @staticmethod
def installMySQL(password): def installMySQL(password):

View File

@@ -7,6 +7,7 @@ import os
import tarfile import tarfile
import shutil import shutil
from mailUtilities import mailUtilities from mailUtilities import mailUtilities
from processUtilities import ProcessUtilities
class modSec: class modSec:
installLogPath = "/home/cyberpanel/modSecInstallLog" installLogPath = "/home/cyberpanel/modSecInstallLog"
@@ -111,10 +112,10 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
data = open(tempConfigPath).readlines() data = open(tempConfigPath).readlines()
os.remove(tempConfigPath) os.remove(tempConfigPath)
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
confData = open(confFile).readlines() confData = open(confFile).readlines()
conf = open(confFile, 'w') conf = open(confFile, 'w')
for items in confData: for items in confData:
@@ -145,6 +146,38 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
conf.close() conf.close()
print "1,None"
return
else:
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/modsec.conf")
confData = open(confFile).readlines()
conf = open(confFile, 'w')
for items in confData:
if items.find('SecAuditEngine ') > -1:
conf.writelines(data[0])
continue
elif items.find('SecRuleEngine ') > -1:
conf.writelines(data[1])
continue
elif items.find('SecDebugLogLevel') > -1:
conf.writelines(data[2])
continue
elif items.find('SecAuditLogRelevantStatus ') > -1:
conf.writelines(data[4])
continue
elif items.find('SecAuditLogParts ') > -1:
conf.writelines(data[3])
continue
elif items.find('SecAuditLogType ') > -1:
conf.writelines(data[5])
continue
else:
conf.writelines(items)
conf.close()
print "1,None" print "1,None"
return return
@@ -160,7 +193,10 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
data = rulesFile.read() data = rulesFile.read()
rulesFile.close() rulesFile.close()
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
rulesFilePath = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/rules.conf") rulesFilePath = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/rules.conf")
else:
rulesFilePath = os.path.join(virtualHostUtilities.Server_root, "conf/rules.conf")
rulesFile = open(rulesFilePath,'w') rulesFile = open(rulesFilePath,'w')
rulesFile.write(data) rulesFile.write(data)
@@ -180,6 +216,8 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
@staticmethod @staticmethod
def setupComodoRules(): def setupComodoRules():
try: try:
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
pathTOOWASPFolder = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/comodo") pathTOOWASPFolder = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/comodo")
extractLocation = os.path.join(virtualHostUtilities.Server_root, "conf/modsec") extractLocation = os.path.join(virtualHostUtilities.Server_root, "conf/modsec")
@@ -199,6 +237,25 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
tar.extractall(extractLocation) tar.extractall(extractLocation)
tar.close() tar.close()
return 1
else:
if os.path.exists('/usr/local/lsws/conf/comodo_litespeed'):
shutil.rmtree('/usr/local/lsws/conf/comodo_litespeed')
extractLocation = os.path.join(virtualHostUtilities.Server_root, "conf")
if os.path.exists('cpanel_litespeed_vendor'):
os.remove('cpanel_litespeed_vendor')
command = "wget https://waf.comodo.com/api/cpanel_litespeed_vendor"
result = subprocess.call(shlex.split(command))
if result == 1:
return 0
command = "unzip cpanel_litespeed_vendor -d " + extractLocation
subprocess.call(shlex.split(command))
return 1 return 1
except BaseException, msg: except BaseException, msg:
@@ -209,41 +266,43 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
@staticmethod @staticmethod
def installComodo(): def installComodo():
try: try:
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
if modSec.setupComodoRules() == 0: if modSec.setupComodoRules() == 0:
print '0, Unable to download Comodo Rules.' print '0, Unable to download Comodo Rules.'
return return
owaspRulesConf = """modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/modsecurity.conf owaspRulesConf = """modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/modsecurity.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/00_Init_Initialization.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/00_Init_Initialization.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/01_Init_AppsInitialization.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/01_Init_AppsInitialization.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/02_Global_Generic.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/02_Global_Generic.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/03_Global_Agents.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/03_Global_Agents.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/04_Global_Domains.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/04_Global_Domains.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/05_Global_Backdoor.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/05_Global_Backdoor.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/06_XSS_XSS.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/06_XSS_XSS.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/07_Global_Other.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/07_Global_Other.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/08_Bruteforce_Bruteforce.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/08_Bruteforce_Bruteforce.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/09_HTTP_HTTP.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/09_HTTP_HTTP.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/10_HTTP_HTTPDoS.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/10_HTTP_HTTPDoS.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/11_HTTP_Protocol.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/11_HTTP_Protocol.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/12_HTTP_Request.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/12_HTTP_Request.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/13_Outgoing_FilterGen.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/13_Outgoing_FilterGen.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/14_Outgoing_FilterASP.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/14_Outgoing_FilterASP.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/15_Outgoing_FilterPHP.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/15_Outgoing_FilterPHP.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/16_Outgoing_FilterSQL.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/16_Outgoing_FilterSQL.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/17_Outgoing_FilterOther.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/17_Outgoing_FilterOther.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/18_Outgoing_FilterInFrame.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/18_Outgoing_FilterInFrame.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/19_Outgoing_FiltersEnd.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/19_Outgoing_FiltersEnd.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/20_PHP_PHPGen.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/20_PHP_PHPGen.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/21_SQL_SQLi.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/21_SQL_SQLi.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/22_Apps_Joomla.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/22_Apps_Joomla.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/23_Apps_JComponent.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/23_Apps_JComponent.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/24_Apps_WordPress.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/24_Apps_WordPress.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/25_Apps_WPPlugin.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/25_Apps_WPPlugin.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/26_Apps_WHMCS.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/26_Apps_WHMCS.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/27_Apps_Drupal.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/27_Apps_Drupal.conf
modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/28_Apps_OtherApps.conf modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/28_Apps_OtherApps.conf
""" """
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
@@ -261,6 +320,29 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/28_Apps_OtherApps.conf
conf.close() conf.close()
print "1,None"
return
else:
if os.path.exists('/usr/local/lsws/conf/comodo_litespeed'):
shutil.rmtree('/usr/local/lsws/conf/comodo_litespeed')
extractLocation = os.path.join(virtualHostUtilities.Server_root, "conf")
if os.path.exists('cpanel_litespeed_vendor'):
os.remove('cpanel_litespeed_vendor')
command = "wget https://waf.comodo.com/api/cpanel_litespeed_vendor"
result = subprocess.call(shlex.split(command))
if result == 1:
return 0
command = "unzip cpanel_litespeed_vendor -d " + extractLocation
result = subprocess.call(shlex.split(command))
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
print "1,None" print "1,None"
return return
@@ -273,6 +355,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/28_Apps_OtherApps.conf
def disableComodo(): def disableComodo():
try: try:
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
confData = open(confFile).readlines() confData = open(confFile).readlines()
conf = open(confFile, 'w') conf = open(confFile, 'w')
@@ -287,6 +370,14 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/28_Apps_OtherApps.conf
print "1,None" print "1,None"
else:
try:
shutil.rmtree('/usr/local/lsws/conf/comodo_litespeed')
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [disableComodo]')
print "1,None"
except BaseException, msg: except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile( logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [disableComodo]") str(msg) + " [disableComodo]")

View File

@@ -1,11 +1,15 @@
from CyberCPLogFileWriter import CyberCPLogFileWriter as logging from CyberCPLogFileWriter import CyberCPLogFileWriter as logging
import subprocess import subprocess
import shlex import shlex
import os
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
class ProcessUtilities: class ProcessUtilities:
litespeedProcess = "litespeed" litespeedProcess = "litespeed"
ent = 1
OLS = 0
centos = 1
ubuntu = 0
@staticmethod @staticmethod
def getLitespeedProcessNumber(): def getLitespeedProcessNumber():
@@ -14,7 +18,7 @@ class ProcessUtilities:
try: try:
import psutil import psutil
for proc in psutil.process_iter(): for proc in psutil.process_iter():
if proc.name() == ProcessUtilities.litespeedProcess: if proc.name().find(ProcessUtilities.litespeedProcess) > -1:
finalListOfProcesses.append(proc.pid) finalListOfProcesses.append(proc.pid)
except BaseException,msg: except BaseException,msg:
@@ -30,7 +34,11 @@ class ProcessUtilities:
@staticmethod @staticmethod
def restartLitespeed(): def restartLitespeed():
try: try:
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
command = "sudo systemctl restart lsws" command = "sudo systemctl restart lsws"
else:
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
@@ -45,7 +53,11 @@ class ProcessUtilities:
@staticmethod @staticmethod
def stopLitespeed(): def stopLitespeed():
try: try:
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
command = "sudo systemctl stop lsws" command = "sudo systemctl stop lsws"
else:
command = "sudo /usr/local/lsws/bin/lswsctrl stop"
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
@@ -57,4 +69,58 @@ class ProcessUtilities:
except subprocess.CalledProcessError, msg: except subprocess.CalledProcessError, msg:
logging.writeToFile(str(msg) + "[stopLitespeed]") logging.writeToFile(str(msg) + "[stopLitespeed]")
@staticmethod
def executioner(command):
try:
res = subprocess.call(shlex.split(command))
if res == 1:
raise 0
else:
return 1
except BaseException, msg:
return 0
@staticmethod
def killLiteSpeed():
pids = ProcessUtilities.getLitespeedProcessNumber()
if pids !=0:
for items in pids:
try:
command = 'sudo kill -9 ' + str(items)
ProcessUtilities.executioner(command)
except:
pass
@staticmethod
def decideServer():
entPath = '/usr/local/lsws/bin/lshttpd'
if os.readlink(entPath) == '/usr/local/lsws/bin/lshttpd/openlitespeed':
return ProcessUtilities.OLS
else:
return ProcessUtilities.ent
@staticmethod
def decideDistro():
distroPath = '/etc/lsb-release'
if os.path.exists(distroPath):
return ProcessUtilities.ubuntu
else:
return ProcessUtilities.centos
@staticmethod
def executioner(command, statusFile):
try:
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
if res == 1:
raise 0
else:
return 1
except BaseException, msg:
logging.writeToFile(str(msg))
return 0

View File

@@ -1,9 +1,10 @@
import CyberCPLogFileWriter as logging import CyberCPLogFileWriter as logging
import shutil
import os import os
import shlex import shlex
import subprocess import subprocess
import socket import socket
from plogical.processUtilities import ProcessUtilities
from websiteFunctions.models import ChildDomains, Websites
class sslUtilities: class sslUtilities:
@@ -58,8 +59,8 @@ class sslUtilities:
return [0, "347 " + str(msg) + " [issueSSLForDomain]"] return [0, "347 " + str(msg) + " [issueSSLForDomain]"]
@staticmethod @staticmethod
def installSSLForDomain(virtualHostName): def installSSLForDomain(virtualHostName, adminEmail='usman@cyberpersons.com'):
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = sslUtilities.Server_root + "/conf/vhosts/" + virtualHostName confPath = sslUtilities.Server_root + "/conf/vhosts/" + virtualHostName
completePathToConfigFile = confPath + "/vhost.conf" completePathToConfigFile = confPath + "/vhost.conf"
@@ -150,17 +151,97 @@ class sslUtilities:
writeSSLConfig.close() writeSSLConfig.close()
return 1 return 1
except BaseException, msg: except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]]")
return 0 return 0
else:
confPath = sslUtilities.Server_root + "/conf/vhosts/" + virtualHostName
completePathToConfigFile = confPath + "/vhost.conf"
## Check if SSL VirtualHost already exists
data = open(completePathToConfigFile, 'r').readlines()
for items in data:
if items.find('*:443') > -1:
return 1
try:
try:
chilDomain = ChildDomains.objects.get(domain=virtualHostName)
externalApp = chilDomain.master.externalApp
DocumentRoot = ' DocumentRoot ' + chilDomain.path + '\n'
except BaseException, msg:
website = Websites.objects.get(domain=virtualHostName)
externalApp = website.externalApp
DocumentRoot = ' DocumentRoot /home/' + virtualHostName + '/public_html\n'
data = open(completePathToConfigFile, 'r').readlines()
phpHandler = ''
for items in data:
if items.find('AddHandler') > -1 and items.find('php') > -1:
phpHandler = items
break
confFile = open(completePathToConfigFile, 'a')
doNotModify = '\n\n# Do not modify this file, this is auto-generated file.\n\n'
VirtualHost = '<VirtualHost *:443>\n\n'
ServerName = ' ServerName ' + virtualHostName + '\n'
ServerAlias = ' ServerAlias www.' + virtualHostName + '\n'
ScriptAlias = ' Alias /.filemanager/ /usr/local/lsws/FileManager\n'
ServerAdmin = ' ServerAdmin ' + adminEmail + '\n'
SeexecUserGroup = ' SuexecUserGroup ' + externalApp + ' ' + externalApp + '\n'
CustomLogCombined = ' CustomLog /home/' + virtualHostName + '/logs/' + virtualHostName + '.access_log combined\n'
confFile.writelines(doNotModify)
confFile.writelines(VirtualHost)
confFile.writelines(ServerName)
confFile.writelines(ServerAlias)
confFile.writelines(ScriptAlias)
confFile.writelines(ServerAdmin)
confFile.writelines(SeexecUserGroup)
confFile.writelines(DocumentRoot)
confFile.writelines(CustomLogCombined)
DirectoryFileManager = """\n <Directory /usr/local/lsws/FileManager>
AllowOverride All
Options +Includes -Indexes +ExecCGI
php_value display_errors "Off"
php_value upload_max_filesize "200M"
php_value post_max_size "250M"
</Directory>\n"""
confFile.writelines(DirectoryFileManager)
SSLEngine = ' SSLEngine on\n'
SSLVerifyClient = ' SSLVerifyClient none\n'
SSLCertificateFile = ' SSLCertificateFile /etc/letsencrypt/live/' + virtualHostName + '/fullchain.pem\n'
SSLCertificateKeyFile = ' SSLCertificateKeyFile /etc/letsencrypt/live/' + virtualHostName + '/privkey.pem\n'
confFile.writelines(SSLEngine)
confFile.writelines(SSLVerifyClient)
confFile.writelines(SSLCertificateFile)
confFile.writelines(SSLCertificateKeyFile)
confFile.writelines(phpHandler)
VirtualHostEnd = '</VirtualHost>\n'
confFile.writelines(VirtualHostEnd)
confFile.close()
return 1
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]")
return 0
@staticmethod @staticmethod
def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None): def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None):
try: try:
acmePath = '/root/.acme.sh/acme.sh' acmePath = '/root/.acme.sh/acme.sh'
if os.path.exists('/etc/lsb-release'): if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
acmePath = '/home/cyberpanel/.acme.sh/acme.sh' acmePath = '/home/cyberpanel/.acme.sh/acme.sh'
if not os.path.exists(acmePath): if not os.path.exists(acmePath):
@@ -239,30 +320,13 @@ class sslUtilities:
def issueSSLForDomain(domain, adminEmail, sslpath, aliasDomain = None): def issueSSLForDomain(domain, adminEmail, sslpath, aliasDomain = None):
try: try:
if sslUtilities.obtainSSLForADomain(domain, adminEmail, sslpath, aliasDomain) == 1: if sslUtilities.obtainSSLForADomain(domain, adminEmail, sslpath, aliasDomain) == 1:
if sslUtilities.installSSLForDomain(domain, adminEmail) == 1:
if sslUtilities.installSSLForDomain(domain) == 1:
return [1, "None"] return [1, "None"]
else: else:
return [0, "210 Failed to install SSL for domain. [issueSSLForDomain]"] return [0, "210 Failed to install SSL for domain. [issueSSLForDomain]"]
else: else:
pathToStoreSSL = "/etc/letsencrypt/live/" + domain return [0, "283 Failed to obtain SSL for domain. [issueSSLForDomain]"]
command = 'mkdir -p ' + pathToStoreSSL
subprocess.call(shlex.split(command))
pathToStoreSSLPrivKey = "/etc/letsencrypt/live/" + domain + "/privkey.pem"
pathToStoreSSLFullChain = "/etc/letsencrypt/live/" + domain + "/fullchain.pem"
command = 'openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout ' + pathToStoreSSLPrivKey + ' -out ' + pathToStoreSSLFullChain
cmd = shlex.split(command)
subprocess.call(cmd)
if sslUtilities.installSSLForDomain(domain) == 1:
logging.CyberCPLogFileWriter.writeToFile("Self signed SSL issued for " + domain + ".")
return [1, "None"]
else:
return [0, "220 Failed to install SSL for domain. [issueSSLForDomain]"]
except BaseException,msg: except BaseException,msg:
return [0, "347 "+ str(msg)+ " [issueSSLForDomain]"] return [0, "347 "+ str(msg)+ " [issueSSLForDomain]"]

View File

@@ -16,6 +16,7 @@ from databases.models import Databases
from mysqlUtilities import mysqlUtilities from mysqlUtilities import mysqlUtilities
from dnsUtilities import DNS from dnsUtilities import DNS
from random import randint from random import randint
from processUtilities import ProcessUtilities
## If you want justice, you have come to the wrong place. ## If you want justice, you have come to the wrong place.
@@ -87,7 +88,12 @@ class vhost:
cmd = shlex.split(command) cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
command = "chmod -R 666 " + pathLogs command = "chmod -R 666 " + pathLogs
else:
command = "chmod -R 755 " + pathLogs
cmd = shlex.split(command) cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
@@ -176,6 +182,7 @@ class vhost:
@staticmethod @staticmethod
def perHostVirtualConf(vhFile, administratorEmail,virtualHostUser, phpVersion, virtualHostName, openBasedir): def perHostVirtualConf(vhFile, administratorEmail,virtualHostUser, phpVersion, virtualHostName, openBasedir):
# General Configurations tab # General Configurations tab
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
try: try:
confFile = open(vhFile, "w+") confFile = open(vhFile, "w+")
@@ -371,11 +378,11 @@ class vhost:
htaccessAutoLoad = """ htaccessAutoLoad = """
rewrite { rewrite {
enable 1 enable 1
autoLoadHtaccess 1 autoLoadHtaccess 1
} }
""" """
confFile.write(htaccessAutoLoad) confFile.write(htaccessAutoLoad)
confFile.close() confFile.close()
@@ -385,6 +392,69 @@ rewrite {
str(msg) + " [IO Error with per host config file [perHostVirtualConf]]") str(msg) + " [IO Error with per host config file [perHostVirtualConf]]")
return 0 return 0
return 1 return 1
else:
try:
confFile = open(vhFile, "w+")
doNotModify = '# Do not modify this file, this is auto-generated file.\n\n'
VirtualHost = '<VirtualHost *:80>\n\n'
ServerName = ' ServerName ' + virtualHostName + '\n'
ServerAlias = ' ServerAlias www.' + virtualHostName + '\n'
ScriptAlias = ' Alias /.filemanager/ /usr/local/lsws/FileManager\n'
ServerAdmin = ' ServerAdmin ' + administratorEmail + '\n'
SeexecUserGroup = ' SuexecUserGroup ' + virtualHostUser + ' ' + virtualHostUser + '\n'
DocumentRoot = ' DocumentRoot /home/' + virtualHostName + '/public_html\n'
CustomLogCombined = ' CustomLog /home/' + virtualHostName + '/logs/' + virtualHostName + '.access_log combined\n'
confFile.writelines(doNotModify)
confFile.writelines(VirtualHost)
confFile.writelines(ServerName)
confFile.writelines(ServerAlias)
confFile.writelines(ScriptAlias)
confFile.writelines(ServerAdmin)
confFile.writelines(SeexecUserGroup)
confFile.writelines(DocumentRoot)
confFile.writelines(CustomLogCombined)
DirectoryFileManager = """\n <Directory /usr/local/lsws/FileManager>
Options +Includes -Indexes +ExecCGI
php_value display_errors "Off"
php_value upload_max_filesize "200M"
php_value post_max_size "250M"
</Directory>\n"""
confFile.writelines(DirectoryFileManager)
## external app
if phpVersion == "PHP 5.3":
php = "53"
elif phpVersion == "PHP 5.4":
php = "55"
elif phpVersion == "PHP 5.5":
php = "55"
elif phpVersion == "PHP 5.6":
php = "56"
elif phpVersion == "PHP 7.0":
php = "70"
elif phpVersion == "PHP 7.1":
php = "71"
elif phpVersion == "PHP 7.2":
php = "72"
AddType = ' AddHandler application/x-httpd-php' + php + ' .php .php7 .phtml\n\n'
VirtualHostEnd = '</VirtualHost>\n'
confFile.writelines(AddType)
confFile.writelines(VirtualHostEnd)
confFile.close()
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [perHostVirtualConf]]")
return 0
return 1
@staticmethod @staticmethod
def createNONSSLMapEntry(virtualHostName): def createNONSSLMapEntry(virtualHostName):
@@ -420,6 +490,7 @@ rewrite {
#restrained 1 #restrained 1
#} #}
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
try: try:
if vhost.createNONSSLMapEntry(virtualHostName) == 0: if vhost.createNONSSLMapEntry(virtualHostName) == 0:
@@ -441,14 +512,26 @@ rewrite {
writeDataToFile.close() writeDataToFile.close()
return [1,"None"] return [1,"None"]
except BaseException,msg: except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]")
return [0,"223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"] return [0,"223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"]
else:
try:
writeDataToFile = open("/usr/local/lsws/conf/httpd.conf", 'a')
configFile = 'Include /usr/local/lsws/conf/vhosts/' + virtualHostName + '/vhost.conf\n'
writeDataToFile.writelines(configFile)
writeDataToFile.close()
writeDataToFile.close()
return [1, "None"]
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]")
return [0, "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"]
@staticmethod @staticmethod
def deleteVirtualHostConfigurations(virtualHostName): def deleteVirtualHostConfigurations(virtualHostName):
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
try: try:
## Deleting master conf ## Deleting master conf
@@ -481,15 +564,52 @@ rewrite {
command = "sudo rm -rf /home/vmail/" + virtualHostName command = "sudo rm -rf /home/vmail/" + virtualHostName
subprocess.call(shlex.split(command)) subprocess.call(shlex.split(command))
except BaseException, msg: except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0 return 0
return 1 return 1
else:
try:
## Deleting master conf
numberOfSites = str(Websites.objects.count() + ChildDomains.objects.count())
vhost.deleteCoreConf(virtualHostName, numberOfSites)
delWebsite = Websites.objects.get(domain=virtualHostName)
databases = Databases.objects.filter(website=delWebsite)
childDomains = delWebsite.childdomains_set.all()
## Deleting child domains
for items in childDomains:
numberOfSites = Websites.objects.count() + ChildDomains.objects.count()
vhost.deleteCoreConf(items.domain, numberOfSites)
for items in databases:
mysqlUtilities.deleteDatabase(items.dbName, items.dbUser)
delWebsite.delete()
## Deleting DNS Zone if there is any.
DNS.deleteDNSZone(virtualHostName)
installUtilities.installUtilities.reStartLiteSpeed()
## Delete mail accounts
command = "sudo rm -rf /home/vmail/" + virtualHostName
subprocess.call(shlex.split(command))
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0
return 1
@staticmethod @staticmethod
def deleteCoreConf(virtualHostName, numberOfSites): def deleteCoreConf(virtualHostName, numberOfSites):
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
try: try:
virtualHostPath = "/home/" + virtualHostName virtualHostPath = "/home/" + virtualHostName
@@ -533,7 +653,39 @@ rewrite {
logging.CyberCPLogFileWriter.writeToFile( logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0 return 0
return 1
else:
virtualHostPath = "/home/" + virtualHostName
try:
shutil.rmtree(virtualHostPath)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host directory from /home continuing..]")
try:
confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName
shutil.rmtree(confPath)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration directory from /conf ]")
try:
data = open("/usr/local/lsws/conf/httpd.conf").readlines()
writeDataToFile = open("/usr/local/lsws/conf/httpd.conf", 'w')
for items in data:
if items.find('/' + virtualHostName + '/') > -1:
pass
else:
writeDataToFile.writelines(items)
writeDataToFile.close()
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0
return 1 return 1
@staticmethod @staticmethod
@@ -544,11 +696,8 @@ rewrite {
@staticmethod @staticmethod
def changePHP(vhFile, phpVersion): def changePHP(vhFile, phpVersion):
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
# General Configurations tab
finalphp = 0 finalphp = 0
try: try:
data = open(vhFile, "r").readlines() data = open(vhFile, "r").readlines()
@@ -583,12 +732,52 @@ rewrite {
print "1,None" print "1,None"
return 1,'None' return 1,'None'
except BaseException, msg: except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile( logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [changePHP]]") str(msg) + " [IO Error with per host config file [changePHP]]")
print 0,str(msg) print 0,str(msg)
return [0, str(msg) + " [IO Error with per host config file [changePHP]]"] return [0, str(msg) + " [IO Error with per host config file [changePHP]]"]
else:
try:
data = open(vhFile, "r").readlines()
if phpVersion == "PHP 5.3":
finalphp = 53
elif phpVersion == "PHP 5.4":
finalphp = 54
elif phpVersion == "PHP 5.5":
finalphp = 55
elif phpVersion == "PHP 5.6":
finalphp = 56
elif phpVersion == "PHP 7.0":
finalphp = 70
elif phpVersion == "PHP 7.1":
finalphp = 71
elif phpVersion == "PHP 7.2":
finalphp = 72
writeDataToFile = open(vhFile, "w")
finalString = ' AddHandler application/x-httpd-php' + str(finalphp) + ' .php\n'
for items in data:
if items.find("AddHandler application/x-httpd") > -1:
writeDataToFile.writelines(finalString)
else:
writeDataToFile.writelines(items)
writeDataToFile.close()
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
return 1, 'None'
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [changePHP]]")
print 0, str(msg)
return [0, str(msg) + " [IO Error with per host config file [changePHP]]"]
@staticmethod @staticmethod
def addRewriteRules(virtualHostName, fileName=None): def addRewriteRules(virtualHostName, fileName=None):
@@ -648,8 +837,6 @@ rewrite {
print str(inMB) + "," + str(percentage) print str(inMB) + "," + str(percentage)
else: else:
print "0,0" print "0,0"
except OSError, msg: except OSError, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]")
print "0,0" print "0,0"
@@ -782,17 +969,15 @@ rewrite {
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectoryForDomain]]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectoryForDomain]]")
return [0, "[351 Not able to directories for virtual host [createDirectoryForDomain]]"] return [0, "[351 Not able to directories for virtual host [createDirectoryForDomain]]"]
if vhost.perHostDomainConf(path, masterDomain, completePathToConfigFile, if vhost.perHostDomainConf(path, masterDomain, domain, completePathToConfigFile,
administratorEmail, phpVersion, virtualHostUser, openBasedir) == 1: administratorEmail, phpVersion, virtualHostUser, openBasedir) == 1:
return [1, "None"] return [1, "None"]
else: else:
return [0, "[359 Not able to create per host virtual configurations [perHostVirtualConf]"] return [0, "[359 Not able to create per host virtual configurations [perHostVirtualConf]"]
@staticmethod @staticmethod
def perHostDomainConf(path, masterDomain, vhFile, administratorEmail, phpVersion, virtualHostUser, openBasedir): def perHostDomainConf(path, masterDomain, domain, vhFile, administratorEmail, phpVersion, virtualHostUser, openBasedir):
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
# General Configurations tab
try: try:
confFile = open(vhFile, "w+") confFile = open(vhFile, "w+")
@@ -938,20 +1123,73 @@ rewrite {
confFile.writelines(extprocessorEnd) confFile.writelines(extprocessorEnd)
htaccessAutoLoad = """ htaccessAutoLoad = """
rewrite { rewrite {
enable 1 enable 1
autoLoadHtaccess 1 autoLoadHtaccess 1
} }
""" """
confFile.write(htaccessAutoLoad) confFile.write(htaccessAutoLoad)
confFile.close() confFile.close()
except BaseException, msg: except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile( logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [perHostDomainConf]]") str(msg) + " [IO Error with per host config file [perHostDomainConf]]")
return 0 return 0
return 1 return 1
else:
try:
confFile = open(vhFile, "w+")
doNotModify = '# Do not modify this file, this is auto-generated file.\n\n'
VirtualHost = '<VirtualHost *:80>\n\n'
ServerName = ' ServerName ' + domain + '\n'
ServerAlias = ' ServerAlias www.' + domain + '\n'
ServerAdmin = ' ServerAdmin ' + administratorEmail + '\n'
SeexecUserGroup = ' SuexecUserGroup ' + virtualHostUser + ' ' + virtualHostUser + '\n'
DocumentRoot = ' DocumentRoot ' + path + '\n'
CustomLogCombined = ' CustomLog /home/' + masterDomain + '/logs/' + masterDomain + '.access_log combined\n'
confFile.writelines(doNotModify)
confFile.writelines(VirtualHost)
confFile.writelines(ServerName)
confFile.writelines(ServerAlias)
confFile.writelines(ServerAdmin)
confFile.writelines(SeexecUserGroup)
confFile.writelines(DocumentRoot)
confFile.writelines(CustomLogCombined)
## external app
if phpVersion == "PHP 5.3":
php = "53"
elif phpVersion == "PHP 5.4":
php = "55"
elif phpVersion == "PHP 5.5":
php = "55"
elif phpVersion == "PHP 5.6":
php = "56"
elif phpVersion == "PHP 7.0":
php = "70"
elif phpVersion == "PHP 7.1":
php = "71"
elif phpVersion == "PHP 7.2":
php = "72"
AddType = ' AddHandler application/x-httpd-php' + php + ' .php .php7 .phtml\n\n'
VirtualHostEnd = '</VirtualHost>\n'
confFile.writelines(AddType)
confFile.writelines(VirtualHostEnd)
confFile.close()
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [IO Error with per host config file [perHostDomainConf]]")
return 0
return 1
@staticmethod @staticmethod
def createConfigInMainDomainHostFile(domain, masterDomain): def createConfigInMainDomainHostFile(domain, masterDomain):
@@ -963,6 +1201,7 @@ rewrite {
# restrained 1 # restrained 1
# } # }
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
try: try:
if vhost.createNONSSLMapEntry(domain) == 0: if vhost.createNONSSLMapEntry(domain) == 0:
@@ -988,3 +1227,14 @@ rewrite {
logging.CyberCPLogFileWriter.writeToFile( logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]") str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]")
return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"] return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"]
else:
try:
writeDataToFile = open("/usr/local/lsws/conf/httpd.conf", 'a')
configFile = 'Include /usr/local/lsws/conf/vhosts/' + domain + '/vhost.conf\n'
writeDataToFile.writelines(configFile)
writeDataToFile.close()
return [1, "None"]
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]")
return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"]

View File

@@ -150,7 +150,6 @@ class WebsiteManager:
## Create Configurations ## Create Configurations
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " createVirtualHost --virtualHostName " + domain + \ execPath = execPath + " createVirtualHost --virtualHostName " + domain + \
" --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \ " --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \
"' --virtualHostUser " + externalApp + " --ssl " + str(data['ssl']) + " --dkimCheck " \ "' --virtualHostUser " + externalApp + " --ssl " + str(data['ssl']) + " --dkimCheck " \

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/FIleManager.iml" filepath="$PROJECT_DIR$/.idea/FIleManager.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,600 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="9320a755-b878-4593-8eac-7d773157fabd" name="Default" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="fileManager.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="414">
<caret line="80" column="26" lean-forward="true" selection-start-line="80" selection-start-column="26" selection-end-line="80" selection-end-column="26" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="caller.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="CSS File" />
<option value="HTML File" />
<option value="JavaScript File" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>../../assets</find>
<find>ajax/libs/angularjs/1.2.12/angular.js</find>
<find>AbnTestController</find>
<find>AbnTest</find>
<find>listAction</find>
<find>$commandToExecute</find>
</findStrings>
<replaceStrings>
<replace>assets</replace>
</replaceStrings>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/assets/prac.js" />
<option value="$PROJECT_DIR$/javaprac.html" />
<option value="$PROJECT_DIR$/admin-blog.html" />
<option value="$PROJECT_DIR$/tree.html" />
<option value="$PROJECT_DIR$/js/tree.js" />
<option value="$PROJECT_DIR$/js/fileManager.js" />
<option value="$PROJECT_DIR$/css/fileManager.css" />
<option value="$PROJECT_DIR$/index.html" />
<option value="$PROJECT_DIR$/php/caller.php" />
<option value="$PROJECT_DIR$/php/fileManager.php" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1419" />
<option name="y" value="-4" />
<option name="width" value="1299" />
<option name="height" value="764" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="FileManager" type="b2602c69:ProjectViewProjectNode" />
<item name="FileManager" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="FileManager" type="b2602c69:ProjectViewProjectNode" />
<item name="FileManager" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="php" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="list.type.of.created.stylesheet" value="CSS" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="9320a755-b878-4593-8eac-7d773157fabd" name="Default" comment="" />
<created>1511505785266</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1511505785266</updated>
<workItem from="1511505786403" duration="25402000" />
<workItem from="1512371928726" duration="717000" />
<workItem from="1512401006678" duration="9000" />
<workItem from="1512401100852" duration="2365000" />
<workItem from="1523948661253" duration="7874000" />
<workItem from="1524303326266" duration="7000" />
<workItem from="1524730597265" duration="8000" />
<workItem from="1525085664919" duration="10000" />
<workItem from="1525683960581" duration="13000" />
<workItem from="1526291898810" duration="13000" />
<workItem from="1526512471223" duration="71000" />
<workItem from="1530908210451" duration="3368000" />
<workItem from="1531046295316" duration="1117000" />
<workItem from="1531052646849" duration="625000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="41599000" />
</component>
<component name="ToolWindowManager">
<frame x="1419" y="-4" width="1303" height="780" extended-state="6" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.12759416" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32934132" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="1" />
</breakpoint-manager>
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/assets/prac.js" />
<entry file="file://$PROJECT_DIR$/index-alt.html" />
<entry file="file://$PROJECT_DIR$/admin-blog.html" />
<entry file="file://$PROJECT_DIR$/javaprac.html" />
<entry file="file://$PROJECT_DIR$/js/tree.js" />
<entry file="file://$PROJECT_DIR$/tree.html" />
<entry file="file://$PROJECT_DIR$/js/fileManager.js" />
<entry file="file://$PROJECT_DIR$/css/fileManager.css" />
<entry file="file://$PROJECT_DIR$/index.html" />
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cache/.fr-Tsiwv1/CyberCP/install/FileManager/php/fileManager.php" />
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="414">
<caret line="80" column="26" lean-forward="true" selection-start-line="80" selection-start-column="26" selection-end-line="80" selection-end-column="26" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#getPermissions#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="e#6737#7475#0#PHP" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@@ -0,0 +1,127 @@
<?php
class Caller{
private $basePath = null;
public function __construct($basePath = null)
{
$this->basePath = $basePath ?: dirname(__DIR__);
}
public function requestHandler()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST' and isset($_POST['method'])) {
$pathToSeed = '/home/' . $_POST['domainName'] . '/..filemanagerkey';
$receivedSeed = $_POST['domainRandomSeed'];
$myfile = fopen($pathToSeed, "r") or die("Unable to open file!");
$seed = fread($myfile,filesize($pathToSeed));
fclose($myfile);
if ($seed != $receivedSeed){
$answer = array(
'uploadStatus' => 0,
'answer' => 'Not allowed to upload in this path.',
'error_message' => "None",
'fileName' => $_FILES['file']['name']
);
$json = json_encode($answer);
echo $json;
return;
}
switch ($_POST['method']) {
case 'upload':
$this->uploadFile();
break;
}
}
}
private function uploadFile(){
try {
if (!empty($_FILES)) {
if($this->return_bytes(ini_get('upload_max_filesize')) < $_SERVER['CONTENT_LENGTH']){
throw new Exception("Size of uploaded file is greater than upload limit!");
}
$completePath = $this->cleanInput($_POST['completePath']);
$fileName = $this->cleanInput($_FILES['file']['name']);
$homePath = $this->cleanInput($_POST['home']);
$tempPath = $_FILES['file']['tmp_name'];
$uploadPath = $completePath . DIRECTORY_SEPARATOR . $fileName;
$pos = strpos($uploadPath, $homePath);
if ($pos === false) {
throw new Exception("Not allowed to upload in this path!");
}
if(move_uploaded_file($tempPath, $uploadPath)==true){
$answer = array(
'uploadStatus' => 1,
'answer' => 'File transfer completed',
'error_message' => "None",
'fileName' => $_FILES['file']['name']
);
$json = json_encode($answer);
echo $json;
}
else{
throw new Exception("Can not move uploaded file to destination location!");
}
}
else {
throw new Exception("No Files to upload!");
}
}
catch(Exception $e) {
$answer = array(
'uploadStatus' => 0,
'answer' => 'No files',
'error_message' => $e->getMessage(),
'fileName' => $_FILES['file']['name'],
);
$json = json_encode($answer);
echo $json;
}
}
private function return_bytes($val) {
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
switch($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
}
private function cleanInput($input) {
$search = array(
'@<script[^>]*?>.*?</script>@si',
'@<[\/\!]*?[^<>]*?>@si',
'@<style[^>]*?>.*?</style>@siU',
'@<![\s\S]*?--[ \t\n\r]*>@'
);
$output = preg_replace($search, '', $input);
return $output;
}
}
$caller = new Caller("/");
$caller->requestHandler();

View File

@@ -0,0 +1,748 @@
<?php
class fileManager
{
private $basePath = null;
public function requestHandler()
{
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$pathToSeed = '/home/' . $request->domainName . '/..filemanagerkey';
$receivedSeed = $request->domainRandomSeed;
$myfile = fopen($pathToSeed, "r") or die("Unable to open file!");
$seed = fread($myfile,filesize($pathToSeed));
fclose($myfile);
if ($seed != $receivedSeed){
$json_data = array(
"error_message" => "You can not open filemanager for this domain.",
"copied" => 1,
);
$json = json_encode($json_data);
echo $json;
return;
}
if (isset($request->method)) {
switch ($request->method) {
case 'list':
$this->listDir($request->completeStartingPath);
break;
case 'listForTable':
$home = $this->cleanInput($request->home);
$completeStartingPath = $this->cleanInput($request->completeStartingPath);
$this->listForTable($home,$completeStartingPath);
break;
case 'readFileContents':
$this->readFileContents($request->fileName);
break;
case 'writeFileContents':
$this->writeFileContents($request->fileName, $request->fileContent);
break;
case 'createNewFolder':
$folderName = $this->cleanInput($request->folderName);
$this->createNewFolder($folderName);
break;
case 'createNewFile':
$fileName = $this->cleanInput($request->fileName);
$this->createNewFile($fileName);
break;
case 'deleteFolderOrFile':
$this->deleteFolderOrFile($request->path, $request->fileAndFolders);
break;
case 'compress':
$compressedFileName = $this->cleanInput($request->compressedFileName);
$this->compress($request->basePath, $request->listOfFiles, $compressedFileName, $request->compressionType);
break;
case 'extract':
$extractionLocation = $this->cleanInput($request->extractionLocation);
$this->extract($request->home,$request->basePath,$request->fileToExtract,$request->extractionType,$extractionLocation);
break;
case 'move':
$this->moveFileAndFolders($request->home,$request->basePath,$request->newPath,$request->fileAndFolders);
break;
case 'copy':
$this->copyFileAndFolders($request->home,$request->basePath,$request->newPath,$request->fileAndFolders);
break;
case 'rename':
$newFileName = $this->cleanInput($request->newFileName);
$this->renameFileOrFolder($request->basePath,$request->existingName,$newFileName);
break;
case 'changePermissions':
$this->changePermissions($request->basePath, $request->permissionsPath, $request->newPermissions, $request->recursive);
break;
}
}
}
private function changePermissions($basePath, $permissionsPath, $newPermissions, $recursive)
{
try {
$completePath = $basePath . DIRECTORY_SEPARATOR . $permissionsPath;
if($recursive == 1){
$commandToExecute = 'chmod -R ' . $newPermissions . " '". $completePath . "'";
$programOutput = fopen('temp.txt', 'a');
}else{
$commandToExecute = 'chmod ' . $newPermissions . " '". $completePath . "'";
$programOutput = fopen('temp.txt', 'a');
}
exec($commandToExecute, $programOutput);
$json_data = array(
"error_message" => "None",
"permissionsChanged" => 1,
);
$json = json_encode($json_data);
echo $json;
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"permissionsChanged" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function listDir($basePath)
{
try {
$path = "";
$listPath = $basePath . $path;
$files = scandir($listPath);
$json_data = array(
"error_message" => "None",
"fetchStatus" => 1
);
$counter = 0;
$tempDir = array();
$tempFiles = array();
// sorting files at end
foreach ($files as $dirFile) {
$completePath = $basePath . $path . DIRECTORY_SEPARATOR . $dirFile;
if (is_dir($completePath) == true) {
array_push($tempDir, $dirFile);
} else {
array_push($tempFiles, $dirFile);
}
}
$result = array_merge($tempDir, $tempFiles);
foreach ($result as $dirFile) {
if ($dirFile == "." or $dirFile == "..") {
continue;
}
$arrayCounter = 0;
$tempArray = array($dirFile);
$arrayCounter += 1;
$completePath = $basePath . $path . DIRECTORY_SEPARATOR . $dirFile;
$tempArray[$arrayCounter] = $completePath;
$arrayCounter += 1;
if (is_dir($completePath) == true) {
$list = true;
$tempArray[$arrayCounter] = $list;
} else {
$list = false;
$tempArray[$arrayCounter] = $list;
}
$json_data[(string)$counter] = $tempArray;
$counter += 1;
}
$json = json_encode($json_data);
echo $json;
} catch (Exception $e) {
$answer = array(
'uploadStatus' => 0,
'answer' => [1, 2, 3],
'error_message' => $e->getMessage(),
);
$json = json_encode($answer);
echo $json;
}
}
private function getPermissions($fileName){
$perms = fileperms($fileName);
switch ($perms & 0xF000) {
case 0xC000: // socket
$info = 's';
break;
case 0xA000: // symbolic link
$info = 'l';
break;
case 0x8000: // regular
$info = 'r';
break;
case 0x6000: // block special
$info = 'b';
break;
case 0x4000: // directory
$info = 'd';
break;
case 0x2000: // character special
$info = 'c';
break;
case 0x1000: // FIFO pipe
$info = 'p';
break;
default: // unknown
$info = 'u';
}
// Owner
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ?
(($perms & 0x0800) ? 's' : 'x' ) :
(($perms & 0x0800) ? 'S' : '-'));
// Group
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ?
(($perms & 0x0400) ? 's' : 'x' ) :
(($perms & 0x0400) ? 'S' : '-'));
// World
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ?
(($perms & 0x0200) ? 't' : 'x' ) :
(($perms & 0x0200) ? 'T' : '-'));
return $info;
}
private function listForTable($home,$basePath)
{
try {
$pos = strpos($basePath, $home);
if ($pos === false) {
throw new Exception("Not allowed to browse this path, going back home!");
}
$path = "";
$listPath = $basePath . $path;
$files = scandir($listPath);
$json_data = array("error_message" => "None",
"fetchStatus" => 1
);
$counter = 0;
$tempDir = array();
$tempFiles = array();
// sorting files at end
foreach ($files as $dirFile) {
$completePath = $basePath . $path . DIRECTORY_SEPARATOR . $dirFile;
if (is_dir($completePath) == true) {
array_push($tempDir, $dirFile);
} else {
array_push($tempFiles, $dirFile);
}
}
$result = array_merge($tempDir, $tempFiles);
foreach ($result as $dirFile) {
if ($dirFile == "." or $dirFile == "..") {
continue;
}
$arrayCounter = 0;
$tempArray = array($dirFile);
$arrayCounter += 1;
$completePath = $basePath . $path . DIRECTORY_SEPARATOR . $dirFile;
$tempArray[$arrayCounter] = $completePath;
$arrayCounter += 1;
// find last modified
$lastModified = date("F d Y H:i:s.", filemtime($completePath));
$tempArray[$arrayCounter] = $lastModified;
$arrayCounter += 1;
// find size of file
$fileSize = (int)(filesize($completePath) / 1024);
$tempArray[$arrayCounter] = $fileSize;
$arrayCounter += 1;
// find permissions of file
$tempArray[$arrayCounter] = substr(sprintf('%o', fileperms($completePath)), -4);;
$arrayCounter += 1;
// Deciding if the current path is file or dir.
if (is_dir($completePath) == true) {
$list = true;
$tempArray[$arrayCounter] = $list;
} else {
$list = false;
$tempArray[$arrayCounter] = $list;
}
$json_data[(string)$counter] = $tempArray;
$counter += 1;
}
$json = json_encode($json_data);
echo $json;
} catch (Exception $e) {
$answer = array(
'fetchStatus' => 0,
'error_message' => $e->getMessage(),
);
$json = json_encode($answer);
echo $json;
}
}
private function readFileContents($pathToFile)
{
try {
$listPath = $pathToFile;
$contentsofFile = file_get_contents($pathToFile);
if ($contentsofFile !== false) {
$json_data = array(
"error_message" => "None",
"fetchStatus" => 1,
"fileContents" => $contentsofFile
);
$json = json_encode($json_data);
echo $json;
} else {
throw new Exception("Can not read the file Contents");
}
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"fetchStatus" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function writeFileContents($pathToFile, $fileContent)
{
try {
$contentsofFile = file_put_contents($pathToFile, $fileContent);
if ($contentsofFile !== false) {
$json_data = array(
"error_message" => "None",
"saveStatus" => 1,
);
$json = json_encode($json_data);
echo $json;
} else {
throw new Exception("Can not write the file Contents.");
}
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"saveStatus" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function createNewFolder($folderName)
{
try {
$returnVal = mkdir($folderName);
if ($returnVal !== false) {
$json_data = array(
"error_message" => "None",
"createStatus" => 1,
);
$json = json_encode($json_data);
echo $json;
} else {
throw new Exception("Can not create Folder");
}
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"createStatus" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function createNewFile($fileName)
{
try {
if (touch($fileName)) {
$json_data = array(
"error_message" => "None",
"createStatus" => 1,
);
$json = json_encode($json_data);
echo $json;
} else {
throw new Exception("Can not create file!");
}
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"createStatus" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function deleteFolderOrFile($basePath, $fileAndFolders)
{
try {
foreach ($fileAndFolders as $path) {
$path = $basePath . DIRECTORY_SEPARATOR . $path;
if (is_dir($path) == true) {
$commandToExecute = 'rm -rf ' . "'".$path ."'";
$programOutput = fopen('temp.txt', 'a');
exec($commandToExecute, $programOutput);
} else {
if (unlink($path)) {
continue;
} else {
throw new Exception("Can not delete!");
}
}
}
$json_data = array(
"error_message" => "None",
"deleteStatus" => 1,
);
$json = json_encode($json_data);
echo $json;
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"deleteStatus" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function compress($basePath, $listOfFiles, $compressedFileName, $compressionType)
{
try {
chdir($basePath);
if ($compressionType == "zip") {
$compressedFileName = $basePath . DIRECTORY_SEPARATOR . $compressedFileName . ".zip";
$commandToExecute = 'zip -r ' . $compressedFileName . ' ';
foreach ($listOfFiles as $file) {
$completePathToFile = $file;
$commandToExecute = $commandToExecute ."'". $completePathToFile ."'". ' ';
}
$programOutput = fopen('temp.txt', 'a');
exec($commandToExecute, $programOutput);
$json_data = array(
"error_message" => $commandToExecute,
"compressed" => 1,
);
$json = json_encode($json_data);
echo $json;
}
else {
$compressedFileName = $basePath . DIRECTORY_SEPARATOR . $compressedFileName . ".tar.gz";
$commandToExecute = 'tar -czvf ' . $compressedFileName . ' ';
foreach ($listOfFiles as $file) {
$completePathToFile = $file;
$commandToExecute = $commandToExecute ."'". $completePathToFile ."'". ' ';
}
$programOutput = fopen('temp.txt', 'a');
exec($commandToExecute, $programOutput);
$json_data = array(
"error_message" => "None",
"compressed" => 1,
);
$json = json_encode($json_data);
echo $json;
}
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"compressed" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function extract($home,$basePath,$completeFileToExtract, $extractionType, $extractionLocation)
{
try {
$pos = strpos($extractionLocation, $home);
if ($pos === false) {
throw new Exception("Not allowed to extact in this path, please choose location inside home!");
}
if ($extractionType == "zip") {
$commandToExecute = "unzip -o '" . $completeFileToExtract . "' -d '" . $extractionLocation . "'";
$programOutput = fopen('temp.txt', 'a');
exec($commandToExecute, $programOutput);
$json_data = array(
"error_message" => $commandToExecute,
"extracted" => 1,
);
$json = json_encode($json_data);
echo $json;
} else {
$commandToExecute = "tar xf '" . $completeFileToExtract . "' -C '" . $extractionLocation . "'";
$programOutput = fopen('temp.txt', 'a');
exec($commandToExecute, $programOutput);
$json_data = array(
"error_message" => "None",
"extracted" => 1,
);
$json = json_encode($json_data);
echo $json;
}
}catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"extracted" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function moveFileAndFolders($home,$basePath, $newPath, $fileAndFolders)
{
try {
$pos = strpos($newPath, $home);
if ($pos === false) {
throw new Exception("Not allowed to move in this path, please choose location inside home!");
}
if(!file_exists($newPath)){
if(!mkdir($newPath, 0777, true)){
$json_data = array(
"error_message" => "Can not create the new folder, it already exists!",
"moved" => 0,
);
$json = json_encode($json_data);
echo $json;
die();
}
}
foreach ($fileAndFolders as $path) {
$completePathToFile = $basePath . DIRECTORY_SEPARATOR . $path;
$completeNewPath = $newPath . DIRECTORY_SEPARATOR . $path;
$commandToExecute = 'mv ' ."'". $completePathToFile . "'" . ' ' . "'" . $completeNewPath . "'";
$programOutput = fopen('temp.txt', 'a');
exec($commandToExecute, $programOutput);
}
$json_data = array(
"error_message" => "None",
"moved" => 1,
);
$json = json_encode($json_data);
echo $json;
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"moved" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function copyFileAndFolders($home,$basePath, $newPath, $fileAndFolders)
{
try {
$pos = strpos($newPath, $home);
if ($pos === false) {
throw new Exception("Not allowed to move in this path, please choose location inside home!");
}
if(!file_exists($newPath)){
if(!mkdir($newPath, 0777, true)){
throw new Exception("Can not create the new folder, it already exists!");
}
}
foreach ($fileAndFolders as $path) {
$completePathToFile = $basePath . DIRECTORY_SEPARATOR . $path;
$completeNewPath = $newPath . DIRECTORY_SEPARATOR . $path;
$commandToExecute = 'cp ' ."'". $completePathToFile . "'" . ' ' . "'" . $completeNewPath . "'";
$programOutput = fopen('temp.txt', 'a');
exec($commandToExecute, $programOutput);
}
$json_data = array(
"error_message" => "None",
"copied" => 1,
);
$json = json_encode($json_data);
echo $json;
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"copied" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function renameFileOrFolder($basePath, $currentName, $newName)
{
try {
$completeOldPath = $basePath . DIRECTORY_SEPARATOR . $currentName;
$completeNewPath = $basePath . DIRECTORY_SEPARATOR . $newName;
$commandToExecute = 'mv ' ."'". $completeOldPath . "'" . ' ' . "'" . $completeNewPath . "'";
$programOutput = fopen('temp.txt', 'a');
exec($commandToExecute, $programOutput);
$json_data = array(
"error_message" => "None",
"renamed" => 1,
);
$json = json_encode($json_data);
echo $json;
} catch (Exception $e) {
$json_data = array(
"error_message" => $e->getMessage(),
"renamed" => 0,
);
$json = json_encode($json_data);
echo $json;
}
}
private function cleanInput($input) {
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments
);
$output = preg_replace($search, '', $input);
return $output;
}
}
$caller = new fileManager();
$caller->requestHandler();

View File

@@ -0,0 +1,202 @@
#
# PLAIN TEXT CONFIGURATION FILE
#
serverName lscp
user nobody
group nobody
priority 0
inMemBufSize 60M
swappingDir /tmp/lshttpd/swap
autoFix503 1
gracefulRestartTimeout 300
mime $SERVER_ROOT/conf/mime.properties
showVersionNumber 0
adminEmails root@localhost
adminRoot $SERVER_ROOT/admin/
errorlog $SERVER_ROOT/logs/error.log {
logLevel DEBUG
debugLevel 0
rollingSize 10M
enableStderrLog 1
}
accesslog $SERVER_ROOT/logs/access.log {
rollingSize 10M
keepDays 30
compressArchive 0
}
indexFiles index.html, index.php
expires {
enableExpires 1
expiresByType image/*=A604800, text/css=A604800, application/x-javascript=A604800
}
tuning {
eventDispatcher best
maxConnections 2000
maxSSLConnections 1000
connTimeout 300
maxKeepAliveReq 1000
smartKeepAlive 0
keepAliveTimeout 5
sndBufSize 0
rcvBufSize 0
maxReqURLLen 8192
maxReqHeaderSize 16380
maxReqBodySize 2047M
maxDynRespHeaderSize 8192
maxDynRespSize 2047M
maxCachedFileSize 4096
totalInMemCacheSize 20M
maxMMapFileSize 256K
totalMMapCacheSize 40M
useSendfile 1
fileETag 28
enableGzipCompress 1
enableDynGzipCompress 1
gzipCompressLevel 6
compressibleTypes text/*,application/x-javascript,application/javascript,application/xml, image/svg+xml
gzipAutoUpdateStatic 1
gzipStaticCompressLevel 6
gzipMaxFileSize 1M
gzipMinFileSize 300
SSLCryptoDevice null
}
fileAccessControl {
followSymbolLink 1
checkSymbolLink 0
requiredPermissionMask 000
restrictedPermissionMask 000
}
perClientConnLimit {
staticReqPerSec 0
dynReqPerSec 0
outBandwidth 0
inBandwidth 0
softLimit 10000
hardLimit 10000
gracePeriod 15
banPeriod 300
}
CGIRLimit {
maxCGIInstances 20
minUID 11
minGID 10
priority 0
CPUSoftLimit 10
CPUHardLimit 50
memSoftLimit 460M
memHardLimit 470M
procSoftLimit 400
procHardLimit 450
}
accessDenyDir {
dir /
dir /etc/*
dir /dev/*
dir $SERVER_ROOT/conf/*
dir $SERVER_ROOT/admin/conf/*
}
accessControl {
allow ALL
}
scripthandler {
add lsapi:php70 php
}
railsDefaults {
maxConns 5
env LSAPI_MAX_REQS=1000
env LSAPI_MAX_IDLE=60
initTimeout 60
retryTimeout 0
pcKeepAliveTimeout 60
respBuffer 0
backlog 50
runOnStartUp 1
extMaxIdleTime 300
priority 3
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 500
procHardLimit 600
}
module cache {
param <<<END_param
enableCache 0
enablePrivateCache 0
checkPublicCache 1
checkPrivateCache 1
qsCache 1
reqCookieCache 1
ignoreReqCacheCtrl 1
ignoreRespCacheCtrl 0
respCookieCache 1
expireInSeconds 3600
privateExpireInSeconds 3600
maxStaleAge 200
maxCacheObjSize 10000000
storagepath cachedata
noCacheDomain
noCacheUrl
no-vary 0
addEtag 0
END_param
}
listener Default{
address *:80
secure 0
map Example *
}
vhTemplate centralConfigLog {
templateFile $SERVER_ROOT/conf/templates/ccl.conf
listeners Default
}
vhTemplate PHP_SuEXEC {
templateFile $SERVER_ROOT/conf/templates/phpsuexec.conf
listeners Default
}
vhTemplate EasyRailsWithSuEXEC {
templateFile $SERVER_ROOT/conf/templates/rails.conf
listeners Default
}
virtualHost Example{
vhRoot $SERVER_ROOT/Example/
allowSymbolLink 1
enableScript 1
restrained 1
maxKeepAliveReq
smartKeepAlive
setUIDMode 0
chrootMode 0
configFile $SERVER_ROOT/conf/vhosts/Example/vhconf.conf
}
include phpconfigs/php53.conf
include phpconfigs/php54.conf
include phpconfigs/php55.conf
include phpconfigs/php56.conf
include phpconfigs/php70.conf
include phpconfigs/php71.conf

View File

@@ -0,0 +1,158 @@
default = application/octet-stream
3gp = video/3gpp
3g2 = video/3gpp2
ai, eps = application/postscript
aif, aifc, aiff = audio/x-aiff
asc = text/plain
asf = video/asf
asx = video/x-ms-asf
au = audio/basic
avi = video/x-msvideo
bcpio = application/x-bcpio
bmp = image/bmp
bin = application/octet-stream
bz, bz2 = application/x-bzip
cdf = application/x-netcdf
class = application/java-vm
cpio = application/x-cpio
cpt = application/mac-compactpro
crt = application/x-x509-ca-cert
csh = application/x-csh
css = text/css
dcr,dir, dxr = application/x-director
dms = application/octet-stream
doc = application/msword
dtd = application/xml-dtd
dvi = application/x-dvi
eot = application/vnd.ms-fontobject
etx = text/x-setext
exe = application/x-executable
ez = application/andrew-inset
flv = video/x-flv
gif = image/gif
gtar = application/x-gtar
gz, gzip = application/gzip
hdf = application/x-hdf
hqx = application/mac-binhex40
htc = text/x-component
html, htm = text/html
ice = x-conference/x-cooltalk
ico = image/x-icon
ief = image/ief
iges, igs = model/iges
iso = application/x-cd-image
java = text/plain
jar = application/java-archive
jnlp = application/x-java-jnlp-file
jpeg, jpe, jpg = image/jpeg
js = application/x-javascript
js2 = application/javascript
js3 = text/javascript
json = application/json
jsp = text/plain
kar = audio/midi
latex = application/x-latex
lha, lzh = application/octet-stream
man = application/x-troff-man
mdb = application/vnd.ms-access
me = application/x-troff-me
mesh = model/mesh
mid, midi = audio/midi
mif = application/vnd.mif
movie = video/x-sgi-movie
mov = video/quicktime
mp2, mp3, mpga = audio/mpeg
mpeg, mpe, mpg = video/mpeg
mp4 = video/mp4
mpp = application/vnd.ms-project
ms = application/x-troff-ms
msh = model/mesh
nc = application/x-netcdf
oda = application/oda
odb = application/vnd.oasis.opendocument.database
odc = application/vnd.oasis.opendocument.chart
odf = application/vnd.oasis.opendocument.formula
odg = application/vnd.oasis.opendocument.graphics
odi = application/vnd.oasis.opendocument.image
odp = application/vnd.oasis.opendocument.presentation
ods = application/vnd.oasis.opendocument.spreadsheet
odt = application/vnd.oasis.opendocument.text
ogg = audio/ogg
otf = application/x-font-woff
pbm = image/x-portable-bitmap
pdb = chemical/x-pdb
pdf = application/pdf
pgm = image/x-portable-graymap
pgn = application/x-chess-pgn
pls = audio/x-scpls
png = image/png
pnm = image/x-portable-anymap
ppm = image/x-portable-pixmap
ppt = application/vnd.ms-powerpoint
ps = application/postscript
qt,qtvr = video/quicktime
ra = audio/x-realaudio
ram, rm = audio/x-pn-realaudio
rar = application/x-rar-compressed
ras = image/x-cmu-raster
rgb = image/x-rgb
roff, t, tr = application/x-troff
rss = application/rss+xml
rsd = application/rsd+xml
rtf = application/rtf
rtx = text/richtext
ser = application/java-serialized-object
sgml, sgm = text/sgml
sh = application/x-sh
shar = application/x-shar
shtml = application/x-httpd-shtml
silo = model/mesh
sit = application/x-stuffit
skd, skm, skp, skt = application/x-koan
smi,smil = application/smil
snd = audio/basic
spl = application/x-futuresplash
sql = text/x-sql
src = application/x-wais-source
sv4cpio = application/x-sv4cpio
sv4crc = application/x-sv4crc
svg, svgz = image/svg+xml
swf = application/x-shockwave-flash
tar = application/x-tar
tcl = application/x-tcl
tex = application/x-tex
texi, texinfo = application/x-texinfo
tgz = application/x-gtar
tiff, tif = image/tiff
tsv = text/tab-separated-values
ttf, ttc = application/x-font-ttf
txt = text/plain
ustar = application/x-ustar
vcd = application/x-cdlink
vrml = model/vrml
vxml = application/voicexml+xml
wav = audio/vnd.wave
wax = audio/x-ms-wax
wbmp = image/vnd.wap.wbmp
wma = audio/x-ms-wma
wml = text/vnd.wap.wml
wmlc = application/vnd.wap.wmlc
wmls = text/vnd.wap.wmlscript
wmlsc = application/vnd.wap.wmlscriptc
woff = application/font-woff
woff2 = font/woff2
woff_o1 = application/x-font-woff
wtls-ca-certificate = application/vnd.wap.wtls-ca-certificate
wri = application/vnd.ms-write
wrl = model/vrml
xbm = image/x-xbitmap
xhtml, xht = application/xhtml+xml
xls = application/vnd.ms-excel
xml, xsd, xsl = application/xml
xslt = application/xslt+xml
xpm = image/x-xpixmap
xwd = image/x-xwindowdump
xyz = chemical/x-pdb
zip = application/zip
z = application/compress

View File

@@ -0,0 +1,86 @@
allowSymbolLink 1
chrootMode 0
enableScript 1
restrained 1
setUIDMode 0
vhRoot $SERVER_ROOT/$VH_NAME/
configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
virtualHostConfig {
enableGzip 1
docRoot $VH_ROOT/html/
hotlinkCtrl {
allowedHosts
enableHotlinkCtrl 0
suffixes gif, jpeg, jpg
allowDirectAccess 1
redirectUri
onlySelf 1
}
general {
enableContextAC 0
}
expires {
expiresDefault
enableExpires 1
}
rewrite {
enable 0
logLevel 0
rules <<<MY_END
RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot
RewriteRule ^/nospider/ - [F]
MY_END
}
index {
useServer 0
autoIndex 0
indexFiles index.html
autoIndexURI /_autoindex/default.php
}
accessLog $SERVER_ROOT/logs/$VH_NAME.access.log{
useServer 0
keepDays 30
rollingSize 100M
compressArchive 1
logUserAgent 1
logReferer 1
}
errorlog {
useServer 1
}
htAccess {
allowOverride 0
accessFileName .htaccess
}
context /cgi-bin/{
type cgi
location $VH_ROOT/cgi-bin/
allowBrowse 1
}
awstats {
updateMode 0
siteAliases 127.0.0.1 localhost
updateInterval 86400
updateOffset 0
siteDomain localhost
workingDir $VH_ROOT/awstats
awstatsURI /awstats/
}
accessControl {
deny
allow *
}
}

View File

@@ -0,0 +1,111 @@
head 1.1;
access;
symbols;
locks
root:1.1; strict;
comment @# @;
1.1
date 2017.08.17.05.47.23; author root; state Exp;
branches;
next ;
desc
@/usr/local/CyberCP/conf/templates/ccl.conf0
@
1.1
log
@Update
@
text
@allowSymbolLink 1
chrootMode 0
enableScript 1
restrained 1
setUIDMode 0
vhRoot $SERVER_ROOT/$VH_NAME/
configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
virtualHostConfig {
enableGzip 1
docRoot $VH_ROOT/html/
hotlinkCtrl {
allowedHosts
enableHotlinkCtrl 0
suffixes gif, jpeg, jpg
allowDirectAccess 1
redirectUri
onlySelf 1
}
general {
enableContextAC 0
}
expires {
expiresDefault
enableExpires 1
}
rewrite {
enable 0
logLevel 0
rules <<<MY_END
RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot
RewriteRule ^/nospider/ - [F]
MY_END
}
index {
useServer 0
autoIndex 0
indexFiles index.html
autoIndexURI /_autoindex/default.php
}
accessLog $SERVER_ROOT/logs/$VH_NAME.access.log{
useServer 0
keepDays 30
rollingSize 100M
compressArchive 1
logUserAgent 1
logReferer 1
}
errorlog {
useServer 1
}
htAccess {
allowOverride 0
accessFileName .htaccess
}
context /cgi-bin/{
type cgi
location $VH_ROOT/cgi-bin/
allowBrowse 1
}
awstats {
updateMode 0
siteAliases 127.0.0.1 localhost
updateInterval 86400
updateOffset 0
siteDomain localhost
workingDir $VH_ROOT/awstats
awstatsURI /awstats/
}
accessControl {
deny
allow *
}
}
@

View File

@@ -0,0 +1,100 @@
allowSymbolLink 1
chrootMode 0
enableScript 1
restrained 1
setUIDMode 2
vhRoot $SERVER_ROOT/$VH_NAME/
configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
virtualHostConfig {
enableGzip 1
docRoot $VH_ROOT/public_html/
htAccess {
accessFileName .htaccess
allowOverride 31
}
rewrite {
enable 0
logLevel 0
}
awstats {
updateMode 0
workingDir $VH_ROOT/awstats
awstatsURI /awstats/
siteDomain localhost
siteAliases 127.0.0.1 localhost
updateInterval 86400
updateOffset 0
securedConn 0
}
extProcessor $VH_NAME_lsphp{
path $SERVER_ROOT/fcgi-bin/lsphp
backlog 10
instances 5
runOnStartUp 0
respBuffer 0
autoStart 1
extMaxIdleTime 60
priority 0
memSoftLimit 100M
memHardLimit 150M
procSoftLimit 100
procHardLimit 200
type lsapi
address uds://tmp/lshttpd/$VH_NAME_lsphp.sock
maxConns 5
initTimeout 60
retryTimeout 0
persistConn 1
pcKeepAliveTimeout 30
}
index {
useServer 0
autoIndex 0
autoIndexURI /_autoindex/default.php
indexFiles index.html
}
accessLog $SERVER_ROOT/logs/$VH_NAME.access.log{
keepDays 30
rollingSize 100M
compressArchive 1
useServer 0
logHeaders 3
}
errorlog {
useServer 1
}
hotlinkCtrl {
enableHotlinkCtrl 0
suffixes gif, jpeg, jpg
allowDirectAccess 1
onlySelf 1
}
accessControl {
allow *
}
scriptHandler {
add lsapi:$VH_NAME_lsphp php
}
expires {
enableExpires 1
}
context /cgi-bin/{
type cgi
location $VH_ROOT/cgi-bin/
accessControl
rewrite
}
}

View File

@@ -0,0 +1,125 @@
head 1.1;
access;
symbols;
locks
root:1.1; strict;
comment @# @;
1.1
date 2017.08.17.05.47.23; author root; state Exp;
branches;
next ;
desc
@/usr/local/CyberCP/conf/templates/phpsuexec.conf0
@
1.1
log
@Update
@
text
@allowSymbolLink 1
chrootMode 0
enableScript 1
restrained 1
setUIDMode 2
vhRoot $SERVER_ROOT/$VH_NAME/
configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
virtualHostConfig {
enableGzip 1
docRoot $VH_ROOT/public_html/
htAccess {
accessFileName .htaccess
allowOverride 31
}
rewrite {
enable 0
logLevel 0
}
awstats {
updateMode 0
workingDir $VH_ROOT/awstats
awstatsURI /awstats/
siteDomain localhost
siteAliases 127.0.0.1 localhost
updateInterval 86400
updateOffset 0
securedConn 0
}
extProcessor $VH_NAME_lsphp{
path $SERVER_ROOT/fcgi-bin/lsphp
backlog 10
instances 5
runOnStartUp 0
respBuffer 0
autoStart 1
extMaxIdleTime 60
priority 0
memSoftLimit 100M
memHardLimit 150M
procSoftLimit 100
procHardLimit 200
type lsapi
address uds://tmp/lshttpd/$VH_NAME_lsphp.sock
maxConns 5
initTimeout 60
retryTimeout 0
persistConn 1
pcKeepAliveTimeout 30
}
index {
useServer 0
autoIndex 0
autoIndexURI /_autoindex/default.php
indexFiles index.html
}
accessLog $SERVER_ROOT/logs/$VH_NAME.access.log{
keepDays 30
rollingSize 100M
compressArchive 1
useServer 0
logHeaders 3
}
errorlog {
useServer 1
}
hotlinkCtrl {
enableHotlinkCtrl 0
suffixes gif, jpeg, jpg
allowDirectAccess 1
onlySelf 1
}
accessControl {
allow *
}
scriptHandler {
add lsapi:$VH_NAME_lsphp php
}
expires {
enableExpires 1
}
context /cgi-bin/{
type cgi
location $VH_ROOT/cgi-bin/
accessControl
rewrite
}
}
@

View File

@@ -0,0 +1,76 @@
allowSymbolLink 1
chrootMode 0
enableScript 1
restrained 1
setUIDMode 2
vhRoot $SERVER_ROOT/$VH_NAME/
configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
virtualHostConfig {
enableGzip 1
docRoot $VH_ROOT/public/
accessControl {
allow *
}
hotlinkCtrl {
suffixes gif, jpeg, jpg
allowDirectAccess 1
onlySelf 1
enableHotlinkCtrl 0
}
rewrite {
enable 0
logLevel 0
}
index {
useServer 0
autoIndex 0
indexFiles index.html
autoIndexURI /_autoindex/default.php
}
accessLog $SERVER_ROOT/logs/$VH_NAME.access.log{
logHeaders 3
compressArchive 0
useServer 0
keepDays 30
rollingSize 500M
}
errorlog {
useServer 1
}
context /{
railsEnv 1
maxConns 5
location $VH_ROOT/
type rails
accessControl
addDefaultCharset off
}
htAccess {
allowOverride 0
accessFileName .htaccess
}
expires {
enableExpires 1
}
awstats {
workingDir $VH_ROOT/awstats
awstatsURI /awstats/
siteDomain localhost
siteAliases 127.0.0.1 localhost
updateMode 0
updateInterval 86400
updateOffset 0
securedConn 0
}
}

View File

@@ -0,0 +1,101 @@
head 1.1;
access;
symbols;
locks
root:1.1; strict;
comment @# @;
1.1
date 2017.08.17.05.47.23; author root; state Exp;
branches;
next ;
desc
@/usr/local/CyberCP/conf/templates/rails.conf0
@
1.1
log
@Update
@
text
@allowSymbolLink 1
chrootMode 0
enableScript 1
restrained 1
setUIDMode 2
vhRoot $SERVER_ROOT/$VH_NAME/
configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
virtualHostConfig {
enableGzip 1
docRoot $VH_ROOT/public/
accessControl {
allow *
}
hotlinkCtrl {
suffixes gif, jpeg, jpg
allowDirectAccess 1
onlySelf 1
enableHotlinkCtrl 0
}
rewrite {
enable 0
logLevel 0
}
index {
useServer 0
autoIndex 0
indexFiles index.html
autoIndexURI /_autoindex/default.php
}
accessLog $SERVER_ROOT/logs/$VH_NAME.access.log{
logHeaders 3
compressArchive 0
useServer 0
keepDays 30
rollingSize 500M
}
errorlog {
useServer 1
}
context /{
railsEnv 1
maxConns 5
location $VH_ROOT/
type rails
accessControl
addDefaultCharset off
}
htAccess {
allowOverride 0
accessFileName .htaccess
}
expires {
enableExpires 1
}
awstats {
workingDir $VH_ROOT/awstats
awstatsURI /awstats/
siteDomain localhost
siteAliases 127.0.0.1 localhost
updateMode 0
updateInterval 86400
updateOffset 0
securedConn 0
}
}
@

View File

@@ -0,0 +1,4 @@
group1: user1,user2, user3
group2:
user: user8, test
group3:

View File

@@ -0,0 +1,2 @@
test:kF2EDBE2Ux8sQ
user1:SQtevcsBBnBPY

View File

@@ -0,0 +1,119 @@
docRoot $VH_ROOT/html/
enableGzip 1
context /docs/{
allowBrowse 1
location $SERVER_ROOT/docs/
type NULL
}
context /protected/{
required user test
authName Protected
type NULL
allowBrowse 1
location protected/
realm SampleProtectedArea
accessControl {
deny
allow *
}
}
context /blocked/{
allowBrowse 0
type NULL
}
context /cgi-bin/{
allowBrowse 1
location $VH_ROOT/cgi-bin/
type cgi
}
expires {
enableExpires 1
}
index {
autoIndexURI /_autoindex/default.php
indexFiles index.html
autoIndex 0
useServer 0
}
errorPage 404{
url /error404.html
}
errorlog $VH_ROOT/logs/error.log{
logLevel DEBUG
rollingSize 10M
useServer 1
}
accessLog $VH_ROOT/logs/access.log{
compressArchive 0
logReferer 1
keepDays 30
rollingSize 10M
logUserAgent 1
useServer 0
}
htAccess {
accessFileName .htaccess
allowOverride 0
}
awstats {
updateInterval 86400
workingDir $VH_ROOT/awstats
updateOffset 0
siteDomain localhost
siteAliases 127.0.0.1 localhost
updateMode 0
awstatsURI /awstats/
}
rewrite {
enable 0
logLevel 0
rules <<<END_rules
RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot
RewriteRule ^/nospider/ - [F]
END_rules
}
hotlinkCtrl {
suffixes gif, jpeg, jpg
allowedHosts
allowDirectAccess 1
enableHotlinkCtrl 0
onlySelf 1
}
accessControl {
deny
allow *
}
realm SampleProtectedArea {
userDB {
cacheTimeout 60
maxCacheSize 200
location $SERVER_ROOT/conf/vhosts/Example/htpasswd
}
groupDB {
cacheTimeout 60
maxCacheSize 200
location $SERVER_ROOT/conf/vhosts/Example/htgroup
}
}
general {
enableContextAC 0
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,67 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
# Warning: Do not edit this file directly, this file is autogenerated.
#
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
ServerRoot "/usr/local/lsws"
Listen 0.0.0.0:80
Listen [::]:80
Listen 0.0.0.0:443
Listen [::]:443
User nobody
Group nobody
ServerAdmin root@localhost
<Directory />
AllowOverride none
</Directory>
<Directory /home>
AllowOverride All
Options +Includes -Indexes +ExecCGI
</Directory>
DirectoryIndex index.php index.html
<Files ".ht*">
Require all denied
</Files>
ErrorLog "/usr/local/lsws/logs/error.log"
LogLevel warn
LogFormat '"%v %h %l %u %t \"%r\" %>s %b"' combined
CustomLog "/usr/local/lsws/logs/access.log" combined
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
#AddHandler cgi-script .cgi
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
SSLProtocol all -SSLv3 -TLSv1
SSLHonorCipherOrder on
SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:HIGH:!EDH-RSA-DES-CBC3-SHA:!DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4
<IfModule Litespeed>
CacheRoot /home/lscache/
</IfModule>
Include /usr/local/lsws/conf/modsec.conf

View File

@@ -0,0 +1,388 @@
<?xml version="1.0" encoding="UTF-8"?>
<httpServerConfig>
<serverName>$HOSTNAME</serverName>
<user>nobody</user>
<group>nobody</group>
<priority>0</priority>
<chrootPath>/</chrootPath>
<enableChroot>0</enableChroot>
<inMemBufSize>120M</inMemBufSize>
<swappingDir>/tmp/lshttpd/swap</swappingDir>
<autoFix503>1</autoFix503>
<loadApacheConf>1</loadApacheConf>
<autoReloadApacheConf>0</autoReloadApacheConf>
<apacheConfFile>/usr/local/lsws/conf/httpd.conf</apacheConfFile>
<apachePortOffset>0</apachePortOffset>
<apacheIpOffset>0</apacheIpOffset>
<phpSuExec>1</phpSuExec>
<phpSuExecMaxConn>5</phpSuExecMaxConn>
<mime>$SERVER_ROOT/conf/mime.properties</mime>
<showVersionNumber>0</showVersionNumber>
<autoUpdateInterval>86400</autoUpdateInterval>
<autoUpdateDownloadPkg>1</autoUpdateDownloadPkg>
<adminEmails>usman@cyberpersons.com</adminEmails>
<adminRoot>$SERVER_ROOT/admin/</adminRoot>
<logging>
<log>
<fileName>$SERVER_ROOT/logs/error.log</fileName>
<logLevel>DEBUG</logLevel>
<debugLevel>0</debugLevel>
<rollingSize>10M</rollingSize>
<enableStderrLog>1</enableStderrLog>
<enableAioLog>1</enableAioLog>
</log>
<accessLog>
<fileName>$SERVER_ROOT/logs/access.log</fileName>
<rollingSize>10M</rollingSize>
<keepDays>30</keepDays>
<compressArchive>0</compressArchive>
</accessLog>
</logging>
<indexFiles>index.html, index.php</indexFiles>
<htAccess>
<allowOverride>0</allowOverride>
<accessFileName>.htaccess</accessFileName>
</htAccess>
<expires>
<enableExpires>1</enableExpires>
<expiresByType>image/*=A604800, text/css=A604800, application/x-javascript=A604800, application/javascript=A604800</expiresByType>
</expires>
<tuning>
<eventDispatcher>best</eventDispatcher>
<maxConnections>2000</maxConnections>
<maxSSLConnections>200</maxSSLConnections>
<connTimeout>300</connTimeout>
<maxKeepAliveReq>1000</maxKeepAliveReq>
<smartKeepAlive>0</smartKeepAlive>
<keepAliveTimeout>5</keepAliveTimeout>
<sndBufSize>0</sndBufSize>
<rcvBufSize>0</rcvBufSize>
<maxReqURLLen>8192</maxReqURLLen>
<maxReqHeaderSize>16380</maxReqHeaderSize>
<maxReqBodySize>500M</maxReqBodySize>
<maxDynRespHeaderSize>8K</maxDynRespHeaderSize>
<maxDynRespSize>500M</maxDynRespSize>
<maxCachedFileSize>4096</maxCachedFileSize>
<totalInMemCacheSize>20M</totalInMemCacheSize>
<maxMMapFileSize>256K</maxMMapFileSize>
<totalMMapCacheSize>40M</totalMMapCacheSize>
<useSendfile>1</useSendfile>
<useAIO>1</useAIO>
<AIOBlockSize>4</AIOBlockSize>
<enableGzipCompress>1</enableGzipCompress>
<enableDynGzipCompress>1</enableDynGzipCompress>
<gzipCompressLevel>1</gzipCompressLevel>
<compressibleTypes>text/*,application/x-javascript,application/javascript,application/xml, image/svg+xml</compressibleTypes>
<gzipAutoUpdateStatic>1</gzipAutoUpdateStatic>
<gzipStaticCompressLevel>6</gzipStaticCompressLevel>
<gzipMaxFileSize>1M</gzipMaxFileSize>
<gzipMinFileSize>300</gzipMinFileSize>
<SSLCryptoDevice>null</SSLCryptoDevice>
</tuning>
<quic>
<quicEnable>1</quicEnable>
</quic>
<security>
<fileAccessControl>
<followSymbolLink>1</followSymbolLink>
<checkSymbolLink>0</checkSymbolLink>
<requiredPermissionMask>000</requiredPermissionMask>
<restrictedPermissionMask>000</restrictedPermissionMask>
</fileAccessControl>
<perClientConnLimit>
<staticReqPerSec>0</staticReqPerSec>
<dynReqPerSec>0</dynReqPerSec>
<outBandwidth>0</outBandwidth>
<inBandwidth>0</inBandwidth>
<softLimit>10000</softLimit>
<hardLimit>10000</hardLimit>
<gracePeriod>15</gracePeriod>
<banPeriod>300</banPeriod>
</perClientConnLimit>
<CGIRLimit>
<maxCGIInstances>200</maxCGIInstances>
<minUID>11</minUID>
<minGID>10</minGID>
<priority>0</priority>
<CPUSoftLimit>300</CPUSoftLimit>
<CPUHardLimit>600</CPUHardLimit>
<memSoftLimit>1450M</memSoftLimit>
<memHardLimit>1500M</memHardLimit>
<procSoftLimit>1400</procSoftLimit>
<procHardLimit>1450</procHardLimit>
</CGIRLimit>
<censorshipControl>
<enableCensorship>0</enableCensorship>
<logLevel>0</logLevel>
<defaultAction>deny,log,status:403</defaultAction>
<scanPOST>1</scanPOST>
<uploadTmpDir>/tmp</uploadTmpDir>
<secAuditLog>$SERVER_ROOT/logs/security_audit.log</secAuditLog>
</censorshipControl>
<censorshipRuleSet>
<name>XSS attack</name>
<ruleSetAction>log,deny,status:403,msg:'XSS attack'</ruleSetAction>
<enabled>1</enabled>
<ruleSet>SecFilterSelective ARGS &quot;(alert|expression|eval|url)[[:space:]]*\(&quot;
SecFilterSelective ARGS &quot;(&amp;\{.+\}|(&amp;#[[0-9a-fA-F]]|\x5cx[0-9a-fA-F]){2})&quot;
SecFilterSelective ARGS &quot;((javascript|vbscript):|style[[:space:]]*=)&quot;
SecFilterSelective ARGS &quot;(fromCharCode|http-equiv|&lt;.+&gt;|innerHTML|dynsrc|--&gt;)&quot;
SecFilterSelective ARGS &quot;document\.(body|cookie|location|write)&quot;
SecFilterSelective ARGS_VALUES &quot;jsessionid|phpsessid|onReadyStateChange|xmlHttp&quot;
SecFilterSelective ARGS &quot;&lt;(applet|div|embed|iframe|img|meta|object|script|textarea)&quot;
# JavaScript event handlers
SecFilterSelective ARGS &quot;on(Abort|Blur|Click|DblClick|DragDrop|Error|Focus|KeyUp|KeyDown|KeyPrerss|Load|Mouse(Down|Out|Over|Up)|Move|Reset|Resize|Select|Submit|Unload)&quot;</ruleSet>
</censorshipRuleSet>
<censorshipRuleSet>
<name>SQL injection</name>
<ruleSetAction>log,pass,msg:'SQL Injection attack'</ruleSetAction>
<enabled>1</enabled>
<ruleSet>#SQL generic
SecFilterSelective ARGS &quot;drop[[:space:]]+(database|table|column|procedure)&quot;
SecFilterSelective ARGS &quot;delete[[:space:]]+from|create[[:space:]]+table|update.+set.+=|insert[[:space:]]+into.+values&quot;
SecFilterSelective ARGS &quot;select.+from|bulk[[:space:]]+insert|union.+select|alter[[:space:]]+table&quot;
SecFilterSelective ARGS &quot;or.+1[[:space:]]*=[[:space:]]1|or 1=1--'|'.+--&quot;
SecFilterSelective ARGS &quot;into[[:space:]]+outfile|load[[:space:]]+data|/\*.+\*/&quot;</ruleSet>
</censorshipRuleSet>
<accessDenyDir>
<dir>/</dir>
<dir>/etc/*</dir>
<dir>/dev/*</dir>
<dir>$SERVER_ROOT/conf/*</dir>
<dir>$SERVER_ROOT/admin/conf/*</dir>
</accessDenyDir>
<accessControl>
<allow>ALL</allow>
</accessControl>
</security>
<extProcessorList>
<extProcessor>
<type>lsapi</type>
<name>lsphp5</name>
<address>uds://tmp/lshttpd/lsphp5.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/fcgi-bin/lsphp5</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp53</name>
<address>uds://tmp/lshttpd/lsphp53.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp53/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp54</name>
<address>uds://tmp/lshttpd/lsphp54.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp54/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp55</name>
<address>uds://tmp/lshttpd/lsphp55.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp55/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp56</name>
<address>uds://tmp/lshttpd/lsphp56.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp56/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp70</name>
<address>uds://tmp/lshttpd/lsphp70.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp70/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp71</name>
<address>uds://tmp/lshttpd/lsphp71.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp71/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp72</name>
<address>uds://tmp/lshttpd/lsphp72.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp72/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
</extProcessorList>
<scriptHandlerList>
<scriptHandler>
<suffix>php</suffix>
<type>lsapi</type>
<handler>lsphp5</handler>
</scriptHandler>
<scriptHandler>
<suffix>php5</suffix>
<type>lsapi</type>
<handler>lsphp5</handler>
</scriptHandler>
<scriptHandler>
<suffix>php53</suffix>
<type>lsapi</type>
<handler>lsphp53</handler>
</scriptHandler>
<scriptHandler>
<suffix>php54</suffix>
<type>lsapi</type>
<handler>lsphp54</handler>
</scriptHandler>
<scriptHandler>
<suffix>php55</suffix>
<type>lsapi</type>
<handler>lsphp55</handler>
</scriptHandler>
<scriptHandler>
<suffix>php56</suffix>
<type>lsapi</type>
<handler>lsphp56</handler>
</scriptHandler>
<scriptHandler>
<suffix>php70</suffix>
<type>lsapi</type>
<handler>lsphp70</handler>
</scriptHandler>
<scriptHandler>
<suffix>php71</suffix>
<type>lsapi</type>
<handler>lsphp71</handler>
</scriptHandler>
<scriptHandler>
<suffix>php72</suffix>
<type>lsapi</type>
<handler>lsphp72</handler>
</scriptHandler>
</scriptHandlerList>
<railsDefaults>
<railsEnv>1</railsEnv>
<maxConns>5</maxConns>
<env>LSAPI_MAX_IDLE=60</env>
<initTimeout>180</initTimeout>
<retryTimeout>0</retryTimeout>
<pcKeepAliveTimeout>60</pcKeepAliveTimeout>
<respBuffer>0</respBuffer>
<backlog>50</backlog>
<runOnStartUp>1</runOnStartUp>
<priority>3</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</railsDefaults>
</httpServerConfig>

View File

@@ -0,0 +1,506 @@
#!/bin/sh
cd `dirname "$0"`
source ./functions.sh 2>/dev/null
if [ $? != 0 ]; then
. ./functions.sh
if [ $? != 0 ]; then
echo [ERROR] Can not include 'functions.sh'.
exit 1
fi
fi
test_license()
{
COPY_LICENSE_KEY=1
if [ -f "$LSWS_HOME/conf/serial.no" ]; then
if [ ! -f "$LSINSTALL_DIR/serial.no" ]; then
cp "$LSWS_HOME/conf/serial.no" "$LSINSTALL_DIR/serial.no"
else
diff "$LSWS_HOME/conf/serial.no" "$LSINSTALL_DIR/serial.no" 1>/dev/null
if [ $? -ne 0 ]; then
COPY_LICENSE_KEY=0
fi
fi
fi
# if [ $COPY_LICENSE_KEY -eq 1 ]; then
# if [ -f "$LSWS_HOME/conf/license.key" ] && [ ! -f "$LSINSTALL_DIR/license.key" ]; then
# cp "$LSWS_HOME/conf/license.key" "$LSINSTALL_DIR/license.key"
# fi
# if [ -f "$LSWS_HOME/conf/license.key" ] && [ -f "$LSINSTALL_DIR/license.key" ]; then
# diff "$LSWS_HOME/conf/license.key" "$LSINSTALL_DIR/license.key"
# if [ $? -ne 0 ]; then
# cp "$LSWS_HOME/conf/license.key" "$LSINSTALL_DIR/license.key"
# fi
# fi
# fi
if [ -f "$LSINSTALL_DIR/license.key" ] && [ -f "$LSINSTALL_DIR/serial.no" ]; then
echo "License key and serial number are available, testing..."
echo
bin/lshttpd -V
if [ $? -eq 0 ]; then
LICENSE_OK=1
if [ -f "$LSINSTALL_DIR/conf/license.key" ]; then
mv "$LSINSTALL_DIR/conf/license.key" "$LSINSTALL_DIR/license.key"
bin/lshttpd -t
fi
fi
echo
fi
if [ "x$LICENSE_OK" = "x" ]; then
if [ -f "$LSINSTALL_DIR/serial.no" ]; then
# echo "Serial number is available."
# printf "Would you like to register a license key for this server? [Y/n]"
# read TMP_YN
# echo ""
# if [ "x$TMP_YN" = "x" ] || [ `expr "$TMP_YN" : '[Yy]'` -gt 0 ]; then
echo "Contacting licensing server ..."
echo ""
$LSINSTALL_DIR/bin/lshttpd -r
if [ $? -eq 0 ]; then
echo "[OK] License key received."
$LSINSTALL_DIR/bin/lshttpd -t
if [ $? -eq 0 ]; then
LICENSE_OK=1
else
echo "The license key received does not work."
fi
fi
# fi
fi
fi
if [ "x$LICENSE_OK" = "x" ]; then
if [ -f "$LSINSTALL_DIR/trial.key" ]; then
$LSINSTALL_DIR/bin/lshttpd -t
if [ $? -ne 0 ]; then
exit 1
fi
else
cat <<EOF
[ERROR] Sorry, installation will abort without a valid license key.
For evaluation purpose, please obtain a trial license key from our web
site http://www.litespeedtech.com, copy it to this directory
and run Installer again.
If a production license has been purchased, please copy the serial number
from your confirmation email to this directory and run Installer again.
NOTE:
Please remember to set ftp to BINARY mode when you ftp trial.key from
another machine.
EOF
exit 1
fi
fi
}
configChroot()
{
ENABLE_CHROOT=0
CHROOT_PATH="/"
if [ -f "$LSWS_HOME/conf/httpd_config.xml" ]; then
OLD_ENABLE_CHROOT_CONF=`grep "<enableChroot>" "$LSWS_HOME/conf/httpd_config.xml"`
OLD_CHROOT_PATH_CONF=`grep "<chrootPath>" "$LSWS_HOME/conf/httpd_config.xml"`
OLD_ENABLE_CHROOT=`expr "$OLD_ENABLE_CHROOT_CONF" : '.*<enableChroot>\(.*\)</enableChroot>.*'`
OLD_CHROOT_PATH=`expr "$OLD_CHROOT_PATH_CONF" : '[^<]*<chrootPath>\([^<]*\)</chrootPath>.*'`
if [ "x$OLD_ENABLE_CHROOT" != "x" ]; then
ENABLE_CHROOT=$OLD_ENABLE_CHROOT
fi
if [ "x$OLD_CHROOT_PATH" != "x" ]; then
CHROOT_PATH=$OLD_CHROOT_PATH
fi
fi
CHANGE_CHROOT=0
if [ $INST_USER = "root" ]; then
CHANGE_CHROOT=1
if [ $INSTALL_TYPE = "upgrade" ]; then
CHANGE_CHROOT=0
if [ $ENABLE_CHROOT -eq 1 ]; then
cat <<EOF
Chroot is enabled with your current setup and root directory is set to
$CHROOT_PATH
EOF
else
echo "Chroot is disabled with your current setup."
echo
fi
printf "%s" "Would you like to change chroot settings [y/N]? "
TMP_URC='n'
echo ""
if [ "x$TMP_URC" != "x" ]; then
if [ `expr "$TMP_URC" : '[Yy]'` -gt 0 ]; then
CHANGE_CHROOT=1
fi
fi
fi
if [ $CHANGE_CHROOT -eq 1 ]; then
cat<<EOF
LiteSpeed Web Server Enterprise Edition can run in chroot environment.
It is impossible for the chrooted process and its children processes to
access files outside the new root directory.
With chroot configured properly, there is no need to worry about sensitive
data being accidentally exposed by insecure CGI programs or web server itself.
Even when a hacker some how gain a shell access, all files he can access is
under the chrooted directory.
This installation script will try to setup the initial chroot environment
automatically.
However, it is not easy to setup a chroot environment and you CGI program may
break. So we do not recommend enabling it for the first time user.
It can be enabled later by running this installation script again.
EOF
SUCC=0
printf "%s" "Enable chroot [y/N]: "
TMP_YN='n'
if [ `expr "x$TMP_YN" : 'x[Yy]'` -gt 1 ]; then
ENABLE_CHROOT=1
fi
LSWS_HOME_LEN=`expr "$LSWS_HOME" : '.*'`
if [ $ENABLE_CHROOT -eq 1 ]; then
while [ $SUCC -eq 0 ]; do
cat <<EOF
Chroot path must be absolute path and the server root
$LSWS_HOME
must be included in the chroot directory tree.
EOF
printf "%s" "Chroot directory without trailing '/': "
TMP_CHROOT='n'
if [ "x$TMP_CHROOT" != "x" ]; then
if [ $TMP_CHROOT = '/' ]; then
echo "Set chroot directory to '/' will disable chroot."
printf "%s" "Are you sure? [y/N]"
read TMP_YN
if [ `expr "x$TMP_YN" : 'x[Yy]'` -gt 1 ]; then
ENABLE_CHROOT=0
SUCC=1
fi
else
CHROOT_LEN=`expr "$TMP_CHROOT" : '.*'`
MATCH_LEN=`expr "$LSWS_HOME" : "$TMP_CHROOT"`
if [ $CHROOT_LEN -ne $MATCH_LEN ]; then
echo "Server root is not included in the chroot directory tree"
else
TMP_CHROOT2="$TMP_CHROOT/"
TMP_HOME="$LSWS_HOME/"
MATCH_LEN=`expr "$TMP_HOME" : "$TMP_CHROOT2"`
if [ $MATCH_LEN -le $CHROOT_LEN ]; then
echo "Server root is not included in the chroot diretory tree"
else
SUCC=1
CHROOT_PATH=$TMP_CHROOT
fi
fi
fi
fi
done
fi
fi
fi
}
changeChroot()
{
util_cpfile "$SDIR_OWN" $EXEC_MOD admin/misc/chroot.sh
if [ $CHANGE_CHROOT -eq 1 ]; then
if [ $ENABLE_CHROOT -eq 1 ]; then
$LSWS_HOME/admin/misc/chroot.sh $CHROOT_PATH
$LSWS_HOME/admin/misc/chroot.sh $CHROOT_PATH $LSWS_HOME/bin/lshttpd
$LSWS_HOME/admin/misc/chroot.sh $CHROOT_PATH $LSWS_HOME/admin/fcgi-bin/admin_php5
$LSWS_HOME/admin/misc/chroot.sh $CHROOT_PATH $LSWS_HOME/bin/lscgid
if [ -f $LSWS_HOME/fcgi-bin/php ]; then
$LSWS_HOME/admin/misc/chroot.sh $CHROOT_PATH $LSWS_HOME/fcgi-bin/php
fi
$LSWS_HOME/admin/misc/chroot.sh $CHROOT_PATH $LSWS_HOME/fcgi-bin/lsphp
if [ `expr "x$CHROOT_PATH" : '^x/[^/]'` -gt 1 ]; then
cp $CHROOT_PATH/etc/passwd $CHROOT_PATH/etc/passwd.ls_bak
cp $CHROOT_PATH/etc/group $CHROOT_PATH/etc/group.ls_bak
egrep "$WS_USER|lsadm" /etc/passwd > $CHROOT_PATH/etc/passwd
grep "$WS_GROUP" /etc/group > $CHROOT_PATH/etc/group
fi
fi
cp $LSWS_HOME/conf/httpd_config.xml $LSWS_HOME/conf/httpd_config.xml.bak
chown "$DIR_OWN" $LSWS_HOME/conf/httpd_config.xml.bak
RES=`grep '</chrootPath>' $LSWS_HOME/conf/httpd_config.xml.bak`
if [ $? -eq 1 ]; then
sed -e "s#</group>#</group><chrootPath>$CHROOT_PATH</chrootPath><enableChroot>$ENABLE_CHROOT</enableChroot>#" "$LSWS_HOME/conf/httpd_config.xml.bak" > "$LSWS_HOME/conf/httpd_config.xml"
else
sed -e "s#<chrootPath>.*<\/chrootPath>#<chrootPath>$CHROOT_PATH<\/chrootPath>#" -e "s/<enableChroot>.*<\/enableChroot>/<enableChroot>$ENABLE_CHROOT<\/enableChroot>/" "$LSWS_HOME/conf/httpd_config.xml.bak" > "$LSWS_HOME/conf/httpd_config.xml"
fi
fi
}
installLicense()
{
if [ -f ./serial.no ]; then
cp -f ./serial.no $LSWS_HOME/conf
chown "$SDIR_OWN" $LSWS_HOME/conf/serial.no
chmod "$DOC_MOD" $LSWS_HOME/conf/serial.no
fi
if [ -f ./license.key ]; then
cp -f ./license.key $LSWS_HOME/conf
chown "$SDIR_OWN" $LSWS_HOME/conf/license.key
chmod "$CONF_MOD" $LSWS_HOME/conf/license.key
fi
if [ -f ./trial.key ]; then
cp -f ./trial.key $LSWS_HOME/conf
chown "$SDIR_OWN" $LSWS_HOME/conf/trial.key
chmod "$DOC_MOD" $LSWS_HOME/conf/trial.key
fi
}
portOffset()
{
SUCC=0
SEL=0
while [ $SUCC -eq "0" ]; do
cat <<EOF
Would you like to run LiteSpeed along side with Apache on another port
to make sure everything work properly? If yes, please set "Port Offset"
to a non-zero value, LiteSpeed will run on Port 80 + "Port Offset",
otherwise, set to "0" to replace Apache.
EOF
printf "%s" "Port Offset [2000]? "
TMPS=0
echo ""
if [ "x$TMPS" != "x" ]; then
if [ `expr "$TMP_PORT" : '.*[^0-9]'` -gt 0 ]; then
echo "[ERROR] Only digits is allowed, try again!"
else
AP_PORT_OFFSET=$TMPS
SUCC=1
fi
else
SUCC=1
fi
done
}
enablePHPsuExec()
{
SUCC=0
SEL=0
while [ $SUCC -eq "0" ]; do
cat <<EOF
PHP suEXEC will run php scripts of each web site as the user who own the
document root directory,
LiteSpeed PHP suEXEC does not have any performance penalty like other PHP
suEXEC implementation, and .htaccess configuration overriden has been fully
supported.
Note: You may need to fix some file/directory permissions if phpSuexec or
suphp was not used with Apache.
Would you like to enable PHP suEXEC?
0. No
1. Yes
2. Only in user's home directory (DirectAdmin should use this)
EOF
printf "%s" "Please select (0-2)? [2]"
TMPS=1
echo ""
if [ "x$TMPS" != "x" ]; then
if [ `expr "$TMPS" : '[012]'` -gt 0 ]; then
PHP_SUEXEC=$TMPS
SUCC=1
else
echo "[ERROR] Wrong selection, try again!"
fi
else
SUCC=1
fi
done
}
hostPanelConfig()
{
SETUP_PHP=1
portOffset
enablePHPsuExec
}
hostPanels()
{
SUCC=0
SEL=0
while [ $SUCC -eq "0" ]; do
cat <<EOF
Will you use LiteSpeed Web Server with a hosting control panel?
0. NONE
1. cPanel
2. DirectAdmin
3. Plesk
4. Hsphere
5. Interworx
6. Lxadmin
7. ISPManager
EOF
printf "%s" "Please select (0-7) [0]? "
TMPS=0
echo ""
if [ "x$TMPS" != "x" ]; then
if [ `expr "$TMPS" : '[01234567]'` -gt 0 ]; then
SEL=$TMPS
SUCC=1
PANEL_VARY=""
if [ $SEL -eq "1" ]; then
HOST_PANEL="cpanel"
WS_USER=nobody
WS_GROUP=nogroup
if [ -e "/etc/cpanel/ea4/is_ea4" ] ; then
PANEL_VARY=".ea4"
fi
elif [ $SEL -eq "2" ]; then
HOST_PANEL="directadmin"
WS_USER=apache
WS_GROUP=apache
elif [ $SEL -eq "3" ]; then
HOST_PANEL="plesk"
USER_INFO=`id apache 2>/dev/null`
TST_USER=`expr "$USER_INFO" : 'uid=.*(\(.*\)) gid=.*'`
if [ "x$TST_USER" = "xapache" ]; then
WS_USER=apache
WS_GROUP=apache
else
WS_USER=www-data
WS_GROUP=www-data
# default PID FILE, source the real one, debian and ubuntu different
APACHE_PID_FILE=/var/run/apache2/apache2.pid
source /etc/apache2/envvars 2>/dev/null
if [ $? != 0 ]; then
. /etc/apache2/envvars
fi
PANEL_VARY=".debian"
fi
ADMIN_PORT=7088
elif [ $SEL -eq "4" ]; then
HOST_PANEL="hsphere"
WS_USER=httpd
WS_GROUP=httpd
elif [ $SEL -eq "5" ]; then
HOST_PANEL="interworx"
WS_USER=apache
WS_GROUP=apache
elif [ $SEL -eq "6" ]; then
HOST_PANEL="lxadminh"
WS_USER=apache
WS_GROUP=apache
elif [ $SEL -eq "7" ]; then
HOST_PANEL="ispmanager"
WS_USER=apache
WS_GROUP=apache
fi
fi
DIR_OWN=$WS_USER:$WS_GROUP
CONF_OWN=$WS_USER:$WS_GROUP
else
SUCC=1
fi
done
}
LSINSTALL_DIR=`dirname "$0"`
cd $LSINSTALL_DIR
init
license
install_dir
test_license
admin_login
if [ $INSTALL_TYPE = "reinstall" ]; then
configAdminEmail
if [ $INST_USER = "root" ]; then
hostPanels
fi
if [ "x$HOST_PANEL" = "x" ]; then
getUserGroup
stopLshttpd
getServerPort
getAdminPort
configRuby
enablePHPHandler
else
hostPanelConfig
fi
fi
if [ "x$HOST_PANEL" = "x" ]; then
configChroot
fi
cat <<EOF
Installing, please wait...
EOF
if [ "x$HOST_PANEL" = "xdirectadmin" ]; then
chmod g+x /var/log/httpd/
chgrp apache /var/log/httpd/
chown apache:apache /var/log/httpd/domains
fi
if [ "x$HOST_PANEL" = "x" ]; then
buildConfigFiles
else
buildApConfigFiles
fi
installation
installLicense
if [ "x$HOST_PANEL" = "x" ]; then
changeChroot
# setupPHPAccelerator
installAWStats
fi
finish

View File

@@ -0,0 +1,21 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
# Warning: Do not edit this file directly, this file is autogenerated.
#
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
<IfModule security2_module>
SecRuleEngine off
SecAuditEngine on
SecDebugLogLevel 0
SecAuditLogRelevantStatus ^(?:5|4(?!04))
SecAuditLogParts ABIJDEFHZ
SecAuditLogType Serial
SecAuditLog /usr/local/lsws/logs/auditmodsec.log
SecDataDir /usr/local/lsws/modsec
Include /usr/local/lsws/conf/comodo_litespeed/*.conf
Include /usr/local/lsws/conf/rules.conf
</IfModule>

View File

@@ -0,0 +1,213 @@
#!/usr/local/CyberCP/bin/python2
import os,sys
sys.path.append('/usr/local/CyberCP')
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
django.setup()
import subprocess
import shlex
import argparse
import shutil
import plogical.CyberCPLogFileWriter as logging
from plogical.processUtilities import ProcessUtilities
class ServerStatusUtil:
lswsInstallStatusPath = '/home/cyberpanel/switchLSWSStatus'
serverRootPath = '/usr/local/lsws/'
@staticmethod
def executioner(command, statusFile):
try:
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
if res == 1:
raise 0
else:
return 1
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0
@staticmethod
def installLiteSpeed(licenseKey, statusFile):
try:
cwd = os.getcwd()
try:
command = 'groupadd nobody'
ServerStatusUtil.executioner(command, statusFile)
except:
pass
try:
command = 'usermod -a -G nobody nobody'
ServerStatusUtil.executioner(command, statusFile)
except:
pass
try:
command = 'systemctl stop lsws'
ServerStatusUtil.executioner(command, statusFile)
except:
pass
command = 'wget https://www.litespeedtech.com/packages/5.0/lsws-5.3-ent-x86_64-linux.tar.gz'
if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0
command = 'tar zxf lsws-5.3-ent-x86_64-linux.tar.gz'
if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0
writeSerial = open('lsws-5.3/serial.no', 'w')
writeSerial.writelines(licenseKey)
writeSerial.close()
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/install.sh', 'lsws-5.3/')
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/functions.sh', 'lsws-5.3/')
os.chdir('lsws-5.3')
command = 'chmod +x install.sh'
if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0
command = 'chmod +x functions.sh'
if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0
command = './install.sh'
if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0
os.chdir(cwd)
confPath = '/usr/local/lsws/conf/'
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/httpd_config.xml', confPath)
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/modsec.conf', confPath)
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/httpd.conf', confPath)
try:
command = 'chown -R lsadm:lsadm ' + confPath
subprocess.call(shlex.split(command))
except:
pass
return 1
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0
@staticmethod
def setupFileManager(statusFile):
try:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Setting up Filemanager files..\n")
fileManagerPath = ServerStatusUtil.serverRootPath+"FileManager"
if os.path.exists(fileManagerPath):
shutil.rmtree(fileManagerPath)
shutil.copytree("/usr/local/CyberCP/serverStatus/litespeed/FileManager",fileManagerPath)
## remove unnecessary files
command = 'chmod -R 777 ' + fileManagerPath
if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Filemanager files are set!\n")
return 1
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0
@staticmethod
def recover():
FNULL = open(os.devnull, 'w')
if os.path.exists('/usr/local/lsws'):
shutil.rmtree('/usr/local/lsws')
command = 'tar -zxvf /usr/local/olsBackup.tar.gz -C /usr/local/'
ServerStatusUtil.executioner(command, FNULL)
command = 'mv /usr/local/usr/local/lsws /usr/local'
ServerStatusUtil.executioner(command, FNULL)
if os.path.exists('/usr/local/usr'):
shutil.rmtree('/usr/local/usr')
@staticmethod
def switchTOLSWS(licenseKey):
try:
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
FNULL = open(os.devnull, 'w')
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Starting conversion process..\n")
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Removing OpenLiteSpeed..\n")
## Try to stop current LiteSpeed Process
ProcessUtilities.killLiteSpeed()
if os.path.exists('/usr/local/lsws'):
command = 'tar -zcvf /usr/local/olsBackup.tar.gz /usr/local/lsws'
if ServerStatusUtil.executioner(command, FNULL) == 0:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Failed to create backup of current LSWS. [404]")
ServerStatusUtil.recover()
return 0
dirs = os.listdir('/usr/local/lsws')
for dir in dirs:
if dir.find('lsphp') > -1:
continue
finalDir = '/usr/local/lsws/' + dir
try:
shutil.rmtree(finalDir)
except:
pass
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"OpenLiteSpeed removed.\n")
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Installing LiteSpeed Enterprise Web Server ..\n")
if ServerStatusUtil.installLiteSpeed(licenseKey, statusFile) == 0:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Failed to install LiteSpeed. [404]")
ServerStatusUtil.recover()
return 0
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"LiteSpeed Enterprise Web Server installed.\n")
if ServerStatusUtil.setupFileManager(statusFile) == 0:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Failed to set up File Manager. [404]")
ServerStatusUtil.recover()
return 0
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Successfully switched to LITESPEED ENTERPRISE WEB SERVER. [200]\n")
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
ServerStatusUtil.recover()
def main():
parser = argparse.ArgumentParser(description='Server Status Util.')
parser.add_argument('function', help='Specific a function to call!')
parser.add_argument('--licenseKey', help='LITESPEED ENTERPRISE WEB SERVER License Key')
args = parser.parse_args()
if args.function == "switchTOLSWS":
ServerStatusUtil.switchTOLSWS(args.licenseKey)
if __name__ == "__main__":
main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -5,7 +5,7 @@
/* 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) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -13,7 +13,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.serverStatusCouldNotConnect = true; $scope.serverStatusCouldNotConnect = true;
$scope.restartLitespeed = function(){ $scope.restartLitespeed = function () {
$scope.disableReboot = true; $scope.disableReboot = true;
@@ -21,21 +21,19 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.restartorStopLoading = false; $scope.restartorStopLoading = false;
var url = "/serverstatus/startorstopLitespeed"; var url = "/serverstatus/startorstopLitespeed";
var data = { var data = {
reboot:1, reboot: 1,
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
@@ -44,7 +42,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.disableReboot = false; $scope.disableReboot = false;
$scope.disableStop = false; $scope.disableStop = false;
if(response.data.reboot == 1){ if (response.data.reboot == 1) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = false; $scope.actionResult = false;
@@ -52,7 +50,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.serverStatusCouldNotConnect = true; $scope.serverStatusCouldNotConnect = true;
} }
else{ else {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -62,6 +60,7 @@ app.controller('litespeedStatus', function($scope,$http) {
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -72,13 +71,9 @@ app.controller('litespeedStatus', function($scope,$http) {
} }
}; };
$scope.stopLitespeed = function () {
$scope.stopLitespeed = function(){
$scope.disableReboot = true; $scope.disableReboot = true;
@@ -86,21 +81,19 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.restartorStopLoading = false; $scope.restartorStopLoading = false;
var url = "/serverstatus/startorstopLitespeed"; var url = "/serverstatus/startorstopLitespeed";
var data = { var data = {
reboot:0, reboot: 0,
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
@@ -109,7 +102,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.disableReboot = false; $scope.disableReboot = false;
$scope.disableStop = false; $scope.disableStop = false;
if(response.data.shutdown == 1){ if (response.data.shutdown == 1) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = false; $scope.actionResult = false;
@@ -117,7 +110,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.serverStatusCouldNotConnect = true; $scope.serverStatusCouldNotConnect = true;
} }
else{ else {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -127,6 +120,7 @@ app.controller('litespeedStatus', function($scope,$http) {
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -137,24 +131,136 @@ app.controller('litespeedStatus', function($scope,$http) {
} }
};
/// License Manager
$scope.cpLoading = true;
$scope.fetchedData = true;
$scope.changeSerialBox = true;
$scope.hideLicenseStatus = function () {
$scope.fetchedData = true;
};
$scope.licenseStatus = function () {
$scope.cpLoading = false;
$scope.changeSerialBox = true;
var url = "/serverstatus/licenseStatus";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.status === 1) {
$scope.cpLoading = true;
$scope.fetchedData = false;
new PNotify({
title: 'Success!',
text: 'Status successfully fetched',
type: 'success'
});
$scope.lsSerial = response.data.lsSerial;
$scope.lsexpiration = response.data.lsexpiration;
}
else {
$scope.cpLoading = true;
new PNotify({
title: 'Operation Failed!',
text: response.data.erroMessage,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cpLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page.',
type: 'error'
});
}
};
$scope.showSerialBox = function () {
$scope.fetchedData = true;
$scope.changeSerialBox = false;
};
$scope.changeLicense = function () {
$scope.cpLoading = false;
var url = "/serverstatus/changeLicense";
var data = {newKey: $scope.newKey};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.status === 1) {
$scope.cpLoading = true;
new PNotify({
title: 'Success!',
text: 'License successfully Updated',
type: 'success'
});
}
else {
$scope.cpLoading = true;
new PNotify({
title: 'Operation Failed!',
text: response.data.erroMessage,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cpLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page.',
type: 'error'
});
}
}; };
}); });
/* Java script code to start/stop litespeed */ /* Java script code to start/stop litespeed */
/* Java script code to read log file */ /* Java script code to read log file */
app.controller('readCyberCPLogFile', function ($scope, $http) {
app.controller('readCyberCPLogFile', function($scope,$http) {
$scope.logFileLoading = false; $scope.logFileLoading = false;
$scope.logsFeteched = true; $scope.logsFeteched = true;
@@ -166,19 +272,18 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
var data = {}; var data = {};
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
if (response.data.logstatus == 1) {
if(response.data.logstatus == 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -187,9 +292,8 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
$scope.logsData = response.data.logsdata; $scope.logsData = response.data.logsdata;
} }
else{ else {
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = true; $scope.logsFeteched = true;
@@ -200,6 +304,7 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.logFileLoading = true; $scope.logFileLoading = true;
@@ -209,9 +314,7 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
} }
$scope.fetchLogs = function () {
$scope.fetchLogs = function(){
$scope.logFileLoading = false; $scope.logFileLoading = false;
@@ -224,19 +327,18 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
var data = {}; var data = {};
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
if (response.data.logstatus == 1) {
if(response.data.logstatus == 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -245,9 +347,8 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
$scope.logsData = response.data.logsdata; $scope.logsData = response.data.logsdata;
} }
else{ else {
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = true; $scope.logsFeteched = true;
@@ -258,6 +359,7 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.logFileLoading = true; $scope.logFileLoading = true;
@@ -267,29 +369,23 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
} }
}; };
}); });
/* Java script code to read log file ends here */ /* Java script code to read log file ends here */
/* Java script code to read log file ends here */ /* Java script code to read log file ends here */
/* Services */ /* Services */
app.controller('servicesManager', function($scope,$http) { app.controller('servicesManager', function ($scope, $http) {
$scope.services = false; $scope.services = false;
$scope.btnDisable = false; $scope.btnDisable = false;
$scope.actionLoader = false; $scope.actionLoader = false;
function getServiceStatus(){ function getServiceStatus() {
$scope.btnDisable = true; $scope.btnDisable = true;
url = "/serverstatus/servicesStatus"; url = "/serverstatus/servicesStatus";
@@ -366,6 +462,7 @@ app.controller('servicesManager', function($scope,$http) {
$scope.btnDisable = false; $scope.btnDisable = false;
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
@@ -374,7 +471,7 @@ app.controller('servicesManager', function($scope,$http) {
}; };
getServiceStatus(); getServiceStatus();
$scope.serviceAction = function(serviceName, action){ $scope.serviceAction = function (serviceName, action) {
$scope.ActionProgress = true; $scope.ActionProgress = true;
$scope.btnDisable = true; $scope.btnDisable = true;
$scope.ActionSuccessfull = false; $scope.ActionSuccessfull = false;
@@ -385,23 +482,23 @@ app.controller('servicesManager', function($scope,$http) {
url = "/serverstatus/servicesAction"; url = "/serverstatus/servicesAction";
var data = { var data = {
service:serviceName, service: serviceName,
action:action action: action
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
console.log(response.data); console.log(response.data);
if(response.data.serviceAction == 1){ if (response.data.serviceAction == 1) {
setTimeout(function() { setTimeout(function () {
getServiceStatus(); getServiceStatus();
$scope.ActionSuccessfull = true; $scope.ActionSuccessfull = true;
$scope.ActionFailed = false; $scope.ActionFailed = false;
@@ -410,8 +507,8 @@ app.controller('servicesManager', function($scope,$http) {
$scope.btnDisable = false; $scope.btnDisable = false;
}, 3000); }, 3000);
} }
else{ else {
setTimeout(function() { setTimeout(function () {
getServiceStatus(); getServiceStatus();
$scope.ActionSuccessfull = false; $scope.ActionSuccessfull = false;
$scope.ActionFailed = true; $scope.ActionFailed = true;
@@ -423,6 +520,7 @@ app.controller('servicesManager', function($scope,$http) {
} }
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.ActionSuccessfull = false; $scope.ActionSuccessfull = false;
$scope.ActionFailed = false; $scope.ActionFailed = false;
@@ -434,3 +532,108 @@ app.controller('servicesManager', function($scope,$http) {
} }
}); });
app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
$scope.cyberPanelLoading = true;
$scope.installBoxGen = true;
$scope.switchTOLSWS = function () {
$scope.cyberPanelLoading = false;
$scope.installBoxGen = true;
url = "/serverstatus/switchTOLSWS";
var data = {
licenseKey: $scope.licenseKey
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
$scope.installBoxGen = false;
getRequestStatus();
}
else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
function getRequestStatus() {
$scope.cyberPanelLoading = false;
url = "/serverstatus/switchTOLSWSStatus";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.abort === 0) {
$scope.requestData = response.data.requestStatus;
$timeout(getRequestStatus, 1000);
}
else {
// Notifications
$scope.cyberPanelLoading = true;
$timeout.cancel();
$scope.requestData = response.data.requestStatus;
if (response.data.installed === 1) {
$timeout(function () {
$window.location.reload();
}, 3000);
}
}
}
function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
}
});

View File

@@ -3,14 +3,13 @@
{% block title %}{% trans "LiteSpeed Status - CyberPanel" %}{% endblock %} {% block title %}{% trans "LiteSpeed Status - CyberPanel" %}{% endblock %}
{% block content %} {% block content %}
{% load static %} {% load static %}
{% get_current_language as LANGUAGE_CODE %} {% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} --> <!-- Current language: {{ LANGUAGE_CODE }} -->
{% if OLS %}
<div class="container">
<div class="container">
<div id="page-title"> <div id="page-title">
<h2>{% trans "LiteSpeed Status:" %} <img src="{% static 'images/lsON.png' %}"></h2> <h2>{% trans "LiteSpeed Status:" %} <img src="{% static 'images/lsON.png' %}"></h2>
@@ -68,12 +67,14 @@
</div> </div>
{% endif %} {% endif %}
<button ng-click="restartLitespeed()" ng-disabled="disableReboot" class="btn btn-alt btn-hover btn-blue-alt"> <button ng-click="restartLitespeed()" ng-disabled="disableReboot"
class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Reboot Litespeed" %}</span> <span>{% trans "Reboot Litespeed" %}</span>
<i class="glyph-icon icon-arrow-right"></i> <i class="glyph-icon icon-arrow-right"></i>
</button> </button>
<button ng-click="stopLitespeed()" ng-disable="disableStop" class="btn btn-alt btn-hover btn-danger"> <button ng-click="stopLitespeed()" ng-disable="disableStop"
class="btn btn-alt btn-hover btn-danger">
<span>{% trans "Stop LiteSpeed" %}</span> <span>{% trans "Stop LiteSpeed" %}</span>
<i class="glyph-icon icon-arrow-right"></i> <i class="glyph-icon icon-arrow-right"></i>
</button> </button>
@@ -96,8 +97,6 @@
</div> </div>
</div> </div>
@@ -132,9 +131,248 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="container">
<div ng-controller="lswsSwitch" class="example-box-wrapper">
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
<h3 class="content-box-header bg-blue">
{% trans "Switch to LiteSpeed Enterprise Web Server" %} <img ng-hide="cyberPanelLoading"
src="/static/images/loading.gif">
</h3>
<div class="content-box-wrapper">
<div class="row">
<div class="col-md-12">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "License Key" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="licenseKey"
required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="switchTOLSWS()"
class="btn btn-primary btn-lg btn-block">{% trans "Switch" %}</button>
</div>
</div>
</form>
</div>
<!------ LSWS Switch box ----------------->
<div style="margin-top: 2%" ng-hide="installBoxGen" class="col-md-12">
<form action="/" id="" class="form-horizontal bordered-row">
<div class="form-group">
<div class="col-sm-12 text-center">
<h3><img style="width:70px"
src="{% static 'images/litespeed-logo.png' %}"> {% trans "With great wisdom comes great responsibility." %}
<img ng-hide="cyberPanelLoading" src="/static/images/loading.gif"></h3>
</div>
<div style="margin-top: 2%;" class="col-sm-12">
<textarea ng-model="requestData" rows="15"
class="form-control">{{ requestData }}</textarea>
</div>
</div>
</form>
</div>
</div> <!----- LSWS Switch box ----------------->
</div>
</div>
</div>
</div>
</div>
{% else %}
<div ng-controller="litespeedStatus" class="container">
<div id="page-title">
<h2>{% trans "LiteSpeed Status:" %} <img src="{% static 'images/lsON.png' %}"></h2>
<p>{% trans "On this page you can get information regarding your LiteSpeed processes." %}</p>
</div>
<div class="row">
<div class="panel">
<div class="panel-body">
<div class="col-md-12">
<div class="example-box-wrapper">
{% if processList %}
<h3 class="content-box-header bg-black">
{% trans "LiteSpeed Processes" %}
</h3>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>{% trans "Process ID" %}</th>
<th>{% trans "Name" %}</th>
</tr>
</thead>
<tbody>
{% for items in processList %}
<tr>
<td>{{ forloop.counter }}</td>
<td> {{ items }}</td>
{% if forloop.counter == 1 %}
<td>{% trans "Main Process" %}</td>
{% elif forloop.counter == 2 %}
<td>{% trans "lscgid Process" %}</td>
{% else %}
<td>{% trans "Worker Process" %}</td>
{% endif %}
{% endfor %}
</tr>
</tbody>
</table>
{% else %}
<div class="alert alert-danger">
<p>{% trans "Could not fetch details, either LiteSpeed is not running or some error occurred, please see CyberPanel Main log file." %}</p>
</div>
{% endif %}
<button ng-click="restartLitespeed()" ng-disabled="disableReboot"
class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Reboot Litespeed" %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
<button ng-click="stopLitespeed()" ng-disable="disableStop"
class="btn btn-alt btn-hover btn-danger">
<span>{% trans "Stop LiteSpeed" %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
<img ng-hide="restartorStopLoading" src="{% static 'images/loading.gif' %}">
<div ng-hide="actionResult" class="alert alert-success">
<p>{% trans "Action successful." %}</p>
</div>
<div ng-hide="actionResultBad" class="alert alert-danger">
<p>{% trans "Error Occurred. See CyberPanel main log file." %}</p>
</div>
<div ng-hide="serverStatusCouldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server." %}</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="example-box-wrapper">
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
<h3 class="content-box-header bg-blue">
{% trans "License Manager" %} <img ng-hide="cpLoading" src="/static/images/loading.gif">
</h3>
<div class="content-box-wrapper">
<div class="row">
<div class="col-md-6" style="margin-bottom: 2%;">
<a ng-click="licenseStatus(1)" href="" title="{% trans 'License Status' %}">
<img src="{% static 'images/agreement.png' %}">
</a>
<a ng-click="licenseStatus(1)" href="" title="{% trans 'License Status' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans 'License Status' %}</span>
</a>
</div>
<div class="col-md-6" style="margin-bottom: 2%;">
<a ng-click="showSerialBox()" href="" title="{% trans 'Change License' %}">
<img src="{% static 'images/change.png' %}">
</a>
<a ng-click="showSerialBox()" href="" title="{% trans 'Change License' %}">
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans 'Change License' %}</span>
</a>
</a>
</div>
<div class="col-md-12">
<div ng-hide="fetchedData">
<div class="alert alert-success">
<div class="bg-green alert-icon">
<i class="glyph-icon icon-check"></i>
</div>
<div class="alert-content">
<h4 class="alert-title">{$ lsSerial $}</h4>
<p>{$ lsexpiration $}</p>
</div>
</div>
</div>
</div>
<!---------- HTML For Changing Serial No --------------->
<div ng-hide="changeSerialBox" class="col-md-12">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "New key" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="newKey" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="changeLicense()"
class="btn btn-primary btn-lg btn-block">{% trans "Change Key" %}</button>
</div>
</div>
</form>
</div>
<!---------- HTML For Changing Serial No --------------->
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %} {% endblock %}

View File

@@ -35,7 +35,7 @@
</div> </div>
<div class="serviceDetails"> <div class="serviceDetails">
<div class="serviceHeading"> <div class="serviceHeading">
<h5><b>OpenLiteSpeed</b></h5> <h5><b>{{ serverName }}</b></h5>
<span class="help-block" ng-bind="olsStatus">Stopped</span> <span class="help-block" ng-bind="olsStatus">Stopped</span>
</div> </div>
<div class="serviceActionBtn"> <div class="serviceActionBtn">

View File

@@ -3,13 +3,17 @@ import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.serverStatusHome, name='serverStatusHome'), url(r'^$', views.serverStatusHome, name='serverStatusHome'),
url(r'^litespeedStatus', views.litespeedStatus, name='litespeedStatus'), url(r'^litespeedStatus$', views.litespeedStatus, name='litespeedStatus'),
url(r'^startorstopLitespeed', views.stopOrRestartLitespeed, name='startorstopLitespeed'), url(r'^startorstopLitespeed$', views.stopOrRestartLitespeed, name='startorstopLitespeed'),
url(r'^cyberCPMainLogFile', views.cyberCPMainLogFile, name='cyberCPMainLogFile'), url(r'^cyberCPMainLogFile$', views.cyberCPMainLogFile, name='cyberCPMainLogFile'),
url(r'^getFurtherDataFromLogFile',views.getFurtherDataFromLogFile,name='getFurtherDataFromLogFile'), url(r'^getFurtherDataFromLogFile$',views.getFurtherDataFromLogFile,name='getFurtherDataFromLogFile'),
url(r'^servicesStatus', views.servicesStatus, name='servicesStatus'), url(r'^servicesStatus$', views.servicesStatus, name='servicesStatus'),
url(r'^servicesAction', views.servicesAction, name='servicesAction'), url(r'^servicesAction$', views.servicesAction, name='servicesAction'),
url(r'^services', views.services, name='services'), url(r'^services$', views.services, name='services'),
url(r'^switchTOLSWS$', views.switchTOLSWS, name='switchTOLSWS'),
url(r'^switchTOLSWSStatus$', views.switchTOLSWSStatus, name='switchTOLSWSStatus'),
url(r'^licenseStatus$', views.licenseStatus, name='licenseStatus'),
url(r'^changeLicense$', views.changeLicense, name='changeLicense'),
] ]

View File

@@ -3,7 +3,6 @@ from __future__ import unicode_literals
from django.shortcuts import render,redirect from django.shortcuts import render,redirect
from django.http import HttpResponse from django.http import HttpResponse
from plogical.processUtilities import ProcessUtilities
import plogical.CyberCPLogFileWriter as logging import plogical.CyberCPLogFileWriter as logging
from loginSystem.views import loadLoginPage from loginSystem.views import loadLoginPage
import json import json
@@ -13,6 +12,10 @@ import shlex
import socket import socket
from plogical.acl import ACLManager from plogical.acl import ACLManager
import os import os
from plogical.virtualHostUtilities import virtualHostUtilities
import time
import serverStatusUtil
from plogical.processUtilities import ProcessUtilities
# Create your views here. # Create your views here.
def serverStatusHome(request): def serverStatusHome(request):
@@ -26,7 +29,6 @@ def litespeedStatus(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1: if currentACL['admin'] == 1:
@@ -36,6 +38,9 @@ def litespeedStatus(request):
processList = ProcessUtilities.getLitespeedProcessNumber() processList = ProcessUtilities.getLitespeedProcessNumber()
OLS = 0
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
OLS = 1
try: try:
versionInformation = subprocess.check_output(["/usr/local/lsws/bin/lshttpd", "-v"]).split("\n") versionInformation = subprocess.check_output(["/usr/local/lsws/bin/lshttpd", "-v"]).split("\n")
@@ -54,16 +59,16 @@ def litespeedStatus(request):
except subprocess.CalledProcessError,msg: except subprocess.CalledProcessError,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
return render(request,"serverStatus/litespeedStatus.html",{"processList":processList,"liteSpeedVersionStatus":"For some reaons not able to load version details, see CyberCP main log file."}) return render(request,"serverStatus/litespeedStatus.html",{"processList":processList,"liteSpeedVersionStatus":"For some reaons not able to load version details, see CyberCP main log file.", 'OLS': OLS})
if(processList!=0): if(processList!=0):
dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules, dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules,
"loadedModules": loadedModules} "loadedModules": loadedModules, 'OLS':OLS}
return render(request,"serverStatus/litespeedStatus.html",dataForHtml) return render(request,"serverStatus/litespeedStatus.html",dataForHtml)
else: else:
dataForHtml = {"lsversion": lsversion, "modules": modules, dataForHtml = {"lsversion": lsversion, "modules": modules,
"loadedModules": loadedModules} "loadedModules": loadedModules, 'OLS': OLS}
return render(request, "serverStatus/litespeedStatus.html",dataForHtml) return render(request, "serverStatus/litespeedStatus.html",dataForHtml)
except KeyError,msg: except KeyError,msg:
@@ -152,8 +157,14 @@ def services(request):
pass pass
else: else:
return ACLManager.loadError() return ACLManager.loadError()
data = {}
return render(request, 'serverStatus/services.html') if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
data['serverName'] = 'OpenLiteSpeed'
else:
data['serverName'] = 'LiteSpeed Ent'
return render(request, 'serverStatus/services.html', data)
except KeyError: except KeyError:
return redirect(loadLoginPage) return redirect(loadLoginPage)
@@ -302,3 +313,134 @@ def servicesAction(request):
final_dic = {'serviceAction': 0, 'error_message': str(msg)} final_dic = {'serviceAction': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
def switchTOLSWS(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)
execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/serverStatus/serverStatusUtil.py"
execPath = execPath + " switchTOLSWS --licenseKey " + data['licenseKey']
subprocess.Popen(shlex.split(execPath))
time.sleep(2)
data_ret = {'status': 1, 'error_message': "None", }
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def switchTOLSWSStatus(request):
try:
command = 'sudo cat ' + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath
output = subprocess.check_output(shlex.split(command))
if output.find('[404]') > -1:
data_ret = {'abort': 1, 'requestStatus': output, 'installed': 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
elif output.find('[200]') > -1:
data_ret = {'abort': 1, 'requestStatus': output, 'installed': 1}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'abort': 0, 'requestStatus': output, 'installed': 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'abort': 1, 'requestStatus': str(msg), 'installed': 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def licenseStatus(request):
try:
userID = request.session['userID']
try:
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson('status', 0)
command = 'sudo cat /usr/local/lsws/conf/serial.no'
serial = subprocess.check_output(shlex.split(command))
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
expiration = subprocess.check_output(shlex.split(command))
final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': serial, 'lsexpiration': expiration}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
final_dic = {'status': 0, 'erroMessage': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError, msg:
final_dic = {'status': 0, 'erroMessage': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def changeLicense(request):
try:
userID = request.session['userID']
try:
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson('status', 0)
data = json.loads(request.body)
newKey = data['newKey']
command = 'sudo chown -R cyberpanel:cyberpanel /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
serialPath = '/usr/local/lsws/conf/serial.no'
serialFile = open(serialPath, 'w')
serialFile.write(newKey)
serialFile.close()
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
command = 'sudo /usr/local/lsws/bin/lshttpd -r'
subprocess.call(shlex.split(command))
command = 'sudo /usr/local/lsws/bin/lswsctrl restart'
subprocess.call(shlex.split(command))
final_dic = {'status': 1, "erroMessage": 'None'}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
final_dic = {'status': 0, 'erroMessage': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError, msg:
final_dic = {'status': 0, 'erroMessage': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)

View File

@@ -3,10 +3,6 @@
*/ */
/* Java script code to ADD Firewall Rules */ /* Java script code to ADD Firewall Rules */
app.controller('firewallController', function($scope,$http) { app.controller('firewallController', function($scope,$http) {
@@ -548,8 +544,6 @@ app.controller('firewallController', function($scope,$http) {
/* Java script code to ADD Firewall Rules */ /* Java script code to ADD Firewall Rules */
/* Java script code to Secure SSH */ /* Java script code to Secure SSH */
app.controller('secureSSHCTRL', function($scope,$http) { app.controller('secureSSHCTRL', function($scope,$http) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -5,7 +5,7 @@
/* 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) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -13,7 +13,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.serverStatusCouldNotConnect = true; $scope.serverStatusCouldNotConnect = true;
$scope.restartLitespeed = function(){ $scope.restartLitespeed = function () {
$scope.disableReboot = true; $scope.disableReboot = true;
@@ -21,21 +21,19 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.restartorStopLoading = false; $scope.restartorStopLoading = false;
var url = "/serverstatus/startorstopLitespeed"; var url = "/serverstatus/startorstopLitespeed";
var data = { var data = {
reboot:1, reboot: 1,
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
@@ -44,7 +42,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.disableReboot = false; $scope.disableReboot = false;
$scope.disableStop = false; $scope.disableStop = false;
if(response.data.reboot == 1){ if (response.data.reboot == 1) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = false; $scope.actionResult = false;
@@ -52,7 +50,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.serverStatusCouldNotConnect = true; $scope.serverStatusCouldNotConnect = true;
} }
else{ else {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -62,6 +60,7 @@ app.controller('litespeedStatus', function($scope,$http) {
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -72,13 +71,10 @@ app.controller('litespeedStatus', function($scope,$http) {
} }
}; };
$scope.stopLitespeed = function(){ $scope.stopLitespeed = function () {
$scope.disableReboot = true; $scope.disableReboot = true;
@@ -86,21 +82,19 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.restartorStopLoading = false; $scope.restartorStopLoading = false;
var url = "/serverstatus/startorstopLitespeed"; var url = "/serverstatus/startorstopLitespeed";
var data = { var data = {
reboot:0, reboot: 0,
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
@@ -109,7 +103,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.disableReboot = false; $scope.disableReboot = false;
$scope.disableStop = false; $scope.disableStop = false;
if(response.data.shutdown == 1){ if (response.data.shutdown == 1) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = false; $scope.actionResult = false;
@@ -117,7 +111,7 @@ app.controller('litespeedStatus', function($scope,$http) {
$scope.serverStatusCouldNotConnect = true; $scope.serverStatusCouldNotConnect = true;
} }
else{ else {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -127,6 +121,7 @@ app.controller('litespeedStatus', function($scope,$http) {
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -137,24 +132,15 @@ app.controller('litespeedStatus', function($scope,$http) {
} }
}; };
}); });
/* Java script code to start/stop litespeed */ /* Java script code to start/stop litespeed */
/* Java script code to read log file */ /* Java script code to read log file */
app.controller('readCyberCPLogFile', function ($scope, $http) {
app.controller('readCyberCPLogFile', function($scope,$http) {
$scope.logFileLoading = false; $scope.logFileLoading = false;
$scope.logsFeteched = true; $scope.logsFeteched = true;
@@ -166,19 +152,18 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
var data = {}; var data = {};
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
if (response.data.logstatus == 1) {
if(response.data.logstatus == 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -187,9 +172,8 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
$scope.logsData = response.data.logsdata; $scope.logsData = response.data.logsdata;
} }
else{ else {
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = true; $scope.logsFeteched = true;
@@ -200,6 +184,7 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.logFileLoading = true; $scope.logFileLoading = true;
@@ -209,9 +194,7 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
} }
$scope.fetchLogs = function () {
$scope.fetchLogs = function(){
$scope.logFileLoading = false; $scope.logFileLoading = false;
@@ -224,19 +207,18 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
var data = {}; var data = {};
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
if (response.data.logstatus == 1) {
if(response.data.logstatus == 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -245,9 +227,8 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
$scope.logsData = response.data.logsdata; $scope.logsData = response.data.logsdata;
} }
else{ else {
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = true; $scope.logsFeteched = true;
@@ -258,6 +239,7 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.logFileLoading = true; $scope.logFileLoading = true;
@@ -267,29 +249,23 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
} }
}; };
}); });
/* Java script code to read log file ends here */ /* Java script code to read log file ends here */
/* Java script code to read log file ends here */ /* Java script code to read log file ends here */
/* Services */ /* Services */
app.controller('servicesManager', function($scope,$http) { app.controller('servicesManager', function ($scope, $http) {
$scope.services = false; $scope.services = false;
$scope.btnDisable = false; $scope.btnDisable = false;
$scope.actionLoader = false; $scope.actionLoader = false;
function getServiceStatus(){ function getServiceStatus() {
$scope.btnDisable = true; $scope.btnDisable = true;
url = "/serverstatus/servicesStatus"; url = "/serverstatus/servicesStatus";
@@ -366,6 +342,7 @@ app.controller('servicesManager', function($scope,$http) {
$scope.btnDisable = false; $scope.btnDisable = false;
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
@@ -374,7 +351,7 @@ app.controller('servicesManager', function($scope,$http) {
}; };
getServiceStatus(); getServiceStatus();
$scope.serviceAction = function(serviceName, action){ $scope.serviceAction = function (serviceName, action) {
$scope.ActionProgress = true; $scope.ActionProgress = true;
$scope.btnDisable = true; $scope.btnDisable = true;
$scope.ActionSuccessfull = false; $scope.ActionSuccessfull = false;
@@ -385,23 +362,23 @@ app.controller('servicesManager', function($scope,$http) {
url = "/serverstatus/servicesAction"; url = "/serverstatus/servicesAction";
var data = { var data = {
service:serviceName, service: serviceName,
action:action action: action
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
console.log(response.data); console.log(response.data);
if(response.data.serviceAction == 1){ if (response.data.serviceAction == 1) {
setTimeout(function() { setTimeout(function () {
getServiceStatus(); getServiceStatus();
$scope.ActionSuccessfull = true; $scope.ActionSuccessfull = true;
$scope.ActionFailed = false; $scope.ActionFailed = false;
@@ -410,8 +387,8 @@ app.controller('servicesManager', function($scope,$http) {
$scope.btnDisable = false; $scope.btnDisable = false;
}, 3000); }, 3000);
} }
else{ else {
setTimeout(function() { setTimeout(function () {
getServiceStatus(); getServiceStatus();
$scope.ActionSuccessfull = false; $scope.ActionSuccessfull = false;
$scope.ActionFailed = true; $scope.ActionFailed = true;
@@ -423,6 +400,7 @@ app.controller('servicesManager', function($scope,$http) {
} }
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$scope.ActionSuccessfull = false; $scope.ActionSuccessfull = false;
$scope.ActionFailed = false; $scope.ActionFailed = false;
@@ -434,3 +412,108 @@ app.controller('servicesManager', function($scope,$http) {
} }
}); });
app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
$scope.cyberPanelLoading = true;
$scope.installBoxGen = true;
$scope.switchTOLSWS = function () {
$scope.cyberPanelLoading = false;
$scope.installBoxGen = true;
url = "/serverstatus/switchTOLSWS";
var data = {
licenseKey: $scope.licenseKey
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
$scope.installBoxGen = false;
getRequestStatus();
}
else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
function getRequestStatus() {
$scope.cyberPanelLoading = false;
url = "/serverstatus/switchTOLSWSStatus";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.abort === 0) {
$scope.requestData = response.data.requestStatus;
$timeout(getRequestStatus, 1000);
}
else {
// Notifications
$scope.cyberPanelLoading = true;
$timeout.cancel();
$scope.requestData = response.data.requestStatus;
if (response.data.installed === 1) {
$timeout(function () {
$window.location.reload();
}, 3000);
}
}
}
function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
}
});