centralize acl control

This commit is contained in:
Usman Nasir
2021-02-23 23:38:58 +05:00
parent 72ae933042
commit 07b5b278b5
11 changed files with 900 additions and 826 deletions

View File

@@ -10,7 +10,7 @@ from django.shortcuts import HttpResponse
from math import ceil from math import ceil
from websiteFunctions.models import Websites from websiteFunctions.models import Websites
from CLManager.models import CLPackages from CLManager.models import CLPackages
from plogical.httpProc import httpProc
class CLManagerMain(multi.Thread): class CLManagerMain(multi.Thread):
@@ -27,29 +27,14 @@ class CLManagerMain(multi.Thread):
self.submitCageFSInstall() self.submitCageFSInstall()
elif self.function == 'enableOrDisable': elif self.function == 'enableOrDisable':
self.enableOrDisable() self.enableOrDisable()
except BaseException as msg: except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]') logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]')
def renderC(self): def renderC(self):
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
data = {} data = {}
data['CL'] = 0 data['CL'] = 0
data['activatedPath'] = 0 data['activatedPath'] = 0
data['ipAddress'] = ipAddress
CLPath = '/etc/sysconfig/cloudlinux' CLPath = '/etc/sysconfig/cloudlinux'
activatedPath = '/home/cyberpanel/cloudlinux' activatedPath = '/home/cyberpanel/cloudlinux'
@@ -60,11 +45,14 @@ class CLManagerMain(multi.Thread):
data['activatedPath'] = 1 data['activatedPath'] = 1
if data['CL'] == 0: if data['CL'] == 0:
return render(self.request, 'CLManager/notAvailable.html', data) proc = httpProc(self.request, 'CLManager/notAvailable.html', data, 'admin')
return proc.render()
elif data['activatedPath'] == 0: elif data['activatedPath'] == 0:
return render(self.request, 'CLManager/notAvailable.html', data) proc = httpProc(self.request, 'CLManager/notAvailable.html', data, 'admin')
return proc.render()
else: else:
return render(self.request, 'CLManager/cloudLinux.html', data) proc = httpProc(self.request, 'CLManager/cloudLinux.html', data, 'admin')
return proc.render()
def submitCageFSInstall(self): def submitCageFSInstall(self):
try: try:

View File

