Skip to content

Commit

Permalink
Merge branch 'v3.0.0' of github.com:usmannasir/cyberpanel into v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Feb 11, 2024
2 parents 670e46c + 3bb1488 commit d36c7f9
Show file tree
Hide file tree
Showing 7 changed files with 357 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CyberCP/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ['*']

Expand Down
8 changes: 8 additions & 0 deletions databases/databaseManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ def OptimizeMySQL(self, request = None, userID = None):
proc = httpProc(request, template, data, 'admin')
return proc.render()

def Upgardemysql(self, request = None, userID = None):
data={}
data['mysqlversions']=['10.6','10.11']
template = 'databases/Updatemysql.html'
proc = httpProc(request, template, data, 'admin')
return proc.render()


def fetchDatabases(self, userID = None, data = None):
try:

Expand Down
161 changes: 160 additions & 1 deletion databases/static/databases/databases.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,4 +836,163 @@ app.controller('OptimizeMysql', function ($scope, $http) {
});
}
}
})
})


app.controller('mysqlupdate', function ($scope, $http, $timeout) {
$scope.cyberPanelLoading = true;
$scope.dbLoading = true;
$scope.modeSecInstallBox = true;
$scope.modsecLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.modSecSuccessfullyInstalled = true;
$scope.installationFailed = true;

$scope.Upgardemysql = function () {
$scope.dbLoading = false;
$scope.installform = true;
$scope.modSecNotifyBox = true;
$scope.modeSecInstallBox = false;
$scope.modsecLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.modSecSuccessfullyInstalled = true;
$scope.installationFailed = true;


url = "/dataBases/upgrademysqlnow";

var data = {
mysqlversion: $scope.version
};

var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};

$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);


function ListInitialData(response) {
$scope.cyberhosting = true;
if (response.data.status === 1) {
$scope.modSecNotifyBox = true;
$scope.modeSecInstallBox = false;
$scope.modsecLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.modSecSuccessfullyInstalled = true;
$scope.installationFailed = true;

$scope.statusfile = response.data.tempStatusPath

$timeout(getRequestStatus, 1000);

} else {
$scope.errorMessage = response.data.error_message;

$scope.modSecNotifyBox = false;
$scope.modeSecInstallBox = true;
$scope.modsecLoading = true;
$scope.failedToStartInallation = false;
$scope.couldNotConnect = true;
$scope.modSecSuccessfullyInstalled = true;
}

}

function cantLoadInitialData(response) {
$scope.cyberhosting = true;
new PNotify({
title: 'Error!',
text: 'Could not connect to server, please refresh this page.',
type: 'error'
});
}
}


function getRequestStatus() {

$scope.modSecNotifyBox = true;
$scope.modeSecInstallBox = false;
$scope.modsecLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.modSecSuccessfullyInstalled = true;
$scope.installationFailed = true;

url = "/dataBases/upgrademysqlstatus";

var data = {
statusfile: $scope.statusfile
};

var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};


$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);


function ListInitialDatas(response) {


if (response.data.abort === 0) {

$scope.modSecNotifyBox = true;
$scope.modeSecInstallBox = false;
$scope.modsecLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.modSecSuccessfullyInstalled = true;
$scope.installationFailed = true;

$scope.requestData = response.data.requestStatus;
$timeout(getRequestStatus, 1000);
} else {
// Notifications
$timeout.cancel();
$scope.modSecNotifyBox = false;
$scope.modeSecInstallBox = false;
$scope.modsecLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;

$scope.requestData = response.data.requestStatus;

if (response.data.installed === 0) {
$scope.installationFailed = false;
$scope.errorMessage = response.data.error_message;
} else {
$scope.modSecSuccessfullyInstalled = false;
$timeout(function () {
$window.location.reload();
}, 3000);
}

}

}

