Alias Manager.

This commit is contained in:
usmannasir
2018-05-08 21:25:37 +05:00
parent e71c8e53c6
commit 9571f0a666
15 changed files with 1224 additions and 271 deletions

View File

@@ -0,0 +1,28 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.css v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px}
.toggle{position:relative;overflow:hidden}
.toggle input[type=checkbox]{display:none}
.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none}
.toggle.off .toggle-group{left:-100%}
.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0}
.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0}
.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px}
.toggle.btn{min-width:59px;min-height:34px}
.toggle-on.btn{padding-right:24px}
.toggle-off.btn{padding-left:24px}
.toggle.btn-lg{min-width:79px;min-height:45px}
.toggle-on.btn-lg{padding-right:31px}
.toggle-off.btn-lg{padding-left:31px}
.toggle-handle.btn-lg{width:40px}
.toggle.btn-sm{min-width:50px;min-height:30px}
.toggle-on.btn-sm{padding-right:20px}
.toggle-off.btn-sm{padding-left:20px}
.toggle.btn-xs{min-width:35px;min-height:22px}
.toggle-on.btn-xs{padding-right:12px}
.toggle-off.btn-xs{padding-left:12px}

View File

@@ -0,0 +1,9 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.js v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('<label class="btn">').html(this.options.on).addClass(this._onstyle+" "+b),d=a('<label class="btn">').html(this.options.off).addClass(this._offstyle+" "+b+" active"),e=a('<span class="toggle-handle btn btn-default">').addClass(b),f=a('<div class="toggle-group">').append(c,d,e),g=a('<div class="toggle btn" data-toggle="toggle">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(b).addClass(this.options.style);this.$element.wrap(g),a.extend(this,{$toggle:this.$element.parent(),$toggleOn:c,$toggleOff:d,$toggleGroup:f}),this.$toggle.append(f);var h=this.options.width||Math.max(c.outerWidth(),d.outerWidth())+e.outerWidth()/2,i=this.options.height||Math.max(c.outerHeight(),d.outerHeight());c.addClass("toggle-on"),d.addClass("toggle-off"),this.$toggle.css({width:h,height:i}),this.options.height&&(c.css("line-height",c.height()+"px"),d.css("line-height",d.height()+"px")),this.update(!0),this.trigger(!0)},c.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},c.prototype.on=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),void(a||this.trigger()))},c.prototype.off=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),void(a||this.trigger()))},c.prototype.enable=function(){this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},c.prototype.disable=function(){this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},c.prototype.update=function(a){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(a):this.off(a)},c.prototype.trigger=function(b){this.$element.off("change.bs.toggle"),b||this.$element.change(),this.$element.on("change.bs.toggle",a.proxy(function(){this.update()},this))},c.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var d=a.fn.bootstrapToggle;a.fn.bootstrapToggle=b,a.fn.bootstrapToggle.Constructor=c,a.fn.toggle.noConflict=function(){return a.fn.bootstrapToggle=d,this},a(function(){a("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),a(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(b){var c=a(this).find("input[type=checkbox]");c.bootstrapToggle("toggle"),b.preventDefault()})}(jQuery);
//# sourceMappingURL=bootstrap-toggle.min.js.map

View File

@@ -14,8 +14,8 @@
<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="18">
<caret line="19" column="0" lean-forward="false" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
<state relative-caret-position="396">
<caret line="40" column="52" lean-forward="false" selection-start-line="40" selection-start-column="52" selection-end-line="40" selection-end-column="52" />
<folding>
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
@@ -111,8 +111,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
@@ -129,6 +127,8 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
@@ -167,16 +167,17 @@
<workItem from="1524303326266" duration="7000" />
<workItem from="1524730597265" duration="8000" />
<workItem from="1525085664919" duration="10000" />
<workItem from="1525683960581" duration="13000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="36392000" />
<option name="totallyTimeSpent" value="36405000" />
</component>
<component name="ToolWindowManager">
<frame x="1466" y="-4" width="1303" height="780" extended-state="6" />
<layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23443505" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23443505" 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" />
@@ -316,6 +317,35 @@
</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#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">
@@ -357,8 +387,8 @@
<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="18">
<caret line="19" column="0" lean-forward="false" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
<state relative-caret-position="396">
<caret line="40" column="52" lean-forward="false" selection-start-line="40" selection-start-column="52" selection-end-line="40" selection-end-column="52" />
<folding>
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />

View File

@@ -305,6 +305,7 @@ def submitPasswordChange(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
#######
def dkimManager(request):
try:
@@ -450,7 +451,6 @@ def generateDKIMKeys(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def installOpenDKIM(request):
try:
val = request.session['userID']
@@ -473,7 +473,8 @@ def installStatusOpenDKIM(request):
try:
if request.method == 'POST':
installStatus = unicode(open(mailUtilities.installLogPath, "r").read())
command = "sudo cat " + mailUtilities.installLogPath
installStatus = subprocess.check_output(shlex.split(command))
if installStatus.find("[200]")>-1:

View File

@@ -8,7 +8,8 @@ import shlex
class mailUtilities:
installLogPath = "/home/cyberpanel/modSecInstallLog"
installLogPath = "/home/cyberpanel/openDKIMInstallLog"
cyberPanelHome = "/home/cyberpanel"
@staticmethod
def createEmailAccount(domain):
@@ -118,10 +119,13 @@ class mailUtilities:
path = "/etc/opendkim.conf"
if os.path.exists(path):
return 1
else:
command = "sudo cat " + path
res = subprocess.call(shlex.split(command))
if res == 1:
return 0
else:
return 1
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
@@ -143,7 +147,6 @@ class mailUtilities:
str(msg) + " [generateKeys]")
print "0," + str(msg)
@staticmethod
def configureOpenDKIM():
try:
@@ -206,10 +209,28 @@ milter_default_action = accept
print "0," + str(msg)
return
@staticmethod
def checkHome():
try:
try:
command = "sudo mkdir " + mailUtilities.cyberPanelHome
subprocess.call(shlex.split(command))
command = "sudo chown -R cyberpanel:cyberpanel " + mailUtilities.cyberPanelHome
subprocess.call(shlex.split(command))
except:
command = "sudo chown -R cyberpanel:cyberpanel " + mailUtilities.cyberPanelHome
subprocess.call(shlex.split(command))
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkHome]")
@staticmethod
def installOpenDKIM(install, openDKIMINstall):
try:
mailUtilities.checkHome()
command = 'sudo yum install opendkim -y'
cmd = shlex.split(command)
@@ -221,7 +242,7 @@ milter_default_action = accept
writeToFile = open(mailUtilities.installLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile("[Could not Install]")
logging.CyberCPLogFileWriter.writeToFile("[Could not Install OpenDKIM.]")
return 0
else:
writeToFile = open(mailUtilities.installLogPath, 'a')
@@ -230,6 +251,9 @@ milter_default_action = accept
return 1
except BaseException, msg:
writeToFile = open(mailUtilities.installLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installOpenDKIM]")

View File

@@ -6,16 +6,20 @@ from virtualHostUtilities import virtualHostUtilities
import os
import tarfile
import shutil
from mailUtilities import mailUtilities
class modSec:
installLogPath = "/home/cyberpanel/modSecInstallLog"
tempRulesFile = "/home/cyberpanel/tempModSecRules"
mirrorPath = "mirror.cyberpanel.net"
@staticmethod
def installModSec(install, modSecInstall):
try:
mailUtilities.checkHome()
command = 'sudo yum install ols-modsecurity -y'
cmd = shlex.split(command)

View File

@@ -5,6 +5,7 @@ import thread
import installUtilities
import argparse
import os
from mailUtilities import mailUtilities
class phpUtilities:
@@ -14,6 +15,8 @@ class phpUtilities:
def installPHPExtension(extension,extensions):
try:
mailUtilities.checkHome()
command = 'sudo yum install '+extension +' -y'
cmd = shlex.split(command)
@@ -40,6 +43,8 @@ class phpUtilities:
def unInstallPHPExtension(extension,extensions):
try:
mailUtilities.checkHome()
command = 'sudo rpm --nodeps -e ' + extension + ' -v'
cmd = shlex.split(command)

View File

@@ -9,6 +9,30 @@ class sslUtilities:
Server_root = "/usr/local/lsws"
@staticmethod
def checkIfSSLMap(virtualHostName):
try:
data = open("/usr/local/lsws/conf/httpd_config.conf").readlines()
sslCheck = 0
for items in data:
if items.find("listener SSL") > -1:
sslCheck = 1
continue
if sslCheck == 1:
if items.find("}") > -1:
return 0
if items.find(virtualHostName) > -1 and sslCheck == 1:
data = filter(None, items.split(" "))
if data[1] == virtualHostName:
return 1
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkIfSSLMap]]")
return 0
@staticmethod
def installSSLForDomain(virtualHostName):
@@ -49,6 +73,9 @@ class sslUtilities:
else:
if sslUtilities.checkIfSSLMap(virtualHostName) == 0:
data = open("/usr/local/lsws/conf/httpd_config.conf").readlines()
writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'w')
sslCheck = 0
@@ -135,7 +162,7 @@ class sslUtilities:
@staticmethod
def obtainSSLForADomain(virtualHostName,adminEmail,sslpath):
def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None):
try:
## Obtaining Server IP
@@ -147,6 +174,8 @@ class sslUtilities:
## Obtaining Domain IPs
if aliasDomain == None:
ipRecords = sslUtilities.getDNSRecords(virtualHostName)
@@ -170,6 +199,58 @@ class sslUtilities:
"Failed to obtain DNS records for " + virtualHostName + ", issuing self signed certificate.")
return 0
else:
ipRecords = sslUtilities.getDNSRecords(virtualHostName)
if ipRecords[0] == 1:
if serverIPAddress == ipRecords[1] and serverIPAddress == ipRecords[2]:
ipRecordsAlias = sslUtilities.getDNSRecords(aliasDomain)
if serverIPAddress == ipRecordsAlias[1] and serverIPAddress == ipRecordsAlias[2]:
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName + " -d " + aliasDomain + " -d www." + aliasDomain
else:
if serverIPAddress == ipRecordsAlias[2]:
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName + " -d " + aliasDomain
else:
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName
else:
if serverIPAddress == ipRecords[2]:
ipRecordsAlias = sslUtilities.getDNSRecords(aliasDomain)
if serverIPAddress == ipRecordsAlias[1] and serverIPAddress == ipRecordsAlias[2]:
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d " + aliasDomain + " -d www." + aliasDomain
else:
if serverIPAddress == ipRecordsAlias[2]:
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d " + aliasDomain
else:
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName
logging.CyberCPLogFileWriter.writeToFile(
"SSL is issued without 'www' due to DNS error for domain : " + virtualHostName)
else:
ipRecordsAlias = sslUtilities.getDNSRecords(aliasDomain)
if serverIPAddress == ipRecordsAlias[1] and serverIPAddress == ipRecordsAlias[2]:
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + aliasDomain + " -d www." + aliasDomain
else:
if serverIPAddress == ipRecordsAlias[2]:
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + aliasDomain
else:
return 0
else:
logging.CyberCPLogFileWriter.writeToFile(
"Failed to obtain DNS records for " + virtualHostName + ", issuing self signed certificate.")
return 0
## SSL Paths
@@ -182,23 +263,37 @@ class sslUtilities:
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
srcPrivKey = "/etc/letsencrypt/live/" + virtualHostName + "/privkey.pem"
srcFullChain = "/etc/letsencrypt/live/" + virtualHostName + "/fullchain.pem"
##
output = subprocess.check_output(shlex.split(command))
data = output.split('\n')
if output.find('Congratulations!') > -1 or output.find('no action taken.') > -1:
if output.find('Congratulations!') > -1:
###### Copy SSL To config location ######
for items in data:
if items.find(virtualHostName) > -1 and items.find('fullchain.pem') > -1:
srcFullChain = items.strip(' ')
elif items.find(virtualHostName) > -1 and items.find('privkey.pem') > -1:
srcPrivKey = items.strip(' ')
if os.path.exists(pathToStoreSSLPrivKey):
os.remove(pathToStoreSSLPrivKey)
if os.path.exists(pathToStoreSSLFullChain):
os.remove(pathToStoreSSLFullChain)
shutil.copy(srcPrivKey, pathToStoreSSLPrivKey)
shutil.copy(srcFullChain, pathToStoreSSLFullChain)
return 1
elif output.find('no action taken.') > -1:
return 1
elif output.find('Failed authorization procedure') > -1:
logging.CyberCPLogFileWriter.writeToFile('Failed authorization procedure for ' + virtualHostName + " while issuing Let's Encrypt SSL.")
return 0
@@ -212,10 +307,10 @@ class sslUtilities:
return 0
def issueSSLForDomain(domain,adminEmail,sslpath):
def issueSSLForDomain(domain,adminEmail,sslpath, aliasDomain = None):
try:
if sslUtilities.obtainSSLForADomain(domain, adminEmail, sslpath) == 1:
if sslUtilities.obtainSSLForADomain(domain, adminEmail, sslpath, aliasDomain) == 1:
if sslUtilities.installSSLForDomain(domain) == 1:
return [1, "None"]

