mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-07 23:05:55 +02:00
Prestashop Installer
This commit is contained in:
BIN
websiteFunctions/static/images/icons/prestashop.png
Normal file
BIN
websiteFunctions/static/images/icons/prestashop.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -566,6 +566,7 @@ app.controller('websitePages', function($scope, $http, $timeout, $window) {
|
||||
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
|
||||
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
|
||||
$scope.setupGit = $("#domainNamePage").text() + "/setupGit";
|
||||
$scope.installPrestaURL = $("#domainNamePage").text() + "/installPrestaShop";
|
||||
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
|
||||
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
|
||||
|
||||
@@ -1443,6 +1444,7 @@ app.controller('websitePages', function($scope, $http, $timeout, $window) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
//////// SSL Part
|
||||
|
||||
$scope.sslSaved = true;
|
||||
@@ -4720,4 +4722,197 @@ app.controller('setupGit', function($scope, $http, $timeout, $window) {
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
app.controller('installPrestaShopCTRL', function($scope, $http, $timeout) {
|
||||
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.wpInstallLoading = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
$scope.databasePrefix = 'ps_';
|
||||
|
||||
var statusFile;
|
||||
var domain = $("#domainNamePage").text();
|
||||
var path;
|
||||
|
||||
|
||||
|
||||
$scope.goBack = function () {
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.wpInstallLoading = true;
|
||||
$scope.goBackDisable = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
function getInstallStatus(){
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile,
|
||||
domainName: domain
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.abort === 1){
|
||||
|
||||
if(response.data.installStatus === 1){
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.wpInstallLoading = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
if (typeof path !== 'undefined'){
|
||||
$scope.installationURL = "http://"+domain+"/"+path;
|
||||
}
|
||||
else{
|
||||
$scope.installationURL = domain;
|
||||
}
|
||||
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = false;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.wpInstallLoading = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
|
||||
$timeout(getInstallStatus,1000);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.canNotFetch = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$scope.installPrestShop = function(){
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.wpInstallLoading = false;
|
||||
$scope.goBackDisable = true;
|
||||
$scope.currentStatus = "Starting installation..";
|
||||
|
||||
path = $scope.installPath;
|
||||
|
||||
|
||||
url = "/websites/prestaShopInstall";
|
||||
|
||||
var home = "1";
|
||||
|
||||
if (typeof path !== 'undefined'){
|
||||
home = "0";
|
||||
}
|
||||
|
||||
|
||||
var data = {
|
||||
domain: domain,
|
||||
home:home,
|
||||
path:path,
|
||||
shopName: $scope.shopName,
|
||||
firstName: $scope.firstName,
|
||||
lastName: $scope.lastName,
|
||||
databasePrefix: $scope.databasePrefix,
|
||||
email: $scope.email,
|
||||
password: $scope.password
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.installStatus === 1)
|
||||
{
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getInstallStatus();
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = false;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.wpInstallLoading = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
@@ -0,0 +1,141 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Install PrestaShop - 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 "Install PrestaShop" %}</h2>
|
||||
<p>{% trans "One-click PrestaShop Install!" %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="installPrestaShopCTRL" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<span id="domainNamePage">{{ domainName }}</span> - {% trans "Installation Details" %} <img ng-hide="wpInstallLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
||||
<form name="websiteCreationForm" action="/" id="createPackages" class="form-horizontal bordered-row">
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Shop Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="shopName" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "First Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="firstName" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Last Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="lastName" required>
|
||||
</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" class="form-control" ng-model="email" required>
|
||||
</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 type="password" class="form-control" ng-model="password" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Database Prefix" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="databasePrefix" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Path" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="Leave emtpy to install in website home directory. (Without preceding slash)" type="text" class="form-control" ng-model="installPath">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="installPrestShop()" class="btn btn-primary btn-lg btn-block">{% trans "Install Now" %}</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="installationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Installation failed. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationSuccessfull" class="alert alert-success">
|
||||
<p>{% trans "Installation successful. Visit:" %} {$ installationURL $}</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 btn-block">{% trans "Go Back" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -966,10 +966,10 @@
|
||||
|
||||
<div class="col-md-4" style="margin-bottom: 2%;">
|
||||
|
||||
<a href="{$ joomlaInstallURL $}" target="_blank" title="{% trans 'Install Joomla with(?) LSCache' %}">
|
||||
<a href="{$ joomlaInstallURL $}" target="_blank" title="{% trans 'Install Joomla with LSCache' %}">
|
||||
<img src="{% static 'images/icons/joomla-logo.png' %}">
|
||||
</a>
|
||||
<a href="{$ joomlaInstallURL $}" target="_blank" title="{% trans 'Install Joomla with(?) LSCache' %}">
|
||||
<a href="{$ joomlaInstallURL $}" target="_blank" title="{% trans 'Install Joomla with LSCache' %}">
|
||||
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Joomla" %}</span>
|
||||
</a>
|
||||
|
||||
@@ -988,6 +988,19 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-md-4" style="margin-bottom: 2%;">
|
||||
|
||||
<a href="{$ installPrestaURL $}" target="_blank" title="{% trans 'Install Prestashop' %}">
|
||||
<img src="{% static 'images/icons/prestashop.png' %}">
|
||||
</a>
|
||||
<a href="{$ installPrestaURL $}" target="_blank" title="{% trans 'Install Prestashop' %}">
|
||||
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Prestashop" %}</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -88,6 +88,11 @@ urlpatterns = [
|
||||
url(r'^installJoomla$', views.installJoomla, name='installJoomla'),
|
||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/joomlaInstall$', views.joomlaInstall, name='joomlaInstall'),
|
||||
|
||||
## PrestaShop Install
|
||||
|
||||
url(r'^prestaShopInstall$', views.prestaShopInstall, name='prestaShopInstall'),
|
||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/installPrestaShop$', views.installPrestaShop, name='installPrestaShop'),
|
||||
|
||||
|
||||
## Git
|
||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/setupGit$', views.setupGit, name='setupGit'),
|
||||
|
||||
@@ -2345,7 +2345,6 @@ def joomlaInstall(request, domain):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def installJoomla(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -2672,4 +2671,70 @@ def changeBranch(request):
|
||||
except KeyError, msg:
|
||||
status = {"status":0,"error":str(msg)}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
def installPrestaShop(request, domain):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
try:
|
||||
if admin.type != 1:
|
||||
website = Websites.objects.get(domain=domain)
|
||||
if website.admin != admin:
|
||||
raise BaseException('You do not own this website.')
|
||||
|
||||
|
||||
return render(request, 'websiteFunctions/installPrestaShop.html', {'domainName' : domain})
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def prestaShopInstall(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(id=val)
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['admin'] = admin
|
||||
extraArgs['domainName'] = data['domain']
|
||||
extraArgs['home'] = data['home']
|
||||
extraArgs['shopName'] = data['shopName']
|
||||
extraArgs['firstName'] = data['firstName']
|
||||
extraArgs['lastName'] = data['lastName']
|
||||
extraArgs['databasePrefix'] = data['databasePrefix']
|
||||
extraArgs['email'] = data['email']
|
||||
extraArgs['password'] = data['password']
|
||||
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
if data['home'] == '0':
|
||||
extraArgs['path'] = data['path']
|
||||
|
||||
background = ApplicationInstaller('prestashop', extraArgs)
|
||||
background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'installStatus': 1, 'error_message': 'None', 'tempStatusPath': extraArgs['tempStatusPath']}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
## Installation ends
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except KeyError, msg:
|
||||
status = {"installStatus":0,"error":str(msg)}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installJoomla]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
Reference in New Issue
Block a user