<?php
ini_set('display_errors', 1);

require_once '../../resources/base_path_include.php';
require_once $base_path_to_learning_resources  . "includes/connect.php"; // use require for mandatory files
require_once $base_path_to_learning_resources . 'lib/function.php';
require_once $base_path_to_learning_resources . 'lib/validate_api_signature.php';

//valdation file
require_once $base_path_to_learning_resources . 'lib/validate_function.php';
require_once $base_path_to_learning . '/user_management/check_username_availability.php';
require_once $base_path_to_learning . 'user_management/authenticate.php';
require_once $base_path_to_learning . 'admin_api/academic_session/functions/registration_functions.php';

require_once $base_path_to_learning . 'functions/common_functions.php';

//db access function
require_once $base_path_to_learning_resources . 'includes/specific_db_config.php';
require_once $base_path_to_learning . 'user_management/faculty/functions.php';
require_once $base_path_to_learning . "vendor/autoload.php";
require_once $base_path_to_learning_resources . 'lib/bucket_functions/bucket_functions.php';
require_once $base_path_to_learning_resources . 'includes/aws_bucket_config.php';

use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

// $postdata = json_decode(file_get_contents("php://input"), true);
// checkIfNoPhpContentsReceive();


$request_method = $_SERVER['REQUEST_METHOD'];
echo "Request Method: " . $request_method . "<br>";

// Capture GET variables
if (!empty($_GET)) {
    echo "<h3>GET Data 1:</h3>";
    echo "<pre>";
    print_r($_GET);
    echo "</pre>";
}

// Capture POST variables
if (!empty($_POST)) {
    echo "<h3>POST Data 2:</h3>";
    echo "<pre>";
    print_r($_POST);
    echo "</pre>";
}

// Capture JSON input (if sent)
$json_data = file_get_contents("php://input");
if (!empty($json_data)) {
    echo "<h3>Raw JSON Data 3:</h3>";
    echo "<pre>" . $json_data . "</pre>";

    $decoded_data = json_decode($json_data, true);
    if ($decoded_data) {
        echo "<h3>Decoded JSON 4:</h3>";
        echo "<pre>";
        print_r($decoded_data);
        echo "</pre>";
    }
}

// Log everything for debugging
$log_data = date("Y-m-d H:i:s") . " | Method: " . $request_method . " | Data: " . $json_data . "\n";
file_put_contents("biometric_debug_log.txt", $log_data, FILE_APPEND);