-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.php
75 lines (69 loc) · 2.33 KB
/
auth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
if (!isset($_SESSION))
session_start();
include "config.php";
include "navbar.php";
#####################################################################################
### SCHIMBA VARIABILA PENTRU A STOCA PAROLELE ALTUNDEVA DACA NU MERGE .htaccess ! ###
#####################################################################################
$ROOTPASS = "$root/pass";
ini_set('display_errors', 0);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
?>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="box" style="padding:3px;">
<h2>Autentificare/Inregistrare</h2>
<div class="table">
<form method="post">
<div class="tr">
<div class="td">
<label for="name">
<b>Nume de utilizator</b>
</label>
</div>
<div class="td" id="pt2">
<input required type="text" name="name">
</div>
<div>
<label for="pass">
<b>Parola</b>
</label>
</div>
<div class="td" id="pt2">
<input required type="text" name="pass" autocomplete="off" style="-webkit-text-security: disc;">
</div>
<?php
require "$root/verify.php";
echo $_SESSION["captcha"].'<br /><br /><br />';
echo "<input required type=\"text\" placeholder=\"CAPTCHA\" name=\"captcha\" autocomplete=\"off\">";
?>
<button class="button" id="button2">OK</button>
</form>
</div>
</div>
<?php
if (isset($_POST)) {
$nume = @$_POST["name"];
$pass = @$_POST["pass"];
$fisNume = "$ROOTPASS/$nume.txt";
if ($_SESSION["solve"] == @$_POST["captcha"]) {
if (!file_exists($fisNume)) {
# Creeam profilul daca nu exista
mkdir("profile/$nume");
mkdir("profile/$nume/sol");
file_put_contents("profile/$nume/bio.txt", "Hello, world!");
# Facem un symbolic link
symlink("../../profile.php", "profile/$nume/index.php");
file_put_contents($fisNume, password_hash($pass, PASSWORD_DEFAULT));
} else if (password_verify($pass, file_get_contents($fisNume))) {
$_SESSION["nume"] = $nume;
}
}
}
?>
</body>
</html>