Merge branch 'v2.3.5-dev' of github.com:usmannasir/cyberpanel into v2.3.5-dev

This commit is contained in:
usmannasir
2023-12-10 10:58:36 +05:00
15 changed files with 119 additions and 74 deletions

View File

@@ -47,7 +47,7 @@ class cliParser:
## Database Arguments
parser.add_argument('--dbName', help='Database name.')
parser.add_argument('--dbUsername', help='Datbase username.')
parser.add_argument('--dbUsername', help='Database username.')
parser.add_argument('--dbPassword', help='Database password.')
parser.add_argument('--databaseWebsite', help='Database website.')
@@ -58,7 +58,7 @@ class cliParser:
### Additional Arguments for user manager
parser.add_argument('--firstName', help='First name while creating user.')
parser.add_argument('--lastName', help='First name while creating user.')
parser.add_argument('--lastName', help='Last name while creating user.')
parser.add_argument('--websitesLimit', help='Website limit while creating user.')
parser.add_argument('--selectedACL', help='Select ACL while creating user.')
parser.add_argument('--securityLevel', help='Set security level while creating user.')

View File

@@ -120,12 +120,11 @@ class cyberPanel:
websites = Websites.objects.all()
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
with open(ipFile, 'r') as f:
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
json_data = "["
checker = 0
json_data = []
for items in websites:
if items.state == 0:
@@ -134,14 +133,8 @@ class cyberPanel:
state = "Active"
dic = {'domain': items.domain, 'adminEmail': items.adminEmail, 'ipAddress': ipAddress,
'admin': items.admin.userName, 'package': items.package.packageName, 'state': state}
json_data.append(dic)
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_json = json.dumps(json_data)
print(final_json)

View File

