diff --git a/README.md b/README.md index dc9f6d6..5953cfb 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ Once installed create a mysql user for phpmyadmin and cofigure it in `/var/www/h ``` mysql CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'MY_PASSWORD'; +CREATE DATABASE phpmyadmin; GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'%'; FLUSH PRIVILEGES; quit diff --git a/var/www/common.php b/var/www/common.php index f28c3ee..dd51bf3 100644 --- a/var/www/common.php +++ b/var/www/common.php @@ -600,9 +600,14 @@ function del_user_db(PDO $db, int $user_id, string $mysql_db) { } } +function get_new_tor_instance(PDO $db){ + $stmt = $db->query('SELECT s.ID FROM service_instances AS s LEFT JOIN onions AS o ON (s.ID = o.instance) GROUP BY s.ID ORDER BY count(s.ID) LIMIT 1;'); + return $stmt->fetch(PDO::FETCH_NUM)[0]; +} + function add_user_onion(PDO $db, int $user_id, string $onion, string $priv_key, int $onion_version) { $stmt=$db->prepare('INSERT INTO onions (user_id, onion, private_key, version, enabled, instance) VALUES (?, ?, ?, ?, 2, ?);'); - $stmt->execute([$user_id, $onion, $priv_key, $onion_version, SERVICE_INSTANCES[array_rand(SERVICE_INSTANCES)]]); + $stmt->execute([$user_id, $onion, $priv_key, $onion_version, get_new_tor_instance($db)]); } function del_user_onion(PDO $db, int $user_id, string $onion) { diff --git a/var/www/html/admin.php b/var/www/html/admin.php index a00280c..890a92e 100644 --- a/var/www/html/admin.php +++ b/var/www/html/admin.php @@ -55,10 +55,10 @@ if(empty($_SESSION['logged_in'])){ echo '
'; }elseif(substr($_REQUEST['action'], 0, 7) === 'approve'){ diff --git a/var/www/html/index.php b/var/www/html/index.php index e14b554..a652ee9 100644 --- a/var/www/html/index.php +++ b/var/www/html/index.php @@ -45,6 +45,6 @@ header('Content-Type: text/html; charset=UTF-8');