From 78ba449fa3ef76c044336fb8e16d3b9094eed88d Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Sun, 22 Jan 2023 20:00:49 +0100 Subject: [PATCH] Make scripts translatable --- .gitignore | 3 + README.md | 8 + update-translation.sh | 3 + var/www/common.php | 156 ++-- var/www/composer.json | 6 +- var/www/cron.php | 12 +- var/www/find_old.php | 6 +- var/www/html/admin.php | 109 ++- var/www/html/coinpayments_ipn.php | 14 +- var/www/html/delete.php | 12 +- var/www/html/faq.php | 23 +- var/www/html/files.php | 78 +- var/www/html/home.php | 112 +-- var/www/html/index.php | 69 +- var/www/html/list.php | 9 +- var/www/html/login.php | 34 +- var/www/html/password.php | 34 +- var/www/html/pgp.php | 22 +- var/www/html/register.php | 54 +- var/www/html/upgrade.php | 24 +- var/www/locale/hosting.pot | 1195 +++++++++++++++++++++++++++++ var/www/setup.php | 87 ++- 22 files changed, 1652 insertions(+), 418 deletions(-) create mode 100644 .gitignore create mode 100755 update-translation.sh create mode 100644 var/www/locale/hosting.pot diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d7c7170 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +var/www/vendor/ +var/www/composer.lock +*~ diff --git a/README.md b/README.md index 9da38ff..aa87427 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,14 @@ General Information: This is a setup for a Tor based shared hosting server. It is provided as is and before putting it into production you should make changes according to your needs. This is a work in progress and you should carefully check the commit history for changes before updating. +Translation: +-------------------------- + +Translations are managed in [Weblate](https://weblate.danwin1210.de/projects/DanWin/hosting). +If you prefer manually submitting translations, the script `update-translations.sh` can be used to update the language template and translation files from source. +It will generate the file `var/www/locale/hosting.pot` which you can then use as basis to create a new language file in `var/www/YOUR_LANG_CODE/LC_MESSAGES/hosting.po` and edit it with a translation program, such as [Poedit](https://poedit.net/). +Once you are done, you can open a pull request, or [email me](mailto:daniel@danwin1210.de), to include the translation. + Installation Instructions: -------------------------- diff --git a/update-translation.sh b/update-translation.sh new file mode 100755 index 0000000..3723e24 --- /dev/null +++ b/update-translation.sh @@ -0,0 +1,3 @@ +#!/bin/bash +xgettext --from-code UTF-8 -o var/www/locale/hosting.pot `find var/www/ -iname '*.php'` +for translation in `find var/www/locale -iname '*.po'`; do msgmerge -U "$translation" var/www/locale/hosting.pot; msgfmt -o ${translation:0:-2}mo "$translation"; done diff --git a/var/www/common.php b/var/www/common.php index dd33675..1a2e1b3 100644 --- a/var/www/common.php +++ b/var/www/common.php @@ -63,62 +63,6 @@ session.use_strict_mode = 1 session.serialize_handler=igbinary apc.serializer=igbinary '; -const NGINX_DEFAULT = 'server { - listen unix:/var/run/nginx/suspended backlog=4096 proxy_protocol; - 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=4096 default_server; - listen unix:/var/run/nginx.sock backlog=4096 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/8.2-hosting; - } - } - location /squirrelmail { - 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/8.2-squirrelmail; - } - } - location /phpmyadmin { - 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/8.2-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/8.2-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 @@ -143,6 +87,57 @@ const COINPAYMENTS_IPN_SECRET = 'COINPAYMENTS_IPN_SECRET'; //Coinpayments IPN se const COINPAYMENTS_FAKE_BUYER_EMAIL = 'daniel@danwin1210.me'; //fixed email used for the required buyer email field const SITE_NAME = "Daniel's Hosting"; //globally changes the sites title const HOME_MOUNT_PATH = '/home'; //mount path of the home directory. Usually /home as own partition or / on a system with no extra home partition +const CONTACT_URL = 'https://danwin1210.de/contact.php'; //url to contact form +const PRIVACY_URL = 'https://danwin1210.de/privacy.php'; //url to privacy policy +const CLEARNET_A = '116.202.17.147'; // IPv4 Address of your clearnet gateway +const CLEARNET_AAAA = '2a01:4f8:c010:d56::1'; // IPv6 Address of your clearnet gateway +const CLEARNET_ADDRESS = 'hosting.danwin1210.me'; //Domain under which the service is reachable in clearnet +const CLEARNET_SUBDOMAINS = 'danwin1210.me'; //domain of which all subdomains are mapped to this server +const DEFAULT_LANG = 'en'; //default language +const LANGUAGES = [ //available languages + 'en' => ['name' => 'English', 'locale' => 'en_GB', 'dir' => 'ltr'], +]; + + +$language = DEFAULT_LANG; +$locale = LANGUAGES[DEFAULT_LANG]['locale']; +$dir = LANGUAGES[DEFAULT_LANG]['dir']; + +if(isset($_REQUEST['lang']) && isset(LANGUAGES[$_REQUEST['lang']])){ + $locale = LANGUAGES[$_REQUEST['lang']]['locale']; + $language = $_REQUEST['lang']; + $dir = LANGUAGES[$_REQUEST['lang']]['dir']; + setcookie('language', $_REQUEST['lang'], ['expires' => 0, 'path' => '/', 'domain' => '', 'secure' => ($_SERVER['HTTPS'] ?? '' === 'on'), 'httponly' => true, 'samesite' => 'Strict']); +}elseif(isset($_COOKIE['language']) && isset(LANGUAGES[$_COOKIE['language']])){ + $locale = LANGUAGES[$_COOKIE['language']]['locale']; + $language = $_COOKIE['language']; + $dir = LANGUAGES[$_COOKIE['language']]['dir']; +}elseif(!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ + $prefLocales = array_reduce( + explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']), + function (array $res, string $el) { + list($l, $q) = array_merge(explode(';q=', $el), [1]); + $res[$l] = (float) $q; + return $res; + }, []); + arsort($prefLocales); + foreach($prefLocales as $l => $q){ + $lang = locale_lookup(array_keys(LANGUAGES), $l); + if(!empty($lang)){ + $locale = LANGUAGES[$lang]['locale']; + $language = $lang; + $dir = LANGUAGES[$lang]['dir']; + setcookie('language', $lang, ['expires' => 0, 'path' => '/', 'domain' => '', 'secure' => ($_SERVER['HTTPS'] ?? '' === 'on'), 'httponly' => true, 'samesite' => 'Strict']); + break; + } + } +} +putenv('LC_ALL='.$locale); +setlocale(LC_ALL, $locale); + +bindtextdomain('hosting', __DIR__.'/locale'); +bind_textdomain_codeset('hosting', 'UTF-8'); +textdomain('hosting'); function get_onion_v2($pkey) : string { $keyData = openssl_pkey_get_details($pkey); @@ -205,7 +200,7 @@ function send_captcha(): void $db = get_db_instance(); $stmt = $db->prepare('INSERT INTO captcha (id, time, code) VALUES (?, ?, ?);'); $stmt->execute([$randid, $time, $code]); - echo "Copy: "; + echo ''._('Copy:').' '; if(CAPTCHA === 1){ $im = imagecreatetruecolor(55, 24); $bg = imagecolorallocate($im, 0, 0, 0); @@ -285,7 +280,7 @@ function send_captcha(): void imagegif($im); imagedestroy($im); echo base64_encode(ob_get_clean()).'">'; - echo ""; + echo ''; } function check_login() : array { @@ -364,7 +359,7 @@ NumPrimaryGuards '.NUM_GUARDS.' while($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){ $system_account = sanitize_system_account($tmp['system_account']); if($system_account === false){ - echo "ERROR: Account $tmp[system_account] looks strange\n"; + printf(_('ERROR: Account %s looks strange').PHP_EOL, $tmp['system_account']); continue; } if(!file_exists("/var/lib/tor-instances/$instance/hidden_service_$tmp[onion].onion")){ @@ -532,7 +527,7 @@ function rewrite_nginx_config(): void while($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){ $system_account = sanitize_system_account($tmp['system_account']); if($system_account === false){ - echo "ERROR: Account $tmp[system_account] looks strange\n"; + printf(_('ERROR: Account %s looks strange').PHP_EOL, $tmp['system_account']); continue; } if($tmp['php']>0){ @@ -570,7 +565,7 @@ function rewrite_nginx_config(): void while($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){ $system_account = sanitize_system_account($tmp['system_account']); if($system_account === false){ - echo "ERROR: Account $tmp[system_account] looks strange\n"; + printf(_('ERROR: Account %s looks strange').PHP_EOL, $tmp['system_account']); continue; } if($tmp['php']>0){ @@ -611,7 +606,7 @@ function rewrite_nginx_config(): void while($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){ $system_account = sanitize_system_account($tmp['system_account']); if($system_account === false){ - echo "ERROR: Account $tmp[system_account] looks strange\n"; + printf(_('ERROR: Account %s looks strange').PHP_EOL, $tmp['system_account']); continue; } $nginx_mysql.="server { @@ -655,7 +650,7 @@ pm.max_children = 8 while($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){ $system_account = sanitize_system_account($tmp['system_account']); if($system_account === false){ - echo "ERROR: Account $tmp[system_account] looks strange\n"; + printf(_('ERROR: Account %s looks strange').PHP_EOL, $tmp['system_account']); continue; } $php.='['.$tmp['system_account']."] @@ -816,7 +811,7 @@ function del_user_domain(int $user_id, string $domain): void function check_csrf_error(): false|string { if(empty($_POST['csrf_token']) || $_POST['csrf_token'] !== $_SESSION['csrf_token']){ - return 'Invalid CSRF token, please try again.'; + return _('Invalid CSRF token, please try again.'); } return false; } @@ -838,7 +833,7 @@ function get_db_instance() : PDO { try{ $db=new PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME, DBUSER, DBPASS, [PDO::ATTR_ERRMODE=>PDO::ERRMODE_WARNING, PDO::ATTR_PERSISTENT=>PERSISTENT]); }catch(PDOException $e){ - die('No Connection to MySQL database!'); + die(_('No Connection to MySQL database!')); } } return $db; @@ -973,7 +968,7 @@ function setup_chroot(string $account, string $last_account): void { $system_account = sanitize_system_account($account); if($system_account === false){ - echo "ERROR: Account $account looks strange\n"; + printf(_('ERROR: Account %s looks strange').PHP_EOL, $account); return; } $last_account = sanitize_system_account($last_account); @@ -1016,7 +1011,7 @@ function update_system_user_password(string $user, string $password): void { $system_account = sanitize_system_account($user); if($system_account === false){ - echo "ERROR: Account $user looks strange\n"; + printf(_('ERROR: Account %s looks strange').PHP_EOL, $user); return; } $fp = fopen("/etc/shadow", "r+"); @@ -1058,11 +1053,11 @@ function main_menu(string $current_site): void { echo '

'; $sites = [ - 'index.php' => 'Info', - 'register.php' => 'Register', - 'login.php' => 'Login', - 'list.php' => 'List of hosted sites', - 'faq.php' => 'FAQ', + 'index.php' => _('Info'), + 'register.php' => _('Register'), + 'login.php' => _('Login'), + 'list.php' => _('List of hosted sites'), + 'faq.php' => _('FAQ'), ]; $first = true; foreach($sites as $link => $name){ @@ -1086,14 +1081,14 @@ function main_menu(string $current_site): void function dashboard_menu(array $user, string $current_site): void { - echo '

Logged in as ' . htmlspecialchars($user['username']); + echo '

'.sprintf(_('Logged in as %s'), htmlspecialchars($user['username'])); $sites = [ - 'logout.php' => 'Logout', - 'home.php' => 'Dashboard', - 'pgp.php' => 'PGP 2FA', - 'password.php' => 'Change password', - 'files.php' => 'FileManager', - 'delete.php' => 'Delete account', + 'logout.php' => _('Logout'), + 'home.php' => _('Dashboard'), + 'pgp.php' => _('PGP 2FA'), + 'password.php' => _('Change password'), + 'files.php' => _('FileManager'), + 'delete.php' => _('Delete account'), ]; foreach($sites as $link => $name){ if($link===$current_site){ @@ -1107,8 +1102,9 @@ function dashboard_menu(array $user, string $current_site): void function print_header(string $sub_title, string $style = '', string $base_target = '_self'): void { + global $language, $dir; ?> - + <?php echo htmlspecialchars(SITE_NAME) . ' - ' . htmlspecialchars($sub_title); ?> diff --git a/var/www/composer.json b/var/www/composer.json index 25b1f33..abe7d7a 100644 --- a/var/www/composer.json +++ b/var/www/composer.json @@ -9,6 +9,8 @@ "ext-posix": "*", "ext-gnupg": "*", "ext-ssh2": "*", - "ext-fileinfo": "*" - } + "ext-fileinfo": "*", + "ext-gettext": "*", + "ext-intl": "*" + } } diff --git a/var/www/cron.php b/var/www/cron.php index aa9aba0..2334dbb 100644 --- a/var/www/cron.php +++ b/var/www/cron.php @@ -26,11 +26,11 @@ $stmt=$db->query("SELECT users.system_account, new_account.password, users.id, u while($account=$stmt->fetch(PDO::FETCH_ASSOC)){ $system_account = basename($account['system_account']); if($system_account !== $account['system_account']){ - echo "ERROR: Account $account[system_account] looks strange\n"; + printf(_("ERROR: Account %s looks strange").PHP_EOL, $account['system_account']); continue; } if(posix_getpwnam($system_account) !== false){ - echo "ERROR: Account $account[system_account] already exists\n"; + printf(_("ERROR: Account %s already exists").PHP_EOL, $account['system_account']); continue; } $reload[$account['instance']] = true; @@ -52,7 +52,7 @@ $mark_onions=$db->prepare('UPDATE onions SET enabled=-1 WHERE user_id=? AND enab foreach($accounts as $account){ $system_account = sanitize_system_account($account['system_account']); if($system_account === false){ - echo "ERROR: Account $account[system_account] looks strange\n"; + printf(_("ERROR: Account %s looks strange").PHP_EOL, $account['system_account']); continue; } $reload[$account['instance']]=true; @@ -95,7 +95,7 @@ $drop_user=$db->prepare("DROP USER ?@'%';"); foreach($accounts as $account){ $system_account = sanitize_system_account($account['system_account']); if($system_account === false){ - echo "ERROR: Account $account[system_account] looks strange\n"; + printf(_("ERROR: Account %s looks strange").PHP_EOL, $account['system_account']); continue; } //kill processes of the user to allow deleting system users @@ -131,7 +131,7 @@ $del=$db->prepare("DELETE FROM pass_change WHERE user_id=?;"); while($account=$stmt->fetch(PDO::FETCH_ASSOC)){ $system_account = sanitize_system_account($account['system_account']); if($system_account === false){ - echo "ERROR: Account $account[system_account] looks strange\n"; + printf(_("ERROR: Account %s looks strange").PHP_EOL, $account['system_account']); continue; } update_system_user_password($system_account, $account['password']); @@ -144,7 +144,7 @@ $updated=$db->prepare("UPDATE disk_quota SET updated = 0 WHERE user_id=?;"); while($account=$stmt->fetch(PDO::FETCH_ASSOC)){ $system_account = sanitize_system_account($account['system_account']); if($system_account === false){ - echo "ERROR: Account $account[system_account] looks strange\n"; + printf(_("ERROR: Account %s looks strange").PHP_EOL, $account['system_account']); continue; } exec('quotatool -u '. escapeshellarg($system_account) . ' -i -q ' . escapeshellarg($account['quota_files']) . ' -l ' . escapeshellarg($account['quota_files']) . ' ' . HOME_MOUNT_PATH); diff --git a/var/www/find_old.php b/var/www/find_old.php index 2ded764..56b7f58 100644 --- a/var/www/find_old.php +++ b/var/www/find_old.php @@ -9,7 +9,7 @@ $update=$db->prepare('UPDATE disk_quota SET quota_size_used = ?, quota_files_use foreach($all_accounts as $tmp){ $system_account = sanitize_system_account($tmp['system_account']); if($system_account === false){ - echo "ERROR: Account $tmp[system_account] looks strange\n"; + printf(_("ERROR: Account %s looks strange").PHP_EOL, $tmp['system_account']); continue; } $quota = shell_exec('quota -pu ' . escapeshellarg($tmp['system_account'])); @@ -25,7 +25,7 @@ foreach($all_accounts as $tmp){ foreach($all_accounts as $tmp){ $system_account = sanitize_system_account($tmp['system_account']); if($system_account === false){ - echo "ERROR: Account $tmp[system_account] looks strange\n"; + printf(_("ERROR: Account %s looks strange").PHP_EOL, $tmp['system_account']); continue; } exec('find '.escapeshellarg("/home/$tmp[system_account]/tmp").' -path '.escapeshellarg("/home/$tmp[system_account]/tmp/*").' -cmin +1440 -delete'); @@ -41,7 +41,7 @@ $all=$stmt->fetchAll(PDO::FETCH_ASSOC); foreach($all as $tmp){ $system_account = sanitize_system_account($tmp['system_account']); if($system_account === false){ - echo "ERROR: Account $tmp[system_account] looks strange\n"; + printf(_("ERROR: Account %s looks strange").PHP_EOL, $tmp['system_account']); continue; } //check modification times diff --git a/var/www/html/admin.php b/var/www/html/admin.php index ec3dfe9..8055e38 100644 --- a/var/www/html/admin.php +++ b/var/www/html/admin.php @@ -6,9 +6,9 @@ session_start(['name'=>'hosting_admin']); if($_SERVER['REQUEST_METHOD']==='HEAD'){ exit; // headers sent, no further processing needed } -print_header('Admin panel', 'td{padding:5px;}', '_blank'); +print_header(_('Admin panel'), 'td{padding:5px;}', '_blank'); ?> -

Hosting - Admin panel

+

'; - echo ""; + echo ''; send_captcha(); - echo ""; + echo ''; echo '
Password
'._('Password').'
'; if($error){ - echo "

$error

"; + echo '

'.$error.'

'; }elseif(isset($_POST['pass'])){ - echo "

Wrong password!

"; + echo '

'._('Wrong password!').'

'; } - echo '

If you disabled cookies, please re-enable them. You can\'t log in without!

'; + echo '

'._("If you disabled cookies, please re-enable them. You can't log in without!").'

'; }else{ echo '

'; if(REQUIRE_APPROVAL){ $stmt=$db->query('SELECT COUNT(*) FROM new_account WHERE approved=0;'); $cnt=$stmt->fetch(PDO::FETCH_NUM)[0]; - echo 'Approve pending sites ($cnt) | "; + echo ''.sprintf(_('Approve pending sites (%s)'), $cnt).' | '; } - echo 'List of accounts | Delete accounts | Suspend hidden services | Edit hidden services | Logout

'; + echo ''._('List of accounts').' | '._('Delete accounts').' | '._('Suspend hidden services').' | '._('Edit hidden services').' | '._('Logout').'

'; if(empty($_REQUEST['action']) || $_REQUEST['action']==='login'){ - echo '

Welcome to the admin panel!

'; + echo '

'._('Welcome to the admin panel!').'

'; }elseif($_REQUEST['action'] === 'logout'){ session_destroy(); header('Location: ' . $_SERVER['SCRIPT_NAME']); @@ -47,9 +47,9 @@ if(empty($_SESSION['logged_in'])){ echo '
'; echo ''; echo ''; - echo ''; + echo ''; $stmt=$db->query('SELECT users.username, onions.onion, onions.enabled FROM users INNER JOIN onions ON (onions.user_id=users.id) ORDER BY users.username;'); - $sccounts = []; + $accounts = []; while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ $accounts[$tmp[0]] []= [$tmp[1], $tmp[2]]; } @@ -68,43 +68,38 @@ if(empty($_SESSION['logged_in'])){ echo "$onion[0].onion"; } } - echo ""; + echo ''; } echo '
UsernameOnion linkAction
'._('Username').''._('Onion link').''._('Action').'
'; - }elseif(substr($_REQUEST['action'], 0, 7) === 'approve'){ + }elseif( str_starts_with( $_REQUEST[ 'action' ], 'approve' ) ){ $onion = substr($_REQUEST['action'], 8); if(!empty($onion)){ if($error=check_csrf_error()){ - echo '

'.$error.'

'; + echo '

'.$error.'

'; }else{ $stmt=$db->prepare('UPDATE new_account INNER JOIN onions ON (onions.user_id=new_account.user_id) SET new_account.approved=1 WHERE onions.onion=?;'); $stmt->execute([$onion]); - echo '

Successfully approved

'; + echo '

'._('Successfully approved').'

'; } } echo '
'; echo ''; echo ''; - echo ''; + echo ''; $stmt=$db->query('SELECT users.username, onions.onion FROM users INNER JOIN new_account ON (users.id=new_account.user_id) INNER JOIN onions ON (onions.user_id=users.id) WHERE new_account.approved=0 ORDER BY users.username;'); while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ - echo ""; + echo "'; } echo '
UsernameOnion addressAction
'._('Username').''._('Onion address').''._('Action').'
$tmp[0]$tmp[1].onion
$tmp[0]$tmp[1].onion
'; - }elseif(substr($_REQUEST['action'], 0, 6) === 'delete'){ - $onion = ''; - if(isset($_POST['onion'])){ - $onion = $_POST['onion']; - }else{ - $onion = substr($_REQUEST['action'], 7); - } - echo '

Delete accouts:

'; + }elseif( str_starts_with( $_REQUEST[ 'action' ], 'delete' ) ){ + $onion = $_POST[ 'onion' ] ?? substr( $_REQUEST[ 'action' ], 7 ); + echo '

'._('Delete accounts:').'

'; echo '
'; echo ''; - echo '

Onion address:

'; - echo '

'; + echo '
'; if(!empty($onion)){ if($error=check_csrf_error()){ echo '

'.$error.'

'; @@ -114,63 +109,53 @@ if(empty($_SESSION['logged_in'])){ if($user_id=$stmt->fetch(PDO::FETCH_NUM)){ $stmt=$db->prepare('UPDATE users SET todelete=1 WHERE id=?;'); $stmt->execute($user_id); - echo "

Successfully queued for deletion!

"; + echo '

'._('Successfully queued for deletion!').'

'; }else{ - echo "

Onion address not hosted by us!

"; + echo '

'._('Onion address not hosted by us!').'

'; } }else{ - echo "

Invalid onion address!

"; + echo '

'._('Invalid onion address!').'

'; } } - }elseif(substr($_REQUEST['action'], 0, 7) === 'suspend'){ - $onion = ''; - if(isset($_POST['onion'])){ - $onion = $_POST['onion']; - }else{ - $onion = substr($_REQUEST['action'], 8); - } - echo '

Suspend hidden service:

'; + }elseif( str_starts_with( $_REQUEST[ 'action' ], 'suspend' ) ){ + $onion = $_POST[ 'onion' ] ?? substr( $_REQUEST[ 'action' ], 8 ); + echo '

'._('Suspend hidden service:').'

'; echo '
'; echo ''; - echo '

Onion address:

'; - echo '

'; + echo '
'; if(!empty($onion)){ if($error=check_csrf_error()){ - echo '

'.$error.'

'; + echo '

'.$error.'

'; }elseif(preg_match('~^([a-z2-7]{16}|[a-z2-7]{56})(\.onion)?$~', $onion, $match)){ $stmt=$db->prepare('SELECT instance FROM onions WHERE onion=?;'); $stmt->execute([$match[1]]); if($instance=$stmt->fetch(PDO::FETCH_NUM)){ $stmt=$db->prepare('UPDATE onions SET enabled=-2 WHERE onion=?;'); $stmt->execute([$match[1]]); - echo "

Successfully queued for suspension!

"; + echo '

'._('Successfully queued for suspension!').'

'; enqueue_instance_reload($instance[0]); }else{ - echo "

Onion address not hosted by us!

"; + echo '

'._('Onion address not hosted by us!').'

'; } }else{ - echo "

Invalid onion address!

"; + echo '

'._('Invalid onion address!').'

'; } } - }elseif(substr($_REQUEST['action'], 0, 4) === 'edit'){ - $onion = ''; - if(isset($_POST['onion'])){ - $onion = $_POST['onion']; - }else{ - $onion = substr($_REQUEST['action'], 5); - } - echo '

Edit hidden service:

'; + }elseif( str_starts_with( $_REQUEST[ 'action' ], 'edit' ) ){ + $onion = $_POST[ 'onion' ] ?? substr( $_REQUEST[ 'action' ], 5 ); + echo '

'._('Edit hidden service:').'

'; echo '
'; echo ''; - echo '

Onion address:

'; echo '

'; if(!empty($onion)){ if($error=check_csrf_error()){ - echo '

'.$error.'

'; + echo '

'.$error.'

'; }elseif(preg_match('~^([a-z2-7]{16}|[a-z2-7]{56})(\.onion)?$~', $onion, $match)){ if(isset($_POST['num_intros'])){ $stmt=$db->prepare('SELECT version, instance FROM onions WHERE onion=?;'); @@ -195,7 +180,7 @@ if(empty($_SESSION['logged_in'])){ } $stmt->execute([$enabled, $enable_smtp, $num_intros, $max_streams, $match[1]]); enqueue_instance_reload($onion[1]); - echo "

Changes successfully saved!

"; + echo '

'._('Changes successfully saved!').'

'; } } $stmt=$db->prepare('SELECT onion, enabled, enable_smtp, num_intros, max_streams, version FROM onions WHERE onion=?;'); @@ -203,22 +188,22 @@ if(empty($_SESSION['logged_in'])){ if($onion=$stmt->fetch(PDO::FETCH_NUM)){ echo '
'; echo ''; - echo ''; + echo '
OnionEnabledSMTP enabledNr. of introsMax streams per rend circuitSave
'; echo ''; echo ''; + echo '>'._('Enabled').''; echo ''; + echo '>'._('Enabled').''; echo ''; echo ''; - echo ''; + echo ''; }else{ - echo "

Onion address not hosted by us!

"; + echo '

'._('Onion address not hosted by us!').'

'; } }else{ - echo "

Invalid onion address!

"; + echo '

'._('Invalid onion address!').'

'; } } } diff --git a/var/www/html/coinpayments_ipn.php b/var/www/html/coinpayments_ipn.php index 59abff1..6bb5757 100644 --- a/var/www/html/coinpayments_ipn.php +++ b/var/www/html/coinpayments_ipn.php @@ -2,28 +2,28 @@ require('../common.php'); if(!ENABLE_UPGRADES){ - die('Upgrades disabled'); + die(_('Upgrades disabled')); } if(!COINPAYMENTS_ENABLED){ - die('CoinPayments disabled'); + die(_('CoinPayments disabled')); } if(empty($_SERVER['HTTP_HMAC'])){ - die("No HMAC signature sent"); + die(_('No HMAC signature sent')); } $merchant = $_POST['merchant'] ?? ''; if(empty($merchant)){ - die("No Merchant ID passed"); + die(_('No Merchant ID passed')); } if($merchant !== COINPAYMENTS_MERCHANT_ID){ - die("Invalid Merchant ID"); + die(_('Invalid Merchant ID')); } $request = file_get_contents('php://input'); if(empty($request)){ - die("Error reading POST data"); + die(_('Error reading POST data')); } $hmac = hash_hmac("sha512", $request, COINPAYMENTS_IPN_SECRET); if($hmac !== $_SERVER['HTTP_HMAC']){ - die("HMAC signature does not match"); + die(_('HMAC signature does not match')); } $db = get_db_instance(); $status = 0; diff --git a/var/www/html/delete.php b/var/www/html/delete.php index f880aed..337106f 100644 --- a/var/www/html/delete.php +++ b/var/www/html/delete.php @@ -5,9 +5,9 @@ $user=check_login(); $msg=''; if($_SERVER['REQUEST_METHOD']==='POST'){ if($error=check_csrf_error()){ - $msg.='

'.$error.'

'; + $msg.='

'.$error.'

'; }elseif(!isset($_POST['pass']) || !password_verify($_POST['pass'], $user['password'])){ - $msg.='

Wrong password.

'; + $msg.='

'._('Wrong password!').'

'; }else{ $stmt=$db->prepare('UPDATE users SET todelete=1 WHERE id=?;'); $stmt->execute([$user['id']]); @@ -19,11 +19,11 @@ if($_SERVER['REQUEST_METHOD']==='POST'){ header('Content-Type: text/html; charset=UTF-8'); print_header('Delete account'); ?> -

This will delete your account and all data asociated with it. It can't be un-done. Are you sure?

+

'._('Onion').''._('Enabled').''._('SMTP enabled').''._('Nr. of intros').''._('Max streams per rend circuit').''._('Save').'
- - + +
Enter your account password to confirm
-

No, don't delete.

+

diff --git a/var/www/html/faq.php b/var/www/html/faq.php index 8a52003..d6533c5 100644 --- a/var/www/html/faq.php +++ b/var/www/html/faq.php @@ -1,20 +1,19 @@ -

Hosting - FAQ

+

- - - - - - - - - + + + + + + + + +
QuestionAnswer
Your rules are so strict. Can't you make an exception for my site?No, I will not make exceptions for any site and neither am I corruptible by offering me money. Once I start making an exception for your site, I would have to for every other site as well which is the same as if the rules didn't exist.
I have an .htaccess file, but it doesn't work. How can I fix it?.htaccess files are meant for Apache2 webservers. My server is based on NginX, which is much faster due to using static configuration files and not reading files like .htaccess at runtime. You can contact me and tell me your sites address where the .htaccess file is. I will then check your .htaccess and convert the rules to NginX rules and apply those.
I just uploaded my page, but it's broken. HELP!Most likely your site makes use of rewriting rules, which are typically located in an .htaccess file or are mentioned in a README file. Just contact me in this case. Also see the previous question.
Can I host a porn site?Yes as long as your content is legal you may upload adult content.
What is the directory structure for when I connect via sftp?There are several directories you on the server for your account:
Maildir - used to store your mails in (don't touch it)
data - You can store application data here that should not be accessible via your site. E.g. configuration or database files.
tmp - anything saved here will automatically be deleted after about 24 hours
www - this is where you upload your website which becomes then available under your domain.
logs - you will find webserver logs here
.ssh - by uploading your ssh public key as authorzed_keys in this folder, you can authenticate to sftp using your ssh key, without a password
My application is very ressource intensive, or I want to host a different service e.g. my own tor relay. Can you get me a VPS?Yes, if you have special requirements, want a dedicated VPS for your application or just want to anonymously support the TOR network (or other networks) without having to deal with server setup etc. I can offer you a managed VPS hosting. However, this will not be for free. It depends on which server you want me to get. For details, contact me
I want to also publish my site on clearnet. Can you offer a clearnet relay?Yes, I can offer you a free subdomain on my server, e.g. yoursite.danwin1210.me, which you can configure in your dashboard. Or if you have your own domain you can use that one, point your DNS settings to the IPs given in your dashboard and contact me for setting up an SSL certificate for your domain.
I'm using CloudFlare, but when I open my site, it shows too many redirects.By default CloudFlare makes unencrypted requests to the backend server, but my server tells any client that wants an insecure connection to upgrade to a secure connection and use https:// instead of http://. CloudFlare just forwards this redirection to the client, which then again asks CloudFlare for the same thing again, but CloudFlare still connects to my server via an insecure http:// connection. To fix this, go to your CloudFlare dashboard and manage your domains settings. Under "Crypto" you can find settings for SSL. Change the setting from Flexible to Full, which makes CloudFlare use a secure https:// connection when talking to my server.
contact me and tell me your sites address where the .htaccess file is. I will then check your .htaccess and convert the rules to NginX rules and apply those.'), CONTACT_URL); ?>
contact me in this case. Also see the previous question.'), CONTACT_URL); ?>
Maildir - used to store your mails in (don't touch it)
data - You can store application data here that should not be accessible via your site. E.g. configuration or database files.
tmp - anything saved here will automatically be deleted after about 24 hours
www - this is where you upload your website which becomes then available under your domain.
logs - you will find webserver logs here
.ssh - by uploading your ssh public key as authorized_keys in this folder, you can authenticate to sftp using your ssh key, without a password"); ?>
contact me'), CONTACT_URL); ?>
contact me for setting up an SSL certificate for your domain.'), CLEARNET_SUBDOMAINS, CONTACT_URL); ?>
diff --git a/var/www/html/files.php b/var/www/html/files.php index ee12163..56e3533 100644 --- a/var/www/html/files.php +++ b/var/www/html/files.php @@ -9,7 +9,7 @@ if(empty($_SESSION['sftp_pass'])){ send_login(); exit; } -$ssh=ssh2_connect('127.0.0.1') or die ('No Connection to SFTP server!'); +$ssh=ssh2_connect('127.0.0.1') or die (_('No Connection to SFTP server!')); if(@!ssh2_auth_password($ssh, $user['system_account'], $_SESSION['sftp_pass'])){ send_login(); exit; @@ -119,21 +119,21 @@ if(!is_dir("ssh2.sftp://$sftp$dir")){ exit; } -if(!empty($_POST['mkdir']) && !empty($_POST['name'])){ +if(isset($_POST['mkdir']) && !empty($_POST['name'])){ if($error=check_csrf_error()){ die($error); } ssh2_sftp_mkdir($sftp, "$dir/$_POST[name]", 0750); } -if(!empty($_POST['mkfile']) && !empty($_POST['name'])){ +if(isset($_POST['mkfile']) && !empty($_POST['name'])){ if($error=check_csrf_error()){ die($error); } file_put_contents("ssh2.sftp://$sftp$dir$_POST[name]", ''); } -if(!empty($_POST['delete']) && !empty($_POST['files'])){ +if(isset($_POST['delete']) && !empty($_POST['files'])){ if($error=check_csrf_error()){ die($error); } @@ -142,7 +142,7 @@ if(!empty($_POST['delete']) && !empty($_POST['files'])){ } } -if(!empty($_POST['rename_2']) && !empty($_POST['files'])){ +if(isset($_POST['rename_2']) && !empty($_POST['files'])){ if($error=check_csrf_error()){ die($error); } @@ -151,7 +151,7 @@ if(!empty($_POST['rename_2']) && !empty($_POST['files'])){ } } -if(!empty($_POST['rename']) && !empty($_POST['files'])){ +if(isset($_POST['rename']) && !empty($_POST['files'])){ if($error=check_csrf_error()){ die($error); } @@ -159,7 +159,7 @@ if(!empty($_POST['rename']) && !empty($_POST['files'])){ exit; } -if(!empty($_POST['edit_2']) && !empty($_POST['files'])){ +if(isset($_POST['edit_2']) && !empty($_POST['files'])){ if($error=check_csrf_error()){ die($error); } @@ -168,7 +168,7 @@ if(!empty($_POST['edit_2']) && !empty($_POST['files'])){ } } -if(!empty($_POST['edit']) && !empty($_POST['files'])){ +if(isset($_POST['edit']) && !empty($_POST['files'])){ if($error=check_csrf_error()){ die($error); } @@ -176,7 +176,7 @@ if(!empty($_POST['edit']) && !empty($_POST['files'])){ exit; } -if(!empty($_POST['unzip']) && !empty($_POST['files'])){ +if(isset($_POST['unzip']) && !empty($_POST['files'])){ if($error=check_csrf_error()){ die($error); } @@ -264,12 +264,12 @@ $style = '.list td:nth-child(3){word-break:break-all;} .list td:nth-child(5){tex .doc{min-width:22px; background:no-repeat url(data:img/gif;base64,R0lGODlhFAAWAPL/AAAAADMzM/8zM5lmM//MM2bM/5mZmf///yH5BAUAAAgALAAAAAAUABYAAARvMMhJJ7oYhcO730F2bV5JhtlZceSBjixBFDT7YedMFxwQ+ECYa1c7AI5IgDAwaDY9hqhBqWE5n9AotVXqHqZCbxdcNSbPHTJXnN72zsl2mC0vcwTmOEdNL/E7eHB1a3R/fXtbAVKLjFE/GXCRSBcRADs=);} .txt{min-width:22px; background:no-repeat url(data:img/gif;base64,R0lGODlhFAAWAPH/AAAAADMzM5mZmf///yH5BAUAAAQALAAAAAAUABYAAANYGLq89JCEQaudIb5pO88R11UiuI3XBXFA61JAEM8nCrtujbeW4AuAmq3yC0puuxcFKBwSjaykcsA8OntQpPTZvFZF2un3iu1ul1kyuuv8Bn7wuE8WkdqNCQA7);} .sh{min-width:22px; background:no-repeat url(data:img/gif;base64,R0lGODlhFAAWAPH/AAAAADMzM5mZmf///yH5BAUAAAQALAAAAAAUABYAAANgGLq89JCEQaudIb5pO88R11UiuFXAkJIXxAEwjAYATZ9UuuZxjPc7imAoAOBUyBHRKBk5hUzR01L8AXuVanPa0b6usWyU2x2rwDLokTzw8tDiNdnNVksCxLx+eIOg0Q8JADs=);}'; -print_header('FileManager - Index of '.$dir, $style); +print_header(sprintf(_('FileManager - Index of %s'), $dir), $style); $dir=htmlspecialchars($dir); ?> -

Index of

+

-

Upload up to 1GB and up to 100 files at once


+


- - -

+ + +

- - - -
+ + + +
- - - + + + - +
FileLast ModifiedSize

">Parent Directory
">

- - - -

+ + + +