Initial commit with updated Auth and media ignored
This commit is contained in:
48
migration/get_all_driver_fingerprints.php
Executable file
48
migration/get_all_driver_fingerprints.php
Executable file
@@ -0,0 +1,48 @@
|
||||
|
||||
<?php
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// get_all_driver_fingerprints.php
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
// ⚠️ يُستخدم مرة واحدة فقط ثم يُحذف من السيرفر
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
require_once __DIR__ . '/../get_connect.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: https://intaleqapp.com');
|
||||
header('Access-Control-Allow-Methods: POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(200); exit; }
|
||||
|
||||
// ── التحقق من admin_key ────────────────────────────────────────
|
||||
$adminKey = filterRequest('admin_key') ?? '';
|
||||
$expectedAdminKey = getenv('MIGRATION_ADMIN_KEY');
|
||||
|
||||
if (empty($adminKey) || !hash_equals($expectedAdminKey, $adminKey)) {
|
||||
http_response_code(403);
|
||||
exit(json_encode(['error' => 'Forbidden']));
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $con->prepare('
|
||||
SELECT captain_id, fingerPrint
|
||||
FROM driverToken
|
||||
WHERE fingerPrint IS NOT NULL
|
||||
AND fingerPrint != ""
|
||||
ORDER BY captain_id
|
||||
');
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'count' => count($rows),
|
||||
'data' => $rows,
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('❌ [get_all_driver_fingerprints] ' . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Server error']);
|
||||
}
|
||||
57
migration/get_all_fingerprints.php
Executable file
57
migration/get_all_fingerprints.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// get_all_fingerprints.php — جلب كل البصمات للترحيل
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
// ⚠️ يُستخدم مرة واحدة فقط ثم يُحذف من السيرفر
|
||||
// محمي بـ admin_key لمنع الوصول العشوائي
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
|
||||
require_once __DIR__ . '/../get_connect.php';
|
||||
//include 'functions.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: https://intaleqapp.com');
|
||||
header('Access-Control-Allow-Methods: POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
// ── التحقق من admin_key ────────────────────────────────────────
|
||||
$adminKey = filterRequest('admin_key') ?? '';
|
||||
$expectedAdminKey = getenv('MIGRATION_ADMIN_KEY'); // أضفه في .env
|
||||
|
||||
if (empty($adminKey) || !hash_equals($expectedAdminKey, $adminKey)) {
|
||||
http_response_code(403);
|
||||
echo json_encode(['error' => 'Forbidden']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// جلب كل البصمات من جدول tokens
|
||||
// نجيب passengerID + fingerPrint فقط — لا نعطي بيانات حساسة أخرى
|
||||
$stmt = $con->prepare('
|
||||
SELECT passengerID, fingerPrint, "passenger" AS userType
|
||||
FROM tokens
|
||||
WHERE fingerPrint IS NOT NULL
|
||||
AND fingerPrint != ""
|
||||
ORDER BY passengerID
|
||||
');
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'count' => count($rows),
|
||||
'data' => $rows,
|
||||
]);
|
||||
http_response_code(200);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('❌ [get_all_fingerprints] ' . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Server error']);
|
||||
}
|
||||
49
migration/update_driver_fingerprint_admin.php
Executable file
49
migration/update_driver_fingerprint_admin.php
Executable file
@@ -0,0 +1,49 @@
|
||||
|
||||
<?php
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// update_driver_fingerprint_admin.php
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
// ⚠️ يُستخدم فقط أثناء الترحيل ثم يُحذف
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
|
||||
require_once __DIR__ . '/../get_connect.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: https://intaleqapp.com');
|
||||
header('Access-Control-Allow-Methods: POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(200); exit; }
|
||||
|
||||
$adminKey = filterRequest('admin_key') ?? '';
|
||||
$expectedAdminKey = getenv('MIGRATION_ADMIN_KEY');
|
||||
|
||||
if (empty($adminKey) || !hash_equals($expectedAdminKey, $adminKey)) {
|
||||
http_response_code(403);
|
||||
exit(json_encode(['error' => 'Forbidden']));
|
||||
}
|
||||
|
||||
try {
|
||||
$captainId = filterRequest('captain_id') ?? '';
|
||||
$fingerprint = filterRequest('fingerprint') ?? '';
|
||||
|
||||
if (empty($captainId) || empty($fingerprint)) {
|
||||
http_response_code(400);
|
||||
exit(json_encode(['error' => 'Missing parameters']));
|
||||
}
|
||||
|
||||
$stmt = $con->prepare('
|
||||
UPDATE driverToken
|
||||
SET fingerPrint = :fp
|
||||
WHERE captain_id = :cid
|
||||
');
|
||||
$stmt->execute([':fp' => $fingerprint, ':cid' => $captainId]);
|
||||
|
||||
echo json_encode(['status' => 'success', 'affected' => $stmt->rowCount()]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('❌ [update_driver_fingerprint_admin] ' . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Server error']);
|
||||
}
|
||||
63
migration/update_fingerprint_admin.php
Executable file
63
migration/update_fingerprint_admin.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// update_fingerprint_admin.php — تحديث بصمة واحدة (للترحيل)
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
// ⚠️ يُستخدم فقط أثناء عملية الترحيل ثم يُحذف
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
|
||||
require_once __DIR__ . '/../get_connect.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: https://intaleqapp.com');
|
||||
header('Access-Control-Allow-Methods: POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
// ── التحقق من admin_key ────────────────────────────────────────
|
||||
$adminKey = filterRequest('admin_key') ?? '';
|
||||
$expectedAdminKey = getenv('MIGRATION_ADMIN_KEY');
|
||||
|
||||
if (empty($adminKey) || !hash_equals($expectedAdminKey, $adminKey)) {
|
||||
http_response_code(403);
|
||||
echo json_encode(['error' => 'Forbidden']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$passengerID = filterRequest('passengerID') ?? '';
|
||||
$fingerprint = filterRequest('fingerprint') ?? '';
|
||||
|
||||
if (empty($passengerID) || empty($fingerprint)) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'Missing parameters']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $con->prepare('
|
||||
UPDATE tokens
|
||||
SET fingerPrint = :fp
|
||||
WHERE passengerID = :pid
|
||||
');
|
||||
$stmt->execute([
|
||||
':fp' => $fingerprint,
|
||||
':pid' => $passengerID,
|
||||
]);
|
||||
|
||||
$affected = $stmt->rowCount();
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'affected' => $affected,
|
||||
]);
|
||||
http_response_code(200);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('❌ [update_fingerprint_admin] ' . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Server error']);
|
||||
}
|
||||
Reference in New Issue
Block a user