@@ -0,0 +1,42 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Home - CyberPanel" %}{% endblock %}
{% block content %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Home" %}</h2>
<p>{% trans "Use the tabs to navigate through the control panel." %}</p>
</div>
<!--- Hide statistics for non-admins--->
<div class="mx-10 col-lg-9 panel col-md-push-50">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Something went wrong..." %}
</h3>
<div class="example-box-wrapper mt-5">
<div class="alert alert-danger">
<h4 class="alert-title">Error</h4>
<p>Error: {{ error_message }}</p>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -4,18 +4,17 @@
{% block content %} {% block content %}
{% get_current_language as LANGUAGE_CODE %} {% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} --> <!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container"> <div class="container">
<div id="page-title"> <div id="page-title">
<h2>{% trans "Home" %}</h2> <h2>{% trans "Home" %}</h2>
<p>{% trans "Use the tabs to navigate through the control panel." %}</p> <p>{% trans "Use the tabs to navigate through the control panel." %}</p>
</div> </div>
<!--- Hide statistics for non-admins---> <!--- Hide statistics for non-admins--->
<div class="mx-10 col-lg-9 panel col-md-push-50"> <div class="mx-10 col-lg-9 panel col-md-push-50">
<div class="panel-body"> <div class="panel-body">
<h3 class="content-box-header"> <h3 class="content-box-header">
@@ -25,7 +24,8 @@
<div class="example-box-wrapper mt-5"> <div class="example-box-wrapper mt-5">
<div class="row mx-5"> <div class="row mx-5">
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'loadUsersHome' %}" title="{% trans 'User Functions' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'loadUsersHome' %}" title="{% trans 'User Functions' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Users" %} {% trans "Users" %}
</div> </div>
@@ -36,7 +36,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'loadWebsitesHome' %}" title="{% trans 'Website Functions' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'loadWebsitesHome' %}" title="{% trans 'Website Functions' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Websites" %} {% trans "Websites" %}
</div> </div>
@@ -47,7 +48,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'packagesHome' %}" title="{% trans 'Add/Modify Packages' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'packagesHome' %}" title="{% trans 'Add/Modify Packages' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Packages" %} {% trans "Packages" %}
</div> </div>
@@ -58,7 +60,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'loadDatabaseHome' %}" title="{% trans 'Database Functions' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'loadDatabaseHome' %}" title="{% trans 'Database Functions' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Databases" %} {% trans "Databases" %}
</div> </div>
@@ -69,7 +72,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'dnsHome' %}" title="{% trans 'Control DNS' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'dnsHome' %}" title="{% trans 'Control DNS' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "DNS" %} {% trans "DNS" %}
</div> </div>
@@ -80,7 +84,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'loadFTPHome' %}" title="{% trans 'FTP Functions' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'loadFTPHome' %}" title="{% trans 'FTP Functions' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "FTP" %} {% trans "FTP" %}
</div> </div>
@@ -91,7 +96,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'loadBackupHome' %}" title="{% trans 'Back up' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'loadBackupHome' %}" title="{% trans 'Back up' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Back up" %} {% trans "Back up" %}
</div> </div>
@@ -102,7 +108,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'loadEmailHome' %}" title="{% trans 'Emails' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'loadEmailHome' %}" title="{% trans 'Emails' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Emails" %} {% trans "Emails" %}
</div> </div>
@@ -113,7 +120,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'loadSSLHome' %}" title="{% trans 'SSL' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'loadSSLHome' %}" title="{% trans 'SSL' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "SSL" %} {% trans "SSL" %}
</div> </div>
@@ -126,7 +134,8 @@
{% if admin %} {% if admin %}
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'serverStatusHome' %}" title="{% trans 'Server Status' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'serverStatusHome' %}" title="{% trans 'Server Status' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Status" %} {% trans "Status" %}
</div> </div>
@@ -137,7 +146,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'loadPHPHome' %}" title="{% trans 'PHP Configurations' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'loadPHPHome' %}" title="{% trans 'PHP Configurations' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "PHP" %} {% trans "PHP" %}
</div> </div>
@@ -148,7 +158,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'logsHome' %}" title="{% trans 'Logs' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'logsHome' %}" title="{% trans 'Logs' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Logs" %} {% trans "Logs" %}
</div> </div>
@@ -159,7 +170,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{% url 'securityHome' %}" title="{% trans 'Security' %}" class="tile-box tile-box-shortcut btn-primary"> <a href="{% url 'securityHome' %}" title="{% trans 'Security' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header"> <div class="tile-header">
{% trans "Security" %} {% trans "Security" %}
</div> </div>
@@ -261,9 +273,7 @@
{% endif %} {% endif %}
</div>
</div>
{% endblock %} {% endblock %}

View File

@@ -344,19 +344,21 @@
<i class="glyph-icon icon-dashboard"></i> <i class="glyph-icon icon-dashboard"></i>
<span>{% trans "Dashboard" %}</span> <span>{% trans "Dashboard" %}</span>
</a> </a>
<a class="versionManagement" href="{% url 'versionManagment' %}" {% if admin or versionManagement %}
<a href="{% url 'versionManagment' %}"
title="{% trans 'Version Management' %}"> title="{% trans 'Version Management' %}">
<i class="glyph-icon tooltip-button icon-info" <i class="glyph-icon tooltip-button icon-info"
title="{% trans 'Version Management' %}" data-original-title=".icon-cloud-upload" title="{% trans 'Version Management' %}" data-original-title=".icon-cloud-upload"
aria-describedby="tooltip896208"></i> aria-describedby="tooltip896208"></i>
<span>{% trans "Version Management" %}</span> <span>{% trans "Version Management" %}</span>
</a> </a>
<a class="versionManagement" href="https://platform.cyberpanel.net" <a href="https://cloudcyberpanel.net/?utm_source=cyberpanel&utm_medium=cyberpanel&utm_campaign=cyberpanel_self_host"
title="{% trans 'Connect' %}"> title="{% trans 'Connect' %}">
<i class="glyph-icon tooltip-button icon-link" title="{% trans 'Connect' %}" <i class="glyph-icon tooltip-button icon-link" title="{% trans 'Connect' %}"
data-original-title=".icon-cloud-upload" aria-describedby="tooltip896208"></i> data-original-title=".icon-cloud-upload" aria-describedby="tooltip896208"></i>
<span>{% trans "Connect" %}</span> <span>{% trans "Connect" %}</span>
</a> </a>
{% endif %}
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li class="header"><span>{% trans "Main" %}</span></li> <li class="header"><span>{% trans "Main" %}</span></li>
@@ -392,18 +394,20 @@
title="{% trans 'Reseller Center' %}"><span>{% trans "Reseller Center" %}</span></a> title="{% trans 'Reseller Center' %}"><span>{% trans "Reseller Center" %}</span></a>
</li> </li>
{% endif %} {% endif %}
<li class="serverACL"><a href="{% url 'createNewACL' %}" {% if admin %}
<li><a href="{% url 'createNewACL' %}"
title="{% trans 'Create New ACL' %}"><span>{% trans "Create New ACL" %}</span></a> title="{% trans 'Create New ACL' %}"><span>{% trans "Create New ACL" %}</span></a>
</li> </li>
<li class="serverACL"><a href="{% url 'deleteACL' %}" <li><a href="{% url 'deleteACL' %}"
title="{% trans 'Delete ACL' %}"><span>{% trans "Delete ACL" %}</span></a> title="{% trans 'Delete ACL' %}"><span>{% trans "Delete ACL" %}</span></a>
</li> </li>
<li class="serverACL"><a href="{% url 'modifyACL' %}" <li><a href="{% url 'modifyACL' %}"
title="{% trans 'Modify ACL' %}"><span>{% trans "Modify ACL" %}</span></a> title="{% trans 'Modify ACL' %}"><span>{% trans "Modify ACL" %}</span></a>
</li> </li>
<li class="serverACL"><a href="{% url 'apiAccess' %}" <li><a href="{% url 'apiAccess' %}"
title="{% trans 'API Access' %}"><span>{% trans "API Access" %}</span></a> title="{% trans 'API Access' %}"><span>{% trans "API Access" %}</span></a>
</li> </li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -417,24 +421,32 @@
<div class="sidebar-submenu"> <div class="sidebar-submenu">
<ul> <ul>
<li class="createWebsite"><a href="{% url 'createWebsite' %}" {% if admin or createWebsite %}
<li><a href="{% url 'createWebsite' %}"
title="{% trans 'Create Website' %}"><span>{% trans "Create Website" %}</span></a> title="{% trans 'Create Website' %}"><span>{% trans "Create Website" %}</span></a>
</li> </li>
{% endif %}
<li><a href="{% url 'listWebsites' %}" <li><a href="{% url 'listWebsites' %}"
title="{% trans 'List Websites' %}"><span>{% trans "List Websites" %}</span></a> title="{% trans 'List Websites' %}"><span>{% trans "List Websites" %}</span></a>
</li> </li>
<li><a href="{% url 'listChildDomains' %}" <li><a href="{% url 'listChildDomains' %}"
title="{% trans 'List Child Domains' %}"><span>{% trans "List Child Domains" %}</span></a> title="{% trans 'List Child Domains' %}"><span>{% trans "List Child Domains" %}</span></a>
</li> </li>
<li class="modifyWebsite"><a href="{% url 'modifyWebsite' %}" {% if admin or modifyWebsite %}
<li><a href="{% url 'modifyWebsite' %}"
title="{% trans 'Modify Website' %}"><span>{% trans "Modify Website" %}</span></a> title="{% trans 'Modify Website' %}"><span>{% trans "Modify Website" %}</span></a>
</li> </li>
<li class="suspendWebsite"><a href="{% url 'siteState' %}" {% endif %}
{% if admin or suspendWebsite %}
<li><a href="{% url 'siteState' %}"
title="{% trans 'Suspend/Unsuspend' %}"><span>{% trans "Suspend/Unsuspend" %}</span></a> title="{% trans 'Suspend/Unsuspend' %}"><span>{% trans "Suspend/Unsuspend" %}</span></a>
</li> </li>
<li class="deleteWebsite"><a href="{% url 'deleteWebsite' %}" {% endif %}
{% if admin or deleteWebsite %}
<li><a href="{% url 'deleteWebsite' %}"
title="{% trans 'Delete Website' %}"><span>{% trans "Delete Website" %}</span></a> title="{% trans 'Delete Website' %}"><span>{% trans "Delete Website" %}</span></a>
</li> </li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -447,23 +459,30 @@
<div id="packageSub" class="sidebar-submenu"> <div id="packageSub" class="sidebar-submenu">
<ul> <ul>
<li class="createPackage"><a href="{% url 'createPackage' %}" {% if admin or createPackage %}
<li><a href="{% url 'createPackage' %}"
title="{% trans 'Create Package' %}"><span>{% trans "Create Package" %}</span></a> title="{% trans 'Create Package' %}"><span>{% trans "Create Package" %}</span></a>
</li> </li>
<li class="listPackages"><a href="{% url 'listPackages' %}" {% endif %}
{% if admin or listPackages %}
<li><a href="{% url 'listPackages' %}"
title="{% trans 'List Packages' %}"><span>{% trans "List Packages" %}</span></a> title="{% trans 'List Packages' %}"><span>{% trans "List Packages" %}</span></a>
</li> </li>
<li class="deletePackage"><a href="{% url 'deletePackage' %}" {% endif %}
{% if admin or deletePackage %}
<li><a href="{% url 'deletePackage' %}"
title="{% trans 'Delete Package' %}"><span>{% trans "Delete Package" %}</span></a> title="{% trans 'Delete Package' %}"><span>{% trans "Delete Package" %}</span></a>
</li> </li>
<li class="modifyPackage"><a href="{% url 'modifyPackage' %}" {% endif %}
{% if admin or modifyPackage %}
<li><a href="{% url 'modifyPackage' %}"
title="{% trans 'Modify Package' %}"><span>{% trans "Modify Package" %}</span></a> title="{% trans 'Modify Package' %}"><span>{% trans "Modify Package" %}</span></a>
</li> </li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li> <li>
<a title="{% trans 'Databases' %}"> <a title="{% trans 'Databases' %}">
<i class="glyph-icon icon-database" title="{% trans 'Databases' %}"></i> <i class="glyph-icon icon-database" title="{% trans 'Databases' %}"></i>
@@ -472,19 +491,26 @@
<div class="sidebar-submenu"> <div class="sidebar-submenu">
<ul> <ul>
<li class="createDatabase"><a href="{% url 'createDatabase' %}" {% if admin or createDatabase %}
<li><a href="{% url 'createDatabase' %}"
title="{% trans 'Create Database' %}"><span>{% trans "Create Database" %}</span></a> title="{% trans 'Create Database' %}"><span>{% trans "Create Database" %}</span></a>
</li> </li>
<li class="deleteDatabase"><a href="{% url 'deleteDatabase' %}" {% endif %}
{% if admin or deleteDatabase %}
<li><a href="{% url 'deleteDatabase' %}"
title="{% trans 'Delete Database' %}"><span>{% trans "Delete Database" %}</span></a> title="{% trans 'Delete Database' %}"><span>{% trans "Delete Database" %}</span></a>
</li> </li>
<li class="listDatabases"><a href="{% url 'listDBs' %}" {% endif %}
{% if admin or listDatabases %}
<li><a href="{% url 'listDBs' %}"
title="{% trans 'List Databases' %}"><span>{% trans "List Databases" %}</span></a> title="{% trans 'List Databases' %}"><span>{% trans "List Databases" %}</span></a>
</li> </li>
{% endif %}
{% if admin or createDatabase %}
<li><a href="{% url 'phpMyAdmin' %}" <li><a href="{% url 'phpMyAdmin' %}"
title="{% trans 'PHPMYAdmin' %}"><span>{% trans "PHPMYAdmin" %}</span></a> title="{% trans 'PHPMYAdmin' %}"><span>{% trans "PHPMYAdmin" %}</span></a>
</li> </li>
<!----<li><a href="{% url 'modifyPackage' %}" title="Change Password"><span>Change Password</span></a></li>---> {% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -498,24 +524,36 @@
<div class="sidebar-submenu"> <div class="sidebar-submenu">
<ul> <ul>
<li class="createNameServer"><a href="{% url 'createNameserver' %}" {% if admin or createNameServer %}
<li><a href="{% url 'createNameserver' %}"
title="{% trans 'Create Nameserver' %}"><span>{% trans "Create Nameserver" %}</span></a> title="{% trans 'Create Nameserver' %}"><span>{% trans "Create Nameserver" %}</span></a>
</li> </li>
<li class="serverACL"><a href="{% url 'configureDefaultNameServers' %}" {% endif %}
{% if admin %}
<li><a href="{% url 'configureDefaultNameServers' %}"
title="{% trans 'Configure Default Nameservers' %}"><span>{% trans "Config Default Nameservers" %}</span></a> title="{% trans 'Configure Default Nameservers' %}"><span>{% trans "Config Default Nameservers" %}</span></a>
</li> </li>
<li class="createDNSZone"><a href="{% url 'createDNSZone' %}" {% endif %}
{% if admin or createDNSZone %}
<li><a href="{% url 'createDNSZone' %}"
title="{% trans 'Create DNS Zone' %}"><span>{% trans "Create DNS Zone" %}</span></a> title="{% trans 'Create DNS Zone' %}"><span>{% trans "Create DNS Zone" %}</span></a>
</li> </li>
<li class="deleteZone"><a href="{% url 'deleteDNSZone' %}" {% endif %}
{% if admin or deleteZone %}
<li><a href="{% url 'deleteDNSZone' %}"
title="{% trans 'Delete Zone' %}"><span>{% trans "Delete Zone" %}</span></a> title="{% trans 'Delete Zone' %}"><span>{% trans "Delete Zone" %}</span></a>
</li> </li>
<li class="addDeleteRecords"><a href="{% url 'addDeleteDNSRecords' %}" {% endif %}
{% if admin or addDeleteRecords %}
<li><a href="{% url 'addDeleteDNSRecords' %}"
title="{% trans 'Add/Delete Records' %}"><span>{% trans "Add/Delete Records" %}</span></a> title="{% trans 'Add/Delete Records' %}"><span>{% trans "Add/Delete Records" %}</span></a>
</li> </li>
{% endif %}
{% if admin or addDeleteRecords %}
<li class="addDeleteRecords"><a href="{% url 'addDeleteDNSRecordsCloudFlare' %}" <li class="addDeleteRecords"><a href="{% url 'addDeleteDNSRecordsCloudFlare' %}"
title="{% trans 'CloudFlare' %}"><span>{% trans "CloudFlare" %}</span></a> title="{% trans 'CloudFlare' %}"><span>{% trans "CloudFlare" %}</span></a>
</li> </li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -529,49 +567,69 @@
<div class="sidebar-submenu"> <div class="sidebar-submenu">
<ul> <ul>
<li class="createEmail"><a href="{% url 'createEmailAccount' %}" {% if admin or createEmail %}
<li><a href="{% url 'createEmailAccount' %}"
title="{% trans 'Create Email Account' %}"><span>{% trans "Create Email" %}</span></a> title="{% trans 'Create Email Account' %}"><span>{% trans "Create Email" %}</span></a>
</li> </li>
<li class="listEmails"><a href="{% url 'listEmails' %}" {% endif %}
{% if admin or listEmails %}
<li><a href="{% url 'listEmails' %}"
title="{% trans 'List Emails' %}"><span>{% trans "List Emails" %}</span></a> title="{% trans 'List Emails' %}"><span>{% trans "List Emails" %}</span></a>
</li> </li>
<li class="deleteEmail"><a href="{% url 'deleteEmailAccount' %}" {% endif %}
{% if admin or deleteEmail %}
<li><a href="{% url 'deleteEmailAccount' %}"
title="{% trans 'Delete Email Account' %}"><span>{% trans "Delete Email" %}</span></a> title="{% trans 'Delete Email Account' %}"><span>{% trans "Delete Email" %}</span></a>
</li> </li>
<li class="emailForwarding"><a href="{% url 'emailForwarding' %}" {% endif %}
{% if admin or emailForwarding %}
<li><a href="{% url 'emailForwarding' %}"
title="{% trans 'Email Forwarding' %}"><span>{% trans "Email Forwarding" %}</span></a> title="{% trans 'Email Forwarding' %}"><span>{% trans "Email Forwarding" %}</span></a>
</li> </li>
<li class="changeEmailPassword"><a href="{% url 'changeEmailAccountPassword' %}" {% endif %}
{% if admin or changeEmailPassword %}
<li><a href="{% url 'changeEmailAccountPassword' %}"
title="{% trans 'Change Password' %}"><span>{% trans "Change Password" %}</span></a> title="{% trans 'Change Password' %}"><span>{% trans "Change Password" %}</span></a>
</li> </li>
<li class="dkimManager"><a href="{% url 'dkimManager' %}" {% endif %}
{% if admin or dkimManager %}
<li><a href="{% url 'dkimManager' %}"
title="{% trans 'DKIM Manager' %}"><span>{% trans "DKIM Manager" %}</span></a> title="{% trans 'DKIM Manager' %}"><span>{% trans "DKIM Manager" %}</span></a>
</li> </li>
{% endif %}
{% if admin or createEmail %}
<li><a href="/rainloop/index.php" title="{% trans 'Access Webmail' %}" <li><a href="/rainloop/index.php" title="{% trans 'Access Webmail' %}"
target="_blank"><span>{% trans "Access Webmail" %}</span></a></li> target="_blank"><span>{% trans "Access Webmail" %}</span></a>
</li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="ftpAsWhole"> <li class="ftpAsWhole">
<a href="{% url 'packagesHome' %}" title="{% trans 'FTP' %}"> <a href="{% url 'ftpHome' %}" title="{% trans 'FTP' %}">
<i class="glyph-icon icon-cloud-upload"></i> <i class="glyph-icon icon-cloud-upload"></i>
<span>{% trans "FTP" %}</span> <span>{% trans "FTP" %}</span>
</a> </a>
<div class="sidebar-submenu"> <div class="sidebar-submenu">
<ul> <ul>
<li class="createFTPAccount"><a href="{% url 'createFTPAccount' %}" {% if admin or createFTPAccount %}
<li><a href="{% url 'createFTPAccount' %}"
title="{% trans 'Create FTP Account' %}"><span>{% trans "Create FTP Account" %}</span></a> title="{% trans 'Create FTP Account' %}"><span>{% trans "Create FTP Account" %}</span></a>
</li> </li>
<li class="deleteFTPAccount"><a href="{% url 'deleteFTPAccount' %}" {% endif %}
{% if admin or deleteFTPAccount %}
<li><a href="{% url 'deleteFTPAccount' %}"
title="{% trans 'Delete FTP Account' %}"><span>{% trans "Delete FTP Account" %}</span></a> title="{% trans 'Delete FTP Account' %}"><span>{% trans "Delete FTP Account" %}</span></a>
</li> </li>
<li class="listFTPAccounts"><a href="{% url 'listFTPAccounts' %}" {% endif %}
{% if admin or listFTPAccounts %}
<li><a href="{% url 'listFTPAccounts' %}"
title="{% trans 'List FTP Accounts' %}"><span>{% trans "List FTP Accounts" %}</span></a> title="{% trans 'List FTP Accounts' %}"><span>{% trans "List FTP Accounts" %}</span></a>
</li> </li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -585,24 +643,36 @@
<div class="sidebar-submenu"> <div class="sidebar-submenu">
<ul> <ul>
<li class="createBackup"><a href="{% url 'backupSite' %}" {% if admin or createBackup %}
<li><a href="{% url 'backupSite' %}"
title="{% trans 'Create Back up' %}"><span>{% trans "Create Back up" %}</span></a> title="{% trans 'Create Back up' %}"><span>{% trans "Create Back up" %}</span></a>
</li> </li>
<li class="restoreBackup"><a href="{% url 'restoreSite' %}" {% endif %}
{% if admin or restoreBackup %}
<li><a href="{% url 'restoreSite' %}"
title="{% trans 'Restore Back up' %}"><span>{% trans "Restore Back up" %}</span></a> title="{% trans 'Restore Back up' %}"><span>{% trans "Restore Back up" %}</span></a>
</li> </li>
<li class="addDeleteDestinations"><a href="{% url 'backupDestinations' %}" {% endif %}
{% if admin or addDeleteDestinations %}
<li><a href="{% url 'backupDestinations' %}"
title="{% trans 'Add Destination' %}"><span>{% trans "Add/Delete Destination" %}</span></a> title="{% trans 'Add Destination' %}"><span>{% trans "Add/Delete Destination" %}</span></a>
</li> </li>
<li class="scheDuleBackups"><a href="{% url 'scheduleBackup' %}" {% endif %}
{% if admin or scheDuleBackups %}
<li><a href="{% url 'scheduleBackup' %}"
title="{% trans 'Schedule Back up' %}"><span>{% trans "Schedule Back up" %}</span></a> title="{% trans 'Schedule Back up' %}"><span>{% trans "Schedule Back up" %}</span></a>
</li> </li>
<li class="createBackup"><a href="{% url 'gDrive' %}" {% endif %}
{% if admin or googleDriveBackups %}
<li><a href="{% url 'gDrive' %}"
title="{% trans 'Setup Google Drive' %}"><span>{% trans "Setup Google Drive" %}</span></a> title="{% trans 'Setup Google Drive' %}"><span>{% trans "Setup Google Drive" %}</span></a>
</li> </li>
<li class="remoteBackups"><a href="{% url 'remoteBackups' %}" {% endif %}
{% if admin or remoteBackups %}
<li><a href="{% url 'remoteBackups' %}"
title="{% trans 'Remote Back ups' %}"><span>{% trans "Remote Back ups" %}</span></a> title="{% trans 'Remote Back ups' %}"><span>{% trans "Remote Back ups" %}</span></a>
</li> </li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -617,18 +687,26 @@
<div class="sidebar-submenu"> <div class="sidebar-submenu">
<ul> <ul>
<li class="createBackup"><a href="{% url 'createBackupInc' %}" {% if admin or createBackup %}
<li><a href="{% url 'createBackupInc' %}"
title="{% trans 'Create Back up' %}"><span>{% trans "Create/Restore Back up" %}</span></a> title="{% trans 'Create Back up' %}"><span>{% trans "Create/Restore Back up" %}</span></a>
</li> </li>
<li class="restoreBackup"><a href="{% url 'backupDestinationsInc' %}" {% endif %}
{% if admin or restoreBackup %}
<li><a href="{% url 'backupDestinationsInc' %}"
title="{% trans 'Restore Back up' %}"><span>{% trans "Add/Remove Destinations" %}</span></a> title="{% trans 'Restore Back up' %}"><span>{% trans "Add/Remove Destinations" %}</span></a>
</li> </li>
<li class="restoreBackup"><a href="{% url 'scheduleBackupsInc' %}" {% endif %}
{% if admin or restoreBackup %}
<li><a href="{% url 'scheduleBackupsInc' %}"
title="{% trans 'Schedule Back ups' %}"><span>{% trans "Schedule Back ups" %}</span></a> title="{% trans 'Schedule Back ups' %}"><span>{% trans "Schedule Back ups" %}</span></a>
</li> </li>
<li class="remoteBackups"><a href="{% url 'restoreRemoteBackupsInc' %}" {% endif %}
{% if admin or remoteBackups %}
<li><a href="{% url 'restoreRemoteBackupsInc' %}"
title="{% trans 'Restore from Remote Server' %}"><span>{% trans "Restore from Remote" %}</span></a> title="{% trans 'Restore from Remote Server' %}"><span>{% trans "Restore from Remote" %}</span></a>
</li> </li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -643,24 +721,31 @@
<div class="sidebar-submenu"> <div class="sidebar-submenu">
<ul> <ul>
{% if admin or manageSSL %}
<li class="manageSSL"><a href="{% url 'manageSSL' %}" <li class="manageSSL"><a href="{% url 'manageSSL' %}"
title="{% trans 'Manage SSL' %}"><span>{% trans "Manage SSL" %}</span></a> title="{% trans 'Manage SSL' %}"><span>{% trans "Manage SSL" %}</span></a>
</li> </li>
{% endif %}
{% if admin or hostnameSSL %}
<li class="hostnameSSL"><a href="{% url 'sslForHostName' %}" <li class="hostnameSSL"><a href="{% url 'sslForHostName' %}"
title="{% trans 'Hostname SSL' %}"><span>{% trans "Hostname SSL" %}</span></a> title="{% trans 'Hostname SSL' %}"><span>{% trans "Hostname SSL" %}</span></a>
</li> </li>
{% endif %}
{% if admin or mailServerSSL %}
<li class="mailServerSSL"><a href="{% url 'sslForMailServer' %}" <li class="mailServerSSL"><a href="{% url 'sslForMailServer' %}"
title="{% trans 'MailServer SSL' %}"><span>{% trans "MailServer SSL" %}</span></a> title="{% trans 'MailServer SSL' %}"><span>{% trans "MailServer SSL" %}</span></a>
</li> </li>
{% endif %}
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="header serverACL"><span>{% trans "Server" %}</span></li> {% if admin %}
<li class="header"><span>{% trans "Server" %}</span></li>
<li class="serverACL"> <li>
<a href="#" title="{% trans 'Terminal' %}"> <a href="#" title="{% trans 'Terminal' %}">
<i class="glyph-icon icon-linecons-fire"></i> <i class="glyph-icon icon-linecons-fire"></i>
<span>{% trans "Web Terminal" %}</span> <span>{% trans "Web Terminal" %}</span>
@@ -676,7 +761,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="#" title="{% trans 'CloudLinux' %}"> <a href="#" title="{% trans 'CloudLinux' %}">
<i class="glyph-icon icon-linecons-fire"></i> <i class="glyph-icon icon-linecons-fire"></i>
<span>{% trans "CloudLinux" %}</span> <span>{% trans "CloudLinux" %}</span>
@@ -703,8 +788,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li>
<li class="serverACL">
<a href="#" title="{% trans 'Containerization' %}"> <a href="#" title="{% trans 'Containerization' %}">
<i class="glyph-icon icon-linecons-fire"></i> <i class="glyph-icon icon-linecons-fire"></i>
<span>{% trans "Containerization" %}</span> <span>{% trans "Containerization" %}</span>
@@ -721,7 +805,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="#" title="{% trans 'Docker' %}"> <a href="#" title="{% trans 'Docker' %}">
<i class="glyph-icon icon-cogs"></i> <i class="glyph-icon icon-cogs"></i>
<span>{% trans "Docker Manager" %}</span> <span>{% trans "Docker Manager" %}</span>
@@ -744,7 +828,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="#" title="{% trans 'Tuning' %}"> <a href="#" title="{% trans 'Tuning' %}">
<i class="glyph-icon icon-adjust"></i> <i class="glyph-icon icon-adjust"></i>
<span>{% trans "Tuning" %}</span> <span>{% trans "Tuning" %}</span>
@@ -763,7 +847,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="#" title="{% trans 'Server Status' %}"> <a href="#" title="{% trans 'Server Status' %}">
<i class="glyph-icon icon-cog"></i> <i class="glyph-icon icon-cog"></i>
<span>{% trans "Server Status" %}</span> <span>{% trans "Server Status" %}</span>
@@ -794,7 +878,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="{% url 'loadPHPHome' %}" title="{% trans 'PHP' %}"> <a href="{% url 'loadPHPHome' %}" title="{% trans 'PHP' %}">
<i class="glyph-icon icon-code"></i> <i class="glyph-icon icon-code"></i>
<span>{% trans "PHP" %}</span> <span>{% trans "PHP" %}</span>
@@ -813,7 +897,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="{% url 'logsHome' %}" title="{% trans 'Server Status' %}"> <a href="{% url 'logsHome' %}" title="{% trans 'Server Status' %}">
<i class="glyph-icon icon-file"></i> <i class="glyph-icon icon-file"></i>
<span>{% trans "Logs" %}</span> <span>{% trans "Logs" %}</span>
@@ -834,7 +918,8 @@
title="{% trans 'Email Logs' %}"><span>{% trans "Email Log" %}</span></a> title="{% trans 'Email Logs' %}"><span>{% trans "Email Log" %}</span></a>
</li> </li>
<li><a href="{% url 'ftplogs' %}" <li><a href="{% url 'ftplogs' %}"
title="{% trans 'FTP Logs' %}"><span>{% trans "FTP Logs" %}</span></a></li> title="{% trans 'FTP Logs' %}"><span>{% trans "FTP Logs" %}</span></a>
</li>
<li><a href="{% url 'modSecAuditLogs' %}" <li><a href="{% url 'modSecAuditLogs' %}"
title="{% trans 'ModSecurity Audit Logs' %}"><span>{% trans "ModSec Audit Logs" %}</span></a> title="{% trans 'ModSecurity Audit Logs' %}"><span>{% trans "ModSec Audit Logs" %}</span></a>
</li> </li>
@@ -843,7 +928,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="{% url 'securityHome' %}" title="{% trans 'Security' %}"> <a href="{% url 'securityHome' %}" title="{% trans 'Security' %}">
<i class="glyph-icon icon-shield"></i> <i class="glyph-icon icon-shield"></i>
<span>{% trans "Security" %}</span> <span>{% trans "Security" %}</span>
@@ -883,7 +968,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL emailAsWhole"> <li class="emailAsWhole">
<a href="#" title="{% trans 'Mail Settings' %}"> <a href="#" title="{% trans 'Mail Settings' %}">
<i class="glyph-icon icon-envelope"></i> <i class="glyph-icon icon-envelope"></i>
<span>{% trans "Mail Settings" %}</span> <span>{% trans "Mail Settings" %}</span>
@@ -915,7 +1000,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="#" title="{% trans 'Manage Services' %}"> <a href="#" title="{% trans 'Manage Services' %}">
<i class="glyph-icon icon-folder-open"></i> <i class="glyph-icon icon-folder-open"></i>
<span>{% trans "Manage Services" %}</span> <span>{% trans "Manage Services" %}</span>
@@ -940,7 +1025,7 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
<li class="serverACL"> <li>
<a href="#" title="{% trans 'Plugins' %}"> <a href="#" title="{% trans 'Plugins' %}">
<i class="glyph-icon icon-plug"></i> <i class="glyph-icon icon-plug"></i>
<span>{% trans "Plugins" %}</span> <span>{% trans "Plugins" %}</span>
@@ -957,6 +1042,8 @@
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
</li> </li>
{% endif %}
</ul><!-- #sidebar-menu --> </ul><!-- #sidebar-menu -->
</div> </div>

View File

@@ -88,17 +88,6 @@ def getLoadAverage(request):
@ensure_csrf_cookie @ensure_csrf_cookie
def versionManagment(request): def versionManagment(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
elif currentACL['versionManagement'] == 1:
pass
else:
return ACLManager.loadError()
## Get latest version ## Get latest version
getVersion = requests.get('https://cyberpanel.net/version.txt') getVersion = requests.get('https://cyberpanel.net/version.txt')
@@ -113,13 +102,12 @@ def versionManagment(request):
currentVersion = VERSION currentVersion = VERSION
currentBuild = str(BUILD) currentBuild = str(BUILD)
return render(request, 'baseTemplate/versionManagment.html', {'build': currentBuild, template = 'baseTemplate/versionManagment.html'
'currentVersion': currentVersion, finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
'latestVersion': latestVersion, 'latestBuild': latestBuild}
'latestBuild': latestBuild})
except KeyError: proc = httpProc(request, template, finalData, 'versionManagement')
return redirect(loadLoginPage) return proc.render()
def upgrade(request): def upgrade(request):
try: try:

View File

@@ -5,7 +5,7 @@ from plogical.acl import ACLManager
import plogical.CyberCPLogFileWriter as logging import plogical.CyberCPLogFileWriter as logging
from serverStatus.serverStatusUtil import ServerStatusUtil from serverStatus.serverStatusUtil import ServerStatusUtil
import os, stat import os, stat
from plogical.httpProc import httpProc
class ContainerManager(multi.Thread): class ContainerManager(multi.Thread):
defaultConf = """group {groupName}{ defaultConf = """group {groupName}{
@@ -84,14 +84,6 @@ class ContainerManager(multi.Thread):
def renderC(self): def renderC(self):
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
data = {} data = {}
data['OLS'] = 0 data['OLS'] = 0
data['notInstalled'] = 0 data['notInstalled'] = 0
@@ -99,17 +91,20 @@ class ContainerManager(multi.Thread):
if ProcessUtilities.decideServer() == ProcessUtilities.OLS: if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
data['OLS'] = 1 data['OLS'] = 1
data['notInstalled'] = 0 data['notInstalled'] = 0
return render(self.request, 'containerization/notAvailable.html', data) proc = httpProc(self.request, 'containerization/notAvailable.html', data, 'admin')
return proc.render()
elif not ProcessUtilities.containerCheck(): elif not ProcessUtilities.containerCheck():
data['OLS'] = 0 data['OLS'] = 0
data['notInstalled'] = 1 data['notInstalled'] = 1
return render(self.request, 'containerization/notAvailable.html', data) proc = httpProc(self.request, 'containerization/notAvailable.html', data, 'admin')
return proc.render()
else: else:
if self.data == None: if self.data == None:
self.data = {} self.data = {}
self.data['OLS'] = 0 self.data['OLS'] = 0
self.data['notInstalled'] = 0 self.data['notInstalled'] = 0
return render(self.request, self.templateName, self.data) proc = httpProc(self.request, self.templateName, data, 'admin')
return proc.render()
def submitContainerInstall(self): def submitContainerInstall(self):
try: try:
@@ -165,7 +160,6 @@ class ContainerManager(multi.Thread):
# self.data['classID']) + ' protocol ip prio 10 handle 1: cgroup' # self.data['classID']) + ' protocol ip prio 10 handle 1: cgroup'
command = 'sudo tc filter add dev eth0 parent 10: protocol ip prio 10 handle 1: cgroup' command = 'sudo tc filter add dev eth0 parent 10: protocol ip prio 10 handle 1: cgroup'
#logging.CyberCPLogFileWriter.writeToFile(command)
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
self.restartServices() self.restartServices()

View File

@@ -5,7 +5,6 @@ import django
sys.path.append('/usr/local/CyberCP') sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
django.setup() django.setup()
from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
import json import json
from plogical.acl import ACLManager from plogical.acl import ACLManager
@@ -16,34 +15,28 @@ from databases.models import Databases, DBMeta
import argparse import argparse
from loginSystem.models import Administrator from loginSystem.models import Administrator
import plogical.randomPassword as randomPassword import plogical.randomPassword as randomPassword
from plogical.httpProc import httpProc
class DatabaseManager: class DatabaseManager:
REMOTE_ACCESS = 'remote_access' REMOTE_ACCESS = 'remote_access'
def loadDatabaseHome(self, request = None, userID = None): def loadDatabaseHome(self, request = None, userID = None):
try: template = 'databases/index.html'
return render(request, 'databases/index.html') proc = httpProc(request, template, None, 'createDatabase')
except BaseException as msg: return proc.render()
return HttpResponse(str(msg))
def phpMyAdmin(self, request = None, userID = None): def phpMyAdmin(self, request = None, userID = None):
try: template = 'databases/phpMyAdmin.html'
return render(request, 'databases/phpMyAdmin.html') proc = httpProc(request, template, None, 'createDatabase')
except BaseException as msg: return proc.render()
return HttpResponse(str(msg))
def createDatabase(self, request = None, userID = None): def createDatabase(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'createDatabase') == 0:
return ACLManager.loadError()
websitesName = ACLManager.findAllSites(currentACL, userID) websitesName = ACLManager.findAllSites(currentACL, userID)
template = 'databases/createDatabase.html'
return render(request, 'databases/createDatabase.html', {'websitesList': websitesName}) proc = httpProc(request, template, {'websitesList': websitesName}, 'createDatabase')
except BaseException as msg: return proc.render()
return HttpResponse(str(msg))
def submitDBCreation(self, userID = None, data = None, rAPI = None): def submitDBCreation(self, userID = None, data = None, rAPI = None):
try: try:
@@ -84,18 +77,11 @@ class DatabaseManager:
return HttpResponse(json_data) return HttpResponse(json_data)
def deleteDatabase(self, request = None, userID = None): def deleteDatabase(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'deleteDatabase') == 0:
return ACLManager.loadError()
websitesName = ACLManager.findAllSites(currentACL, userID) websitesName = ACLManager.findAllSites(currentACL, userID)
template = 'databases/deleteDatabase.html'
return render(request, 'databases/deleteDatabase.html', {'websitesList': websitesName}) proc = httpProc(request, template, {'websitesList': websitesName}, 'deleteDatabase')
except BaseException as msg: return proc.render()
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse(str(msg))
def fetchDatabases(self, userID = None, data = None): def fetchDatabases(self, userID = None, data = None):
try: try:
@@ -171,16 +157,11 @@ class DatabaseManager:
return HttpResponse(json_data) return HttpResponse(json_data)
def listDBs(self, request = None, userID = None): def listDBs(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'listDatabases') == 0:
return ACLManager.loadError()
websitesName = ACLManager.findAllSites(currentACL, userID) websitesName = ACLManager.findAllSites(currentACL, userID)
template = 'databases/listDataBases.html'
return render(request, 'databases/listDataBases.html', {'websiteList': websitesName}) proc = httpProc(request, template, {'websitesList': websitesName}, 'listDatabases')
except BaseException as msg: return proc.render()
return HttpResponse(str(msg))
def changePassword(self, userID = None, data = None): def changePassword(self, userID = None, data = None):
try: try:

View File

@@ -4,10 +4,10 @@ import errno
import os.path import os.path
import sys import sys
import django import django
sys.path.append('/usr/local/CyberCP') sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
django.setup() django.setup()
from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
import json import json
try: try:
@@ -24,6 +24,7 @@ import CloudFlare
import re import re
import plogical.CyberCPLogFileWriter as logging import plogical.CyberCPLogFileWriter as logging
from plogical.processUtilities import ProcessUtilities from plogical.processUtilities import ProcessUtilities
from plogical.httpProc import httpProc
class DNSManager: class DNSManager:
defaultNameServersPath = '/home/cyberpanel/defaultNameservers' defaultNameServersPath = '/home/cyberpanel/defaultNameservers'
@@ -37,29 +38,23 @@ class DNSManager:
self.email = data[0].rstrip('\n') self.email = data[0].rstrip('\n')
self.key = data[1].rstrip('\n') self.key = data[1].rstrip('\n')
def loadDNSHome(self, request = None, userID = None): def loadDNSHome(self, request = None, userID = None):
try:
admin = Administrator.objects.get(pk=userID) admin = Administrator.objects.get(pk=userID)
return render(request, 'dns/index.html', {"type": admin.type}) template = 'dns/index.html'
except BaseException as msg: proc = httpProc(request, template, {"type": admin.type}, 'createDNSZone')
return HttpResponse(str(msg)) return proc.render()
def createNameserver(self, request = None, userID = None): def createNameserver(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'createNameServer') == 0:
return ACLManager.loadError()
mailUtilities.checkHome() mailUtilities.checkHome()
if os.path.exists('/home/cyberpanel/powerdns'): if os.path.exists('/home/cyberpanel/powerdns'):
return render(request, "dns/createNameServer.html", {"status": 1}) finalData = {"status": 1}
else: else:
return render(request, "dns/createNameServer.html", {"status": 0}) finalData = {"status": 0}
except BaseException as msg: template = 'dns/createNameServer.html'
return HttpResponse(str(msg)) proc = httpProc(request, template, finalData, 'createNameServer')
return proc.render()
def NSCreation(self, userID = None, data = None): def NSCreation(self, userID = None, data = None):
try: try:
@@ -118,17 +113,13 @@ class DNSManager:
return HttpResponse(final_json) return HttpResponse(final_json)
def createDNSZone(self, request = None, userID = None): def createDNSZone(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'createDNSZone') == 0:
return ACLManager.loadError()
if os.path.exists('/home/cyberpanel/powerdns'): if os.path.exists('/home/cyberpanel/powerdns'):
return render(request, 'dns/createDNSZone.html', {"status": 1}) finalData = {'status': 1}
else: else:
return render(request, 'dns/createDNSZone.html', {"status": 0}) finalData = {'status': 0}
except BaseException as msg: template = 'dns/createDNSZone.html'
return HttpResponse(str(msg)) proc = httpProc(request, template, finalData, 'createDNSZone')
return proc.render()
def zoneCreation(self, userID = None, data = None): def zoneCreation(self, userID = None, data = None):
try: try:
@@ -166,21 +157,16 @@ class DNSManager:
return HttpResponse(final_json) return HttpResponse(final_json)
def addDeleteDNSRecords(self, request = None, userID = None): def addDeleteDNSRecords(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'addDeleteRecords') == 0:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/powerdns'): if not os.path.exists('/home/cyberpanel/powerdns'):
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0}) finalData = {"status": 0}
else:
finalData = {"status": 1}
domainsList = ACLManager.findAllDomains(currentACL, userID) finalData['domainsList'] = ACLManager.findAllDomains(currentACL, userID)
template = 'dns/addDeleteDNSRecords.html'
return render(request, 'dns/addDeleteDNSRecords.html', {"domainsList": domainsList, "status": 1}) proc = httpProc(request, template, finalData, 'addDeleteRecords')
return proc.render()
except BaseException as msg:
return HttpResponse(str(msg))
def getCurrentRecordsForDomain(self, userID = None, data = None): def getCurrentRecordsForDomain(self, userID = None, data = None):
try: try:
@@ -499,22 +485,16 @@ class DNSManager:
return HttpResponse(final_json) return HttpResponse(final_json)
def deleteDNSZone(self, request = None, userID = None): def deleteDNSZone(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'deleteZone') == 0:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/powerdns'): if not os.path.exists('/home/cyberpanel/powerdns'):
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0}) finalData = {"status": 0}
else:
finalData = {"status": 1}
domainsList = ACLManager.findAllDomains(currentACL, userID) finalData['domainsList'] = ACLManager.findAllDomains(currentACL, userID)
template = 'dns/deleteDNSZone.html'
return render(request, 'dns/deleteDNSZone.html', {"domainsList": domainsList, "status": 1}) proc = httpProc(request, template, finalData, 'deleteZone')
return proc.render()
except BaseException as msg:
return HttpResponse(str(msg))
def submitZoneDeletion(self, userID = None, data = None): def submitZoneDeletion(self, userID = None, data = None):
try: try:
@@ -549,22 +529,14 @@ class DNSManager:
return HttpResponse(final_json) return HttpResponse(final_json)
def configureDefaultNameServers(self, request=None, userID=None): def configureDefaultNameServers(self, request=None, userID=None):
try:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/powerdns'): if not os.path.exists('/home/cyberpanel/powerdns'):
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0}) data = {"status": 0}
else:
data = {"status": 1}
data = {}
data['domainsList'] = ACLManager.findAllDomains(currentACL, userID) data['domainsList'] = ACLManager.findAllDomains(currentACL, userID)
data['status'] = 1
if os.path.exists(DNSManager.defaultNameServersPath): if os.path.exists(DNSManager.defaultNameServersPath):
nsData = open(DNSManager.defaultNameServersPath, 'r').readlines() nsData = open(DNSManager.defaultNameServersPath, 'r').readlines()
try: try:
@@ -584,11 +556,9 @@ class DNSManager:
except: except:
pass pass
return render(request, 'dns/configureDefaultNameServers.html', data) template = 'dns/configureDefaultNameServers.html'
proc = httpProc(request, template, data, 'admin')
except BaseException as msg: return proc.render()
return HttpResponse(str(msg))
def saveNSConfigurations(self, userID = None, data = None): def saveNSConfigurations(self, userID = None, data = None):
try: try:
@@ -615,7 +585,6 @@ class DNSManager:
except: except:
pass pass
writeToFile = open(DNSManager.defaultNameServersPath, 'w') writeToFile = open(DNSManager.defaultNameServersPath, 'w')
writeToFile.write(nsContent.rstrip('\n')) writeToFile.write(nsContent.rstrip('\n'))
writeToFile.close() writeToFile.close()
@@ -631,35 +600,30 @@ class DNSManager:
return HttpResponse(final_json) return HttpResponse(final_json)
def addDeleteDNSRecordsCloudFlare(self, request = None, userID = None): def addDeleteDNSRecordsCloudFlare(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'addDeleteRecords') == 0:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/powerdns'): if not os.path.exists('/home/cyberpanel/powerdns'):
return render(request, 'dns/addDeleteDNSRecordsCloudFlare.html', {"status": 0}) status = 0
else:
status = 1
admin = Administrator.objects.get(pk=userID) admin = Administrator.objects.get(pk=userID)
CloudFlare = 0 CloudFlare = 0
cfPath = '%s%s' %(DNS.CFPath, admin.userName) cfPath = '%s%s' % (DNS.CFPath, admin.userName)
if os.path.exists(cfPath): if os.path.exists(cfPath):
CloudFlare = 1 CloudFlare = 1
domainsList = ACLManager.findAllDomains(currentACL, userID) domainsList = ACLManager.findAllDomains(currentACL, userID)
self.admin = admin self.admin = admin
self.loadCFKeys() self.loadCFKeys()
data = {"domainsList": domainsList, "status": status, 'CloudFlare': CloudFlare, 'cfEmail': self.email,
return render(request, 'dns/addDeleteDNSRecordsCloudFlare.html', 'cfToken': self.key}
{"domainsList": domainsList, "status": 1, 'CloudFlare': CloudFlare, 'cfEmail': self.email, 'cfToken': self.key})
else: else:
return render(request, 'dns/addDeleteDNSRecordsCloudFlare.html', {"status": 1, 'CloudFlare': CloudFlare}) data = {"status": status, 'CloudFlare': CloudFlare}
except BaseException as msg: template = 'dns/addDeleteDNSRecordsCloudFlare.html'
return HttpResponse(str(msg)) proc = httpProc(request, template, data, 'addDeleteRecords')
return proc.render()
def saveCFConfigs(self, userID = None, data = None): def saveCFConfigs(self, userID = None, data = None):
try: try:

