Compare commits

...

23 Commits

Author SHA1 Message Date
71dd2804fb Merge pull request #151 from 011248163264/patch-5
Update common.php
2026-03-06 14:58:51 +01:00
afd879a494 Merge branch 'master' into patch-5 2026-03-06 14:58:41 +01:00
8b038d913a Merge pull request #158 from 011248163264/master
Update cron.php
2026-03-06 14:57:57 +01:00
3016e14717 Merge pull request #152 from 011248163264/patch-6
Update index.php
2026-03-06 14:57:43 +01:00
8865b649e8 Merge pull request #153 from 011248163264/patch-7
Update home.php
2026-03-06 14:57:32 +01:00
09591293d0 Merge pull request #154 from 011248163264/patch-9
Update common.php
2026-03-06 14:57:20 +01:00
656eb3aaa5 Merge pull request #155 from 011248163264/patch-8
Update setup.php
2026-03-06 14:57:08 +01:00
c6f4a97ed5 Merge pull request #156 from 011248163264/patch-10
Update home.php
2026-03-06 14:56:55 +01:00
d8865acd7f Merge pull request #157 from 011248163264/patch-11
Update list.php
2026-03-06 14:56:40 +01:00
Lin
900d65c4f0 Update cron.php
the default hosting page is generated with site_name and address from the common.php
2026-02-25 20:08:29 +01:00
Lin
5ad393b982 Update list.php
added select with description, only visible when PUB_ONION_DESC = 1 in common.php
2026-02-25 17:49:33 +01:00
Lin
87c1d317d6 Update home.php
added description to select and update, added description field
2026-02-25 17:37:08 +01:00
Lin
af5490dc7c Update common.php
added const for public onion description, when enabled desc shows on list.php
2026-02-25 14:50:27 +01:00
Lin
539a31f567 Update setup.php
added column description for onion domains, used later in home.php and can also enabled or disabled on public onion list.php via common.php
2026-02-25 14:45:09 +01:00
Lin
22442e5dc9 Update home.php
added condition, when CLEARNET = 0 then disable clearnet option on home.php
2026-02-25 14:31:01 +01:00
Lin
0232395710 Update index.php
added backlink
2026-02-25 14:27:39 +01:00
Lin
a52eb82fdc Update common.php
added option to disable clearnet on home.php
added software_url backlink in the footer
2026-02-25 14:26:23 +01:00
608dd188dd Merge pull request #148 from 011248163264/patch-2
Update common.php
2026-02-24 19:45:08 +01:00
f8916e1919 Merge pull request #150 from 011248163264/patch-4
Update index.php
2026-02-24 19:44:57 +01:00
094ddf9b07 Merge pull request #149 from 011248163264/patch-3
Update index.php
2026-02-24 19:44:45 +01:00
Lin
ab68082f18 Update index.php
When a sitename is changed in common.php the site name on index.php is now also changed
2026-02-24 19:24:44 +01:00
Lin
1fbbaa92c7 Update index.php
added const copyright and disclaimer
2026-02-24 18:49:17 +01:00
Lin
73cd0c1c1f Update common.php
added copyright and disclaimerm for index.php, is only visible when not null
2026-02-24 18:48:10 +01:00
6 changed files with 91 additions and 14 deletions

View File

