mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-13 08:46:09 +01:00
db manager
This commit is contained in:
@@ -61,8 +61,6 @@
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1237,6 +1237,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
||||
};
|
||||
|
||||
$scope.fetchstaging = function () {
|
||||
|
||||
$('#wordpresshomeloading').show();
|
||||
$scope.wordpresshomeloading = false;
|
||||
|
||||
@@ -1285,6 +1286,49 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
||||
|
||||
};
|
||||
|
||||
$scope.fetchDatabase = function () {
|
||||
|
||||
$('#wordpresshomeloading').show();
|
||||
$scope.wordpresshomeloading = false;
|
||||
|
||||
var url = "/websites/fetchDatabase";
|
||||
|
||||
var data = {
|
||||
WPid: $('#WPid').html(),
|
||||
}
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
wordpresshomeloading = true;
|
||||
$('#wordpresshomeloading').hide();
|
||||
|
||||
if (response.data.status === 1) {
|
||||
$('#DB_Name').html(response.data.DataBaseName);
|
||||
$('#DB_User').html(response.data.DataBaseUser);
|
||||
$('#tableprefix').html(response.data.tableprefix);
|
||||
} else {
|
||||
alert("Error data.error_message:" + response.data.error_message)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$('#wordpresshomeloading').hide();
|
||||
alert("Error" + response)
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.SaveUpdateConfig = function () {
|
||||
$('#wordpresshomeloading').show();
|
||||
var data = {
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
<p style="display: inline;">
|
||||
</p>
|
||||
|
||||
|
||||
<div>
|
||||
<div class="example-box-wrapper">
|
||||
<ul class="nav-responsive nav nav-tabs">
|
||||
@@ -41,10 +40,9 @@
|
||||
data-toggle="tab">Plugins</a></li>
|
||||
<li class=""><a href="#tab3" ng-click="GetCurrentThemes()"
|
||||
data-toggle="tab">Themes</a></li>
|
||||
<li><a href="#tab4" data-toggle="tab"
|
||||
ng-click="fetchstaging()">Staging</a></li>
|
||||
<li><a href="#tab5" data-toggle="tab"
|
||||
>Backups</a></li>
|
||||
<li><a href="#tab4" data-toggle="tab" ng-click="fetchstaging()">Staging</a></li>
|
||||
<li><a href="#tab5" data-toggle="tab">Backups</a></li>
|
||||
<li><a ng-click="fetchDatabase()" href="#tab6" data-toggle="tab">Database</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab1">
|
||||
@@ -65,7 +63,7 @@
|
||||
Open
|
||||
</a>
|
||||
<a target="_blank"
|
||||
href="/filemanager/{{ wpsite.owner.domain }}?path={{wpsite.path}}"
|
||||
href="/filemanager/{{ wpsite.owner.domain }}?path={{ wpsite.path }}"
|
||||
style="margin-left: 4%">
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
@@ -495,6 +493,41 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab6">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Database for" %} {{ wpsite.title }}
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
<form action="/" class="form-horizontal bordered-row panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label mb-5"
|
||||
style="padding-top: 0px;">{% trans "Database Name" %}</label>
|
||||
<div class="col-sm-1 mb-10">
|
||||
<a target="_blank" href="{% url 'phpMyAdmin' %}"> <div id="DB_Name" class="mb-10 text-bold"></div></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label mb-5"
|
||||
style="padding-top: 0px;">{% trans "Database User" %}</label>
|
||||
<div class="col-sm-1 mb-10">
|
||||
<div id="DB_User" class="mb-10 text-bold"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label mb-5"
|
||||
style="padding-top: 0px;">{% trans "Table Prefix" %}</label>
|
||||
<div class="col-sm-1 mb-10">
|
||||
<div id="tableprefix" class="mb-10 text-bold"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
@@ -99,16 +99,10 @@
|
||||
<table class="table-spacing" style="width: 100%">
|
||||
<thead style="color: white; background-color: #0a6ebd">
|
||||
<tr>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">WordPress Site Title
|
||||
</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">WP-Login
|
||||
</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Domain
|
||||
</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action
|
||||
</th>
|
||||
|
||||
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">WordPress Site Title</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Login</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Domain</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -116,28 +110,26 @@
|
||||
{% for sub in wpsite %}
|
||||
|
||||
<tr>
|
||||
<td style="padding: 13px;" >
|
||||
<td style="padding: 13px;">
|
||||
<a href="{% url 'WPHome' %}?ID={{ sub.id }}">
|
||||
<p style="font-weight: bold; text-transform: uppercase; ">{{ sub.title }}</p>
|
||||
|
||||
</a>
|
||||
|
||||
</td>
|
||||
<td style="padding: 13px;">
|
||||
<a target="_blank"
|
||||
href="{% url 'AutoLogin' %}?id={{ sub.id }}"> WP-admin
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
aria-hidden="true" focusable="false" width="1em"
|
||||
height="1em"
|
||||
style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);"
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
viewBox="0 0 20 20">
|
||||
<path d="M14 10L8 5v3H1v4h7v3l6-5zm3 7H9v2h8c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2H9v2h8v14z"
|
||||
fill="#626262"></path>
|
||||
<a title="Auto Login" style="margin-right: 2%; margin-left: 10px;"
|
||||
target="_blank"
|
||||
href="{% url 'AutoLogin' %}?id={{ sub.id }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="1.5em"
|
||||
style="margin: 3px;" height="1.5em" preserveAspectRatio="xMidYMid meet"
|
||||
viewBox="0 0 16 16">
|
||||
<g fill="#006600">
|
||||
<path d="M12.633 7.653c0-.848-.305-1.435-.566-1.892l-.08-.13c-.317-.51-.594-.958-.594-1.48c0-.63.478-1.218 1.152-1.218c.02 0 .039.002.058.003l.031.003A6.838 6.838 0 0 0 8 1.137A6.855 6.855 0 0 0 2.266 4.23c.16.005.313.009.442.009c.717 0 1.828-.087 1.828-.087c.37-.022.414.521.044.565c0 0-.371.044-.785.065l2.5 7.434l1.5-4.506l-1.07-2.929c-.369-.022-.719-.065-.719-.065c-.37-.022-.326-.588.043-.566c0 0 1.134.087 1.808.087c.718 0 1.83-.087 1.83-.087c.37-.022.413.522.043.566c0 0-.372.043-.785.065l2.48 7.377l.684-2.287l.054-.173c.27-.86.469-1.495.469-2.046zM1.137 8a6.864 6.864 0 0 0 3.868 6.176L1.73 5.206A6.837 6.837 0 0 0 1.137 8z"></path>
|
||||
<path d="M6.061 14.583L8.121 8.6l2.109 5.78c.014.033.03.064.049.094a6.854 6.854 0 0 1-4.218.109zm7.96-9.876c.03.219.047.453.047.706c0 .696-.13 1.479-.522 2.458l-2.096 6.06a6.86 6.86 0 0 0 2.572-9.224z"></path>
|
||||
<path fill-rule="evenodd"
|
||||
d="M0 8c0-4.411 3.589-8 8-8c4.41 0 8 3.589 8 8s-3.59 8-8 8c-4.411 0-8-3.589-8-8zm.367 0c0 4.209 3.424 7.633 7.633 7.633c4.208 0 7.632-3.424 7.632-7.633C15.632 3.79 12.208.367 8 .367C3.79.367.367 3.79.367 8z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
||||
</a>
|
||||
</td>
|
||||
<td style="padding: 13px;">
|
||||
|
||||
@@ -39,6 +39,7 @@ urlpatterns = [
|
||||
url(r'^StatusThemes', views.StatusThemes, name='StatusThemes'),
|
||||
url(r'^CreateStagingNow', views.CreateStagingNow, name='CreateStagingNow'),
|
||||
url(r'^fetchstaging', views.fetchstaging, name='fetchstaging'),
|
||||
url(r'^fetchDatabase', views.fetchDatabase, name='fetchDatabase'),
|
||||
url(r'^SaveUpdateConfig', views.SaveUpdateConfig, name='SaveUpdateConfig'),
|
||||
url(r'^DeploytoProduction', views.DeploytoProduction, name='DeploytoProduction'),
|
||||
url(r'^WPCreateBackup', views.WPCreateBackup, name='WPCreateBackup'),
|
||||
|
||||
@@ -299,6 +299,27 @@ def fetchstaging(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchDatabase(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.fetchDatabase(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def SaveUpdateConfig(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
@@ -745,6 +745,62 @@ class WebsiteManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def fetchDatabase(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
WPManagerID = data['WPid']
|
||||
wpsite = WPSites.objects.get(pk=WPManagerID)
|
||||
|
||||
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
php = PHPManager.getPHPString(wpsite.owner.phpSelection)
|
||||
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||
|
||||
command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path={wpsite.path}'
|
||||
retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, None, None, 1)
|
||||
|
||||
if stdoutput.find('Error:') == -1:
|
||||
DataBaseName = stdoutput.rstrip("\n")
|
||||
else:
|
||||
data_ret = {'status': 0, 'error_message': stdoutput}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get DB_USER --skip-plugins --skip-themes --path={wpsite.path}'
|
||||
retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, None, None, 1)
|
||||
|
||||
if stdoutput.find('Error:') == -1:
|
||||
DataBaseUser = stdoutput.rstrip("\n")
|
||||
else:
|
||||
data_ret = {'status': 0, 'error_message': stdoutput}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get table_prefix --skip-plugins --skip-themes --path={wpsite.path}'
|
||||
retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, None, None, 1)
|
||||
|
||||
if stdoutput.find('Error:') == -1:
|
||||
tableprefix = stdoutput.rstrip("\n")
|
||||
else:
|
||||
data_ret = {'status': 0, 'error_message': stdoutput}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None', "DataBaseUser": DataBaseUser, "DataBaseName": DataBaseName, 'tableprefix': tableprefix}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def SaveUpdateConfig(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user