function cantLoadInitialDatas(response) {

$scope.modSecNotifyBox = false;
$scope.modeSecInstallBox = false;
$scope.modsecLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = false;
$scope.modSecSuccessfullyInstalled = true;
$scope.installationFailed = true;


}

}
});
99 changes: 99 additions & 0 deletions databases/templates/databases/Updatemysql.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "List Databases - CyberPanel" %}{% endblock %}
{% block content %}

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


<div class="container">
<div id="page-title">
<h2>{% trans "Upgrade Mysql" %}

</h2>
<p>{% trans "On this page you can update mysql." %}</p>
</div>
<div ng-controller="mysqlupdate" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Update Mysql" %} <img ng-hide="dbLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">

<form name="websiteCreationForm" action="/"
class="form-horizontal bordered-row panel-body">

<div ng-hide="installform" class="form-group">
<label class="col-sm-3 control-label">{% trans "Mysql version" %} </label>
<div class="col-sm-6">
<select ng-model="version" class="form-control" required>
{% for version in mysqlversions %}
<option>{{ version }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="installform" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="Upgardemysql()"
class="btn btn-primary btn-lg">{% trans "Update Mysql" %}</button>

</div>
</div>


<div ng-hide="modSecNotifyBox" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-6">

<div ng-hide="failedToStartInallation" class="alert alert-danger">
<p>{% trans "Failed to start installation, Error message: " %} {$ errorMessage
$}</p>
</div>

<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>

<div ng-hide="installationFailed" class="alert alert-danger">
<p>{% trans "Installation failed." %} {$ errorMessage $}</p>
</div>

<div ng-hide="modSecSuccessfullyInstalled" class="alert alert-success">
<p>{% trans "CSF successfully installed, refreshing page in 3 seconds.." %}</p>
</div>
</div>
</div>


<div ng-hide="modeSecInstallBox" class="col-md-12">

<form action="/" id="" class="form-horizontal bordered-row">
<div class="form-group">
<div class="col-sm-12 text-center">
<h3><img
src="{% static 'firewall/icons/firewall.png' %}"> {% trans "In winter we must protect each other.." %}
<img ng-hide="modsecLoading" src="/static/images/loading.gif"></h3>
</div>
<div style="margin-top: 2%;" class="col-sm-12">
<textarea ng-model="requestData" rows="15"
class="form-control">{{ requestData }}</textarea>
</div>
</div>
</form>
</div>
</form>
</div>
</div>
</div>
</div>


</div>


{% endblock %}
3 changes: 3 additions & 0 deletions databases/templates/databases/mysqlmanager.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ <h3 style="display: inline-block;" class="content-box-header">MySQL status</h3>
<a style="display: inline-block;" href="{% url 'OptimizeMySQL' %}" class="btn btn-primary">
<i class="glyph-icon icon-database"></i> Optimize MySQL
</a>
<a style="display: inline-block;" href="{% url 'UpgradeMySQL' %}" class="btn btn-primary">
<i class="glyph-icon icon-database"></i> Upgrade MySQL
</a>
</div>

<div class="content-box-header">
Expand Down
3 changes: 3 additions & 0 deletions databases/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
url(r'^fetchDatabases', views.fetchDatabases, name='fetchDatabases'),
url(r'^MysqlManager', views.MySQLManager, name='MysqlManager'),
url(r'^OptimizeMySQL', views.OptimizeMySQL, name='OptimizeMySQL'),
url(r'^upgrademysqlnow', views.upgrademysqlnow, name='upgrademysqlnow'),
url(r'^UpgradeMySQL', views.UpgradeMySQL, name='UpgradeMySQL'),
url(r'^upgrademysqlstatus', views.upgrademysqlstatus, name='upgrademysqlstatus'),
url(r'^getMysqlstatus', views.getMysqlstatus, name='getMysqlstatus'),
url(r'^restartMySQL', views.restartMySQL, name='restartMySQL'),
url(r'^generateRecommendations', views.generateRecommendations, name='generateRecommendations'),
Expand Down
Loading

0 comments on commit d36c7f9

Please sign in to comment.