diff --git a/dns/views.py b/dns/views.py index 64286a937..1a32bacbb 100644 --- a/dns/views.py +++ b/dns/views.py @@ -295,8 +295,6 @@ def getCurrentRecordsForDomain(request): records = Records.objects.filter(domain_id=domain.id) - json_data = "[" - checker = 0 fetchType = "" @@ -319,6 +317,9 @@ def getCurrentRecordsForDomain(request): elif currentSelection == 'srvRecord': fetchType = 'SRV' + json_data = "[" + checker = 0 + for items in records: if items.type == fetchType: diff --git a/static/images/icons/web-domain.png b/static/images/icons/web-domain.png new file mode 100644 index 000000000..37c5a0253 Binary files /dev/null and b/static/images/icons/web-domain.png differ diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js index 0cd8d27ba..0b33e4b55 100644 --- a/static/websiteFunctions/websiteFunctions.js +++ b/static/websiteFunctions/websiteFunctions.js @@ -448,6 +448,7 @@ app.controller('websitePages', function($scope,$http) { }; $scope.fileManagerURL = "/filemanager/"+$("#domainNamePage").text(); + $scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias"; $scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/"; var logType = 0; diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index 0cd8d27ba..5b1def704 100644 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -448,6 +448,7 @@ app.controller('websitePages', function($scope,$http) { }; $scope.fileManagerURL = "/filemanager/"+$("#domainNamePage").text(); + $scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias"; $scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/"; var logType = 0; @@ -2420,5 +2421,21 @@ 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) { + + $scope.aliasTable = false; + $scope.domainAliasForm = true; + $scope.aliasError = true; + $scope.couldNotConnect = true; + $scope.aliasCreated = true; + $scope.manageAliasLoading = true; + +}); + /* Java script code to manage cron ends here */ \ No newline at end of file diff --git a/websiteFunctions/templates/websiteFunctions/domainAlias.html b/websiteFunctions/templates/websiteFunctions/domainAlias.html new file mode 100644 index 000000000..c6ed170af --- /dev/null +++ b/websiteFunctions/templates/websiteFunctions/domainAlias.html @@ -0,0 +1,141 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block title %}{% trans "Domain Aliases - CyberPanel" %}{% endblock %} +{% block content %} + +{% load static %} +{% get_current_language as LANGUAGE_CODE %} + + +
+
+

{% trans "Domain Aliases" %}

+

{% trans "With Domain Aliases you can visit example.com using example.net and view the same content." %}

+
+ +
+
+

+ {% trans "Domain Aliases" %} +

+
+ + +
+ + +
+
+ +
+
+ + + + + + + + + + + + + + {% if noAlias == 1 %} + + {% for alias in aliases %} + + + + + + + + + {% endfor %} + {% else %} + + + + + + + + {% endif %} + + +
{% trans "Master Domain" %}{% trans "Alias" %}{% trans "File System Path" %}{% trans "SSL" %}{% trans "Delete" %}
{{ masterDomain }}{{ alias }}{{ path }} + +
{{ masterDomain }}{% trans 'Domain Aliases not found.' %}
+ + + +
+ + + +
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+

{% trans "Operation failed. Error message:" %} {$ errorMessage $}

+
+ +
+

{% trans "Alias successfully created." %}

+
+
+

{% trans "Could not connect to server. Please refresh this page." %}

+
+
+ +
+ + + + + + + +
+
+
+ + +
+ + +{% endblock %} \ No newline at end of file diff --git a/websiteFunctions/templates/websiteFunctions/website.html b/websiteFunctions/templates/websiteFunctions/website.html index f48ee3a47..a2bb97e91 100644 --- a/websiteFunctions/templates/websiteFunctions/website.html +++ b/websiteFunctions/templates/websiteFunctions/website.html @@ -258,7 +258,7 @@
-
+
@@ -269,7 +269,7 @@
-
+
@@ -279,8 +279,18 @@
+
+ + + + + {% trans "Domain Alias" %} + -
+
+ + +
@@ -668,6 +678,7 @@
+

{% trans "Current rewrite rules in the file fetched." %}

@@ -806,7 +817,7 @@
-
+ -
+
diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py index bb792c247..2bfc315e9 100644 --- a/websiteFunctions/urls.py +++ b/websiteFunctions/urls.py @@ -67,4 +67,9 @@ urlpatterns = [ url(r'^addNewCron',views.addNewCron,name="addNewCron"), + ## Domain Alias + + url(r'^(?P([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/domainAlias$', views.domainAlias, name='domainAlias'), + + ] \ No newline at end of file diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index ed58ab6bb..7d6a1ac4b 100644 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -2611,4 +2611,52 @@ def addNewCron(request): except KeyError, msg: status = {"addNewCron": 0, "error": "Not Logged in"} final_json = json.dumps(status) - return HttpResponse(final_json) \ No newline at end of file + return HttpResponse(final_json) + + +def domainAlias(request,domain): + try: + val = request.session['userID'] + try: + admin = Administrator.objects.get(pk=request.session['userID']) + + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + + command = "sudo cat " + confPath + httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() + + + path = "/home/" + domain + "/public_html" + + + listenerTrueCheck = 0 + noAlias = 0 + aliases = [] + + for items in httpdConfig: + if items.find("listener Default{") > -1 or items.find("Default {") > -1: + listenerTrueCheck = 1 + continue + if listenerTrueCheck == 1: + if items.find(domain) > -1 and items.find('map') > -1: + data = filter(None, items.split(" ")) + if data[1] == domain: + length = len(data) + if length == 3: + break + else: + noAlias = 1 + for i in range(3, length): + aliases.append(data[i]) + + return render(request, 'websiteFunctions/domainAlias.html', { + 'masterDomain': domain, + 'aliases':aliases, + 'path':path, + 'noAlias':noAlias + }) + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg)) + return HttpResponse(str(msg)) + except KeyError: + return redirect(loadLoginPage) \ No newline at end of file