@@ -257,8 +257,10 @@ if ! uname -m | grep -qE 'x86_64|aarch64' ; then
exit
fi
if grep -q -E "CentOS Linux 7|CentOS Linux 8" /etc/os-release ; then
if grep -q -E "CentOS Linux 7|CentOS Linux 8|CentOS Stream" /etc/os-release ; then
Server_OS="CentOS"
elif grep -q "Red Hat Enterprise Linux" /etc/os-release ; then
Server_OS="RedHat"
elif grep -q "AlmaLinux-8" /etc/os-release ; then
Server_OS="AlmaLinux"
elif grep -q -E "CloudLinux 7|CloudLinux 8" /etc/os-release ; then
@@ -271,8 +273,8 @@ elif grep -q -E "openEuler 20.03|openEuler 22.03" /etc/os-release ; then
Server_OS="openEuler"
else
echo -e "Unable to detect your system..."
echo -e "\nCyberPanel is supported on x86_64 based Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10, Ubuntu 22.04, CentOS 7, CentOS 8, AlmaLinux 8, RockyLinux 8, CloudLinux 7, CloudLinux 8, openEuler 20.03, openEuler 22.03...\n"
Debug_Log2 "CyberPanel is supported on x86_64 based Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10, Ubuntu 22.04, CentOS 7, CentOS 8, AlmaLinux 8, RockyLinux 8, CloudLinux 7, CloudLinux 8, openEuler 20.03, openEuler 22.03... [404]"
echo -e "\nCyberPanel is supported on x86_64 based Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10, Ubuntu 22.04, CentOS 7, CentOS 8, CentOS 9, RHEL 8, RHEL 9, AlmaLinux 8, RockyLinux 8, CloudLinux 7, CloudLinux 8, openEuler 20.03, openEuler 22.03...\n"
Debug_Log2 "CyberPanel is supported on x86_64 based Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10, Ubuntu 22.04, CentOS 7, CentOS 8, CentOS 9, RHEL 8, RHEL 9, AlmaLinux 8, RockyLinux 8, CloudLinux 7, CloudLinux 8, openEuler 20.03, openEuler 22.03... [404]"
exit
fi
@@ -281,7 +283,7 @@ Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' |
echo -e "System: $Server_OS $Server_OS_Version detected...\n"
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] || [[ "$Server_OS" = "RockyLinux" ]] ; then
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] || [[ "$Server_OS" = "RockyLinux" ]] || [[ "$Server_OS" = "RedHat" ]] ; then
Server_OS="CentOS"
#CloudLinux gives version id like 7.8, 7.9, so cut it to show first number only
#treat CloudLinux, Rocky and Alma as CentOS
@@ -831,6 +833,24 @@ if [[ $Server_OS = "CentOS" ]] ; then
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
if [[ "$Server_OS_Version" = "9" ]]; then
subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms || yum config-manager --set-enabled crb > /dev/null 2>&1
yum install -y https://cyberpanel.sh/dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Check_Return "yum repo" "no_exit"
yum install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
Check_Return "yum repo" "no_exit"
cat <<EOF >/etc/yum.repos.d/MariaDB.repo
# MariaDB 10.4 CentOS repository list - created 2021-08-06 02:01 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.11/rhel9-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck=1
EOF
fi
if [[ "$Server_OS_Version" = "8" ]]; then
rpm --import https://cyberpanel.sh/www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
rpm --import https://cyberpanel.sh/dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
@@ -1007,6 +1027,9 @@ if [[ "$Server_OS" = "CentOS" ]] || [[ "$Server_OS" = "openEuler" ]] ; then
Check_Return
dnf install -y gpgme-devel
Check_Return
elif [[ "$Server_OS_Version" = "9" ]] ; then
dnf install -y libnsl zip wget strace net-tools curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel MariaDB-server MariaDB-client MariaDB-devel curl-devel git platform-python-devel tar socat python3 zip unzip bind-utils gpgme-devel
Check_Return
elif [[ "$Server_OS_Version" = "20" ]] || [[ "$Server_OS_Version" = "22" ]] ; then
dnf install -y libnsl zip wget strace net-tools curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git python3-devel tar socat python3 zip unzip bind-utils
Check_Return
@@ -1336,6 +1359,11 @@ if [[ "$Server_OS" = "CentOS" ]] ; then
#get this set up beforehand.
fi
if [[ "$Server_OS_Version" = "9" ]] ; then
sed -i 's|rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm|curl -o /etc/yum.repos.d/litespeed.repo https://rpms.litespeedtech.com/centos/litespeed.repo|g' install.py
sed -i "s|mirrorlist=http://mirrorlist.ghettoforge.org/el/8/gf/\$basearch/mirrorlist|baseurl=https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/9/gf/x86_64/|g" /etc/yum.repos.d/gf.repo
sed -i "s|mirrorlist=http://mirrorlist.ghettoforge.org/el/8/plus/\$basearch/mirrorlist|baseurl=https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/9/plus/x86_64/|g" /etc/yum.repos.d/gf.repo
fi
fi
sed -i "s|https://www.litespeedtech.com/|https://cyberpanel.sh/www.litespeedtech.com/|g" installCyberPanel.py
@@ -1534,7 +1562,7 @@ fi
Post_Install_Addon_Redis() {
if [[ "$Server_OS" = "CentOS" ]]; then
if [[ "$Server_OS_Version" = "8" ]]; then
if [[ "$Server_OS_Version" = "8" || "$Server_OS_Version" = "9" ]]; then
yum install -y lsphp??-redis redis
else
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

View File

@@ -113,8 +113,10 @@ if ! uname -m | grep -qE 'x86_64|aarch64' ; then
exit
fi
if grep -q -E "CentOS Linux 7|CentOS Linux 8" /etc/os-release ; then
if grep -q -E "CentOS Linux 7|CentOS Linux 8|CentOS Stream" /etc/os-release ; then
Server_OS="CentOS"
elif grep -q "Red Hat Enterprise Linux" /etc/os-release ; then
Server_OS="RedHat"
elif grep -q -E "CloudLinux 7|CloudLinux 8" /etc/os-release ; then
Server_OS="CloudLinux"
elif grep -q -E "Rocky Linux" /etc/os-release ; then
@@ -137,7 +139,7 @@ Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' |
echo -e "System: $Server_OS $Server_OS_Version detected...\n"
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] || [[ "$Server_OS" = "RockyLinux" ]] ; then
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] || [[ "$Server_OS" = "RockyLinux" ]] || [[ "$Server_OS" = "RedHat" ]]; then
Server_OS="CentOS"
#CloudLinux gives version id like 7.8, 7.9, so cut it to show first number only
#treat CloudLinux, Rocky and Alma as CentOS

View File

@@ -13,8 +13,10 @@ check_OS() {
exit
fi
if grep -q -E "CentOS Linux 7|CentOS Linux 8" /etc/os-release ; then
Server_OS="CentOS"
if grep -q -E "CentOS Linux 7|CentOS Linux 8|CentOS Stream" /etc/os-release ; then
Server_OS="CentOS"
elif grep -q "Red Hat Enterprise Linux" /etc/os-release ; then
Server_OS="RedHat"
elif grep -q "AlmaLinux-8" /etc/os-release ; then
Server_OS="AlmaLinux"
elif grep -q -E "CloudLinux 7|CloudLinux 8" /etc/os-release ; then
@@ -36,7 +38,7 @@ check_OS() {
echo -e "System: $Server_OS $Server_OS_Version detected...\n"
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] || [[ "$Server_OS" = "RockyLinux" ]] ; then
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] || [[ "$Server_OS" = "RockyLinux" ]] || [[ "$Server_OS" = "RedHat" ]]; then
Server_OS="CentOS"
#CloudLinux gives version id like 7.8, 7.9, so cut it to show first number only
#treat CloudLinux, Rocky and Alma as CentOS

