mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
Merge branch 'v2.3.2-dev' of https://github.com/usmannasir/cyberpanel into v2.3.2-dev
This commit is contained in:
@@ -392,15 +392,15 @@ EOF
|
|||||||
|
|
||||||
#all pre-upgrade operation for CentOS 7
|
#all pre-upgrade operation for CentOS 7
|
||||||
elif [[ "$Server_OS_Version" = "8" ]] ; then
|
elif [[ "$Server_OS_Version" = "8" ]] ; then
|
||||||
cat <<EOF >/etc/yum.repos.d/CentOS-PowerTools-CyberPanel.repo
|
# cat <<EOF >/etc/yum.repos.d/CentOS-PowerTools-CyberPanel.repo
|
||||||
[powertools-for-cyberpanel]
|
#[powertools-for-cyberpanel]
|
||||||
name=CentOS Linux \$releasever - PowerTools
|
#name=CentOS Linux \$releasever - PowerTools
|
||||||
mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=PowerTools&infra=\$infra
|
#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=PowerTools&infra=\$infra
|
||||||
baseurl=http://mirror.centos.org/\$contentdir/\$releasever/PowerTools/\$basearch/os/
|
#baseurl=http://mirror.centos.org/\$contentdir/\$releasever/PowerTools/\$basearch/os/
|
||||||
gpgcheck=1
|
#gpgcheck=1
|
||||||
enabled=1
|
#enabled=1
|
||||||
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
|
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
|
||||||
EOF
|
#EOF
|
||||||
|
|
||||||
if [[ "$Server_Country" = "CN" ]] ; then
|
if [[ "$Server_Country" = "CN" ]] ; then
|
||||||
dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el8.noarch.rpm
|
dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el8.noarch.rpm
|
||||||
|
|||||||
@@ -468,3 +468,30 @@ pm.max_spare_servers = {pmMaxSpareServers}
|
|||||||
</IfModule>
|
</IfModule>
|
||||||
}
|
}
|
||||||
}'"""
|
}'"""
|
||||||
|
|
||||||
|
OLSPPConf = """
|
||||||
|
### PASSWORD PROTECTION CONF STARTS
|
||||||
|
|
||||||
|
realm {{RealM_Name}} {
|
||||||
|
|
||||||
|
userDB {
|
||||||
|
location $SERVER_ROOT/conf/vhosts/$VH_NAME/htpasswd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context / {
|
||||||
|
location {{path}}
|
||||||
|
allowBrowse 1
|
||||||
|
realm {{RealM_Name}}
|
||||||
|
|
||||||
|
rewrite {
|
||||||
|
|
||||||
|
}
|
||||||
|
addDefaultCharset off
|
||||||
|
|
||||||
|
phpIniOverride {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
### PASSWORD PROTECTION CONF ENDS
|
||||||
|
"""
|
||||||
|
|||||||
@@ -1245,6 +1245,71 @@ class virtualHostUtilities:
|
|||||||
|
|
||||||
return DiskUsage, DiskUsagePercentage, bwInMB, bwUsage
|
return DiskUsage, DiskUsagePercentage, bwInMB, bwUsage
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def EnableDisablePP(vhostName, username=None, password=None, path=None):
|
||||||
|
try:
|
||||||
|
confPath = f'{virtualHostUtilities.vhostConfPath}/vhosts/{vhostName}/vhost.conf'
|
||||||
|
htpassword = f'{virtualHostUtilities.vhostConfPath}/vhosts/{vhostName}/htpasswd'
|
||||||
|
|
||||||
|
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||||
|
if os.path.exists(htpassword):
|
||||||
|
os.remove(htpassword)
|
||||||
|
removeCheck = 0
|
||||||
|
|
||||||
|
data = open(confPath, 'r').readlines()
|
||||||
|
writeToFile = open(confPath, 'w')
|
||||||
|
for line in data:
|
||||||
|
if line.find('PASSWORD PROTECTION CONF STARTS') > -1:
|
||||||
|
removeCheck = 1
|
||||||
|
continue
|
||||||
|
if line.find('PASSWORD PROTECTION CONF ENDS') > -1:
|
||||||
|
removeCheck = 0
|
||||||
|
continue
|
||||||
|
|
||||||
|
if removeCheck == 0:
|
||||||
|
writeToFile.writelines(line)
|
||||||
|
writeToFile.close()
|
||||||
|
else:
|
||||||
|
writeToFile = open(confPath, 'a')
|
||||||
|
from vhostConfs import vhostConfs
|
||||||
|
OLSPPConf = vhostConfs.OLSPPConf
|
||||||
|
OLSPPConf = OLSPPConf.replace('{{RealM_Name}}', str(randint(1000, 9999)))
|
||||||
|
OLSPPConf = OLSPPConf.replace('{{path}}', path)
|
||||||
|
|
||||||
|
writeToFile.write(OLSPPConf)
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
|
###
|
||||||
|
import bcrypt
|
||||||
|
password = password.encode()
|
||||||
|
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
|
||||||
|
print(hashed.decode())
|
||||||
|
UserPass = f'{username}:{hashed}:{username}'
|
||||||
|
writeToFile = open(htpassword, 'w')
|
||||||
|
writeToFile.write(UserPass)
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
|
os.chmod(htpassword, 0o644)
|
||||||
|
|
||||||
|
uBuntuPath = '/etc/lsb-release'
|
||||||
|
|
||||||
|
if os.path.exists(uBuntuPath):
|
||||||
|
group = 'nogroup'
|
||||||
|
else:
|
||||||
|
group = 'nobody'
|
||||||
|
|
||||||
|
command = f'chown lsadm:{group} {htpassword}'
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
print('1,None')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
print(f'0,{str(msg)}')
|
||||||
|
return 0,str(msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||||
@@ -1412,6 +1477,8 @@ def main():
|
|||||||
virtualHostUtilities.deleteDomain(args.virtualHostName, int(args.DeleteDocRoot))
|
virtualHostUtilities.deleteDomain(args.virtualHostName, int(args.DeleteDocRoot))
|
||||||
elif args.function == 'switchServer':
|
elif args.function == 'switchServer':
|
||||||
virtualHostUtilities.switchServer(args.virtualHostName, args.phpVersion, int(args.server), args.tempStatusPath)
|
virtualHostUtilities.switchServer(args.virtualHostName, args.phpVersion, int(args.server), args.tempStatusPath)
|
||||||
|
elif args.function == 'EnableDisablePP':
|
||||||
|
virtualHostUtilities.EnableDisablePP(args.virtualHostName, args.username, args.password, args.path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -551,20 +551,26 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
|||||||
|
|
||||||
$scope.wordpresshomeloading = false;
|
$scope.wordpresshomeloading = false;
|
||||||
|
|
||||||
var settingValue = 0;
|
|
||||||
|
|
||||||
if ($('#' + setting).is(":checked")) {
|
|
||||||
settingValue = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var url = "/websites/UpdateWPSettings";
|
var url = "/websites/UpdateWPSettings";
|
||||||
|
|
||||||
|
if (setting === "PasswordProtection") {
|
||||||
|
var data = {
|
||||||
|
WPid: $('#WPid').html(),
|
||||||
|
setting: setting,
|
||||||
|
PPUsername: $scope.PPUsername,
|
||||||
|
PPPassword: $scope.PPPassword,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var settingValue = 0;
|
||||||
|
if ($('#' + setting).is(":checked")) {
|
||||||
|
settingValue = 1;
|
||||||
|
}
|
||||||
var data = {
|
var data = {
|
||||||
WPid: $('#WPid').html(),
|
WPid: $('#WPid').html(),
|
||||||
setting: setting,
|
setting: setting,
|
||||||
settingValue: settingValue
|
settingValue: settingValue
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1596,6 +1602,7 @@ app.controller('RestoreWPBackup', function ($scope, $http, $timeout, $window) {
|
|||||||
// alert("Please Select Method of Backup Restore");
|
// alert("Please Select Method of Backup Restore");
|
||||||
// } else {
|
// } else {
|
||||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -135,8 +135,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<h6 style="font-weight: bold">Password Protection</h6>
|
<h6 style="font-weight: bold">Password Protection</h6>
|
||||||
<div class="custom-control custom-switch">
|
<div class="custom-control custom-switch">
|
||||||
<input
|
<input type="radio" data-toggle="modal"
|
||||||
type="radio" data-toggle="modal"
|
|
||||||
data-target="#Passwordprotection"
|
data-target="#Passwordprotection"
|
||||||
class="custom-control-input ng-pristine ng-untouched ng-valid ng-not-empty"
|
class="custom-control-input ng-pristine ng-untouched ng-valid ng-not-empty"
|
||||||
id="passwdprotection">
|
id="passwdprotection">
|
||||||
@@ -165,13 +164,13 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="col-sm-4">Username</label>
|
<label class="col-sm-4">Username</label>
|
||||||
<input required class="col-lg-8"
|
<input ng-model="$parent.PPUsername" required class="col-lg-8"
|
||||||
type="text" placeholder="Username">
|
type="text" placeholder="Username">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 36px;">
|
<div style="margin-top: 36px;">
|
||||||
<label class="col-sm-4">Password</label>
|
<label class="col-sm-4">Password</label>
|
||||||
<input required class="col-lg-8"
|
<input ng-model="$parent.PPPassword" required class="col-lg-8"
|
||||||
type="password" placeholder="*******************">
|
type="password" placeholder="*******************">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -179,7 +178,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-primary"
|
<button type="button" class="btn btn-primary"
|
||||||
ng-click="FiPasswordprotection()">Yes
|
ng-click="UpdateWPSettings('PasswordProtection')">Yes
|
||||||
</button>
|
</button>
|
||||||
<button type="button" ng-disabled="savingSettings"
|
<button type="button" ng-disabled="savingSettings"
|
||||||
class="btn btn-default" data-dismiss="modal">
|
class="btn btn-default" data-dismiss="modal">
|
||||||
|
|||||||
@@ -1191,7 +1191,13 @@ class WebsiteManager:
|
|||||||
|
|
||||||
WPManagerID = data['WPid']
|
WPManagerID = data['WPid']
|
||||||
setting = data['setting']
|
setting = data['setting']
|
||||||
|
|
||||||
|
if setting == 'PasswordProtection':
|
||||||
|
PPUsername = data['PPUsername']
|
||||||
|
PPPassword = data['PPPassword']
|
||||||
|
else:
|
||||||
settingValue = data['settingValue']
|
settingValue = data['settingValue']
|
||||||
|
|
||||||
wpsite = WPSites.objects.get(pk=WPManagerID)
|
wpsite = WPSites.objects.get(pk=WPManagerID)
|
||||||
|
|
||||||
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
|
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
|
||||||
@@ -1264,7 +1270,6 @@ class WebsiteManager:
|
|||||||
else:
|
else:
|
||||||
command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp option update blog_public 0 --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path)
|
command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp option update blog_public 0 --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path)
|
||||||
stdoutput = ProcessUtilities.outputExecutioner(command)
|
stdoutput = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
elif setting == 'maintenanceMode':
|
elif setting == 'maintenanceMode':
|
||||||
|
|
||||||
command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path)
|
command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path)
|
||||||
@@ -1279,6 +1284,11 @@ class WebsiteManager:
|
|||||||
else:
|
else:
|
||||||
command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode deactivate --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path)
|
command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode deactivate --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path)
|
||||||
stdoutput = ProcessUtilities.outputExecutioner(command)
|
stdoutput = ProcessUtilities.outputExecutioner(command)
|
||||||
|
elif setting == 'PasswordProtection':
|
||||||
|
execPath = f"/usr/local/CyberCP/bin/python {virtualHostUtilities.cyberPanel}/plogical/virtualHostUtilities.py"
|
||||||
|
execPath = f"{execPath} EnableDisablePP --username '{PPUsername}' --password '{PPPassword}' --virtualHostName {Webobj.domain} --path {path}"
|
||||||
|
ProcessUtilities.executioner(execPath)
|
||||||
|
|
||||||
|
|
||||||
data_ret = {'status': 1, 'error_message': 'None'}
|
data_ret = {'status': 1, 'error_message': 'None'}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
|
|||||||
Reference in New Issue
Block a user