'hosting_admin']); if($_SERVER['REQUEST_METHOD']==='HEAD'){ exit; // headers sent, no further processing needed } print_header(_('Admin panel'), 'td{padding:5px;}', '_blank'); ?>
'._('Password').' | |
'.$error.'
'; }elseif(isset($_POST['pass'])){ echo ''._('Wrong password!').'
'; } echo ''._("If you disabled cookies, please re-enable them. You can't log in without!").'
'; }else{ echo ''; if(REQUIRE_APPROVAL){ $stmt=$db->query('SELECT COUNT(*) FROM new_account WHERE approved=0;'); $cnt=$stmt->fetch(PDO::FETCH_NUM)[0]; echo ''.sprintf(_('Approve pending sites (%s)'), $cnt).' | '; } echo ''._('List of accounts').' | '._('Delete accounts').' | '._('Suspend hidden services').' | '._('Edit hidden services').' | '._('Logout').'
'; if(empty($_REQUEST['action']) || $_REQUEST['action']==='login'){ echo ''._('Welcome to the admin panel!').'
'; }elseif($_REQUEST['action'] === 'logout'){ session_destroy(); header('Location: ' . $_SERVER['SCRIPT_NAME']); exit; }elseif($_REQUEST['action'] === 'list'){ echo ''; }elseif( str_starts_with( $_REQUEST[ 'action' ], 'approve' ) ){ $onion = substr($_REQUEST['action'], 8); if(!empty($onion)){ if($error=check_csrf_error()){ echo ''.$error.'
'; }else{ $stmt=$db->prepare('UPDATE new_account INNER JOIN onions ON (onions.user_id=new_account.user_id) SET new_account.approved=1 WHERE onions.onion=?;'); $stmt->execute([$onion]); echo ''._('Successfully approved').'
'; } } echo ''; }elseif( str_starts_with( $_REQUEST[ 'action' ], 'delete' ) ){ $onion = $_POST[ 'onion' ] ?? substr( $_REQUEST[ 'action' ], 7 ); echo ''._('Delete accounts:').'
'; echo ''.$error.'
'; }elseif(preg_match('~^([a-z2-7]{16}|[a-z2-7]{56})(\.onion)?$~', $onion, $match)){ $stmt=$db->prepare('SELECT user_id FROM onions WHERE onion=?;'); $stmt->execute([$match[1]]); if($user_id=$stmt->fetch(PDO::FETCH_NUM)){ $stmt=$db->prepare('UPDATE users SET todelete=1 WHERE id=?;'); $stmt->execute($user_id); echo ''._('Successfully queued for deletion!').'
'; }else{ echo ''._('Onion address not hosted by us!').'
'; } }else{ echo ''._('Invalid onion address!').'
'; } } }elseif( str_starts_with( $_REQUEST[ 'action' ], 'suspend' ) ){ $onion = $_POST[ 'onion' ] ?? substr( $_REQUEST[ 'action' ], 8 ); echo ''._('Suspend hidden service:').'
'; echo ''.$error.'
'; }elseif(preg_match('~^([a-z2-7]{16}|[a-z2-7]{56})(\.onion)?$~', $onion, $match)){ $stmt=$db->prepare('SELECT instance FROM onions WHERE onion=?;'); $stmt->execute([$match[1]]); if($instance=$stmt->fetch(PDO::FETCH_NUM)){ $stmt=$db->prepare('UPDATE onions SET enabled=-2 WHERE onion=?;'); $stmt->execute([$match[1]]); echo ''._('Successfully queued for suspension!').'
'; enqueue_instance_reload($instance[0]); }else{ echo ''._('Onion address not hosted by us!').'
'; } }else{ echo ''._('Invalid onion address!').'
'; } } }elseif( str_starts_with( $_REQUEST[ 'action' ], 'edit' ) ){ $onion = $_POST[ 'onion' ] ?? substr( $_REQUEST[ 'action' ], 5 ); echo ''._('Edit hidden service:').'
'; echo ''.$error.'
'; }elseif(preg_match('~^([a-z2-7]{16}|[a-z2-7]{56})(\.onion)?$~', $onion, $match)){ if(isset($_POST['num_intros'])){ $stmt=$db->prepare('SELECT version, instance FROM onions WHERE onion=?;'); $stmt->execute([$match[1]]); if($onion=$stmt->fetch(PDO::FETCH_NUM)){ $stmt=$db->prepare('UPDATE onions SET enabled = ?, enable_smtp = ?, num_intros = ?, max_streams = ? WHERE onion=?;'); $enabled = isset($_POST['enabled']) ? 1 : 0; $enable_smtp = isset($_POST['enable_smtp']) ? 1 : 0; $num_intros = intval($_POST['num_intros']); if($num_intros<3){ $num_intros = 3; }elseif($onion[0]==2 && $num_intros>10){ $num_intros = 10; }elseif($num_intros>20){ $num_intros = 20; } $max_streams = intval($_POST['max_streams']); if($max_streams<0){ $max_streams = 0; }elseif($max_streams>65535){ $max_streams = 65535; } $stmt->execute([$enabled, $enable_smtp, $num_intros, $max_streams, $match[1]]); enqueue_instance_reload($onion[1]); echo ''._('Changes successfully saved!').'
'; } } $stmt=$db->prepare('SELECT onion, enabled, enable_smtp, num_intros, max_streams, version FROM onions WHERE onion=?;'); $stmt->execute([$match[1]]); if($onion=$stmt->fetch(PDO::FETCH_NUM)){ echo '