Added PHP 7.2 support + minor bugfixes and performance tweaks

Note when applying this update you will have to update existing nginx vhosts to match new listening addresses (IPv6). Preferably you should update them to unix socket though and apply the changes to the tor hidden service config as well
This commit is contained in:
Daniel Winzen
2018-02-10 22:10:07 +01:00
parent c65055a9bb
commit fa24bb61ec
95 changed files with 3075 additions and 59 deletions

View File

@ -172,4 +172,3 @@ function get_system_hash($pass){
}
return crypt($pass, '$6$'.$salt.'$');
}
?>

View File

@ -46,11 +46,14 @@ if($id[5]!=0){
}
$nginx="server {
listen 80;
listen [::]:80;
listen unix:/var/run/nginx.sock;
root /home/$onion.onion/www;
server_name $onion.onion *.$onion.onion;
access_log /var/log/nginx/access_$onion.onion.log custom;
access_log /home/$onion.onion/logs/access.log custom;
error_log /var/log/nginx/error_$onion.onion.log notice;
error_log /home/$onion.onion/logs/error.log notice;
disable_symlinks on from=/home/$onion.onion/www;
autoindex $autoindex;
location / {
@ -67,7 +70,7 @@ listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = ondemand
pm.max_children = 8
pm.max_children = 10
pm.process_idle_timeout = 10s;
php_admin_value[sendmail_path] = '/usr/bin/php /var/www/sendmail_wrapper.php \"$onion.onion <$onion.onion@" . ADDRESS . ">\" | /usr/sbin/sendmail -t -i'
php_admin_value[memory_limit] = 256M
@ -84,10 +87,12 @@ php_admin_value[session.save_path] = /home/$onion.onion/tmp
file_put_contents("/etc/php/7.0/fpm/pool.d/$firstchar/$onion.conf", $php);
}elseif($id[4]==2){
file_put_contents("/etc/php/7.1/fpm/pool.d/$firstchar/$onion.conf", $php);
}elseif($id[4]==3){
file_put_contents("/etc/php/7.2/fpm/pool.d/$firstchar/$onion.conf", $php);
}
//save hidden service
mkdir("/var/lib/tor-instances/$firstchar/hidden_service_$onion.onion");
file_put_contents("/var/lib/tor-instances/$firstchar/hidden_service_$onion.onion/hostname", $onion);
file_put_contents("/var/lib/tor-instances/$firstchar/hidden_service_$onion.onion/hostname", "$onion.onion\n");
file_put_contents("/var/lib/tor-instances/$firstchar/hidden_service_$onion.onion/private_key", $priv_key);
chmod("/var/lib/tor-instances/$firstchar/hidden_service_$onion.onion/", 0700);
chmod("/var/lib/tor-instances/$firstchar/hidden_service_$onion.onion/hostname", 0600);
@ -100,7 +105,7 @@ php_admin_value[session.save_path] = /home/$onion.onion/tmp
chgrp("/var/lib/tor-instances/$firstchar/hidden_service_$onion.onion/private_key", "_tor-$firstchar");
//add hidden service to torrc
$torrc=file_get_contents("/etc/tor/instances/$firstchar/torrc");
$torrc.="HiddenServiceDir /var/lib/tor-instances/$firstchar/hidden_service_$onion.onion/\nHiddenServicePort 80 127.0.0.1:80\nHiddenServicePort 25 127.0.0.1:25\n";
$torrc.="HiddenServiceDir /var/lib/tor-instances/$firstchar/hidden_service_$onion.onion/\nHiddenServicePort 80 unix:/var/run/nginx.sock\nHiddenServicePort 25 127.0.0.1:25\n";
file_put_contents("/etc/tor/instances/$firstchar/torrc", $torrc);
//remove from to-add queue
$del->execute([$onion]);
@ -120,10 +125,13 @@ foreach($onions as $onion){
if(file_exists("/etc/php/7.1/fpm/pool.d/$firstchar/$onion[0].conf")){
unlink("/etc/php/7.1/fpm/pool.d/$firstchar/$onion[0].conf");
}
if(file_exists("/etc/php/7.2/fpm/pool.d/$firstchar/$onion[0].conf")){
unlink("/etc/php/7.2/fpm/pool.d/$firstchar/$onion[0].conf");
}
unlink("/etc/nginx/sites-enabled/$onion[0].onion");
//clean torrc from user
$torrc=file_get_contents("/etc/tor/instances/$firstchar/torrc");
$torrc=str_replace("HiddenServiceDir /var/lib/tor-instances/$firstchar/hidden_service_$onion[0].onion/\nHiddenServicePort 80 127.0.0.1:80\nHiddenServicePort 25 127.0.0.1:25\n", '', $torrc);
$torrc=str_replace("HiddenServiceDir /var/lib/tor-instances/$firstchar/hidden_service_$onion[0].onion/\nHiddenServicePort 80 unix:/var/run/nginx.sock\nHiddenServicePort 25 127.0.0.1:25\n", '', $torrc);
file_put_contents("/etc/tor/instances/$firstchar/torrc", $torrc);
//delete hidden service from tor
unlink("/var/lib/tor-instances/$firstchar/hidden_service_$onion[0].onion/hostname");
@ -134,8 +142,9 @@ foreach($onions as $onion){
//reload services
foreach($reload as $key => $val){
exec('service nginx reload');
exec("service php7.0-fpm@$key reload");
exec("service php7.1-fpm@$key reload");
exec("service php7.0-fpm@$key restart");
exec("service php7.1-fpm@$key restart");
exec("service php7.2-fpm@$key restart");
exec("service tor@$key reload");
}
@ -162,4 +171,3 @@ while($onion=$stmt->fetch(PDO::FETCH_NUM)){
exec('usermod -p '. escapeshellarg($onion[1]) . " $onion[0].onion");
$del->execute([$onion[0]]);
}
?>

View File

@ -24,7 +24,8 @@ header('Content-Type: text/html; charset=UTF-8');
<!DOCTYPE html><html><head>
<title>Daniel's Hosting - Delete account</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name="author" content="Daniel Winzen">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head><body>
<p>This will delete your account and all data asociated with it. It can't be un-done. Are you sure?</p>
<?php echo $msg; ?>

View File

@ -65,6 +65,7 @@ const TYPES=[
'xml'=>'doc',
'doc'=>'doc',
'docx'=>'doc',
'css'=>'doc',
'html'=>'doc',
'htm'=>'doc',
'shtml'=>'doc',
@ -131,7 +132,7 @@ if(!empty($_POST['mkfile']) && !empty($_POST['name'])){
$tmpfile='/tmp/'.uniqid();
touch($tmpfile);
ftp_put($ftp, $_POST['name'], $tmpfile, FTP_BINARY);
unlink($tmpflie);
unlink($tmpfile);
}
if(!empty($_POST['delete']) && !empty($_POST['files'])){

View File

@ -54,4 +54,3 @@ echo '<tr><td>Today</td><td><a href="log.php?type=access&amp;old=0" target="_bla
echo '<tr><td>Yesterday</td><td><a href="log.php?type=access&amp;old=1" target="_blank">access.log</log></td><td><a href="log.php?type=error&amp;old=1" target="_blank">error.log</a></td></tr>';
echo '</table>';
echo '</body></html>';
?>

View File

@ -1,18 +1,28 @@
<?php
include('../common.php');
header('Content-Type: text/html; charset=UTF-8');
if(isset($_SERVER['HTTP_HOST']) && preg_match('/danwin1210\.(i2p|me)$/', $_SERVER['HTTP_HOST'])){
if(preg_match('/\.me$/', $_SERVER['HTTP_HOST'])){
$host='https://danwin1210.me';
}else{
$host='http://danwin1210.i2p';
}
}else{
$host='http://tt3j2x4k5ycaa5zt.onion';
}
?>
<!DOCTYPE html><html><head>
<title>Daniel's Hosting</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name="author" content="Daniel Winzen">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head><body>
<p>Info | <a href="register.php">Register</a> | <a href="login.php">Login</a> | <a href="list.php">List of hosted sites</a> | <a href="faq.php">FAQ</a></p>
<p>Here you can get yourself a hosting account on my server.</p>
<p>What you will get:</p>
<ul>
<li>Free anonymous webhosting</li>
<li>Chose between PHP 7.0, 7.1 or no PHP support</li>
<li>Chose between PHP 7.0, 7.1, 7.2 or no PHP support</li>
<li>Nginx Webserver</li>
<li>SQLite support</li>
<li>1 MariaDB (MySQL) database</li>
@ -26,7 +36,7 @@ header('Content-Type: text/html; charset=UTF-8');
<li>Mail sent to anything@your.onion gets automatically redirected to your inbox</li>
<li>Your own .onion address</li>
<li>On request your own clearnet domain or a free subdomain of danwin1210.me. I can setup an I2P domain as well.</li>
<li>There is a missing feature or you need a special configuration? Just <a href="http://tt3j2x4k5ycaa5zt.onion/contact.php">contact me</a> and I'll see what I can do.</li>
<li>There is a missing feature or you need a special configuration? Just <a href="<?php echo "$host/contact.php"; ?>">contact me</a> and I'll see what I can do.</li>
<li>Empty/Unused accounts will be automatically deleted after a month</li>
<li>More to come…</li>
</ul>

View File

@ -25,4 +25,3 @@ while($tmp=$stmt->fetch(PDO::FETCH_NUM)){
}
echo '</table>';
echo '</body></html>';
?>

View File

@ -73,7 +73,8 @@ if($_SERVER['REQUEST_METHOD']==='POST'){
echo '<!DOCTYPE html><html><head>';
echo '<title>Daniel\'s Hosting - Login</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
echo '<meta name=viewport content="width=device-width, initial-scale=1">';
echo '<meta name="author" content="Daniel Winzen">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '</head><body>';
echo '<p><a href="index.php">Info</a> | <a href="register.php">Register</a> | Login | <a href="list.php">List of hosted sites</a> | <a href="faq.php">FAQ</a></p>';
echo $msg;
@ -91,4 +92,3 @@ echo '<tr><td colspan="2"><input type="submit" value="Login"></td></tr>';
echo '</table></form>';
echo '<p>If you disabled cookies, please re-enable them. You currently can\'t log in without</p>';
echo '</body></html>';
?>

View File

@ -2,4 +2,3 @@
session_start();
session_destroy();
header('Location: login.php');
?>

View File

@ -28,7 +28,7 @@ if($_SERVER['REQUEST_METHOD']==='POST'){
$stmt->execute([$user['onion'], $hash]);
$msg.='<p style="color:green;">Successfully changed system account password, change will take affect within the next minute.</p>';
}elseif($_REQUEST['type']==='sql'){
$stmt=$db->prepare("SET PASSWORD FOR '$user[onion].onion'@'localhost'=PASSWORD(?);");
$stmt=$db->prepare("SET PASSWORD FOR '$user[onion].onion'@'%'=PASSWORD(?);");
$stmt->execute([$_POST['newpass']]);
$db->exec('FLUSH PRIVILEGES;');
$msg.='<p style="color:green;">Successfully changed sql password.</p>';
@ -41,7 +41,8 @@ header('Content-Type: text/html; charset=UTF-8');
echo '<!DOCTYPE html><html><head>';
echo '<title>Daniel\'s Hosting - Change password</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
echo '<meta name=viewport content="width=device-width, initial-scale=1">';
echo '<meta name="author" content="Daniel Winzen">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '</head><body>';
echo $msg;
echo '<form method="POST" action="password.php"><table>';
@ -69,4 +70,3 @@ echo '<tr><td colspan="2"><input type="submit" value="Reset"></td></tr>';
echo '</table></form>';
echo '<p><a href="home.php">Go back to dashboard.</a></p>';
echo '</body></html>';
?>

View File

@ -14,7 +14,8 @@ if(!empty($_SESSION['hosting_username'])){
echo '<!DOCTYPE html><html><head>';
echo '<title>Daniel\'s Hosting - Register</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
echo '<meta name=viewport content="width=device-width, initial-scale=1">';
echo '<meta name="author" content="Daniel Winzen">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '</head><body>';
echo '<p><a href="index.php">Info</a> | Register | <a href="login.php">Login</a> | <a href="list.php">List of hosted sites</a> | <a href="faq.php">FAQ</a></p>';
if($_SERVER['REQUEST_METHOD']==='POST'){
@ -107,7 +108,7 @@ if($_SERVER['REQUEST_METHOD']==='POST'){
if(isset($_POST['public']) && $_POST['public']==1){
$public=1;
}
if(isset($_POST['php']) && in_array($_POST['php'], [1, 2])){
if(isset($_POST['php']) && in_array($_POST['php'], [1, 2, 3])){
$php=$_POST['php'];
}
if(isset($_POST['autoindex']) && $_POST['autoindex']==1){
@ -156,7 +157,7 @@ if($_SERVER['REQUEST_METHOD']!=='POST' || (isset($_POST['public']) && $_POST['pu
}else{
$public='';
}
if(isset($_POST['autoindex']) && $_POST['public']==1){
if(isset($_POST['autoindex']) && $_POST['autoindex']==1){
$autoindex=' checked';
}else{
$autoindex='';
@ -164,14 +165,17 @@ if(isset($_POST['autoindex']) && $_POST['public']==1){
$nophp='';
$php70='';
$php71='';
$php72='';
if(isset($_POST['php']) && $_POST['php']==0){
$nophp=' selected';
}elseif(isset($_POST['php']) && $_POST['php']==1){
$php70=' selected';
}elseif(isset($_POST['php']) && $_POST['php']==2){
$php71=' selected';
}else{
$php70=' selected';
$php72=' selected';
}
echo '<tr><td>PHP version</td><td><select name="php"><option value="0"'.$nophp.'>None</option><option value="1" '.$php70.'>PHP 7.0</option><option value="2"'.$php71.'>PHP 7.1</option></select></td></tr>';
echo '<tr><td>PHP version</td><td><select name="php"><option value="0"'.$nophp.'>None</option><option value="1" '.$php70.'>PHP 7.0</option><option value="2"'.$php71.'>PHP 7.1</option><option value="3"'.$php72.'>PHP 7.2</option></select></td></tr>';
echo '<tr><td colspan=2><label><input type="checkbox" name="public" value="1"'.$public.'>Publish site on list of hosted sites</label></td></tr>';
echo '<tr><td colspan=2><label><input type="checkbox" name="autoindex" value="1"'.$autoindex.'>Enable autoindex (listing of files)</label></td></tr>';
echo '<tr><td>Custom private key<br>(optional)</td><td><textarea name="private_key" rows="5" cols="28">';