Skip to content

Commit 8226f85

Browse files
authored
Merge pull request #4231 from armenium/v3.0
Create PostgreSQL_register.php
2 parents d3c3883 + 1063a71 commit 8226f85

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
ob_start();
4+
require_once 'PostgreSQL_funcs.php';
5+
require 'PostgreSQL_config.php';
6+
require 'PostgreSQL_getlogin.php';
7+
ob_end_clean();
8+
9+
session_start();
10+
11+
if (isset($_POST['j_password'])) {
12+
$password = $_POST['j_password'];
13+
} else {
14+
$password = '';
15+
}
16+
if (isset($_POST['j_verify_password'])) {
17+
$verify = $_POST['j_verify_password'];
18+
} else {
19+
$verify = '';
20+
}
21+
if (strcmp($password, $verify)) {
22+
echo "{ \"result\": \"verifyfailed\" }";
23+
return;
24+
}
25+
26+
if (isset($_POST['j_username'])) {
27+
$userid = $_POST['j_username'];
28+
} else {
29+
$userid = '-guest-';
30+
}
31+
if (isset($_POST['j_passcode'])) {
32+
$passcode = $_POST['j_passcode'];
33+
} else {
34+
$passcode = '';
35+
}
36+
$good = false;
37+
38+
$useridlc = strtolower($userid);
39+
40+
$_SESSION['userid'] = '-guest-';
41+
42+
$good = false;
43+
44+
if (strcmp($useridlc, '-guest-')) {
45+
if (isset($pendingreg[$useridlc])) {
46+
if (!strcmp($passcode, $pendingreg[$useridlc])) {
47+
$ctx = hash_init('sha256');
48+
hash_update($ctx, $pwdsalt);
49+
hash_update($ctx, $password);
50+
$hash = hash_final($ctx);
51+
$_SESSION['userid'] = $userid;
52+
$good = true;
53+
$newlines[] = array();
54+
$content = getStandaloneFile('dynmap_reg.php');
55+
if (isset($content)) {
56+
$lines = explode('\n', $content);
57+
$isnew = false;
58+
} else {
59+
$lines = array();
60+
$isnew = true;
61+
}
62+
if (!empty($lines)) {
63+
$cnt = count($lines) - 1;
64+
for ($i = 1; $i < $cnt; $i++) {
65+
list($uid, $pc, $hsh) = explode('=', rtrim($lines[$i]));
66+
if ($uid == $useridlc) {
67+
continue;
68+
}
69+
if (array_key_exists($uid, $pendingreg)) {
70+
$newlines[] = $uid . '=' . $pc . '=' . $hsh;
71+
}
72+
}
73+
}
74+
$newlines[] = $useridlc . '=' . $passcode . '=' . $hash;
75+
if ($isnew) {
76+
insertStandaloneFile('dynmap_reg.php', implode("\n", $newlines));
77+
} else {
78+
updateStandaloneFile('dynmap_reg.php', implode("\n", $newlines));
79+
}
80+
}
81+
}
82+
}
83+
if ($good) {
84+
echo "{ \"result\": \"success\" }";
85+
} else {
86+
echo "{ \"result\": \"registerfailed\" }";
87+
}
88+
cleanupDb();

0 commit comments

Comments
 (0)