PDO::ERRMODE_WARNING, PDO::ATTR_PERSISTENT=>PERSISTENT]); }catch(PDOException $e){ die('No Connection to MySQL database!'); } header('Content-Type: text/html; charset=UTF-8'); session_start(); if(!empty($_SESSION['hosting_username'])){ header('Location: home.php'); exit; } $msg=''; $username=''; if($_SERVER['REQUEST_METHOD']==='POST'){ $ok=true; if(CAPTCHA){ if(!isset($_REQUEST['challenge'])){ echo '

Error: Wrong Captcha

'; $ok=false; }else{ $stmt=$db->prepare('SELECT code FROM captcha WHERE id=?;'); $stmt->execute([$_REQUEST['challenge']]); $stmt->bindColumn(1, $code); if(!$stmt->fetch(PDO::FETCH_BOUND)){ echo '

Error: Captcha expired

'; $ok=false; }else{ $time=time(); $stmt=$db->prepare('DELETE FROM captcha WHERE id=? OR timeexecute([$_REQUEST['challenge'], $time-3600]); if($_REQUEST['captcha']!==$code){ if(strrev($_REQUEST['captcha'])!==$code){ echo '

Error: Wrong captcha

'; $ok=false; } } } } } if(!isset($_POST['username']) || $_POST['username']===''){ $msg.='

Error, username may not be empty.

'; $ok=false; }else{ $stmt=$db->prepare('SELECT username, password FROM users WHERE username=?;'); $stmt->execute([$_POST['username']]); $tmp=[]; if(($tmp=$stmt->fetch(PDO::FETCH_NUM))===false && preg_match('/^([2-7a-z]{16}).onion$/', $_POST['username'], $match)){ $stmt=$db->prepare('SELECT username, password FROM users WHERE onion=?;'); $stmt->execute([$match[1]]); $tmp=$stmt->fetch(PDO::FETCH_NUM); } if($tmp){ if(!isset($_POST['pass']) || !password_verify($_POST['pass'], $tmp[1])){ $msg.='

Error, wrong password.

'; $ok=false; }else{ $username=$tmp[0]; } }else{ $msg.='

Error, username was not found. If you forgot it, you can enter youraccount.onion instead.

'; $ok=false; } } if($ok){ $_SESSION['hosting_username']=$username; session_write_close(); header('Location: home.php'); exit; } } echo ''; echo 'Daniel\'s Hosting - Login'; echo ''; echo ''; echo ''; echo '

Info | Register | Login | List of hosted sites | FAQ

'; echo $msg; echo '
'; echo ''; echo ''; if(CAPTCHA){ send_captcha(); } echo ''; echo '
Username
Password
'; echo '

If you disabled cookies, please re-enable them. You currently can\'t log in without

'; echo ''; ?>