Merge pull request #4231 from armenium/v3.0
Create PostgreSQL_register.php
This commit is contained in:
commit
8226f8526b
1 changed files with 88 additions and 0 deletions
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
require_once 'PostgreSQL_funcs.php';
|
||||||
|
require 'PostgreSQL_config.php';
|
||||||
|
require 'PostgreSQL_getlogin.php';
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (isset($_POST['j_password'])) {
|
||||||
|
$password = $_POST['j_password'];
|
||||||
|
} else {
|
||||||
|
$password = '';
|
||||||
|
}
|
||||||
|
if (isset($_POST['j_verify_password'])) {
|
||||||
|
$verify = $_POST['j_verify_password'];
|
||||||
|
} else {
|
||||||
|
$verify = '';
|
||||||
|
}
|
||||||
|
if (strcmp($password, $verify)) {
|
||||||
|
echo "{ \"result\": \"verifyfailed\" }";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['j_username'])) {
|
||||||
|
$userid = $_POST['j_username'];
|
||||||
|
} else {
|
||||||
|
$userid = '-guest-';
|
||||||
|
}
|
||||||
|
if (isset($_POST['j_passcode'])) {
|
||||||
|
$passcode = $_POST['j_passcode'];
|
||||||
|
} else {
|
||||||
|
$passcode = '';
|
||||||
|
}
|
||||||
|
$good = false;
|
||||||
|
|
||||||
|
$useridlc = strtolower($userid);
|
||||||
|
|
||||||
|
$_SESSION['userid'] = '-guest-';
|
||||||
|
|
||||||
|
$good = false;
|
||||||
|
|
||||||
|
if (strcmp($useridlc, '-guest-')) {
|
||||||
|
if (isset($pendingreg[$useridlc])) {
|
||||||
|
if (!strcmp($passcode, $pendingreg[$useridlc])) {
|
||||||
|
$ctx = hash_init('sha256');
|
||||||
|
hash_update($ctx, $pwdsalt);
|
||||||
|
hash_update($ctx, $password);
|
||||||
|
$hash = hash_final($ctx);
|
||||||
|
$_SESSION['userid'] = $userid;
|
||||||
|
$good = true;
|
||||||
|
$newlines[] = array();
|
||||||
|
$content = getStandaloneFile('dynmap_reg.php');
|
||||||
|
if (isset($content)) {
|
||||||
|
$lines = explode('\n', $content);
|
||||||
|
$isnew = false;
|
||||||
|
} else {
|
||||||
|
$lines = array();
|
||||||
|
$isnew = true;
|
||||||
|
}
|
||||||
|
if (!empty($lines)) {
|
||||||
|
$cnt = count($lines) - 1;
|
||||||
|
for ($i = 1; $i < $cnt; $i++) {
|
||||||
|
list($uid, $pc, $hsh) = explode('=', rtrim($lines[$i]));
|
||||||
|
if ($uid == $useridlc) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (array_key_exists($uid, $pendingreg)) {
|
||||||
|
$newlines[] = $uid . '=' . $pc . '=' . $hsh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$newlines[] = $useridlc . '=' . $passcode . '=' . $hash;
|
||||||
|
if ($isnew) {
|
||||||
|
insertStandaloneFile('dynmap_reg.php', implode("\n", $newlines));
|
||||||
|
} else {
|
||||||
|
updateStandaloneFile('dynmap_reg.php', implode("\n", $newlines));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($good) {
|
||||||
|
echo "{ \"result\": \"success\" }";
|
||||||
|
} else {
|
||||||
|
echo "{ \"result\": \"registerfailed\" }";
|
||||||
|
}
|
||||||
|
cleanupDb();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue