diff --git a/README.md b/README.md new file mode 100644 index 0000000..0894888 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# Vvveb CMS cPanel Installer + +#### One-click Vvveb CMS cPanel auto-installer with MySql and SQLite support + +👉🏻 [Download](https://github.com/Vvveb/cpanel-plugin/archive/main.zip) + +| [](https://raw.githubusercontent.com/Vvveb/cpanel-plugin/main/assets/cpanel-1.png) | [](https://raw.githubusercontent.com/Vvveb/cpanel-plugin/main/assets/cpanel-2.png) | [](https://raw.githubusercontent.com/Vvveb/cpanel-plugin/main/assets/cpanel-3.png) | +|:---:|:---:|:---:| + +## Install + +To install the cpanel plugin login to SSH and run the following commands to install the plugin: + +```bash +wget https://github.com/Vvveb/cpanel-plugin/archive/refs/heads/main.zip +unzip cpanel-plugin-main.zip && cd cpanel-plugin-main/ +chmod +x install.sh && ./install.sh +``` + +## License + +Copyright (c) [Vvveb](https://www.vvveb.com) + +Released under the [GPL 3](https://github.com/Vvveb/cpanel-plugin/blob/main/LICENSE) license. diff --git a/assets/cpanel-1.png b/assets/cpanel-1.png new file mode 100644 index 0000000..c14d283 Binary files /dev/null and b/assets/cpanel-1.png differ diff --git a/assets/cpanel-2.png b/assets/cpanel-2.png new file mode 100644 index 0000000..c1639c8 Binary files /dev/null and b/assets/cpanel-2.png differ diff --git a/assets/cpanel-3.png b/assets/cpanel-3.png new file mode 100644 index 0000000..62334be Binary files /dev/null and b/assets/cpanel-3.png differ diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..5c32811 --- /dev/null +++ b/install.sh @@ -0,0 +1,14 @@ +#!/bin/bash +mkdir -p /usr/local/cpanel/base/frontend/paper_lantern/vvveb + +cp vvveb.tar /usr/local/cpanel/base/frontend/paper_lantern/vvveb +cp vvveb.live.php /usr/local/cpanel/base/frontend/paper_lantern/vvveb/vvveb.live.php + +/usr/local/cpanel/scripts/install_plugin /usr/local/cpanel/base/frontend/paper_lantern/vvveb/vvveb.tar --theme paper_lantern + +mkdir -p /usr/local/cpanel/base/frontend/jupiter/vvveb + +cp vvveb.tar /usr/local/cpanel/base/frontend/jupiter/vvveb/vvveb.tar +cp vvveb.live.php /usr/local/cpanel/base/frontend/jupiter/vvveb/vvveb.live.php + +/usr/local/cpanel/scripts/install_plugin /usr/local/cpanel/base/frontend/jupiter/vvveb/vvveb.tar --theme jupiter diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..5bb632d --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,2 @@ +/usr/local/cpanel/scripts/uninstall_plugin /usr/local/cpanel/base/frontend/paper_lantern/vvveb/vvveb.tar +/usr/local/cpanel/scripts/uninstall_plugin /usr/local/cpanel/base/frontend/jupiter/vvveb/vvveb.tar diff --git a/vvveb.live.php b/vvveb.live.php new file mode 100644 index 0000000..6c8150c --- /dev/null +++ b/vvveb.live.php @@ -0,0 +1,447 @@ +header( 'Vvveb CMS' ); +$accountName = $cpanel->cpanelprint('$user'); +$hostname = $cpanel->cpanelprint('$hostname'); + +$domainData = []; +// Call the API +$response = $cpanel->uapi( + 'DomainInfo', + 'domains_data' +); + +// Handle the response +if ($response['cpanelresult']['result']['status']) { + $data = $response['cpanelresult']['result']['data']; + // Do something with the $data + // So you can see the data shape we print it here. + //var_dump($data); + $domainData = $data['addon_domains'] ?? []; + + if (isset($data['main_domain'])) { + $domainData['main'] = $data['main_domain']; + if (isset($data['sub_domains'])) { + $domainData['main']['sub_domains'] = $data['sub_domains']; + } + } else { + if (isset($data['sub_domains'])) { + $domainData = $data['sub_domains']; + } + } + +} +else { + // Report errors: + echo '
'; + var_dump($response['cpanelresult']['result']['errors']); + echo ''; +} + +//get mysql host name +$hostname = ''; +$response = $cpanel->uapi( + 'Mysql', + 'get_server_information' +); + +// Handle the response +if ($response['cpanelresult']['result']['status']) { + $data = $response['cpanelresult']['result']['data']; + // Do something with the $data + // So you can see the data shape we print it here. + $hostname = $data['host']; +} else { + // Report errors: + echo '
'; + var_dump($response['cpanelresult']['result']['errors']); + echo ''; +} + +function randomStr($length = 16) { + $string = ''; + + while (($len = strlen($string)) < $length) { + $size = $length - $len; + + $bytes = random_bytes($size); + + $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size); + } + + return $string; +} + +function download($url) { + $result = false; + + if (function_exists('curl_init')) { + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FAILONERROR, true); + $result = curl_exec($ch); + curl_close($ch); + } else { + if (ini_get('allow_url_fopen') == '1') { + $context_options = [ + 'http' => [ + 'timeout' => 5, + 'ignore_errors' => 1, + ], + ]; + $context = stream_context_create($context_options); + $result = file_get_contents($url, 'r', $context); + } + } + + return $result; +} + + +function saveDownload($url) { + //$temp = tmpfile(); + $f = false; + $temp = tempnam(sys_get_temp_dir(), 'vvveb_cms'); + + if ($content = download($url)) { + $f = file_put_contents($temp, $content, LOCK_EX); + + return $temp; + } + + return $f; +} + +function printStatus($status) { + echo "$status
'; + var_dump($response['cpanelresult']['result']['errors']); + echo ''; + return; + } + } */ + if ($database_engine == 'mysqli') { + // create database + $response = $cpanel->uapi( + 'Mysql', + 'create_database', + array ( + 'name' => $database, + ) + ); + + // Handle the response + if ($response['cpanelresult']['result']['status']) { + $data = $response['cpanelresult']['result']['data']; + + printStatus("Mysql database $database created"); + + // create user + $response = $cpanel->uapi( + 'Mysql', + 'create_user', + array ( + 'name' => $database_user, + 'password' => $database_user_password, + ) + ); + + // Handle the response + if ($response['cpanelresult']['result']['status']) { + $data = $response['cpanelresult']['result']['data']; + + printStatus("Mysql user $database_user created"); + + // add user to database + $response = $cpanel->uapi( + 'Mysql', + 'set_privileges_on_database', + array ( + 'user' => $database_user, + 'database' => $database, + 'privileges' => 'ALL PRIVILEGES', + ) + ); + + // Handle the response + if ($response['cpanelresult']['result']['status']) { + $data = $response['cpanelresult']['result']['data']; + // Do something with the $data + // So you can see the data shape we print it here. + + printStatus("Mysql user $database_user assigned to $database"); + } + else { + printStatus("Failed to set privileges for $database_user to $database"); + // Report errors: + echo '
'; + var_dump($response['cpanelresult']['result']['errors']); + echo ''; + return; + } + + } + else { + printStatus("Failed to create Mysql user $database_user"); + echo '
'; + var_dump($response['cpanelresult']['result']['errors']); + echo ''; + return; + } + + } + else { + // Report errors: + printStatus("Failed to create Mysql database $database'"); + echo '
'; + var_dump($response['cpanelresult']['result']['errors']); + echo ''; + return; + } + } + + echo '
'; + print_r($data); + echo ''; + echo $result; + } + } else { + printStatus('Error running cli.php!'); + echo $result; + } +} + +if ($_POST) { + installVvveb($cpanel); +} else { +?> + + +footer(); +$cpanel->end(); +?> diff --git a/vvveb.tar b/vvveb.tar new file mode 100644 index 0000000..a19ff14 Binary files /dev/null and b/vvveb.tar differ