diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index db680f6a4..000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/install.sh b/install.sh new file mode 100644 index 000000000..635300c83 --- /dev/null +++ b/install.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +if [ -f "/etc/os-release" ]; then + . /etc/os-release +else + ID="unsupported" + PRETTY_NAME="Your OS does not have a /etc/os-release file" +fi + +if [ "$ID" = "ubuntu" ] && [ "$UBUNTU_CODENAME" = "bionic" ]; then + export DEBIAN_FRONTEND=noninteractive + apt -q -y -o Dpkg::Options::=--force-confnew update + apt -q -y -o Dpkg::Options::=--force-confnew install wget curl + SERVER_OS="Ubuntu" +elif [ "$ID" = "centos" ] || [ "$ID" = "cloudlinux" ]; then + case "$VERSION_ID" in + 7|7.*) + yum install curl wget -y 1> /dev/null + yum update curl wget ca-certificates -y 1> /dev/null + if [ "$ID" = "centos" ]; then + SERVER_OS="CentOS" + else + SERVER_OS="CloudLinux" + fi + ;; + 8|8.*) + printf >&2 '\nCentOS 8/CloudLinux 8 support is currently experimental!\n' + yum install curl wget -y 1> /dev/null + yum update curl wget ca-certificates -y 1> /dev/null + SERVER_OS="CentOS8" + ;; + esac +else + printf >&2 '\nYour OS -- %s -- is not currently supported!\n' "$PRETTY_NAME" + printf >&2 '\nCyberPanel is currently supported on Ubuntu 18.04, CentOS 7 and CloudLinux 7.\n' + exit 1 +fi + +rm -f cyberpanel.sh install.tar.gz +curl --silent -o cyberpanel.sh "https://cyberpanel.sh/?dl&${SERVER_OS}" 2>/dev/null +chmod +x cyberpanel.sh +./cyberpanel.sh "$@" diff --git a/requirments.txt b/requirments.txt index 4b1b8bc45..619db9611 100755 --- a/requirments.txt +++ b/requirments.txt @@ -61,4 +61,5 @@ urllib3==1.22 websocket-client==0.56.0 zope.component==4.4.1 zope.event==4.3.0 -zope.interface==4.5.0 \ No newline at end of file +zope.interface==4.5.0 +validators==0.14.2 diff --git a/test.sh b/test.sh index 910e8cfbd..649fe22cf 100644 --- a/test.sh +++ b/test.sh @@ -1,2 +1,2 @@ test4 -test3 +test3 \ No newline at end of file diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index d779ce7c3..b277e48cf 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -180,14 +180,12 @@ class WebsiteManager: return ACLManager.loadErrorJson('createWebSiteStatus', 0) - if not match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', domain, - M | I): + if not validators.domain(domain): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) - if not match(r'\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b', adminEmail, - M | I): + if not validators.email(adminEmail): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid email."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -250,8 +248,7 @@ class WebsiteManager: path = data['path'] tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999)) - if not match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', domain, - M | I): + if not validators.domain(domain): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1593,8 +1590,7 @@ class WebsiteManager: aliasDomain = data['aliasDomain'] ssl = data['ssl'] - if not match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', aliasDomain, - M | I): + if not validators.domain(aliasDomain): data_ret = {'status': 0, 'createAliasStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2683,14 +2679,12 @@ StrictHostKeyChecking no self.domain = data['masterDomain'] - if not match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', self.domain, - M | I): + if not validators.domain(self.domain): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) - if not match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', data['domainName'], - M | I): + if not validators.domain(data['domainName']): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2756,8 +2750,7 @@ StrictHostKeyChecking no currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) - if not match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', data['childDomain'], - M | I): + if not validators.domain(data['childDomain']): data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2828,4 +2821,4 @@ StrictHostKeyChecking no except BaseException as msg: data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) - return HttpResponse(json_data) \ No newline at end of file + return HttpResponse(json_data)