@@ -13,6 +13,8 @@ const SERVERS=[ //servers and ports we are running on
'dhosting4xxoydyaivckq7tsmtgi4wfs3flpeyitekkmqwu4v4r46syd.onion'=>['sftp'=>22, 'pop3'=>'110', 'imap'=>'143', 'smtp'=>'25'], 'dhosting4xxoydyaivckq7tsmtgi4wfs3flpeyitekkmqwu4v4r46syd.onion'=>['sftp'=>22, 'pop3'=>'110', 'imap'=>'143', 'smtp'=>'25'],
'hosting.danwin1210.me'=>['sftp'=>22, 'pop3'=>'995', 'imap'=>'993', 'smtp'=>'465'] 'hosting.danwin1210.me'=>['sftp'=>22, 'pop3'=>'995', 'imap'=>'993', 'smtp'=>'465']
]; ];
const COPYRIGHT='';
const DISCLAIMER='';
const EMAIL_TO=''; //Send email notifications about new registrations to this address 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 considered as unchanged for deletion const INDEX_MD5S=[ //MD5 sums of index.hosting.html files that should be considered as unchanged for deletion
'd41d8cd98f00b204e9800998ecf8427e', //empty file 'd41d8cd98f00b204e9800998ecf8427e', //empty file
@@ -89,6 +91,9 @@ 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 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 CONTACT_URL = 'https://danwin1210.de/contact.php'; //url to contact form
const PRIVACY_URL = 'https://danwin1210.de/privacy.php'; //url to privacy policy const PRIVACY_URL = 'https://danwin1210.de/privacy.php'; //url to privacy policy
const SOFTWARE_URL = 'https://github.com/DanWin/hosting';
const CLEARNET = '0'; // clearnet enabled = 1 or 0 disabled
const PUB_ONION_DESC = '0'; //enable public onion description, 0 = disabled, 1 = enabled
const CLEARNET_A = '116.202.17.147'; // IPv4 Address of your clearnet gateway 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_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_ADDRESS = 'hosting.danwin1210.me'; //Domain under which the service is reachable in clearnet

View File