View File

@@ -257,6 +257,10 @@ class DNSManager:
recordType = data['recordType']
recordName = data['recordName']
ttl = int(data['ttl'])
if ttl < 0:
raise ValueError("TTL: The item must be greater than 0")
elif ttl > 86400:
raise ValueError("TTL: The item must be lesser than 86401")
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1:
@@ -444,6 +448,10 @@ class DNSManager:
if data['ttlNow'] != None:
record.ttl = int(data['ttlNow'])
if record.ttl < 0:
raise ValueError("TTL: The item must be greater than 0")
elif record.ttl > 86400:
raise ValueError("TTL: The item must be lesser than 86401")
if data['priorityNow'] != None:
record.prio = int(data['priorityNow'])
@@ -826,6 +834,10 @@ class DNSManager:
recordType = data['recordType']
recordName = data['recordName']
ttl = int(data['ttl'])
if ttl < 0:
raise ValueError("TTL: The item must be greater than 0")
elif ttl > 86400:
raise ValueError("TTL: The item must be lesser than 86401")
admin = Administrator.objects.get(pk=userID)
self.admin = admin

View File

@@ -88,7 +88,7 @@
</div>
<div class="col-sm-3 aRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -114,7 +114,7 @@
</div>
<div class="col-sm-3 aaaaRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -141,7 +141,7 @@
</div>
<div class="col-sm-3 cNameRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -167,7 +167,7 @@
</div>
<div class="col-sm-2 mxRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -199,7 +199,7 @@
</div>
<div class="col-sm-3 spfRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -226,7 +226,7 @@
</div>
<div class="col-sm-3 txtRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -253,7 +253,7 @@
</div>
<div class="col-sm-3 soaRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -280,7 +280,7 @@
</div>
<div class="col-sm-3 nsRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -307,7 +307,7 @@
</div>
<div class="col-sm-2 srvRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
@@ -337,7 +337,7 @@
ng-model="recordName">
</div>
<div class="col-sm-3 caaRecord">
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control"
<input placeholder="{% trans 'TTL' %}" type="number" min="0" max="86400" class="form-control"
ng-model="ttl" required>
</div>
<div class="col-sm-3 caaRecord">

View File

@@ -172,7 +172,8 @@ class FileManager:
ProcessUtilities.executioner(command, website.externalApp)
except:
print("Permisson not changed")
def listForTable(self):
try:
finalData = {}

View File