View File

@@ -71,14 +71,12 @@ class ACLManager:
finalResponse['serverIPAddress'] = serverIPAddress finalResponse['serverIPAddress'] = serverIPAddress
finalResponse['adminName'] = admin.firstName finalResponse['adminName'] = admin.firstName
if admin.acl.adminStatus == 1: config = json.loads(admin.acl.config)
if config['adminStatus']:
finalResponse['admin'] = 1 finalResponse['admin'] = 1
else: else:
finalResponse['admin'] = 0 finalResponse['admin'] = 0
config = json.loads(admin.acl.config)
acl = ACL.objects.get(name=admin.acl.name)
finalResponse['versionManagement'] = config['versionManagement'] finalResponse['versionManagement'] = config['versionManagement']
## User Management ## User Management

View File

@@ -2,12 +2,14 @@
from django.shortcuts import render, HttpResponse from django.shortcuts import render, HttpResponse
import json import json
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter
class httpProc: class httpProc:
def __init__(self, request, templateName, data = None): def __init__(self, request, templateName, data = None, function = None):
self.request = request self.request = request
self.templateName = templateName self.templateName = templateName
self.data = data self.data = data
self.function = function
def render(self): def render(self):
@@ -15,19 +17,33 @@ class httpProc:
from loginSystem.models import Administrator from loginSystem.models import Administrator
from plogical.acl import ACLManager from plogical.acl import ACLManager
userID = self.request.session['userID'] userID = self.request.session['userID']
admin = Administrator.objects.get(pk=userID) currentACL = ACLManager.loadedACL(userID)
### Permissions Check
if self.function != None:
if not currentACL['admin']:
if not currentACL[self.function]:
templateName = 'baseTemplate/error.html'
return render(self.request, templateName, {'error_message': 'You are not authorized to access %s' % (self.function)})
### ###
if self.data == None: if self.data == None:
self.data = {} self.data = {}
self.data.update(ACLManager.loadedACL(userID)) ipFile = "/etc/cyberpanel/machineIP"
return render(self.request, self.templateName, self.data) f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
self.data['ipAddress'] = ipAddress
self.data.update(currentACL)
return render(self.request, self.templateName, self.data)
except BaseException as msg: except BaseException as msg:
templateName = 'UserManagement/login.html' templateName = 'baseTemplate/error.html'
return render(self.request, templateName) return render(self.request, templateName, {'error_message': str(msg)})
def renderPre(self): def renderPre(self):
if self.data == None: if self.data == None:

