added Key Grabber

This commit is contained in:
vincent 2025-04-16 09:56:15 +02:00
parent dad99e12c5
commit 070ca57c96

54
keyGrab.php Normal file
View file

@ -0,0 +1,54 @@
<?php
include('../Auth/index.php');
include('../Auth/db.ini.php');
function grabPublicKey($uid){
global $dbservername;
global $dbusername;
global $dbpassword;
global $dbname;
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT publicKey FROM smz_messages_users WHERE uid='$uid'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
return $row["publicKey"];
}
} else {
// ungültige Session
return false;
}
$conn->close();
}
function grabPrivateKey(){
global $dbservername;
global $dbusername;
global $dbpassword;
global $dbname;
global $uid;
// global $password_hash;
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT privateKey FROM smz_messages_users WHERE uid='$uid'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
return $row["privateKey"];
}
} else {
// ungültige Session
return false;
}
$conn->close();
}
?>