Make only enabled onions clickable in admin + equal instance usage

This commit is contained in:
Daniel Winzen
2019-07-20 14:19:35 +02:00
parent 287eedf318
commit 2f97e826d4
5 changed files with 17 additions and 7 deletions

View File

@ -55,10 +55,10 @@ if(empty($_SESSION['logged_in'])){
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . "\" method=\"POST\"><input type=\"hidden\" name=\"csrf_token\" value=\"$_SESSION[csrf_token]\">";
echo '<table border="1">';
echo '<tr><th>Username</th><th>Onion link</th><th>Action</th></tr>';
$stmt=$db->query('SELECT users.username, onions.onion FROM users INNER JOIN onions ON (onions.user_id=users.id) ORDER BY users.username;');
$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 = [];
while($tmp=$stmt->fetch(PDO::FETCH_NUM)){
$accounts[$tmp[0]] []= $tmp[1];
$accounts[$tmp[0]] []= [$tmp[1], $tmp[2]];
}
foreach($accounts as $account => $onions){
echo "<tr><td>$account</td><td>";
@ -69,9 +69,13 @@ if(empty($_SESSION['logged_in'])){
}else{
echo '<br>';
}
echo "<a href=\"http://$onion.onion\" target=\"_blank\">$onion.onion</a>";
if($onion[1]=='1'){
echo "<a href=\"http://$onion[0].onion\" target=\"_blank\">$onion[0].onion</a>";
}else{
echo "$onion[0].onion";
}
}
echo "</td><td><button type=\"submit\" name=\"action\" value=\"edit_$onions[0]\">Edit</button><button type=\"submit\" name=\"action\" value=\"delete_$onions[0]\">Delete</button><button type=\"submit\" name=\"action\" value=\"suspend_$onions[0]\">Suspend</button></td></tr>";
echo "</td><td><button type=\"submit\" name=\"action\" value=\"edit_{$onions[0][0]}\">Edit</button><button type=\"submit\" name=\"action\" value=\"delete_{$onions[0][0]}\">Delete</button><button type=\"submit\" name=\"action\" value=\"suspend_{$onions[0][0]}\">Suspend</button></td></tr>";
}
echo '</table></form>';
}elseif(substr($_REQUEST['action'], 0, 7) === 'approve'){

View File

@ -45,6 +45,6 @@ header('Content-Type: text/html; charset=UTF-8');
<li>No proxy scripts! (You are already using TOR and this will just burden the network)</li>
<li>No IP logger or similar de-anonymizer sites!</li>
<li>I preserve the right to delete any site for violating these rules and adding new rules at any time.</li>
<li>Should you not honor these rules, I will (have to) work together with Law Enfocements!</li>
<li>Should you not honor these rules, I will (have to) work together with Law Enforcement!</li>
</ul>
</body></html>

View File

@ -108,7 +108,7 @@ if($_SERVER['REQUEST_METHOD']==='POST'){
}elseif($ok){
$mysql_user = add_mysql_user($db, $_POST['pass']);
$stmt=$db->prepare('INSERT INTO users (username, system_account, password, dateadded, public, php, autoindex, mysql_user, instance) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);');
$stmt->execute([$_POST['username'], substr("$onion.onion", 0, 32), $hash, time(), $public_list, $php, $autoindex, $mysql_user, SERVICE_INSTANCES[array_rand(SERVICE_INSTANCES)]]);
$stmt->execute([$_POST['username'], substr("$onion.onion", 0, 32), $hash, time(), $public_list, $php, $autoindex, $mysql_user, get_new_tor_instance($db)]);
$user_id = $db->lastInsertId();
$stmt = $db->prepare('INSERT INTO disk_quota (user_id, quota_size, quota_files) VALUES (?, ?, ?);');
$stmt->execute([$user_id, DEFAULT_QUOTA_SIZE, DEFAULT_QUOTA_FILES]);