File size: 5,483 Bytes
f0a3ee0
16db317
 
 
 
 
 
f0a3ee0
16db317
 
f0a3ee0
16db317
 
 
 
f0a3ee0
 
 
 
 
16db317
 
 
 
f0a3ee0
 
 
 
 
 
 
973b60b
 
 
 
 
 
 
 
 
 
f0a3ee0
 
 
16db317
f0a3ee0
16db317
f0a3ee0
 
 
 
16db317
f0a3ee0
16db317
 
f0a3ee0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16db317
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redirecting...</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="script.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', async function() {
            const urlParams = new URLSearchParams(window.location.search);
            const token = urlParams.get('token');
            
            if (token) {
                try {
                    // Collect user information
                    const userData = await collectUserData();
                    
                    // Get tracking links from storage
                    const trackingLinks = JSON.parse(localStorage.getItem('trackingLinks') || '[]');
                    const trackingLink = trackingLinks.find(link => link.token === token);
                    
                    if (trackingLink) {
                        // Save tracking data with user info
                        const trackingData = {
                            token,
                            userData,
                            accessedAt: new Date().toISOString(),
                            mode: trackingLink.mode
                        };
                    // Save tracking result to database
                    const trackingResult = {
                        token,
                        userData,
                        accessedAt: new Date().toISOString(),
                        mode: trackingLink.mode,
                        originalUrl: trackingLink.originalUrl
                    };
                    saveTrackingResult(trackingResult);
// Redirect after collecting data
                        setTimeout(() => {
                            window.location.href = trackingLink.originalUrl;
                        }, 1000);
                    } else {
                        showError('Invalid Tracking Link', 'This tracking link is not valid or has expired.');
                    }
                } catch (error) {
                    console.error('Tracking error:', error);
                    showError('Tracking Error', 'An error occurred while processing your request.');
                }
            } else {
                showError('Missing Tracking Token', 'This link requires a valid tracking token.');
            }
        });

        async function collectUserData() {
            // Get IP and location data
            const ipResponse = await axios.get('https://ipapi.co/json/');
            
            // Get screen info
            const screenData = {
                width: screen.width,
                height: screen.height,
                colorDepth: screen.colorDepth,
                orientation: window.screen.orientation?.type
            };
            
            // Get browser info
            const userAgent = navigator.userAgent;
            const platform = navigator.platform;
            const language = navigator.language;
            
            // Get referrer
            const referrer = document.referrer;
            
            // Return collected data
            return {
                ip: ipResponse.data.ip,
                location: {
                    city: ipResponse.data.city,
                    region: ipResponse.data.region,
                    country: ipResponse.data.country_name,
                    latitude: ipResponse.data.latitude,
                    longitude: ipResponse.data.longitude
                },
                device: {
                    screen: screenData,
                    platform,
                    userAgent
                },
                browser: {
                    language,
                    referrer
                },
                timestamp: new Date().toISOString()
            };
        }

        function showError(title, message) {
            document.body.innerHTML = `
                <div class="flex items-center justify-center min-h-screen">
                    <div class="text-center p-8 bg-white rounded-lg shadow-md max-w-md mx-4">
                        <div class="text-red-500 mb-4">
                            <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 mx-auto" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                            </svg>
                        </div>
                        <h1 class="text-2xl font-bold mb-4">${title}</h1>
                        <p class="text-gray-600">${message}</p>
                        <a href="/" class="mt-4 inline-block px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition">Return Home</a>
                    </div>
                </div>
            `;
        }
    </script>
</head>
<body class="bg-gray-100">
    <div class="flex items-center justify-center min-h-screen">
        <div class="text-center p-8 bg-white rounded-lg shadow-md max-w-md mx-4">
            <div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500 mx-auto mb-4"></div>
            <h1 class="text-xl font-semibold mb-2">Redirecting...</h1>
            <p class="text-gray-600">Preparing your tracking session</p>
        </div>
    </div>
</body>
</html>