mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 13:56:01 +01:00
docker manager
This commit is contained in:
@@ -24,7 +24,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||||||
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
|
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = False
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
@@ -110,15 +110,15 @@ DATABASES = {
|
|||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'cyberpanel',
|
'NAME': 'cyberpanel',
|
||||||
'USER': 'cyberpanel',
|
'USER': 'cyberpanel',
|
||||||
'PASSWORD': 'a9AwLb7zY7ZwCd',
|
'PASSWORD': 'Bz9gF7Hr7X4RtD',
|
||||||
'HOST': 'localhost',
|
'HOST': '127.0.0.1',
|
||||||
'PORT': '',
|
'PORT':'3307'
|
||||||
},
|
},
|
||||||
'rootdb': {
|
'rootdb': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'mysql',
|
'NAME': 'mysql',
|
||||||
'USER': 'root',
|
'USER': 'root',
|
||||||
'PASSWORD': '3bL8X7wGo0kT3b',
|
'PASSWORD': 'sXm5VlRaAsXkDd',
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
'PORT': '',
|
'PORT': '',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ urlpatterns = [
|
|||||||
url(r'^', include('loginSystem.urls')),
|
url(r'^', include('loginSystem.urls')),
|
||||||
url(r'^packages/',include('packages.urls')),
|
url(r'^packages/',include('packages.urls')),
|
||||||
url(r'^websites/',include('websiteFunctions.urls')),
|
url(r'^websites/',include('websiteFunctions.urls')),
|
||||||
url(r'^docker/',include('dockerManager.urls')),
|
|
||||||
url(r'^tuning/',include('tuning.urls')),
|
url(r'^tuning/',include('tuning.urls')),
|
||||||
url(r'^ftp/',include('ftp.urls')),
|
url(r'^ftp/',include('ftp.urls')),
|
||||||
url(r'^serverstatus/',include('serverStatus.urls')),
|
url(r'^serverstatus/',include('serverStatus.urls')),
|
||||||
@@ -41,4 +40,5 @@ urlpatterns = [
|
|||||||
url(r'^plugins/',include('pluginHolder.urls')),
|
url(r'^plugins/',include('pluginHolder.urls')),
|
||||||
url(r'^emailMarketing/', include('emailMarketing.urls')),
|
url(r'^emailMarketing/', include('emailMarketing.urls')),
|
||||||
url(r'^cloudAPI/', include('cloudAPI.urls')),
|
url(r'^cloudAPI/', include('cloudAPI.urls')),
|
||||||
|
url(r'^docker/', include('dockerManager.urls')),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -570,7 +570,7 @@ def changeAdminPassword(request):
|
|||||||
firstName="Cyber", lastName="Panel", acl=acl, token=token)
|
firstName="Cyber", lastName="Panel", acl=acl, token=token)
|
||||||
admin.save()
|
admin.save()
|
||||||
|
|
||||||
vers = version(currentVersion="1.7", build=6)
|
vers = version(currentVersion="1.7", build=7)
|
||||||
vers.save()
|
vers.save()
|
||||||
|
|
||||||
package = Package(admin=admin, packageName="Default", diskSpace=1000,
|
package = Package(admin=admin, packageName="Default", diskSpace=1000,
|
||||||
|
|||||||
@@ -666,9 +666,9 @@
|
|||||||
<script src="{% static 'managePHP/managePHP.js' %}"></script>
|
<script src="{% static 'managePHP/managePHP.js' %}"></script>
|
||||||
<script src="{% static 'baseTemplate/bootstrap-toggle.min.js' %}"></script>
|
<script src="{% static 'baseTemplate/bootstrap-toggle.min.js' %}"></script>
|
||||||
<script src="{% static 'firewall/firewall.js' %}"></script>
|
<script src="{% static 'firewall/firewall.js' %}"></script>
|
||||||
<script src="{% static 'dockerManager/dockerManager.js' %}"></script>
|
|
||||||
<script src="{% static 'manageSSL/manageSSL.js' %}"></script>
|
<script src="{% static 'manageSSL/manageSSL.js' %}"></script>
|
||||||
<script src="{% static 'manageServices/manageServices.js' %}"></script>
|
<script src="{% static 'manageServices/manageServices.js' %}"></script>
|
||||||
|
<script src="{% static 'dockerManager/dockerManager.js' %}"></script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1089,6 +1089,81 @@ class CloudManager:
|
|||||||
|
|
||||||
finalData = mysqlUtilities.restartMySQL()
|
finalData = mysqlUtilities.restartMySQL()
|
||||||
|
|
||||||
|
finalData = json.dumps(finalData)
|
||||||
|
return HttpResponse(finalData)
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchDatabasesMYSQL(self, request):
|
||||||
|
try:
|
||||||
|
request.session['userID'] = self.admin.pk
|
||||||
|
currentACL = ACLManager.loadedACL( self.admin.pk)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 0:
|
||||||
|
return self.ajaxPre(0, 'Only administrators can see MySQL status.')
|
||||||
|
|
||||||
|
finalData = mysqlUtilities.fetchDatabases()
|
||||||
|
|
||||||
|
finalData = json.dumps(finalData)
|
||||||
|
return HttpResponse(finalData)
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchTables(self, request):
|
||||||
|
try:
|
||||||
|
request.session['userID'] = self.admin.pk
|
||||||
|
currentACL = ACLManager.loadedACL( self.admin.pk)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 0:
|
||||||
|
return self.ajaxPre(0, 'Only administrators can see MySQL status.')
|
||||||
|
|
||||||
|
finalData = mysqlUtilities.fetchTables(self.data)
|
||||||
|
|
||||||
|
finalData = json.dumps(finalData)
|
||||||
|
return HttpResponse(finalData)
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def deleteTable(self, request):
|
||||||
|
try:
|
||||||
|
request.session['userID'] = self.admin.pk
|
||||||
|
currentACL = ACLManager.loadedACL( self.admin.pk)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 0:
|
||||||
|
return self.ajaxPre(0, 'Only administrators can see MySQL status.')
|
||||||
|
|
||||||
|
finalData = mysqlUtilities.deleteTable(self.data)
|
||||||
|
|
||||||
|
finalData = json.dumps(finalData)
|
||||||
|
return HttpResponse(finalData)
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchTableData(self, request):
|
||||||
|
try:
|
||||||
|
request.session['userID'] = self.admin.pk
|
||||||
|
currentACL = ACLManager.loadedACL( self.admin.pk)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 0:
|
||||||
|
return self.ajaxPre(0, 'Only administrators can see MySQL status.')
|
||||||
|
|
||||||
|
finalData = mysqlUtilities.fetchTableData(self.data)
|
||||||
|
|
||||||
|
finalData = json.dumps(finalData)
|
||||||
|
return HttpResponse(finalData)
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchStructure(self, request):
|
||||||
|
try:
|
||||||
|
request.session['userID'] = self.admin.pk
|
||||||
|
currentACL = ACLManager.loadedACL( self.admin.pk)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 0:
|
||||||
|
return self.ajaxPre(0, 'Only administrators can see MySQL status.')
|
||||||
|
|
||||||
|
finalData = mysqlUtilities.fetchStructure(self.data)
|
||||||
|
|
||||||
finalData = json.dumps(finalData)
|
finalData = json.dumps(finalData)
|
||||||
return HttpResponse(finalData)
|
return HttpResponse(finalData)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
|
|||||||
@@ -229,6 +229,16 @@ def router(request):
|
|||||||
return cm.applyMySQLChanges(request)
|
return cm.applyMySQLChanges(request)
|
||||||
elif controller == 'restartMySQL':
|
elif controller == 'restartMySQL':
|
||||||
return cm.restartMySQL(request)
|
return cm.restartMySQL(request)
|
||||||
|
elif controller == 'fetchDatabasesMYSQL':
|
||||||
|
return cm.fetchDatabasesMYSQL(request)
|
||||||
|
elif controller == 'fetchTables':
|
||||||
|
return cm.fetchTables(request)
|
||||||
|
elif controller == 'deleteTable':
|
||||||
|
return cm.deleteTable(request)
|
||||||
|
elif controller == 'fetchTableData':
|
||||||
|
return cm.fetchTableData(request)
|
||||||
|
elif controller == 'fetchStructure':
|
||||||
|
return cm.fetchStructure(request)
|
||||||
else:
|
else:
|
||||||
return cm.ajaxPre(0, 'This function is not available in your version of CyberPanel.')
|
return cm.ajaxPre(0, 'This function is not available in your version of CyberPanel.')
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,7 @@
|
|||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h3 class="title-hero">
|
<h3 class="title-hero">
|
||||||
{% trans "Installed Images" %} <img id="imageLoading" src="/static/images/loading.gif" style="display: none;">
|
{% trans "Locally Available Images" %} <img id="imageLoading" src="/static/images/loading.gif" style="display: none;">
|
||||||
{{ test }}
|
|
||||||
</h3><br>
|
</h3><br>
|
||||||
|
|
||||||
<div class="example-box-wrapper">
|
<div class="example-box-wrapper">
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<div id="page-title">
|
<div id="page-title">
|
||||||
<h2 id="domainNamePage">{% trans "Manage Images" %}
|
<h2 id="domainNamePage">{% trans "Manage Images" %}
|
||||||
<a class="pull-right btn btn-primary" href="{% url "containerImage" %}">Create</a>
|
<a class="pull-right btn btn-primary" href="{% url "containerImage" %}">Create Container</a>
|
||||||
</h2>
|
</h2>
|
||||||
<p>{% trans "On this page you can manage docker images." %}</p>
|
<p>{% trans "On this page you can manage docker images." %}</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="imageList">
|
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="imageList">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name (Installed)</th>
|
<th>Name (Locally Available)</th>
|
||||||
<th>Tags</th>
|
<th>Tags</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -4,14 +4,11 @@ from __future__ import unicode_literals
|
|||||||
from django.shortcuts import render,redirect
|
from django.shortcuts import render,redirect
|
||||||
from loginSystem.models import Administrator
|
from loginSystem.models import Administrator
|
||||||
from loginSystem.views import loadLoginPage
|
from loginSystem.views import loadLoginPage
|
||||||
from django.http import HttpResponse
|
|
||||||
from plogical.container import ContainerManager
|
from plogical.container import ContainerManager
|
||||||
from dockerManager.pluginManager import pluginManager
|
from dockerManager.pluginManager import pluginManager
|
||||||
from decorators import preDockerRun
|
from decorators import preDockerRun
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
import json
|
import json
|
||||||
import requests
|
|
||||||
import docker
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|||||||
@@ -1345,9 +1345,9 @@ class FirewallManager:
|
|||||||
if fileName == 'categories.conf':
|
if fileName == 'categories.conf':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if fileName.endswith('dis'):
|
if fileName.endswith('bak'):
|
||||||
status = 0
|
status = 0
|
||||||
fileName = fileName.rstrip('.dis')
|
fileName = fileName.rstrip('.bak')
|
||||||
elif fileName.endswith('conf'):
|
elif fileName.endswith('conf'):
|
||||||
status = 1
|
status = 1
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ class preFlightsChecks:
|
|||||||
|
|
||||||
os.chdir(self.path)
|
os.chdir(self.path)
|
||||||
|
|
||||||
command = "wget http://cyberpanel.sh/CyberPanel.1.7.6.tar.gz"
|
command = "wget http://cyberpanel.sh/CyberPanel.1.7.7.tar.gz"
|
||||||
#command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
|
#command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
|
||||||
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
|
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
|
||||||
'CyberPanel Download',
|
'CyberPanel Download',
|
||||||
@@ -789,7 +789,7 @@ class preFlightsChecks:
|
|||||||
##
|
##
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
command = "tar zxf CyberPanel.1.7.6.tar.gz"
|
command = "tar zxf CyberPanel.1.7.7.tar.gz"
|
||||||
#command = "tar zxf CyberPanelTemp.tar.gz"
|
#command = "tar zxf CyberPanelTemp.tar.gz"
|
||||||
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
|
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
|
||||||
'Extract CyberPanel',1, 1, os.EX_OSERR)
|
'Extract CyberPanel',1, 1, os.EX_OSERR)
|
||||||
|
|||||||
@@ -5409,97 +5409,4 @@ msgstr "Web サイト "
|
|||||||
|
|
||||||
#: websiteFunctions/templates/websiteFunctions/suspendWebsite.html:73
|
#: websiteFunctions/templates/websiteFunctions/suspendWebsite.html:73
|
||||||
msgid "Successfully "
|
msgid "Successfully "
|
||||||
msgstr "成功しました "
|
msgstr "成功しました "
|
||||||
|
|
||||||
#~ msgid "CPU Status"
|
|
||||||
#~ msgstr "CPU の状態"
|
|
||||||
|
|
||||||
#~ msgid "Fullscreen"
|
|
||||||
#~ msgstr "フルスクリーン"
|
|
||||||
|
|
||||||
#~ msgid "System Status"
|
|
||||||
#~ msgstr "システムの状態"
|
|
||||||
|
|
||||||
#~ msgid "Update started..."
|
|
||||||
#~ msgstr "更新を開始..."
|
|
||||||
|
|
||||||
#~ msgid "Update finished..."
|
|
||||||
#~ msgstr "更新を終了..."
|
|
||||||
|
|
||||||
#~ msgid "Account Type"
|
|
||||||
#~ msgstr "アカウント種別"
|
|
||||||
|
|
||||||
#~ msgid "User Accounts Limit"
|
|
||||||
#~ msgstr "ユーザーアカウントの制限"
|
|
||||||
|
|
||||||
#~ msgid "Only Numbers"
|
|
||||||
#~ msgstr "数字のみ"
|
|
||||||
|
|
||||||
#~ msgid "Username should be lowercase alphanumeric."
|
|
||||||
#~ msgstr "ユーザー名は小文字の英数字である必要があります。"
|
|
||||||
|
|
||||||
#~ msgid "Must contain one number and one special character."
|
|
||||||
#~ msgstr "1 つの数字と 1 つの特殊文字を含める必要があります。"
|
|
||||||
|
|
||||||
#~ msgid "Cannot create website. Error message:"
|
|
||||||
#~ msgstr "Web サイトを作成できません。エラーメッセージ:"
|
|
||||||
|
|
||||||
#~ msgid "Website with domain"
|
|
||||||
#~ msgstr "ドメインを持つ Web サイト"
|
|
||||||
|
|
||||||
#~ msgid " is Successfully Created"
|
|
||||||
#~ msgstr " 作成されました"
|
|
||||||
|
|
||||||
#~ msgid "Installation successful. To complete the setup visit:"
|
|
||||||
#~ msgstr "インストールに成功しました。 セットアップを完了するには:"
|
|
||||||
|
|
||||||
#, fuzzy
|
|
||||||
#~| msgid "Username"
|
|
||||||
#~ msgid "Admin Username"
|
|
||||||
#~ msgstr "ユーザー名"
|
|
||||||
|
|
||||||
#, fuzzy
|
|
||||||
#~| msgid "Password"
|
|
||||||
#~ msgid "Admin Password"
|
|
||||||
#~ msgstr "パスワード"
|
|
||||||
|
|
||||||
#, fuzzy
|
|
||||||
#~| msgid "Database Name"
|
|
||||||
#~ msgid "Database prefix"
|
|
||||||
#~ msgstr "データベース名"
|
|
||||||
|
|
||||||
#~ msgid "Daily"
|
|
||||||
#~ msgstr "日次"
|
|
||||||
|
|
||||||
#~ msgid "Weekly"
|
|
||||||
#~ msgstr "週次"
|
|
||||||
|
|
||||||
#~ msgid "HTTP Statistics"
|
|
||||||
#~ msgstr "HTTP の統計情報"
|
|
||||||
|
|
||||||
#~ msgid "Available/Max Connections"
|
|
||||||
#~ msgstr "利用可能/最大 接続数"
|
|
||||||
|
|
||||||
#~ msgid "Available/Max SSL Connections"
|
|
||||||
#~ msgstr "利用可能/最大 SSL 接続数"
|
|
||||||
|
|
||||||
#~ msgid "Requests Processing"
|
|
||||||
#~ msgstr "リクエスト処理数"
|
|
||||||
|
|
||||||
#~ msgid "Total Requests"
|
|
||||||
#~ msgstr "合計リクエスト数"
|
|
||||||
|
|
||||||
#~ msgid "IPV6"
|
|
||||||
#~ msgstr "IPv6"
|
|
||||||
|
|
||||||
#~ msgid "Normal User"
|
|
||||||
#~ msgstr "通常のユーザー"
|
|
||||||
|
|
||||||
#~ msgid "Edit Virtual Host Main Configurations"
|
|
||||||
#~ msgstr "仮想ホストのメイン設定の編集"
|
|
||||||
|
|
||||||
#~ msgid "Configuration saved. Restart LiteSpeed put them in effect."
|
|
||||||
#~ msgstr "設定が保存されました。 LiteSpeed を再起動して有効にします。"
|
|
||||||
|
|
||||||
#~ msgid "Urdu"
|
|
||||||
#~ msgstr "ウルドゥー語"
|
|
||||||
@@ -156,7 +156,7 @@ def loadLoginPage(request):
|
|||||||
firstName="Cyber",lastName="Panel", acl=acl, token=token)
|
firstName="Cyber",lastName="Panel", acl=acl, token=token)
|
||||||
admin.save()
|
admin.save()
|
||||||
|
|
||||||
vers = version(currentVersion="1.7", build=6)
|
vers = version(currentVersion="1.7", build=7)
|
||||||
vers.save()
|
vers.save()
|
||||||
|
|
||||||
package = Package(admin=admin, packageName="Default", diskSpace=1000,
|
package = Package(admin=admin, packageName="Default", diskSpace=1000,
|
||||||
|
|||||||
135
plogical/acl.py
135
plogical/acl.py
@@ -8,12 +8,12 @@ from loginSystem.models import Administrator, ACL
|
|||||||
from django.shortcuts import HttpResponse
|
from django.shortcuts import HttpResponse
|
||||||
from packages.models import Package
|
from packages.models import Package
|
||||||
from websiteFunctions.models import Websites, ChildDomains
|
from websiteFunctions.models import Websites, ChildDomains
|
||||||
from dockerManager.models import Containers
|
|
||||||
from dns.models import Domains
|
from dns.models import Domains
|
||||||
import json
|
import json
|
||||||
from subprocess import call, CalledProcessError
|
from subprocess import call, CalledProcessError
|
||||||
from shlex import split
|
from shlex import split
|
||||||
from CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
from CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||||
|
from dockerManager.models import Containers
|
||||||
|
|
||||||
class ACLManager:
|
class ACLManager:
|
||||||
|
|
||||||
@@ -364,73 +364,6 @@ class ACLManager:
|
|||||||
|
|
||||||
return websiteNames
|
return websiteNames
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def findAllContainers(currentACL, userID):
|
|
||||||
containerName = []
|
|
||||||
|
|
||||||
if currentACL['admin'] == 1:
|
|
||||||
allContainers = Containers.objects.all()
|
|
||||||
for items in allContainers:
|
|
||||||
containerName.append(items.name)
|
|
||||||
else:
|
|
||||||
admin = Administrator.objects.get(pk=userID)
|
|
||||||
|
|
||||||
containers = admin.containers_set.all()
|
|
||||||
admins = Administrator.objects.filter(owner=admin.pk)
|
|
||||||
|
|
||||||
for items in containers:
|
|
||||||
containerName.append(items.name)
|
|
||||||
|
|
||||||
for items in admins:
|
|
||||||
cons = items.containers_set.all()
|
|
||||||
for con in cons:
|
|
||||||
containerName.append(con.name)
|
|
||||||
|
|
||||||
return containerName
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def findContainersObjects(currentACL, userID):
|
|
||||||
|
|
||||||
if currentACL['admin'] == 1:
|
|
||||||
return Containers.objects.all()
|
|
||||||
else:
|
|
||||||
|
|
||||||
containerList = []
|
|
||||||
admin = Administrator.objects.get(pk=userID)
|
|
||||||
|
|
||||||
containers = admin.containers_set.all()
|
|
||||||
|
|
||||||
for items in containers:
|
|
||||||
containerList.append(items)
|
|
||||||
|
|
||||||
admins = Administrator.objects.filter(owner=admin.pk)
|
|
||||||
|
|
||||||
for items in admins:
|
|
||||||
cons = items.containers_set.all()
|
|
||||||
for con in cons:
|
|
||||||
containerList.append(web)
|
|
||||||
|
|
||||||
return containerList
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def checkContainerOwnership(name, userID):
|
|
||||||
try:
|
|
||||||
container = Containers.objects.get(name=name)
|
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
|
||||||
admin = Administrator.objects.get(pk=userID)
|
|
||||||
|
|
||||||
if currentACL['admin'] == 1:
|
|
||||||
return 1
|
|
||||||
elif container.admin == admin:
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
return 0
|
|
||||||
except:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def findWebsiteObjects(currentACL, userID):
|
def findWebsiteObjects(currentACL, userID):
|
||||||
|
|
||||||
@@ -518,6 +451,72 @@ class ACLManager:
|
|||||||
logging.writeToFile(str(msg) + ' [ACLManager.executeCall]')
|
logging.writeToFile(str(msg) + ' [ACLManager.executeCall]')
|
||||||
return 0, str(msg)
|
return 0, str(msg)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def checkContainerOwnership(name, userID):
|
||||||
|
return 1
|
||||||
|
try:
|
||||||
|
container = Containers.objects.get(name=name)
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
return 1
|
||||||
|
elif container.admin == admin:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
except:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def findAllContainers(currentACL, userID):
|
||||||
|
containerName = []
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
allContainers = Containers.objects.all()
|
||||||
|
for items in allContainers:
|
||||||
|
containerName.append(items.name)
|
||||||
|
else:
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
containers = admin.containers_set.all()
|
||||||
|
admins = Administrator.objects.filter(owner=admin.pk)
|
||||||
|
|
||||||
|
for items in containers:
|
||||||
|
containerName.append(items.name)
|
||||||
|
|
||||||
|
for items in admins:
|
||||||
|
cons = items.containers_set.all()
|
||||||
|
for con in cons:
|
||||||
|
containerName.append(con.name)
|
||||||
|
|
||||||
|
|
||||||
|
return containerName
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def findContainersObjects(currentACL, userID):
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
return Containers.objects.all()
|
||||||
|
else:
|
||||||
|
|
||||||
|
containerList = []
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
containers = admin.containers_set.all()
|
||||||
|
|
||||||
|
for items in containers:
|
||||||
|
containerList.append(items)
|
||||||
|
|
||||||
|
admins = Administrator.objects.filter(owner=admin.pk)
|
||||||
|
|
||||||
|
for items in admins:
|
||||||
|
cons = items.containers_set.all()
|
||||||
|
for con in cons:
|
||||||
|
containerList.append(web)
|
||||||
|
|
||||||
|
return containerList
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -498,17 +498,26 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
|
|||||||
def disableRuleFile(fileName, packName):
|
def disableRuleFile(fileName, packName):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||||
confData = open(confFile).readlines()
|
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||||
conf = open(confFile, 'w')
|
confData = open(confFile).readlines()
|
||||||
|
conf = open(confFile, 'w')
|
||||||
|
|
||||||
for items in confData:
|
for items in confData:
|
||||||
if items.find('modsec/'+packName) > -1 and items.find(fileName) > -1:
|
if items.find('modsec/'+packName) > -1 and items.find(fileName) > -1:
|
||||||
conf.write("#" + items)
|
conf.write("#" + items)
|
||||||
else:
|
else:
|
||||||
conf.writelines(items)
|
conf.writelines(items)
|
||||||
|
|
||||||
conf.close()
|
conf.close()
|
||||||
|
|
||||||
|
else:
|
||||||
|
path = '/usr/local/lsws/conf/comodo_litespeed/'
|
||||||
|
completePath = path + fileName
|
||||||
|
completePathBak = path + fileName + '.bak'
|
||||||
|
|
||||||
|
command = 'mv ' + completePath + ' ' + completePathBak
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
print "1,None"
|
print "1,None"
|
||||||
|
|
||||||
@@ -521,17 +530,25 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
|
|||||||
def enableRuleFile(fileName, packName):
|
def enableRuleFile(fileName, packName):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||||
confData = open(confFile).readlines()
|
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||||
conf = open(confFile, 'w')
|
confData = open(confFile).readlines()
|
||||||
|
conf = open(confFile, 'w')
|
||||||
|
|
||||||
for items in confData:
|
for items in confData:
|
||||||
if items.find('modsec/' + packName) > -1 and items.find(fileName) > -1:
|
if items.find('modsec/' + packName) > -1 and items.find(fileName) > -1:
|
||||||
conf.write(items.lstrip('#'))
|
conf.write(items.lstrip('#'))
|
||||||
else:
|
else:
|
||||||
conf.writelines(items)
|
conf.writelines(items)
|
||||||
|
|
||||||
conf.close()
|
conf.close()
|
||||||
|
else:
|
||||||
|
path = '/usr/local/lsws/conf/comodo_litespeed/'
|
||||||
|
completePath = path + fileName
|
||||||
|
completePathBak = path + fileName + '.bak'
|
||||||
|
|
||||||
|
command = 'mv ' + completePathBak + ' ' + completePath
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
print "1,None"
|
print "1,None"
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,37 @@ import MySQLdb as mysql
|
|||||||
import json
|
import json
|
||||||
from random import randint
|
from random import randint
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
|
import MySQLdb.cursors as cursors
|
||||||
|
from math import ceil
|
||||||
|
|
||||||
class mysqlUtilities:
|
class mysqlUtilities:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getPagination(records, toShow):
|
||||||
|
pages = float(records) / float(toShow)
|
||||||
|
|
||||||
|
pagination = []
|
||||||
|
counter = 1
|
||||||
|
|
||||||
|
if pages <= 1.0:
|
||||||
|
pages = 1
|
||||||
|
pagination.append(counter)
|
||||||
|
else:
|
||||||
|
pages = ceil(pages)
|
||||||
|
finalPages = int(pages) + 1
|
||||||
|
|
||||||
|
for i in range(1, finalPages):
|
||||||
|
pagination.append(counter)
|
||||||
|
counter = counter + 1
|
||||||
|
|
||||||
|
return pagination
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def recordsPointer(page, toShow):
|
||||||
|
finalPageNumber = ((page * toShow)) - toShow
|
||||||
|
endPageNumber = finalPageNumber + toShow
|
||||||
|
return endPageNumber, finalPageNumber
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setupConnection():
|
def setupConnection():
|
||||||
try:
|
try:
|
||||||
@@ -25,7 +53,7 @@ class mysqlUtilities:
|
|||||||
password = data.split('\n', 1)[0]
|
password = data.split('\n', 1)[0]
|
||||||
password = password.strip('\n').strip('\r')
|
password = password.strip('\n').strip('\r')
|
||||||
|
|
||||||
conn = mysql.connect(user='root', passwd=password)
|
conn = mysql.connect(user='root', passwd=password, cursorclass=cursors.SSCursor)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
return conn, cursor
|
return conn, cursor
|
||||||
@@ -355,4 +383,227 @@ class mysqlUtilities:
|
|||||||
command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf'
|
command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf'
|
||||||
subprocess.call(shlex.split(command))
|
subprocess.call(shlex.split(command))
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
return 0, str(msg)
|
return 0, str(msg)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fetchDatabases():
|
||||||
|
try:
|
||||||
|
|
||||||
|
connection, cursor = mysqlUtilities.setupConnection()
|
||||||
|
|
||||||
|
if connection == 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data['status'] = 1
|
||||||
|
|
||||||
|
cursor.execute("SHOW DATABASES")
|
||||||
|
result = cursor.fetchall()
|
||||||
|
|
||||||
|
counter = 1
|
||||||
|
json_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for items in result:
|
||||||
|
if items[0] == 'information_schema' or items[0] == 'mysql' or items[0] == 'performance_schema' or items[
|
||||||
|
0] == 'performance_schema':
|
||||||
|
continue
|
||||||
|
|
||||||
|
dic = {
|
||||||
|
'id': counter,
|
||||||
|
'database': items[0]
|
||||||
|
|
||||||
|
}
|
||||||
|
counter = counter + 1
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
|
||||||
|
json_data = json_data + ']'
|
||||||
|
data['databases'] = json_data
|
||||||
|
return data
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fetchTables(name):
|
||||||
|
try:
|
||||||
|
|
||||||
|
connection, cursor = mysqlUtilities.setupConnection()
|
||||||
|
|
||||||
|
if connection == 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data['status'] = 1
|
||||||
|
|
||||||
|
cursor.execute("use " + name['databaseName'])
|
||||||
|
cursor.execute("SHOW TABLE STATUS")
|
||||||
|
result = cursor.fetchall()
|
||||||
|
|
||||||
|
counter = 1
|
||||||
|
json_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for items in result:
|
||||||
|
|
||||||
|
dic = {
|
||||||
|
'Name': items[0],
|
||||||
|
'Engine': items[1],
|
||||||
|
'Version': items[2],
|
||||||
|
'rowFormat': items[3],
|
||||||
|
'rows': items[4],
|
||||||
|
'Collation': items[14]
|
||||||
|
}
|
||||||
|
counter = counter + 1
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
json_data = json_data + ']'
|
||||||
|
data['tables'] = json_data
|
||||||
|
return data
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def deleteTable(name):
|
||||||
|
try:
|
||||||
|
|
||||||
|
connection, cursor = mysqlUtilities.setupConnection()
|
||||||
|
|
||||||
|
if connection == 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data['status'] = 1
|
||||||
|
|
||||||
|
cursor.execute("use " + name['databaseName'])
|
||||||
|
cursor.execute("DROP TABLE " + name['tableName'])
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fetchTableData(name):
|
||||||
|
try:
|
||||||
|
|
||||||
|
connection, cursor = mysqlUtilities.setupConnection()
|
||||||
|
|
||||||
|
if connection == 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
recordsToShow = int(name['recordsToShow'])
|
||||||
|
page = int(name['currentPage'])
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data['status'] = 1
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
cursor.execute("use " + name['databaseName'])
|
||||||
|
cursor.execute("select count(*) from " + name['tableName'])
|
||||||
|
rows = cursor.fetchall()[0][0]
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
cursor.execute("desc " + name['tableName'])
|
||||||
|
result = cursor.fetchall()
|
||||||
|
|
||||||
|
data['completeData'] = '<thead><tr>'
|
||||||
|
|
||||||
|
for items in result:
|
||||||
|
data['completeData'] = data['completeData'] + '<th>' + items[0] + '</th>'
|
||||||
|
|
||||||
|
data['completeData'] = data['completeData'] + '</tr></thead>'
|
||||||
|
|
||||||
|
data['completeData'] = data['completeData'] + '<tbody>'
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
data['pagination'] = mysqlUtilities.getPagination(rows, recordsToShow)
|
||||||
|
endPageNumber, finalPageNumber = mysqlUtilities.recordsPointer(page, recordsToShow)
|
||||||
|
|
||||||
|
cursor.execute("select * from " + name['tableName'])
|
||||||
|
result = cursor.fetchall()
|
||||||
|
|
||||||
|
for items in result[finalPageNumber:endPageNumber]:
|
||||||
|
data['completeData'] = data['completeData'] + '<tr>'
|
||||||
|
for it in items:
|
||||||
|
data['completeData'] = data['completeData'] + '<td>' + str(it) + '</td>'
|
||||||
|
data['completeData'] = data['completeData'] + '</tr>'
|
||||||
|
|
||||||
|
data['completeData'] = data['completeData'] + '</tbody>'
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchTableData]")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fetchStructure(name):
|
||||||
|
try:
|
||||||
|
|
||||||
|
connection, cursor = mysqlUtilities.setupConnection()
|
||||||
|
|
||||||
|
if connection == 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
cursor.execute("use " + name['databaseName'])
|
||||||
|
cursor.execute("desc " + name['tableName'])
|
||||||
|
result = cursor.fetchall()
|
||||||
|
|
||||||
|
## Columns List
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data['status'] = 1
|
||||||
|
|
||||||
|
json_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for items in result:
|
||||||
|
|
||||||
|
dic = {
|
||||||
|
'Name': items[0],
|
||||||
|
'Type': items[1],
|
||||||
|
'Null': items[2],
|
||||||
|
'Key': items[3],
|
||||||
|
'Default': items[4],
|
||||||
|
'Extra': items[5]
|
||||||
|
}
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
json_data = json_data + ']'
|
||||||
|
|
||||||
|
data['columns'] = json_data
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[showStatus]")
|
||||||
|
return 0
|
||||||
@@ -12,6 +12,8 @@ ConfigArgParse==0.13.0
|
|||||||
configobj==4.7.2
|
configobj==4.7.2
|
||||||
cryptography==2.2.2
|
cryptography==2.2.2
|
||||||
decorator==3.4.0
|
decorator==3.4.0
|
||||||
|
docker==3.6.0
|
||||||
|
docker-pycreds==0.4.0
|
||||||
Django==1.11
|
Django==1.11
|
||||||
docutils==0.14
|
docutils==0.14
|
||||||
enum34==1.1.6
|
enum34==1.1.6
|
||||||
|
|||||||
Reference in New Issue
Block a user