Update: 2026-05-06 03:34:30
This commit is contained in:
@@ -22,26 +22,31 @@ if ((!$email && !$id) || !$phone) {
|
||||
$db = Database::getInstance();
|
||||
|
||||
// 1. Sanitize phone
|
||||
$cleanPhone = preg_replace('/[^0-9+]/', '', $phone);
|
||||
$phoneHash = hash('sha256', $cleanPhone);
|
||||
$encryptedPhone = Encryption::encrypt($cleanPhone);
|
||||
try {
|
||||
$cleanPhone = preg_replace('/[^0-9+]/', '', $phone);
|
||||
$phoneHash = hash('sha256', $cleanPhone);
|
||||
$encryptedPhone = Encryption::encrypt($cleanPhone);
|
||||
|
||||
// 2. Update user
|
||||
if ($id) {
|
||||
// 2. Update user
|
||||
if ($id) {
|
||||
$stmt = $db->prepare("UPDATE users SET phone = ?, phone_hash = ? WHERE id = ?");
|
||||
$stmt->execute([$encryptedPhone, $phoneHash, $id]);
|
||||
$identifier = "ID $id";
|
||||
} else {
|
||||
} else {
|
||||
// Note: Searching by encrypted email will likely fail due to IV randomness. Use ID.
|
||||
$stmt = $db->prepare("UPDATE users SET phone = ?, phone_hash = ? WHERE email = ?");
|
||||
$stmt->execute([$encryptedPhone, $phoneHash, $email]);
|
||||
$identifier = "email $email";
|
||||
}
|
||||
}
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
if ($stmt->rowCount() > 0) {
|
||||
echo "✅ Success! Phone updated for $identifier\n";
|
||||
echo " Encrypted: $encryptedPhone\n";
|
||||
echo " Hash: $phoneHash\n";
|
||||
} else {
|
||||
echo "❌ Failed. User with email $email not found or no changes made.\n";
|
||||
} else {
|
||||
echo "❌ Failed. User with $identifier not found or no changes made.\n";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "❌ Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user