['sftp'=>22, 'ftp'=>21, 'pop3'=>'110', 'imap'=>'143', 'smtp'=>'25'],
'hosting.danwin1210.me'=>['sftp'=>22, 'ftp'=>21, 'pop3'=>'995', 'imap'=>'993', 'smtp'=>'465']
];
const EMAIL_TO=''; //Send email notifications about new registrations to this address
const INDEX_MD5S=[ //MD5 sums of index.hosting.html files that should be considdered as unchanged for deletion
'd41d8cd98f00b204e9800998ecf8427e', //empty file
'7ae7e9bac6be76f00e0d95347111f037', //default file
'703fac6634bf637f942db8906092d0ab', //new default file
'e109a5a44969c2a109aee0ea3565529e', //TOR HTML Site
];
const REQUIRE_APPROVAL=false; //require admin approval of new sites? true/false
const ENABLE_SHELL_ACCESS=true; //allows users to login via ssh, when disabled only (s)ftp is allowed - run setup.php to migrate existing accounts
const ADMIN_PASSWORD='MY_PASSWORD'; //password for admin interface
const SERVICE_INSTANCES=['1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; //one character per instance - run multiple tor+php-fpm instances for load balancing, remove all but one instance if you expect less than 100 accounts. Adding new instances is always possible at a later time, just removing one takes some manual cleanup for now - run setup.php after change
const DISABLED_PHP_VERSIONS=[]; //php versions still installed on the system but no longer offered for new accounts
const PHP_VERSIONS=[4 => '7.3']; //currently active php versions
const DEFAULT_PHP_VERSION='7.3'; //default php version
const PHP_CONFIG='memory_limit = 256M
error_reporting = E_ALL
post_max_size = 10G
upload_max_filesize = 10G
max_file_uploads = 100
date.timezone = UTC
pdo_odbc.connection_pooling=off
odbc.allow_persistent = Off
ibase.allow_persistent = 0
mysqli.allow_persistent = Off
pgsql.allow_persistent = Off
opcache.enable=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=20000
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.revalidate_path=1
opcache.save_comments=1
opcache.optimization_level=0xffffffff
opcache.validate_permission=1
opcache.validate_root=1
';
const NGINX_DEFAULT = 'server {
listen unix:/var/run/nginx/suspended backlog=2048;
add_header Content-Type text/html;
location / {
return 200 \'
SuspendedThis domain has been suspended due to violation of our hosting rules.\';
}
}
server {
listen [::]:80 ipv6only=off fastopen=100 backlog=2048 default_server;
listen unix:/var/run/nginx.sock backlog=2048 default_server;
root /var/www/html;
index index.php;
server_name ' . ADDRESS . ' *.' . ADDRESS . ';
location / {
try_files $uri $uri/ =404;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param DOCUMENT_ROOT /html;
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/7.3-hosting;
}
}
location /squirrelmail {
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/7.3-squirrelmail;
}
}
location /phpmyadmin {
root /usr/share;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param DOCUMENT_ROOT /html;
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name;
fastcgi_pass unix:/run/php/7.3-phpmyadmin;
}
}
location /adminer {
root /var/www/html/adminer;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param DOCUMENT_ROOT /html/adminer;
fastcgi_param SCRIPT_FILENAME /html/adminer$fastcgi_script_name;
fastcgi_pass unix:/run/php/7.3-adminer;
}
}
location /externals/jush/ {
root /var/www/html/adminer;
}
location /nginx/ {
root /var/log/;
internal;
}
}
';
const MAX_NUM_USER_DBS = 5; //maximum number of databases a user may have
const MAX_NUM_USER_ONIONS = 3; //maximum number of onion domains a user may have
const MAX_NUM_USER_DOMAINS = 3; //maximum number of clearnet domains a user may have
const SKIP_USER_CHROOT_UPDATE = true; //skips updating user chroots when running setup.php
const DEFAULT_QUOTA_SIZE = 10 * 1024 * 1024; //per user disk quota in kb - Defaults to 10 GB
const DEFAULT_QUOTA_FILES = 100000; //per user file quota - by default allow no more than 100000 files
function get_onion_v2($pkey) : string {
$keyData = openssl_pkey_get_details($pkey);
$pk = base64_decode(substr($keyData['key'], 27, -26));
$skipped_first_22 = substr($pk, 22);
$first_80_bits_of_sha1 = hex2bin(substr(sha1($skipped_first_22), 0, 20));
return base32_encode($first_80_bits_of_sha1);
}
function get_onion_v3(string $sk) : string {
if(PHP_INT_SIZE === 4){
$pk = ParagonIE_Sodium_Core32_Ed25519::sk_to_pk($sk);
}else{
$pk = ParagonIE_Sodium_Core_Ed25519::sk_to_pk($sk);
}
$checksum = substr(hash('SHA3-256', '.onion checksum' . $pk . hex2bin('03'), true), 0, 2);
return base32_encode($pk . $checksum . hex2bin('03'));
}
function base32_encode(string $input) : string {
$map = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', // 7
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', // 15
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', // 23
'y', 'z', '2', '3', '4', '5', '6', '7', // 31
];
if(empty($input)){
return '';
}
$input = str_split($input);
$binaryString = '';
$c = count($input);
for($i = 0; $i < $c; ++$i) {
$binaryString .= str_pad(decbin(ord($input[$i])), 8, '0', STR_PAD_LEFT);
}
$fiveBitBinaryArray = str_split($binaryString, 5);
$base32 = '';
$i = 0;
$c = count($fiveBitBinaryArray);
while($i < $c) {
$base32 .= $map[bindec($fiveBitBinaryArray[$i])];
++$i;
}
return $base32;
}
function send_captcha() {
global $db;
if(!CAPTCHA || !extension_loaded('gd')){
return;
}
$captchachars = 'ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789';
$length = strlen($captchachars)-1;
$code = '';
for($i = 0; $i < 5; ++$i){
$code .= $captchachars[mt_rand(0, $length)];
}
$randid = mt_rand();
$time = time();
$stmt = $db->prepare('INSERT INTO captcha (id, time, code) VALUES (?, ?, ?);');
$stmt->execute([$randid, $time, $code]);
echo "