View File

@@ -13,6 +13,8 @@ from shutil import move
import randomPassword as randomPassword
from mailUtilities import mailUtilities
## If you want justice, you have come to the wrong place.
class virtualHostUtilities:
@@ -902,6 +904,66 @@ class virtualHostUtilities:
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@staticmethod
def checkIfAliasExists(aliasDomain):
try:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
data = open(confPath, 'r').readlines()
for items in data:
if items.find(aliasDomain) > -1:
domains = filter(None, items.split(" "))
for domain in domains:
if domain.strip(',').strip('\n') == aliasDomain:
return 1
return 0
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkIfAliasExists]")
return 1
@staticmethod
def checkIfSSLAliasExists(data, aliasDomain):
try:
for items in data:
if items.strip(',').strip('\n') == aliasDomain:
return 1
return 0
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkIfSSLAliasExists]")
return 1
@staticmethod
def createAliasSSLMap(confPath, masterDomain, aliasDomain):
try:
data = open(confPath, 'r').readlines()
writeToFile = open(confPath, 'w')
sslCheck = 0
for items in data:
if (items.find("listener SSL") > -1):
sslCheck = 1
if items.find(masterDomain) > -1 and items.find('map') > -1 and sslCheck == 1:
data = filter(None, items.split(" "))
if data[1] == masterDomain:
if virtualHostUtilities.checkIfSSLAliasExists(data, aliasDomain) == 0:
writeToFile.writelines(items.rstrip('\n') + ", " + aliasDomain + "\n")
sslCheck = 0
else:
writeToFile.writelines(items)
else:
writeToFile.writelines(items)
writeToFile.close()
installUtilities.installUtilities.reStartLiteSpeed()
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createAliasSSLMap]")
def createVirtualHost(virtualHostName,administratorEmail,phpVersion,virtualHostUser,numberOfSites,ssl,sslPath,dkimCheck):
try:
@@ -1035,19 +1097,6 @@ def issueSSL(virtualHost,path,adminEmail):
FNULL = open(os.devnull, 'w')
srcPrivKey = "/etc/letsencrypt/live/" + virtualHost + "/privkey.pem"
srcFullChain = "/etc/letsencrypt/live/" + virtualHost + "/fullchain.pem"
pathToStoreSSL = virtualHostUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHost
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
if os.path.exists(pathToStoreSSLPrivKey):
os.remove(pathToStoreSSLPrivKey)
if os.path.exists(pathToStoreSSLFullChain):
os.remove(pathToStoreSSLFullChain)
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
if retValues[0] == 0:
@@ -1064,10 +1113,6 @@ def issueSSL(virtualHost,path,adminEmail):
print "1,None"
return
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [issueSSL]")
@@ -1482,9 +1527,6 @@ def issueSSLForHostName(virtualHost,path):
FNULL = open(os.devnull, 'w')
srcPrivKey = "/etc/letsencrypt/live/" + virtualHost + "/privkey.pem"
srcFullChain = "/etc/letsencrypt/live/" + virtualHost + "/fullchain.pem"
pathToStoreSSL = virtualHostUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHost
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
@@ -1493,13 +1535,6 @@ def issueSSLForHostName(virtualHost,path):
destPrivKey = "/usr/local/lscp/key.pem"
destCert = "/usr/local/lscp/cert.pem"
## removing old certs
if os.path.exists(pathToStoreSSLPrivKey):
os.remove(pathToStoreSSLPrivKey)
if os.path.exists(pathToStoreSSLFullChain):
os.remove(pathToStoreSSLFullChain)
## removing old certs for lscpd
if os.path.exists(destPrivKey):
os.remove(destPrivKey)
@@ -1508,55 +1543,18 @@ def issueSSLForHostName(virtualHost,path):
adminEmail = "email@" + virtualHost
if not (os.path.exists(srcPrivKey) and os.path.exists(srcFullChain)):
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
if retValues[0] == 0:
print "0," + str(retValues[1])
return
## lcpd specific functions
shutil.copy(srcPrivKey, destPrivKey)
shutil.copy(srcFullChain, destCert)
command = 'systemctl restart lscpd'
cmd = shlex.split(command)
res = subprocess.call(cmd)
vhostPath = virtualHostUtilities.Server_root + "/conf/vhosts"
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
print "1,None"
else:
###### Copy SSL To config location ######
try:
os.mkdir(pathToStoreSSL)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Directory for SSL already exists.. Continuing [issueSSLForHostName]]")
srcPrivKey = "/etc/letsencrypt/live/" + virtualHost + "/privkey.pem"
srcFullChain = "/etc/letsencrypt/live/" + virtualHost + "/fullchain.pem"
shutil.copy(srcPrivKey, pathToStoreSSLPrivKey)
shutil.copy(srcFullChain, pathToStoreSSLFullChain)
## lcpd specific functions
shutil.copy(srcPrivKey, destPrivKey)
shutil.copy(srcFullChain, destCert)
shutil.copy(pathToStoreSSLPrivKey, destPrivKey)
shutil.copy(pathToStoreSSLFullChain, destCert)
command = 'systemctl restart lscpd'
cmd = shlex.split(command)
res = subprocess.call(cmd)
subprocess.call(cmd)
vhostPath = virtualHostUtilities.Server_root + "/conf/vhosts"
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
@@ -1564,7 +1562,6 @@ def issueSSLForHostName(virtualHost,path):
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
print "1,None"
return
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(
@@ -1576,27 +1573,10 @@ def issueSSLForMailServer(virtualHost,path):
FNULL = open(os.devnull, 'w')
srcPrivKey = "/etc/letsencrypt/live/" + virtualHost + "/privkey.pem"
srcFullChain = "/etc/letsencrypt/live/" + virtualHost + "/fullchain.pem"
pathToStoreSSL = virtualHostUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHost
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
## removing old certs
if os.path.exists(pathToStoreSSLPrivKey):
os.remove(pathToStoreSSLPrivKey)
if os.path.exists(pathToStoreSSLFullChain):
os.remove(pathToStoreSSLFullChain)
adminEmail = "email@" + virtualHost
if not (os.path.exists(srcPrivKey) and os.path.exists(srcFullChain)):
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
if retValues[0] == 0:
@@ -1604,21 +1584,6 @@ def issueSSLForMailServer(virtualHost,path):
return
else:
###### Copy SSL To config location ######
try:
os.mkdir(pathToStoreSSL)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Directory for SSL already exists.. Continuing [issueSSLForHostName]]")
srcPrivKey = "/etc/letsencrypt/live/" + virtualHost + "/privkey.pem"
srcFullChain = "/etc/letsencrypt/live/" + virtualHost + "/fullchain.pem"
shutil.copy(srcPrivKey, pathToStoreSSLPrivKey)
shutil.copy(srcFullChain, pathToStoreSSLFullChain)
## MailServer specific functions
if os.path.exists("/etc/postfix/cert.pem"):
@@ -1642,6 +1607,9 @@ def issueSSLForMailServer(virtualHost,path):
## Postfix
srcPrivKey = pathToStoreSSL + "/privkey.pem"
srcFullChain = pathToStoreSSL + "/fullchain.pem"
shutil.copy(srcPrivKey, "/etc/postfix/key.pem")
shutil.copy(srcFullChain, "/etc/postfix/cert.pem")
@@ -1707,6 +1675,117 @@ def issueSSLForMailServer(virtualHost,path):
print "0,"+str(msg)
def createAlias(masterDomain,aliasDomain,ssl,sslPath, administratorEmail):
try:
if virtualHostUtilities.checkIfAliasExists(aliasDomain) == 0:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
data = open(confPath,'r').readlines()
writeToFile = open(confPath,'w')
listenerTrueCheck = 0
for items in data:
if items.find("listener Default{") > -1 or items.find("Default {") > -1:
listenerTrueCheck = 1
if items.find(masterDomain) > -1 and items.find('map') > -1 and listenerTrueCheck == 1:
data = filter(None, items.split(" "))
if data[1] == masterDomain:
writeToFile.writelines(items.rstrip('\n') + ", " + aliasDomain + "\n")
listenerTrueCheck = 0
else:
writeToFile.writelines(items)
writeToFile.close()
installUtilities.installUtilities.reStartLiteSpeed()
else:
print "0, This domain already exists as vHost or Alias."
return
if ssl == 1:
retValues = sslUtilities.issueSSLForDomain(masterDomain, administratorEmail, sslPath, aliasDomain)
if retValues[0] == 0:
print "0," + str(retValues[1])
return
else:
virtualHostUtilities.createAliasSSLMap(confPath,masterDomain, aliasDomain)
print "1,None"
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createAlias]")
print "0,"+str(msg)
def issueAliasSSL(masterDomain, aliasDomain, sslPath, administratorEmail):
try:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
retValues = sslUtilities.issueSSLForDomain(masterDomain, administratorEmail, sslPath, aliasDomain)
if retValues[0] == 0:
print "0," + str(retValues[1])
return
else:
virtualHostUtilities.createAliasSSLMap(confPath, masterDomain, aliasDomain)
print "1,None"
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueAliasSSL]")
print "0," + str(msg)
def deleteAlias(masterDomain, aliasDomain):
try:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
data = open(confPath, 'r').readlines()
writeToFile = open(confPath, 'w')
aliases = []
for items in data:
if items.find(masterDomain) > -1 and items.find('map') > -1:
data = filter(None, items.split(" "))
if data[1] == masterDomain:
length = len(data)
for i in range(3, length):
currentAlias = data[i].rstrip(',').strip('\n')
if currentAlias != aliasDomain:
aliases.append(currentAlias)
aliasString = ""
for alias in aliases:
aliasString = ", " + alias
writeToFile.writelines(' map ' + masterDomain + " " + masterDomain + aliasString + "\n")
aliases = []
aliasString = ""
else:
writeToFile.writelines(items)
else:
writeToFile.writelines(items)
writeToFile.close()
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [deleteAlias]")
print "0," + str(msg)
def saveSSL(virtualHost,pathToStoreSSL,keyPath,certPath,sslCheck):
try:
@@ -1795,6 +1874,12 @@ def main():
parser.add_argument('--prefix', help='Database Prefix!')
parser.add_argument('--sitename', help='Site Name!')
## Arguments for alias domain
parser.add_argument('--aliasDomain', help='Alias Domain!')
args = parser.parse_args()
if args.function == "createVirtualHost":
@@ -1835,6 +1920,12 @@ def main():
issueSSLForMailServer(args.virtualHostName,args.path)
elif args.function == "findDomainBW":
virtualHostUtilities.findDomainBW(args.virtualHostName, int(args.bandwidth))
elif args.function == 'createAlias':
createAlias(args.masterDomain,args.aliasDomain,int(args.ssl),args.sslPath, args.administratorEmail)
elif args.function == 'issueAliasSSL':
issueAliasSSL(args.masterDomain, args.aliasDomain, args.sslPath, args.administratorEmail)
elif args.function == 'deleteAlias':
deleteAlias(args.masterDomain, args.aliasDomain)
if __name__ == "__main__":
main()

