Check for existing DB record before creating

This commit is contained in:
Cuga Rajal
2022-08-25 17:29:34 -07:00
parent b0d16f8f14
commit 3834370a89
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -53,10 +53,14 @@ if(($nametest == "@") && (mysqli_num_rows($data)>0)) {
}
if(($nametest == "@") && (mysqli_num_rows($data)==0)) {
$token = substr(hash("sha1", $avatarname, false),0,7);
$query = "INSERT INTO $tablename (`token`) VALUES ('". $token . "')";
$data = mysqli_query($dbc, $query);
$token = substr(hash("sha1", $avatarname, false),0,7);
$query2 = "SELECT * FROM $tablename WHERE token='$token' AND avatarname=''";
$data2 = mysqli_query($dbc, $query2);
if(mysqli_num_rows($data2)==0) {
$query3 = "INSERT INTO $tablename (`token`) VALUES ('" . $token . "')";
$data3 = mysqli_query($dbc, $query3);
}
$getstring = base64_url_encode("fn=" . $firstname . "&ln=" . $lastname);
$authlink2 = $authlink . "?token=" . $getstring;
+1 -1
View File
@@ -4,7 +4,7 @@
// This file is expected to be used to present an authorization from on a web browser
// to a user who has attempted to HG teleport to an Opensim region.
//
// Make sure your date.timezone is set in php-ini
// Make sure your date.timezone is set in php.ini
$tokenerror = "You have accessed this page differently than intended. Please use the link provided from your Opensim Viewer.";
$alreadyreg = "It appears that your avatar is already authorized with the system. You may now HG teleport.";