@@ -14,6 +14,28 @@ function getCookie(name) {
return cookieValue;
}
// JavaScript function to convert bytes to a human-readable format
function bytesToHumanReadable(bytes, suffix = 'B') {
let units = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z'];
let i = 0;
while (Math.abs(bytes) >= 1024 && i < units.length - 1) {
bytes /= 1024;
++i;
}
return bytes.toFixed(1) + units[i] + suffix;
}
// JavaScript function to convert kilobytes to a human-readable format
function kilobytesToHumanReadable(kilobytes, suffix = 'KB') {
let units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
let i = 0;
while (Math.abs(kilobytes) >= 1024 && i < units.length - 1) {
kilobytes /= 1024;
++i;
}
return kilobytes.toFixed(2) + ' ' + units[i];
}
var fileManager = angular.module('fileManager', ['angularFileUpload']);
fileManager.config(['$interpolateProvider', function ($interpolateProvider) {
@@ -721,7 +743,8 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
} else {
var fileName = filesData[keys[i]][0];
var lastModified = filesData[keys[i]][2];
var fileSize = filesData[keys[i]][3];
var fileSizeBytes = parseInt(filesData[keys[i]][3], 10); // Assuming this is the size in kilobytes
var fileSize = kilobytesToHumanReadable(fileSizeBytes); // Convert to human-readable format
var permissions = filesData[keys[i]][4];
var dirCheck = filesData[keys[i]][5];
// console.log(fileName);

View File

@@ -153,7 +153,7 @@
<tr>
<th scope="col"></th>
<th scope="col">{% trans "File Name" %}</th>
<th scope="col">{% trans "Size (KB)" %}</th>
<th scope="col">{% trans "Size" %}</th>
<th scope="col">{% trans "Last Modified" %}</th>
<th scope="col">{% trans "Permissions" %}</th>
</tr>
@@ -738,4 +738,4 @@
</div>
</body>
</html>
</html>

View File

@@ -11,6 +11,16 @@ elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
SERVER_OS="CentOS8"
yum install curl wget -y 1> /dev/null
yum update curl wget ca-certificates -y 1> /dev/null
elif echo $OUTPUT | grep -q "CentOS Stream" ; then
echo -e "\nDetecting CentOS Stream...\n"
SERVER_OS="CentOS9"
yum install wget -y 1> /dev/null
yum update curl wget ca-certificates -y 1> /dev/null
elif echo $OUTPUT | grep -q "Red Hat Enterprise Linux" ; then
echo -e "\nDetecting Red Hat Enterprise Linux...\n"
SERVER_OS="RHEL"
yum install wget -y 1> /dev/null
yum update curl wget ca-certificates -y 1> /dev/null
elif echo $OUTPUT | grep -q "AlmaLinux 8" ; then
echo -e "\nDetecting AlmaLinux 8...\n"
SERVER_OS="CentOS8"
@@ -56,4 +66,4 @@ rm -f cyberpanel.sh
rm -f install.tar.gz
curl --silent -o cyberpanel.sh "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null
chmod +x cyberpanel.sh
./cyberpanel.sh $@
./cyberpanel.sh $@

View File

@@ -80,38 +80,12 @@ class cPanelImporter:
def PHPDecider(self, domainName):
if self.PHPVersion == 'inherit':
self.PHPVersion = 'PHP 7.4'
if self.PHPVersion.find('53') > -1:
self.PHPVersion = 'PHP 5.3'
elif self.PHPVersion.find('54') > -1:
self.PHPVersion = 'PHP 5.4'
elif self.PHPVersion.find('55') > -1:
self.PHPVersion = 'PHP 5.5'
elif self.PHPVersion.find('56') > -1:
self.PHPVersion = 'PHP 5.6'
elif self.PHPVersion.find('70') > -1:
self.PHPVersion = 'PHP 7.0'
elif self.PHPVersion.find('71') > -1:
self.PHPVersion = 'PHP 7.1'
elif self.PHPVersion.find('72') > -1:
self.PHPVersion = 'PHP 7.2'
elif self.PHPVersion.find('73') > -1:
self.PHPVersion = 'PHP 7.3'
elif self.PHPVersion.find('74') > -1:
self.PHPVersion = 'PHP 7.4'
elif self.PHPVersion.find('80') > -1:
self.PHPVersion = 'PHP 8.0'
elif self.PHPVersion.find('81') > -1:
self.PHPVersion = 'PHP 8.1'
elif self.PHPVersion.find('82') > -1:
self.PHPVersion = 'PHP 8.2'
if self.PHPVersion == '':
if self.InheritPHP != '':
self.PHPVersion = self.InheritPHP
else:
self.PHPVersion = 'PHP 7.4'
if self.PHPVersion == 'inherit' or not self.PHPVersion:
self.PHPVersion = self.InheritPHP or 'PHP 7.4'
else:
version_number = ''.join(filter(str.isdigit, self.PHPVersion))
if len(version_number) == 2: # Ensure there are exactly two digits
self.PHPVersion = f'PHP {version_number[0]}.{version_number[1]}'
### if the PHP Version extracted from file is not available then change it to next available

View File

@@ -227,7 +227,7 @@
<div class="checkbox">
<label>
<input ng-model="createDNSZone" type="checkbox" value="">
{% trans "Delete DNS Zone" %}
{% trans "Create DNS Zone" %}
</label>
</div>
</div>

View File

@@ -231,7 +231,7 @@
<div class="checkbox">
<label>
<input ng-model="createDNSZone" type="checkbox" value="">
{% trans "Delete DNS Zone" %}
{% trans "Create DNS Zone" %}
</label>
</div>
</div>

View File

@@ -135,12 +135,12 @@ def submitUserCreation(request):
selectedACL = data['selectedACL']
if ACLManager.CheckRegEx("^[\w'\-,.][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*(){}|~<>;:[\]]{2,}$", firstName) == 0:
data_ret = {'status': 0, 'createStatus': 0, 'error_message': 'First Name can only contain Alphabets and should be more then 2 characters..'}
data_ret = {'status': 0, 'createStatus': 0, 'error_message': 'First Name can only contain alphabetic characters, and should be more than 2 characters long...'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
if ACLManager.CheckRegEx("^[\w'\-,.][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*(){}|~<>;:[\]]{2,}$", lastName) == 0:
data_ret = {'status': 0, 'createStatus': 0, 'error_message': 'First Name can only contain Alphabets and should be more then 2 characters..'}
data_ret = {'status': 0, 'createStatus': 0, 'error_message': 'Last Name can only contain alphabetic characters, and should be more than 2 characters long...'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)