Make only enabled onions clickable in admin + equal instance usage
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user