Skip to content

Commit

Permalink
Updated Website Control Panel to add domains.
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Oct 29, 2017
1 parent 4e24f61 commit 6cc8ba2
Show file tree
Hide file tree
Showing 44 changed files with 4,780 additions and 1,202 deletions.
1 change: 0 additions & 1 deletion CyberCP/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@

LANGUAGES = (
('en', _('English')),
('ur-PK', _('Urdu')),
('cn', _('Chinese')),
('br', _('Bulgarian')),
('pt', _('Portuguese')),
Expand Down
Binary file modified CyberCP/settings.pyc
Binary file not shown.
28 changes: 15 additions & 13 deletions backup/templates/backup/remoteBackups.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}Backup Website{% endblock %}
{% block title %}{% trans "Transfer Websites from Remote Server - CyberPanel" %}{% endblock %}
{% block content %}

{% load static %}


{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->

<div class="container">
<div id="page-title">
<h2>Remote Backups</h2>
<p>This feature can import website(s) from remote server</p>
<h2>{% trans "Remote Backups" %}</h2>
<p>{% trans "This feature can import website(s) from remote server" %}</p>
</div>

<div ng-controller="remoteBackupControl" class="panel">
<div class="panel-body">
<h3 class="title-hero">
Remote Backups <img ng-hide="backupLoading" src="{% static 'images/loading.gif' %}">
{% trans "Remote Backups" %} <img ng-hide="backupLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">

<p ng-bind="transferStatus"></p>
<form action="/" class="form-horizontal bordered-row">

<div class="form-group">
<label class="col-sm-3 control-label">IP Address</label>
<label class="col-sm-3 control-label">{% trans "IP Address" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="IPAddress" required>
</div>
</div>


<div class="form-group">
<label class="col-sm-3 control-label">Password</label>
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input ng-change="passwordEnter()" type="password" class="form-control" ng-model="password" required>
</div>
Expand All @@ -41,7 +43,7 @@ <h3 class="title-hero">
<div ng-hide="backupButton" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-disabled="fetchAccountsBtn" ng-click="fetchAccountsFromRemoteServer()" class="btn btn-primary btn-lg btn-block">Fetch Accounts</button>
<button type="button" ng-disabled="fetchAccountsBtn" ng-click="fetchAccountsFromRemoteServer()" class="btn btn-primary btn-lg btn-block">{% trans "Fetch Accounts" %}</button>
</div>
</div>

Expand All @@ -50,11 +52,11 @@ <h3 class="title-hero">

<label class="col-sm-1 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-disabled="startTransferbtn" ng-click="startTransfer()" class="btn btn-primary btn-lg btn-block">Start Transfer</button>
<button type="button" ng-disabled="startTransferbtn" ng-click="startTransfer()" class="btn btn-primary btn-lg btn-block">{% trans "Start Transfer" %}</button>
</div>

<div class="col-sm-4">
<button type="button" ng-disabled="stopTransferbtn" ng-click="cancelRemoteBackup()" class="btn btn-primary btn-lg btn-block">Cancel</button>
<button type="button" ng-disabled="stopTransferbtn" ng-click="cancelRemoteBackup()" class="btn btn-primary btn-lg btn-block">{% trans "Cancel" %}</button>
</div>

</div>
Expand All @@ -67,19 +69,19 @@ <h3 class="title-hero">
<p>{$ error_message $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>Could not connect, please refresh this page.</p>
<p>{% trans "Could not connect, please refresh this page." %}</p>
</div>

<div ng-hide="accountsFetched" class="alert alert-success">
<p>Accounts Successfully Fetched from remote server.</p>
<p>{% trans "Accounts Successfully Fetched from remote server." %}</p>
</div>

<div ng-hide="backupProcessStarted" class="alert alert-success">
<p>Backup Process successfully started.</p>
<p>{% trans "Backup Process successfully started." %}</p>
</div>

<div ng-hide="backupCancelled" class="alert alert-success">
<p>Backup successfully cancelled.</p>
<p>{% trans "Backup successfully cancelled." %}</p>
</div>

</div>
Expand Down
46 changes: 34 additions & 12 deletions backup/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .models import DBUsers
from loginSystem.models import Administrator
import json
from websiteFunctions.models import Websites,Backups,dest,backupSchedules
from websiteFunctions.models import Websites,Backups,dest,backupSchedules,ChildDomains
import plogical.CyberCPLogFileWriter as logging
from loginSystem.views import loadLoginPage
import os
Expand Down Expand Up @@ -187,10 +187,19 @@ def submitBackupCreation(request):

metaFile = open(meta, 'w')

metaFile.write(backupDomain + "\n")
metaFile.write(backupDomain + "-" + website.phpSelection + "\n")

childDomains = website.childdomains_set.all()

databases = website.databases_set.all()

metaFile.write("Child Domains\n")

for items in childDomains:
metaFile.write(items.domain + "-" + items.phpSelection + "-" + items.path + "\n")

metaFile.write("Databases\n")

for items in databases:
dbuser = DBUsers.objects.get(user=items.dbUser)
metaFile.write(items.dbName + "-" + items.dbUser + "-" + dbuser.password + "\n")
Expand Down Expand Up @@ -422,10 +431,10 @@ def restoreStatus(request):
data = json.loads(request.body)
backupFile = data['backupFile'].strip(".tar.gz")

path = "/home/backup/" + backupFile
path = "/home/backup/" + data['backupFile']

if os.path.exists(path):
pass
path = "/home/backup/" + backupFile
else:
dir = data['dir']
path = "/home/backup/transfer-" + str(dir) + "/" + backupFile
Expand Down Expand Up @@ -1055,6 +1064,15 @@ def submitRemoteBackups(request):

pathToSSH = "/root/.ssh/authorized_keys"

if not os.path.exists("/root/.ssh"):
os.makedirs("/root/.ssh")
if not os.path.exists(pathToSSH):
f = open(pathToSSH,"w")
f.close()
else:
if not os.path.exists(pathToSSH):
f = open(pathToSSH,"w")
f.close()


presenseCheck = 0
Expand Down Expand Up @@ -1091,7 +1109,7 @@ def submitRemoteBackups(request):
data_ret = json.dumps(data_ret)
return HttpResponse(data_ret)
else:
data_ret = {'status': 0, 'error_message': "Not able to fetch accounts from remote server.", "dir": "Null"}
data_ret = {'status': 0, 'error_message': "Not able to fetch accounts from remote server. Error Message: "+data['error_message'], "dir": "Null"}
data_ret = json.dumps(data_ret)
return HttpResponse(data_ret)

Expand Down Expand Up @@ -1125,16 +1143,20 @@ def starRemoteTransfer(request):

data = json.loads(r.text)

localStoragePath = "/home/backup/transfer-"+str(data['dir'])

if not os.path.exists(localStoragePath):
os.makedirs(localStoragePath)

if data['transferStatus'] == 1:

## create local directory that will host backups

localStoragePath = "/home/backup/transfer-" + str(data['dir'])

if not os.path.exists(localStoragePath):
os.makedirs(localStoragePath)

final_json = json.dumps({'remoteTransferStatus': 1, 'error_message': "None","dir":data['dir']})
return HttpResponse(final_json)
else:
final_json = json.dumps({'remoteTransferStatus': 0, 'error_message': data['error_message']})
final_json = json.dumps({'remoteTransferStatus': 0, 'error_message':"Can not initiate remote transfer. Error message: "+ data['error_message']})
return HttpResponse(final_json)

except BaseException,msg:
Expand All @@ -1154,7 +1176,7 @@ def getRemoteTransferStatus(request):
username = "admin"

finalData = json.dumps({'dir': dir, "username":username,"password":password})
r = requests.post("https://"+ipAddress+":8090/api/FetchRemoteTransferStatus", data=finalData)
r = requests.post("https://"+ipAddress+":8090/api/FetchRemoteTransferStatus", data=finalData,verify=False)

data = json.loads(r.text)

Expand Down Expand Up @@ -1265,7 +1287,7 @@ def cancelRemoteBackup(request):


finalData = json.dumps({'dir': dir, "username":username,"password":password})
r = requests.post("https://"+ipAddress+":8090/api/cancelRemoteTransfer", data=finalData)
r = requests.post("https://"+ipAddress+":8090/api/cancelRemoteTransfer", data=finalData,verify=False)

data = json.loads(r.text)

Expand Down
5 changes: 5 additions & 0 deletions baseTemplate/static/baseTemplate/custom-js/system-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ app.controller('adminController', function($scope,$http,$timeout) {
$("#backupDestinations").hide();
$("#scheduleBackup").hide();

$("#remoteBackups").hide();
$("#packageHome").hide();
$("#packageSub").hide();
$("#createWebsite").hide();

}
}

Expand Down
13 changes: 7 additions & 6 deletions baseTemplate/templates/baseTemplate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
<div class="sidebar-submenu">

<ul>
<li><a href="{% url 'createWebsite' %}" title="{% trans 'Create Website' %}"><span>{% trans "Create Website" %}</span></a></li>
<li id="createWebsite"><a href="{% url 'createWebsite' %}" title="{% trans 'Create Website' %}"><span>{% trans "Create Website" %}</span></a></li>
<li><a href="{% url 'listWebsites' %}" title="{% trans 'List Websites' %}"><span>{% trans "List Websites" %}</span></a></li>
<li><a href="{% url 'modifyWebsite' %}" title="{% trans 'Modify Website' %}"><span>{% trans "Modify Website" %}</span></a></li>
<li id="siteState"><a href="{% url 'siteState' %}" title="{% trans 'Suspend/Unsuspend' %}"><span>{% trans "Suspend/Unsuspend" %}</span></a></li>
Expand All @@ -458,16 +458,16 @@
</div><!-- .sidebar-submenu -->
</li>
<li>
<a href="{% url 'packagesHome' %}" title="{% trans 'Packages' %}">
<a id="packageHome" href="{% url 'packagesHome' %}" title="{% trans 'Packages' %}">
<i class="glyph-icon icon-cubes"></i>
<span>{% trans "Packages" %}</span>
</a>
<div class="sidebar-submenu">
<div id="packageSub" class="sidebar-submenu">

<ul>
<li><a href="{% url 'createPackage' %}" title="{% trans 'Create Package' %}"><span>{% trans "Create Package" %}</span></a></li>
<li><a href="{% url 'deletePackage' %}" title="{% trans 'Delete Package' %}"><span>{% trans "Delete Package" %}</span></a></li>
<li><a href="{% url 'modifyPackage' %}" title="{% trans 'Modify Package' %}"><span>{% trans "Modify Package" %}</span></a></li>
<li id="createPackage"><a href="{% url 'createPackage' %}" title="{% trans 'Create Package' %}"><span>{% trans "Create Package" %}</span></a></li>
<li id="deletePackage"><a href="{% url 'deletePackage' %}" title="{% trans 'Delete Package' %}"><span>{% trans "Delete Package" %}</span></a></li>
<li id="modifyPackage"><a href="{% url 'modifyPackage' %}" title="{% trans 'Modify Package' %}"><span>{% trans "Modify Package" %}</span></a></li>
</ul>

</div><!-- .sidebar-submenu -->
Expand Down Expand Up @@ -562,6 +562,7 @@
<li id="restoreSite"><a href="{% url 'restoreSite' %}" title="{% trans 'Restore Back up' %}"><span>{% trans "Restore Back up" %}</span></a></li>
<li id="backupDestinations"><a href="{% url 'backupDestinations' %}" title="{% trans 'Add Destination' %}"><span>{% trans "Add/Delete Destination" %}</span></a></li>
<li id="scheduleBackup"><a href="{% url 'scheduleBackup' %}" title="{% trans 'Schedule Back up' %}"><span>{% trans "Schedule Back up" %}</span></a></li>
<li id="remoteBackups"><a href="{% url 'remoteBackups' %}" title="{% trans 'Remote Back ups' %}"><span>{% trans "Remote Back ups" %}</span></a></li>
</ul>

</div><!-- .sidebar-submenu -->
Expand Down
3 changes: 2 additions & 1 deletion databases/templates/databases/listDataBases.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ <h3 class="title-hero">
</div>

<div ng-hide="passwordChanged" class="alert alert-success">
{% trans "Password changed for: " %} <strong>{$ dbUsername $}</strong>
</div>

<div ng-hide="canNotChangePassword" class="alert alert-danger">
<p>{% trans "Cannot change password for " %}<strong>{$ dbUsername $}</strong>, Error message: {$ errorMessage $}</p>
<p>{% trans "Cannot change password for " %}<strong>{$ dbUsername $}</strong>, {% trans "Error message:" %} {$ errorMessage $}</p>
</div>


Expand Down
2 changes: 1 addition & 1 deletion firewall/templates/firewall/secureSSH.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="container">
<div id="page-title">
<h2>{% trans "Secure SSH" %}</h2>
<p>{% trans "Edit PHP Configurations on this page." %}</p>
<p>{% trans "Secure or harden SSH Configurations." %}</p>
</div>

<div ng-controller="secureSSHCTRL" class="panel">
Expand Down
Binary file modified locale/br/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 6cc8ba2

Please sign in to comment.