@@ -36,7 +36,36 @@ while($account=$stmt->fetch(PDO::FETCH_ASSOC)){
$reload[$account['instance']] = true; $reload[$account['instance']] = true;
//add and manage rights of system user //add and manage rights of system user
$shell = ENABLE_SHELL_ACCESS ? '/bin/bash' : '/usr/sbin/nologin'; $shell = ENABLE_SHELL_ACCESS ? '/bin/bash' : '/usr/sbin/nologin';
exec('useradd -l -g www-data -k /var/www/skel -m -s ' . escapeshellarg($shell) . ' ' . escapeshellarg($system_account)); exec('useradd -l -g www-data -m -s ' . escapeshellarg($shell) . ' ' . escapeshellarg($system_account));
//generate default hosting page
$home = "/home/$system_account";
$dir = "$home/www";
$file = "$dir/index.hosting.html";
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
$content = sprintf(
'<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Site hosted by %s service</title>
<meta name="robots" content="noindex">
</head>
<body>
<p>This site is hosted by <a href="http://%s" target="_blank" rel="noopener">%s service</a>.</p>
</body>
</html>',
htmlspecialchars(SITE_NAME, ENT_QUOTES, 'UTF-8'),
htmlspecialchars(ADDRESS, ENT_QUOTES, 'UTF-8'),
htmlspecialchars(SITE_NAME, ENT_QUOTES, 'UTF-8')
);
file_put_contents($file, $content);
chown($dir, $system_account);
chgrp($dir, 'www-data');
chown($file, $system_account);
chgrp($file, 'www-data');
////////
update_system_user_password($system_account, $account['password']); update_system_user_password($system_account, $account['password']);
setup_chroot($system_account, $last_account); setup_chroot($system_account, $last_account);
$last_account = $system_account; $last_account = $system_account;

View File

@@ -131,10 +131,15 @@ if(isset($_REQUEST['action']) && isset($_REQUEST['onion']) && $_REQUEST['action'
if($error=check_csrf_error()){ if($error=check_csrf_error()){
die($error); die($error);
} }
$stmt=$db->prepare('SELECT onions.version, onions.instance FROM onions INNER JOIN users ON (users.id=onions.user_id) WHERE onions.onion = ? AND users.id = ? AND onions.enabled IN (0, 1);'); //$stmt=$db->prepare('SELECT onions.version, onions.instance FROM onions INNER JOIN users ON (users.id=onions.user_id) WHERE onions.onion = ? AND users.id = ? AND onions.enabled IN (0, 1);');
$stmt=$db->prepare('SELECT onions.version, onions.instance, onions.description FROM onions INNER JOIN users ON (users.id=onions.user_id) WHERE onions.onion = ? AND users.id = ? AND onions.enabled IN (0, 1);');
$description = trim($_POST['description'] ?? $_REQUEST['description'] ?? '');
$description = mb_substr($description, 0, 50); // Limit 50
$stmt->execute([$_REQUEST['onion'], $user['id']]); $stmt->execute([$_REQUEST['onion'], $user['id']]);
if($onion=$stmt->fetch(PDO::FETCH_ASSOC)){ if($onion=$stmt->fetch(PDO::FETCH_ASSOC)){
$stmt=$db->prepare('UPDATE onions SET enabled = ?, enable_smtp = ?, num_intros = ?, max_streams = ? WHERE onion = ?;'); //$stmt=$db->prepare('UPDATE onions SET enabled = ?, enable_smtp = ?, num_intros = ?, max_streams = ? WHERE onion = ?;');
$stmt=$db->prepare('UPDATE onions SET enabled = ?,enable_smtp = ?,num_intros = ?,max_streams = ?,description = ?WHERE onion = ?;');
$enabled = isset($_REQUEST['enabled']) ? 1 : 0; $enabled = isset($_REQUEST['enabled']) ? 1 : 0;
$enable_smtp = isset($_REQUEST['enable_smtp']) ? 1 : 0; $enable_smtp = isset($_REQUEST['enable_smtp']) ? 1 : 0;
$num_intros = intval($_REQUEST['num_intros']); $num_intros = intval($_REQUEST['num_intros']);
@@ -151,7 +156,8 @@ if(isset($_REQUEST['action']) && isset($_REQUEST['onion']) && $_REQUEST['action'
}elseif($max_streams>65535){ }elseif($max_streams>65535){
$max_streams = 65535; $max_streams = 65535;
} }
$stmt->execute([$enabled, $enable_smtp, $num_intros, $max_streams, $_REQUEST['onion']]); //$stmt->execute([$enabled, $enable_smtp, $num_intros, $max_streams, $_REQUEST['onion']]);
$stmt->execute([$enabled,$enable_smtp,$num_intros,$max_streams,$description,$_REQUEST['onion']]);
enqueue_instance_reload($onion['instance']); enqueue_instance_reload($onion['instance']);
} }
} }
@@ -176,8 +182,10 @@ if(!empty($msg)){
echo '<p>'.sprintf(_('Enter system account password to check your %s mail:'), $user['system_account'].'@' . ADDRESS).'</td><td><form action="squirrelmail/src/redirect.php" method="post" target="_blank"><input type="hidden" name="login_username" value="'.$user['system_account'].'"><input type="password" name="secretkey"><button type="submit">'._('Login to webmail').'</button></form></p>'; echo '<p>'.sprintf(_('Enter system account password to check your %s mail:'), $user['system_account'].'@' . ADDRESS).'</td><td><form action="squirrelmail/src/redirect.php" method="post" target="_blank"><input type="hidden" name="login_username" value="'.$user['system_account'].'"><input type="password" name="secretkey"><button type="submit">'._('Login to webmail').'</button></form></p>';
echo '<h3>'._('Onion domains').'</h3>'; echo '<h3>'._('Onion domains').'</h3>';
echo '<table border="1">'; echo '<table border="1">';
echo '<tr><th>'._('Onion').'</th><th>'._('Private key').'</th><th>'._('Enabled').'</th><th>'._('SMTP enabled').'</th><th>'._('Nr. of intros').'</th><th>'._('Max streams per rend circuit').'</th><th>'._('Action').'</th></tr>'; //echo '<tr><th>'._('Onion').'</th><th>'._('Private key').'</th><th>'._('Enabled').'</th><th>'._('SMTP enabled').'</th><th>'._('Nr. of intros').'</th><th>'._('Max streams per rend circuit').'</th><th>'._('Action').'</th></tr>';
$stmt=$db->prepare('SELECT onion, private_key, enabled, enable_smtp, num_intros, max_streams FROM onions WHERE user_id = ?;'); echo '<tr><th>'._('Onion').'</th><th>'._('Private key').'</th><th>'._('Enabled').'</th><th>'._('SMTP enabled').'</th><th>'._('Nr. of intros').'</th><th>'._('Max streams per rend circuit').'</th><th>'._('Description').'</th><th>'._('Action').'</th></tr>';
//$stmt=$db->prepare('SELECT onion, private_key, enabled, enable_smtp, num_intros, max_streams FROM onions WHERE user_id = ?;');
$stmt=$db->prepare('SELECT onion, private_key, enabled, enable_smtp, num_intros, max_streams, description FROM onions WHERE user_id = ?;');
$stmt->execute([$user['id']]); $stmt->execute([$user['id']]);
$count_onions = 0; $count_onions = 0;
while($onion=$stmt->fetch(PDO::FETCH_ASSOC)){ while($onion=$stmt->fetch(PDO::FETCH_ASSOC)){
@@ -196,6 +204,8 @@ while($onion=$stmt->fetch(PDO::FETCH_ASSOC)){
echo '>'._('Enabled').'</label></td>'; echo '>'._('Enabled').'</label></td>';
echo '<td><input type="number" name="num_intros" min="3" max="20" value="'.$onion['num_intros'].'"></td>'; echo '<td><input type="number" name="num_intros" min="3" max="20" value="'.$onion['num_intros'].'"></td>';
echo '<td><input type="number" name="max_streams" min="0" max="65535" value="'.$onion['max_streams'].'"></td>'; echo '<td><input type="number" name="max_streams" min="0" max="65535" value="'.$onion['max_streams'].'"></td>';
//added description
echo '<td><input type="text" name="description" maxlength="50" value="'.htmlspecialchars($onion['description'] ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8').'"></td>';
if(in_array($onion['enabled'], [0, 1])){ if(in_array($onion['enabled'], [0, 1])){
echo '<td><button type="submit" name="action" value="edit_onion">'._('Save').'</button>'; echo '<td><button type="submit" name="action" value="edit_onion">'._('Save').'</button>';
echo '<button type="submit" name="action" value="del_onion">'._('Delete').'</button></td>'; echo '<button type="submit" name="action" value="del_onion">'._('Delete').'</button></td>';
@@ -206,7 +216,8 @@ while($onion=$stmt->fetch(PDO::FETCH_ASSOC)){
} }
if($count_onions<MAX_NUM_USER_ONIONS){ if($count_onions<MAX_NUM_USER_ONIONS){
echo "<form action=\"home.php\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"$_SESSION[csrf_token]\">"; echo "<form action=\"home.php\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"$_SESSION[csrf_token]\">";
echo '<tr><td colspan="6">'._('Add additional hidden service:').'<br>'; //echo '<tr><td colspan="6">'._('Add additional hidden service:').'<br>';
echo '<tr><td colspan="7">'._('Add additional hidden service:').'<br>';
echo '<label><input type="radio" name="onion_type" value="3"'; echo '<label><input type="radio" name="onion_type" value="3"';
echo (!isset($_POST['onion_type']) || $_POST['onion_type']==3) ? ' checked' : ''; echo (!isset($_POST['onion_type']) || $_POST['onion_type']==3) ? ' checked' : '';
echo '>'._('Random v3 Address').'</label>'; echo '>'._('Random v3 Address').'</label>';
@@ -219,6 +230,7 @@ if($count_onions<MAX_NUM_USER_ONIONS){
echo '</label></td><td><button type="submit" name="action" value="add_onion">'._('Add onion').'</button></td></tr></form>'; echo '</label></td><td><button type="submit" name="action" value="add_onion">'._('Add onion').'</button></td></tr></form>';
} }
echo '</table>'; echo '</table>';
if (defined('CLEARNET') && CLEARNET !== '0'):
if(MAX_NUM_USER_DOMAINS>0){ if(MAX_NUM_USER_DOMAINS>0){
echo '<h3>'._('Clearnet domains').'</h3>'; echo '<h3>'._('Clearnet domains').'</h3>';
echo '<table border="1">'; echo '<table border="1">';
@@ -251,6 +263,7 @@ if(MAX_NUM_USER_DOMAINS>0){
echo '</table>'; echo '</table>';
echo '<p>'.sprintf(_('To enable your clearnet domain, edit your DNS settings and enter %1$s as your A record and %2$s as your AAAA record. Once you have modified your DNS settings, <a href="%3$s" target="_blank">contact me</a> to configure the SSL certificate. You may also use any subdomain of %4$s'), CLEARNET_A, CLEARNET_AAAA, CONTACT_URL, CLEARNET_SUBDOMAINS).'</p>'; echo '<p>'.sprintf(_('To enable your clearnet domain, edit your DNS settings and enter %1$s as your A record and %2$s as your AAAA record. Once you have modified your DNS settings, <a href="%3$s" target="_blank">contact me</a> to configure the SSL certificate. You may also use any subdomain of %4$s'), CLEARNET_A, CLEARNET_AAAA, CONTACT_URL, CLEARNET_SUBDOMAINS).'</p>';
} }
endif;
echo '<h3>'._('MySQL Database').'</h3>'; echo '<h3>'._('MySQL Database').'</h3>';
echo '<table border="1">'; echo '<table border="1">';
echo '<tr><th>'._('Database').'</th><th>'._('Host').'</th><th>'._('User').'</th><th>'._('Action').'</th></tr>'; echo '<tr><th>'._('Database').'</th><th>'._('Host').'</th><th>'._('User').'</th><th>'._('Action').'</th></tr>';

View File

@@ -3,7 +3,7 @@ require('../common.php');
header('Content-Type: text/html; charset=UTF-8'); header('Content-Type: text/html; charset=UTF-8');
print_header(_('Info')); print_header(_('Info'));
?> ?>
<h1><?php echo _('Hosting - Info'); ?></h1> <h1><?php echo _(SITE_NAME); ?> - Info</h1>
<?php main_menu('index.php'); ?> <?php main_menu('index.php'); ?>
<p><?php echo _('Here you can get yourself a free web hosting account on my server.'); ?></p> <p><?php echo _('Here you can get yourself a free web hosting account on my server.'); ?></p>
<h2><?php echo _('What you get:'); ?></h2> <h2><?php echo _('What you get:'); ?></h2>
@@ -27,6 +27,19 @@ print_header(_('Info'));
<li><?php printf(_('There is a missing feature, or you need a special configuration? Just <a href="%s">contact me</a> and I\'ll see what I can do.'), CONTACT_URL); ?></li> <li><?php printf(_('There is a missing feature, or you need a special configuration? Just <a href="%s">contact me</a> and I\'ll see what I can do.'), CONTACT_URL); ?></li>
<li><?php echo _('More to come…'); ?></li> <li><?php echo _('More to come…'); ?></li>
</ul> </ul>
<?php if (defined('COPYRIGHT') && COPYRIGHT !== ''): ?>
<h2><?php echo _('Copyright'); ?></h2>
<ul>
<li><?php echo _(COPYRIGHT); ?></li>
</ul>
<?php endif; ?>
<?php if (defined('DISCLAIMER') && DISCLAIMER !== ''): ?>
<h2><?php echo _('Disclaimer'); ?></h2>
<ul>
<li><?php echo _(DISCLAIMER); ?></li>
</ul>
<?php endif; ?>
<h2><?php echo _('Rules'); ?></h2> <h2><?php echo _('Rules'); ?></h2>
<ul> <ul>
<li><?php echo _('No child pornography!'); ?></li> <li><?php echo _('No child pornography!'); ?></li>
@@ -41,4 +54,5 @@ print_header(_('Info'));
<li><?php echo _('I preserve the right to delete any site for violating these rules and adding new rules at any time.'); ?></li> <li><?php echo _('I preserve the right to delete any site for violating these rules and adding new rules at any time.'); ?></li>
<li><?php echo _('Should you not honor these rules, I will (have to) work together with Law Enforcement!'); ?></li> <li><?php echo _('Should you not honor these rules, I will (have to) work together with Law Enforcement!'); ?></li>
</ul> </ul>
<?php printf(_('<a href="%s" target="_blank" rel="noopener noreferrer">Based on Daniels Hosting</a>'), SOFTWARE_URL); ?>
</body></html> </body></html>

View File

@@ -3,6 +3,7 @@ require_once('../common.php');
header('Content-Type: text/html; charset=UTF-8'); header('Content-Type: text/html; charset=UTF-8');
$db = get_db_instance(); $db = get_db_instance();
print_header(_('List of hosted sites'), 'td{padding:5px;}', '_blank'); print_header(_('List of hosted sites'), 'td{padding:5px;}', '_blank');
$show_desc = (defined('PUB_ONION_DESC') && (string)PUB_ONION_DESC === '1');
?> ?>
<h1><?php echo _('Hosting - List of hosted sites'); ?></h1> <h1><?php echo _('Hosting - List of hosted sites'); ?></h1>
<?php <?php
@@ -13,11 +14,26 @@ $stmt=$db->query('SELECT COUNT(*) FROM users WHERE public=0;');
$hidden=$stmt->fetch(PDO::FETCH_NUM); $hidden=$stmt->fetch(PDO::FETCH_NUM);
echo '<p>'.sprintf(_('Here is a list of %1$d public hosted sites (%2$d sites hidden):'), $count[0], $hidden[0]).'</p>'; echo '<p>'.sprintf(_('Here is a list of %1$d public hosted sites (%2$d sites hidden):'), $count[0], $hidden[0]).'</p>';
echo '<table border="1">'; echo '<table border="1">';
echo '<tr><td>'._('Onion link').'</td></tr>'; echo '<tr><td>'._('Onion link').'</td>';
$stmt=$db->query('SELECT onions.onion FROM users INNER JOIN onions ON (onions.user_id=users.id) WHERE users.public=1 ORDER BY onions.onion;'); if ($show_desc) {
while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ echo '<td>'._('Description').'</td>';
echo "<tr><td><a href=\"http://$tmp[0].onion\">$tmp[0].onion</a></td></tr>";
} }
echo '</tr>';
// description only when PUB_ONION_DESC = 1 in common.php
if ($show_desc) {
$stmt=$db->query('SELECT onions.onion, onions.description FROM users INNER JOIN onions ON (onions.user_id=users.id) WHERE users.public=1 ORDER BY onions.onion;');
while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
$onion = $row['onion'];
$desc = htmlspecialchars($row['description'] ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
echo "<tr><td><a href=\"http://$onion.onion\">$onion.onion</a></td><td>$desc</td></tr>";
}
} else {
$stmt=$db->query('SELECT onions.onion FROM users INNER JOIN onions ON (onions.user_id=users.id) WHERE users.public=1 ORDER BY onions.onion;');
while($row=$stmt->fetch(PDO::FETCH_NUM)){
$onion = $row[0];
echo "<tr><td><a href=\"http://$onion.onion\">$onion.onion</a></td></tr>";
}
}
echo '</table>';
?> ?>
</table>
</body></html> </body></html>

View File

@@ -25,7 +25,7 @@ if(!$version){
$db->exec("CREATE TABLE new_account (user_id int(11) NOT NULL PRIMARY KEY, password varchar(255) COLLATE latin1_bin NOT NULL, approved tinyint(1) UNSIGNED NOT NULL DEFAULT '0', CONSTRAINT new_account_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;"); $db->exec("CREATE TABLE new_account (user_id int(11) NOT NULL PRIMARY KEY, password varchar(255) COLLATE latin1_bin NOT NULL, approved tinyint(1) UNSIGNED NOT NULL DEFAULT '0', CONSTRAINT new_account_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
$db->exec('CREATE TABLE pass_change (user_id int(11) NOT NULL PRIMARY KEY, password varchar(255) COLLATE latin1_bin NOT NULL, CONSTRAINT pass_change_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;'); $db->exec('CREATE TABLE pass_change (user_id int(11) NOT NULL PRIMARY KEY, password varchar(255) COLLATE latin1_bin NOT NULL, CONSTRAINT pass_change_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;');
$db->exec('CREATE TABLE mysql_databases (user_id int(11) NOT NULL, mysql_database varchar(64) COLLATE latin1_bin NOT NULL, KEY user_id (user_id), CONSTRAINT mysql_database_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;'); $db->exec('CREATE TABLE mysql_databases (user_id int(11) NOT NULL, mysql_database varchar(64) COLLATE latin1_bin NOT NULL, KEY user_id (user_id), CONSTRAINT mysql_database_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;');
$db->exec("CREATE TABLE onions (user_id int(11) NULL, onion varchar(56) COLLATE latin1_bin NOT NULL PRIMARY KEY, private_key varchar(1000) COLLATE latin1_bin NOT NULL, version tinyint(1) NOT NULL, enabled tinyint(1) NOT NULL DEFAULT '1', num_intros tinyint(3) NOT NULL DEFAULT '3', enable_smtp tinyint(1) NOT NULL DEFAULT '1', max_streams tinyint(3) unsigned NOT NULL DEFAULT '6', instance char(1) NOT NULL DEFAULT '2', KEY user_id (user_id), KEY enabled (enabled), KEY instance(instance), CONSTRAINT onions_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT instance_ibfk_1 FOREIGN KEY (instance) REFERENCES service_instances (id) ON DELETE RESTRICT ON UPDATE RESTRICT) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;"); $db->exec("CREATE TABLE onions (user_id int(11) NULL, onion varchar(56) COLLATE latin1_bin NOT NULL PRIMARY KEY, description varchar(100) COLLATE latin1_bin NULL, private_key varchar(1000) COLLATE latin1_bin NOT NULL, version tinyint(1) NOT NULL, enabled tinyint(1) NOT NULL DEFAULT '1', num_intros tinyint(3) NOT NULL DEFAULT '3', enable_smtp tinyint(1) NOT NULL DEFAULT '1', max_streams tinyint(3) unsigned NOT NULL DEFAULT '6', instance char(1) NOT NULL DEFAULT '2', KEY user_id (user_id), KEY enabled (enabled), KEY instance(instance), CONSTRAINT onions_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT instance_ibfk_1 FOREIGN KEY (instance) REFERENCES service_instances (id) ON DELETE RESTRICT ON UPDATE RESTRICT) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
$db->exec("CREATE TABLE domains (user_id int(11) NULL, domain varchar(255) COLLATE latin1_bin NOT NULL PRIMARY KEY, enabled tinyint(1) NOT NULL DEFAULT '1', KEY user_id (user_id), KEY enabled (enabled), CONSTRAINT domains_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;"); $db->exec("CREATE TABLE domains (user_id int(11) NULL, domain varchar(255) COLLATE latin1_bin NOT NULL PRIMARY KEY, enabled tinyint(1) NOT NULL DEFAULT '1', KEY user_id (user_id), KEY enabled (enabled), CONSTRAINT domains_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
$db->exec("CREATE TABLE disk_quota (user_id int(11) NOT NULL, quota_size int(10) unsigned NOT NULL, quota_files int(10) unsigned NOT NULL, updated tinyint(1) NOT NULL DEFAULT 1, quota_size_used int(10) unsigned NOT NULL DEFAULT '0', quota_files_used int(10) unsigned NOT NULL DEFAULT '0', KEY user_id (user_id), KEY updated (updated), CONSTRAINT disk_quota_ibfk_2 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;"); $db->exec("CREATE TABLE disk_quota (user_id int(11) NOT NULL, quota_size int(10) unsigned NOT NULL, quota_files int(10) unsigned NOT NULL, updated tinyint(1) NOT NULL DEFAULT 1, quota_size_used int(10) unsigned NOT NULL DEFAULT '0', quota_files_used int(10) unsigned NOT NULL DEFAULT '0', KEY user_id (user_id), KEY updated (updated), CONSTRAINT disk_quota_ibfk_2 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
$db->exec('CREATE TABLE nginx_rewrites (id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, user_id int(11) NOT NULL, `regex` varchar(255) NOT NULL, replacement varchar(255) NOT NULL, `flag` varchar(9) NOT NULL, ifnotexists tinyint(1) NOT NULL, CONSTRAINT nginx_rewrites_ibfk_2 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;'); $db->exec('CREATE TABLE nginx_rewrites (id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, user_id int(11) NOT NULL, `regex` varchar(255) NOT NULL, replacement varchar(255) NOT NULL, `flag` varchar(9) NOT NULL, ifnotexists tinyint(1) NOT NULL, CONSTRAINT nginx_rewrites_ibfk_2 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');