View File

@@ -2421,5 +2421,266 @@ app.controller('manageCronController', function($scope,$http) {
});
/* Java script code to manage cron ends here */
/* Java script code to manage cron */
app.controller('manageAliasController', function($scope,$http, $timeout, $window) {
var masterDomain = "";
$scope.aliasTable = false;
$scope.addAliasButton = false;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.showAliasForm = function (domainName) {
$scope.domainAliasForm = false;
$scope.aliasTable = true;
$scope.addAliasButton = true;
masterDomain = domainName;
};
$scope.addAliasFunc = function () {
$scope.manageAliasLoading = false;
var ssl;
if ($scope.sslCheck === true){
ssl = 1;
}
else{
ssl = 0
}
url = "/websites/submitAliasCreation";
var data = {
masterDomain: masterDomain,
aliasDomain:$scope.aliasDomain,
ssl:ssl
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.createAliasStatus === 1){
$scope.aliasTable = true;
$scope.addAliasButton = true;
$scope.domainAliasForm = false;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = false;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$timeout(function() { $window.location.reload(); }, 3000);
}
else{
$scope.aliasTable = true;
$scope.addAliasButton = true;
$scope.domainAliasForm = false;
$scope.aliasError = false;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.aliasTable = true;
$scope.addAliasButton = true;
$scope.domainAliasForm = false;
$scope.aliasError = true;
$scope.couldNotConnect = false;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
}
};
$scope.issueSSL = function (masterDomain, aliasDomain) {
$scope.manageAliasLoading = false;
url = "/websites/issueAliasSSL";
var data = {
masterDomain: masterDomain,
aliasDomain:aliasDomain,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.sslStatus === 1){
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = false;
}
else{
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = false;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = false;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
}
};
$scope.removeAlias = function (masterDomain, aliasDomain) {
$scope.manageAliasLoading = false;
url = "/websites/delateAlias";
var data = {
masterDomain: masterDomain,
aliasDomain:aliasDomain,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.deleteAlias === 1){
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = false;
$timeout(function() { $window.location.reload(); }, 3000);
}
else{
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = false;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = false;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
}
};
});
/* Java script code to manage cron ends here */

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -2426,14 +2426,259 @@ app.controller('manageCronController', function($scope,$http) {
/* Java script code to manage cron */
app.controller('manageAliasController', function($scope,$http) {
app.controller('manageAliasController', function($scope,$http, $timeout, $window) {
var masterDomain = "";
$scope.aliasTable = false;
$scope.addAliasButton = false;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.showAliasForm = function (domainName) {
$scope.domainAliasForm = false;
$scope.aliasTable = true;
$scope.addAliasButton = true;
masterDomain = domainName;
};
$scope.addAliasFunc = function () {
$scope.manageAliasLoading = false;
var ssl;
if ($scope.sslCheck === true){
ssl = 1;
}
else{
ssl = 0
}
url = "/websites/submitAliasCreation";
var data = {
masterDomain: masterDomain,
aliasDomain:$scope.aliasDomain,
ssl:ssl
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.createAliasStatus === 1){
$scope.aliasTable = true;
$scope.addAliasButton = true;
$scope.domainAliasForm = false;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = false;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$timeout(function() { $window.location.reload(); }, 3000);
}
else{
$scope.aliasTable = true;
$scope.addAliasButton = true;
$scope.domainAliasForm = false;
$scope.aliasError = false;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.aliasTable = true;
$scope.addAliasButton = true;
$scope.domainAliasForm = false;
$scope.aliasError = true;
$scope.couldNotConnect = false;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
}
};
$scope.issueSSL = function (masterDomain, aliasDomain) {
$scope.manageAliasLoading = false;
url = "/websites/issueAliasSSL";
var data = {
masterDomain: masterDomain,
aliasDomain:aliasDomain,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.sslStatus === 1){
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = false;
}
else{
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = false;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = false;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
}
};
$scope.removeAlias = function (masterDomain, aliasDomain) {
$scope.manageAliasLoading = false;
url = "/websites/delateAlias";
var data = {
masterDomain: masterDomain,
aliasDomain:aliasDomain,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.deleteAlias === 1){
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = false;
$timeout(function() { $window.location.reload(); }, 3000);
}
else{
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = false;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = false;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
}
};
});

View File

@@ -24,9 +24,9 @@
<form action="/" class="form-horizontal bordered-row">
<!------ Modification form that appears after a click --------------->
<div class="form-group">
<div ng-hide="addAliasButton" class="form-group">
<div class="col-sm-4">
<button class="btn ra-100 btn-blue-alt">Create Alias</button>
<button ng-click="showAliasForm('{{ masterDomain }}')" class="btn ra-100 btn-blue-alt">{% trans 'Create Alias' %}</button>
</div>
</div>
@@ -50,9 +50,9 @@
<td>{{ masterDomain }}</td>
<td>{{ alias }}</td>
<td>{{ path }}</td>
<td><button type="button" ng-click="issueSSL(record.childDomain,record.path)" class="btn ra-100 btn-purple">{% trans "Issue" %}</button></td>
<td><button type="button" ng-click="issueSSL('{{ masterDomain }}', '{{ alias }}')" class="btn ra-100 btn-purple">{% trans "Issue" %}</button></td>
<td>
<a class="btn btn-warning" ng-click="removeAlias()" href=""><i class="glyph-icon icon-trash" title="{% trans "Delete" %}"></i></a>
<a class="btn btn-warning" ng-click="removeAlias('{{ masterDomain }}', '{{ alias }}')" href=""><i class="glyph-icon icon-trash" title="{% trans "Delete" %}"></i></a>
</td>
</tr>
{% endfor %}
@@ -99,7 +99,7 @@
<hr>
</form>
<div ng-hide="addAliasButton" class="form-group">
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="addAliasFunc()" class="btn btn-primary btn-lg btn-block">{% trans "Create Alias" %}</button>
@@ -115,8 +115,13 @@
</div>
<div ng-hide="aliasCreated" class="alert alert-success">
<p>{% trans "Alias successfully created." %}</p>
<p>{% trans "Alias successfully created. Refreshing page in 3 seconds..." %}</p>
</div>
<div ng-hide="operationSuccess" class="alert alert-success">
<p>{% trans "Operation Successfull." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>

View File

@@ -70,6 +70,8 @@ urlpatterns = [
## Domain Alias
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/domainAlias$', views.domainAlias, name='domainAlias'),
url(r'^submitAliasCreation',views.submitAliasCreation,name="submitAliasCreation"),
url(r'^issueAliasSSL',views.issueAliasSSL,name="issueAliasSSL"),
url(r'^delateAlias',views.delateAlias,name="delateAlias"),
]

View File

@@ -24,6 +24,7 @@ import re
from random import randint
import hashlib
from xml.etree import ElementTree
from plogical.mailUtilities import mailUtilities
# Create your views here.
@@ -308,24 +309,6 @@ def dnsTemplate(request, domain, admin, dkimCheck):
auth=1)
record.save()
## DKIM Support
if dkimCheck == 1:
path = "/etc/opendkim/keys/" + topLevelDomain + "/default.txt"
command = "sudo cat " + path
output = subprocess.check_output(shlex.split(command))
record = Records(domainOwner=zone,
domain_id=zone.id,
name="default._domainkey." + topLevelDomain,
type="TXT",
content="v=DKIM1; k=rsa; p=" + output[53:269],
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()
else:
if Domains.objects.filter(name=topLevelDomain).count() == 0:
@@ -412,24 +395,6 @@ def dnsTemplate(request, domain, admin, dkimCheck):
auth=1)
record.save()
## DKIM Support
if dkimCheck == 1:
path = "/etc/opendkim/keys/" + topLevelDomain + "/default.txt"
command = "sudo cat " + path
output = subprocess.check_output(shlex.split(command))
record = Records(domainOwner=zone,
domain_id=zone.id,
name="default._domainkey." + topLevelDomain,
type="TXT",
content="v=DKIM1; k=rsa; p=" + output[53:269],
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()
## Creating sub-domain level record.
zone = Domains.objects.get(name=topLevelDomain)
@@ -468,6 +433,35 @@ def dnsTemplate(request, domain, admin, dkimCheck):
logging.CyberCPLogFileWriter.writeToFile(
"We had errors while creating DNS records for: " + domain + ". Error message: " + str(msg))
def createDKIMRecords(request, domain, admin):
try:
import tldextract
extractDomain = tldextract.extract(domain)
topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix
zone = Domains.objects.get(name=topLevelDomain)
path = "/etc/opendkim/keys/" + topLevelDomain + "/default.txt"
command = "sudo cat " + path
output = subprocess.check_output(shlex.split(command))
record = Records(domainOwner=zone,
domain_id=zone.id,
name="default._domainkey." + topLevelDomain,
type="TXT",
content="v=DKIM1; k=rsa; p=" + output[53:269],
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
"We had errors while creating DNS records for: " + domain + ". Error message: " + str(msg))
def siteState(request):
try:
@@ -579,6 +573,12 @@ def submitWebsiteCreation(request):
####### Limitations Check End
##### Zone creation
dnsTemplate(requests, domain, admin, data['dkimCheck'])
## zone creation
numberOfWebsites = str(Websites.objects.count() + ChildDomains.objects.count())
sslpath = "/home/" + domain + "/public_html"
@@ -601,11 +601,10 @@ def submitWebsiteCreation(request):
## Create Configurations ends here
##### Zone creation
## DKIM Check
dnsTemplate(requests, domain, admin, data['dkimCheck'])
## zone creation
if data['dkimCheck'] == 1:
createDKIMRecords(request,domain,admin)
selectedPackage = Package.objects.get(packageName=packageName)
@@ -683,6 +682,18 @@ def submitDomainCreation(request):
else:
path = "/home/" + masterDomain + "/public_html/" + domain
### Zone creation.
try:
restore = data['restore']
restart = 0
except BaseException, msg:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
dnsTemplate(requests, domain, admin, data['dkimCheck'])
## Zone creation.
externalApp = master.externalApp
numberOfWebsites = str(Websites.objects.count() + ChildDomains.objects.count())
@@ -700,22 +711,17 @@ def submitDomainCreation(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## Create Configurations ends here
### Zone creation.
## DKIM Check
try:
restore = data['restore']
restart = 0
except BaseException, msg:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
dnsTemplate(requests, domain, admin, data['dkimCheck'])
## Zone creation.
## Create Configurations ends here
if data['dkimCheck'] == 1:
createDKIMRecords(request, domain, admin)
website = ChildDomains(master=master, domain=domain, path=path, phpSelection=phpSelection, ssl=ssl)
@@ -1811,6 +1817,8 @@ def saveSSL(request):
data = json.loads(request.body)
domain = data['virtualHost']
mailUtilities.checkHome()
## writing data temporary to file
@@ -2647,7 +2655,9 @@ def domainAlias(request,domain):
else:
noAlias = 1
for i in range(3, length):
aliases.append(data[i])
aliases.append(data[i].rstrip(','))
aliases = list(set(aliases))
return render(request, 'websiteFunctions/domainAlias.html', {
'masterDomain': domain,
@@ -2660,3 +2670,146 @@ def domainAlias(request,domain):
return HttpResponse(str(msg))
except KeyError:
return redirect(loadLoginPage)
def submitAliasCreation(request):
try:
if request.method == 'POST':
data = json.loads(request.body)
masterDomain = data['masterDomain']
aliasDomain = data['aliasDomain']
ssl = data['ssl']
admin = Administrator.objects.get(pk=request.session['userID'])
##### Zone creation
dnsTemplate(requests, aliasDomain, admin, 0)
### Zone creation
sslpath = "/home/" + masterDomain + "/public_html"
## Create Configurations
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " createAlias --masterDomain " + masterDomain + " --aliasDomain " + aliasDomain + " --ssl " + str(
ssl) + " --sslPath " + sslpath + " --administratorEmail " + admin.email
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
pass
else:
data_ret = {'createAliasStatus': 0, 'error_message': output, "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## Create Configurations ends here
data_ret = {'createAliasStatus': 1, 'error_message': "None", "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'createAliasStatus': 0, 'error_message': str(msg), "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def issueAliasSSL(request):
try:
if request.method == 'POST':
data = json.loads(request.body)
masterDomain = data['masterDomain']
aliasDomain = data['aliasDomain']
admin = Administrator.objects.get(pk=request.session['userID'])
sslpath = "/home/" + masterDomain + "/public_html"
## Create Configurations
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " issueAliasSSL --masterDomain " + masterDomain + " --aliasDomain " + aliasDomain + " --sslPath " + sslpath + " --administratorEmail " + admin.email
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
pass
else:
data_ret = {'sslStatus': 0, 'error_message': output, "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## Create Configurations ends here
data_ret = {'sslStatus': 1, 'error_message': "None", "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'sslStatus': 0, 'error_message': str(msg), "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def delateAlias(request):
try:
if request.method == 'POST':
data = json.loads(request.body)
masterDomain = data['masterDomain']
aliasDomain = data['aliasDomain']
admin = Administrator.objects.get(pk=request.session['userID'])
sslpath = "/home/" + masterDomain + "/public_html"
## Create Configurations
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " deleteAlias --masterDomain " + masterDomain + " --aliasDomain " + aliasDomain
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
pass
else:
data_ret = {'deleteAlias': 0, 'error_message': output, "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## Create Configurations ends here
data_ret = {'deleteAlias': 1, 'error_message': "None", "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'deleteAlias': 0, 'error_message': str(msg), "existsStatus": 0}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)