View File

@@ -458,6 +458,7 @@ app.controller('deleteUser', function ($scope, $http) {
/* Java script code to create acl */ /* Java script code to create acl */
app.controller('createACLCTRL', function ($scope, $http) { app.controller('createACLCTRL', function ($scope, $http) {
$scope.aclLoading = true; $scope.aclLoading = true;
@@ -520,11 +521,13 @@ app.controller('createACLCTRL', function ($scope, $http) {
// Backup Management // Backup Management
$scope.createBackup = true; $scope.createBackup = true;
$scope.googleDriveBackups = true;
$scope.restoreBackup = false; $scope.restoreBackup = false;
$scope.addDeleteDestinations = false; $scope.addDeleteDestinations = false;
$scope.scheDuleBackups = false; $scope.scheDuleBackups = false;
$scope.remoteBackups = false; $scope.remoteBackups = false;
// SSL Management // SSL Management
$scope.manageSSL = true; $scope.manageSSL = true;
@@ -599,6 +602,7 @@ app.controller('createACLCTRL', function ($scope, $http) {
// Backup Management // Backup Management
createBackup: $scope.createBackup, createBackup: $scope.createBackup,
googleDriveBackups: $scope.googleDriveBackups,
restoreBackup: $scope.restoreBackup, restoreBackup: $scope.restoreBackup,
addDeleteDestinations: $scope.addDeleteDestinations, addDeleteDestinations: $scope.addDeleteDestinations,
scheDuleBackups: $scope.scheDuleBackups, scheDuleBackups: $scope.scheDuleBackups,
@@ -976,6 +980,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) {
// Backup Management // Backup Management
$scope.createBackup = Boolean(response.data.createBackup); $scope.createBackup = Boolean(response.data.createBackup);
$scope.googleDriveBackups = Boolean(response.data.googleDriveBackups);
$scope.restoreBackup = Boolean(response.data.restoreBackup); $scope.restoreBackup = Boolean(response.data.restoreBackup);
$scope.addDeleteDestinations = Boolean(response.data.addDeleteDestinations); $scope.addDeleteDestinations = Boolean(response.data.addDeleteDestinations);
$scope.scheDuleBackups = Boolean(response.data.scheDuleBackups); $scope.scheDuleBackups = Boolean(response.data.scheDuleBackups);
@@ -1076,6 +1081,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) {
// Backup Management // Backup Management
createBackup: $scope.createBackup, createBackup: $scope.createBackup,
googleDriveBackups: $scope.googleDriveBackups,
restoreBackup: $scope.restoreBackup, restoreBackup: $scope.restoreBackup,
addDeleteDestinations: $scope.addDeleteDestinations, addDeleteDestinations: $scope.addDeleteDestinations,
scheDuleBackups: $scope.scheDuleBackups, scheDuleBackups: $scope.scheDuleBackups,