pluginmodel

This commit is contained in:
habi
2022-05-13 14:09:36 +05:00
parent 491993f288
commit 10d4b6bc70
9 changed files with 537 additions and 4 deletions

View File

@@ -394,13 +394,30 @@
<!-------------WordPress---------------------------> <!-------------WordPress--------------------------->
<li> <li>
<a href="{% url 'loadWebsitesHome' %}" title="{% trans 'WordPress' %}"> <a href="{% url 'loadWebsitesHome' %}" title="{% trans 'WordPress' %}">
<div class="glyph-icon icon-globe" title="{% trans 'WordPress' %}"></div> <div class="glyph-icon icon-wordpress" title="{% trans 'WordPress' %}"></div>
<span>{% trans "Wordpress" %}</span> <span>{% trans "Wordpresss" %}</span>
</a> </a>
<div class="sidebar-submenu">
<ul>
{% if admin or createWebsite %}
<li><a href="{% url 'createWordpress' %}"
title="{% trans 'Create Worpress' %}"><span>{% trans "Create Worpress" %}</span></a>
</li>
{% endif %}
<li><a href="#"
title="{% trans 'List Websites' %}"><span>{% trans "List Worpress" %}</span></a>
</li>
<li><a href="{% url 'ConfigurePlugins' %}"
title="{% trans 'ConfigurePlugins' %}"><span>{% trans "Configure Plugins" %}</span></a>
</li>
</ul>
</div><!-- .sidebar-submenu -->
</li> </li>
<li></li> <li>
<a href="{% url 'loadWebsitesHome' %}" title="{% trans 'Websites' %}"> <a href="{% url 'loadWebsitesHome' %}" title="{% trans 'Websites' %}">
<div class="glyph-icon icon-globe" title="{% trans 'Websites' %}"></div> <div class="glyph-icon icon-globe" title="{% trans 'Websites' %}"></div>
<span>{% trans "Websites" %}</span> <span>{% trans "Websites" %}</span>
@@ -413,6 +430,7 @@
title="{% trans 'Create Website' %}"><span>{% trans "Create Website" %}</span></a> title="{% trans 'Create Website' %}"><span>{% trans "Create Website" %}</span></a>
</li> </li>
{% endif %} {% endif %}
<li><a href="{% url 'listWebsites' %}" <li><a href="{% url 'listWebsites' %}"
title="{% trans 'List Websites' %}"><span>{% trans "List Websites" %}</span></a> title="{% trans 'List Websites' %}"><span>{% trans "List Websites" %}</span></a>
</li> </li>

View File

@@ -99,3 +99,9 @@ class NormalBackupJobLogs(models.Model):
owner = models.ForeignKey(NormalBackupJobs, on_delete=models.CASCADE) owner = models.ForeignKey(NormalBackupJobs, on_delete=models.CASCADE)
status = models.IntegerField() status = models.IntegerField()
message = models.TextField() message = models.TextField()
class wpplugins(models.Model):
owner = models.ForeignKey(Websites, on_delete=models.CASCADE)
Name = models.CharField(max_length=255, default='')
config = models.TextField()

View File

@@ -19,6 +19,80 @@ function getCookie(name) {
} }
return cookieValue; return cookieValue;
} }
var arry = []
function selectpluginJs(val) {
$('#mysearch').hide()
arry.push(val)
// console.log(arry)
document.getElementById('selJS').innerHTML = "";
for (var i = 0; i < arry.length; i++) {
$('#selJS').show()
var mlm = '<span style="background-color: #12207a; color: #FFFFFF; padding: 5px; border-radius: 30px"> ' + arry[i] + ' </span>&nbsp &nbsp'
$('#selJS').append(mlm)
}
}
app.controller('WPAddNewPlugin', function ($scope, $http, $timeout, $window) {
$scope.SearchPluginName = function () {
url = "/websites/SearchOnkeyupPlugin";
var searchcontent = $scope.searchcontent;
var data = {
pluginname : searchcontent
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.status === 1) {
// console.log(response.data);
$('#mysearch').show()
document.getElementById('mysearch').innerHTML = "";
var res = response.data.plugns.plugins
// console.log(res);
for (i = 0; i <= res.length; i++) {
//
var tml = '<option onclick="selectpluginJs(\'' + res[i].slug + '\')" style=" border-bottom: 1px solid rgba(90, 91, 92, 0.5); padding: 5px; " value="' + res[i].slug + '">' + res[i].name + '</option> <br>';
$('#mysearch').append(tml);
}
} else {
// $scope.errorMessage = response.data.error_message;
alert("Status not = 1: Error..."+response.data.error_message)
}
}
function cantLoadInitialDatas(response) {
alert("Error..."+response)
}
}
});
/* Java script code to create account */ /* Java script code to create account */

View File

@@ -0,0 +1,71 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "plugin - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2 id="domainNamePage">{% trans "Add New Plugin" %}
</h2>
</div>
<div ng-controller="WPAddNewPlugin" class="panel">
<div class="panel-body">
<div class="example-box-wrapper">
<form name="websiteCreationForm" action="/" id="createPackages"
class="form-horizontal bordered-row panel-body">
<label>{% trans "Plugin Bucket Name" %}</label>
<input name="PluginbucketName" type="text" class="form-control"
ng-model="PluginbucketName"
required>
<label>{% trans "Search Plugin Name" %}</label>
<input name="searchcontent" type="text" class="form-control" ng-model="searchcontent"
ng-keyup="SearchPluginName()"
placeholder="{% trans "Search Plugin...." %}" required>
<div id="mysearch" class="col-lg-12" style="display: none; border-top: none!important;
border: 1px solid rgba(90, 91, 92, 0.7);
position: absolute; z-index: 1;
background-color: #FFFFFF">
</div>
<h3>Selected Plugin</h3>
<div id="selJS" style="display: none; display: flex; flex-direction: row;">
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button ng-disabled="websiteCreationForm.dom.$error.required || websiteCreationForm.email.$invalid"
type="button"
class="btn btn-primary btn-lg">{% trans "Add Plugin Bucket" %}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,21 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "plugin - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2 id="domainNamePage"><h2>{% trans "Configure Plugins" %}</h2>
<a class="pull-right btn btn-primary" href="{% url "Addnewplugin" %}">{% trans "Add New Plugin" %}</a>
</h2>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,206 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Create New WordPress - 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 "Create Wordpress Site" %}</h2>
<p>{% trans "On this page you can launch, list, modify and delete websites from your server." %}</p>
</div>
<div ng-controller="createWebsite" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Website Details" %} <img ng-hide="webSiteCreationLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form name="websiteCreationForm" action="/" id="createPackages"
class="form-horizontal bordered-row panel-body">
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Package" %}</label>
<div class="col-sm-6">
<select ng-model="packageForWebsite" class="form-control">
{% for items in packageList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Owner" %}</label>
<div class="col-sm-6">
<select ng-model="websiteOwner" class="form-control">
{% for items in owernList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Title" %}</label>
<div class="col-sm-6">
<input type="text" name="WPtitle" class="form-control" ng-model="WPtitle" required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Domain Name" %}</label>
<div class="col-sm-6">
<input name="dom" type="text" class="form-control" ng-model="domainNameCreate"
placeholder="{% trans "Do not enter WWW, it will be auto created!" %}" required>
</div>
<div ng-show="websiteCreationForm.dom.$error.pattern"
class="current-pack">{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Username" %}</label>
<div class="col-sm-6">
<input name="Username" type="text" class="form-control" ng-model="WPUsername"
required>
</div>
<div ng-show="websiteCreationForm.dom.$error.pattern"
class="current-pack">{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Email" %}</label>
<div class="col-sm-6">
<input type="email" name="email" class="form-control" ng-model="adminEmail" required>
</div>
<div ng-show="websiteCreationForm.email.$error.email"
class="current-pack">{% trans "Invalid Email" %}</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input name="password" type="password" class="form-control" ng-model="WPPassword"
required>
</div>
<div ng-show="websiteCreationForm.dom.$error.pattern"
class="current-pack">{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select WP Version" %}</label>
<div class="col-sm-6">
<select ng-model="phpSelection" class="form-control">
{% for php in WPVersions %}
<option>{{ php }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input ng-model="sslCheck" type="checkbox" value="">
SSL
</label>
</div>
</div>
<label class="col-sm-3 control-label"></label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input ng-model="dkimCheck" type="checkbox" value="">
DKIM Support
</label>
</div>
</div>
<label class="col-sm-3 control-label"></label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input ng-model="openBasedir" type="checkbox" value="">
open_basedir Protection
</label>
</div>
</div>
<label class="col-sm-3 control-label"></label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input ng-model="mailDomain" type="checkbox" value="">
Create Mail Domain
</label>
</div>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button ng-disabled="websiteCreationForm.dom.$error.required || websiteCreationForm.email.$invalid"
type="button" ng-click="createWebsite()"
class="btn btn-primary btn-lg">{% trans "Create Website" %}</button>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-7">
<div class="alert alert-success text-center">
<h2>{$ currentStatus $}</h2>
</div>
<div class="progress">
<div id="installProgress" class="progress-bar" role="progressbar" aria-valuenow="70"
aria-valuemin="0" aria-valuemax="100" style="width:0%">
<span class="sr-only">70% Complete</span>
</div>
</div>
<div ng-hide="errorMessageBox" class="alert alert-danger">
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="success" class="alert alert-success">
<p>{% trans "Website succesfully created." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()"
class="btn btn-primary btn-lg">{% trans "Go Back" %}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -16,6 +16,17 @@ urlpatterns = [
url(r'^CreateNewDomain$', views.CreateNewDomain, name='CreateNewDomain'), url(r'^CreateNewDomain$', views.CreateNewDomain, name='CreateNewDomain'),
### WordPress
url(r'^createWordpress$', views.WPCreate, name='createWordpress'),
#### AddPlugin
url(r'^ConfigurePlugins$', views.ConfigurePlugins, name='ConfigurePlugins'),
url(r'^Addnewplugin$', views.Addnewplugin, name='Addnewplugin'),
## AddPlugin Ajax
url(r'^SearchOnkeyupPlugin$', views.SearchOnkeyupPlugin, name='SearchOnkeyupPlugin'),
# Website modification url # Website modification url

View File

@@ -6,6 +6,8 @@ from django.http import HttpResponse
from loginSystem.models import Administrator from loginSystem.models import Administrator
from loginSystem.views import loadLoginPage from loginSystem.views import loadLoginPage
import json import json
import plogical.CyberCPLogFileWriter as logging
from plogical.httpProc import httpProc from plogical.httpProc import httpProc
from websiteFunctions.website import WebsiteManager from websiteFunctions.website import WebsiteManager
@@ -26,6 +28,50 @@ def createWebsite(request):
return wm.createWebsite(request, userID) return wm.createWebsite(request, userID)
except KeyError: except KeyError:
return redirect(loadLoginPage) return redirect(loadLoginPage)
def WPCreate(request):
try:
userID = request.session['userID']
wm = WebsiteManager()
return wm.WPCreate(request, userID)
except KeyError:
return redirect(loadLoginPage)
def ConfigurePlugins(request):
try:
userID = request.session['userID']
wm = WebsiteManager()
return wm.ConfigurePlugins(request, userID)
except KeyError:
return redirect(loadLoginPage)
def Addnewplugin(request):
try:
userID = request.session['userID']
wm = WebsiteManager()
return wm.Addnewplugin(request, userID)
except KeyError:
return redirect(loadLoginPage)
def SearchOnkeyupPlugin(request):
try:
userID = request.session['userID']
result = pluginManager.preWebsiteCreation(request)
if result != 200:
return result
wm = WebsiteManager()
coreResult = wm.SearchOnkeyupPlugin(userID, json.loads(request.body))
result = pluginManager.postWebsiteCreation(request, coreResult)
if result != 200:
return result
return coreResult
except KeyError:
return redirect(loadLoginPage)
def modifyWebsite(request): def modifyWebsite(request):
try: try:

View File

@@ -58,6 +58,86 @@ class WebsiteManager:
proc = httpProc(request, 'websiteFunctions/createWebsite.html', proc = httpProc(request, 'websiteFunctions/createWebsite.html',
Data, 'createWebsite') Data, 'createWebsite')
return proc.render() return proc.render()
def WPCreate(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
adminNames = ACLManager.loadAllUsers(userID)
packagesName = ACLManager.loadPackages(userID, currentACL)
phps = PHPManager.findPHPVersions()
FinalVersions = []
#logging.CyberCPLogFileWriter.writeToFile("jassssssssss...............")
counter = 0
try:
import requests
WPVersions = json.loads(requests.get('https://api.wordpress.org/core/version-check/1.7/').text)['offers']
for versions in WPVersions:
if counter == 7:
break
if versions['current'] not in FinalVersions:
FinalVersions.append(versions['current'])
counter = counter + 1
except:
FinalVersions = ['5.6', '5.5.3', '5.5.2']
# logging.CyberCPLogFileWriter.writeToFile("FinalVersions:%s"+str(FinalVersions))
Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps, 'WPVersions': FinalVersions}
proc = httpProc(request, 'websiteFunctions/WPCreate.html',
Data, 'createWebsite')
return proc.render()
def ConfigurePlugins(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
adminNames = ACLManager.loadAllUsers(userID)
packagesName = ACLManager.loadPackages(userID, currentACL)
phps = PHPManager.findPHPVersions()
Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
proc = httpProc(request, 'websiteFunctions/WPConfigurePlugins.html',
Data, 'createWebsite')
return proc.render()
def Addnewplugin(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
adminNames = ACLManager.loadAllUsers(userID)
packagesName = ACLManager.loadPackages(userID, currentACL)
phps = PHPManager.findPHPVersions()
Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
proc = httpProc(request, 'websiteFunctions/WPAddNewPlugin.html',
Data, 'createWebsite')
return proc.render()
def SearchOnkeyupPlugin(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
pluginname = data['pluginname']
# logging.CyberCPLogFileWriter.writeToFile("Plugin Name ....... %s"%pluginname)
url = "http://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[search]=%s" % str(pluginname)
import requests
res = requests.get(url)
r = res.json()
# return proc.ajax(1, 'Done', {'plugins': r})
data_ret = {'status': 1,'plugns': r,}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def modifyWebsite(self, request=None, userID=None, data=None): def modifyWebsite(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)