Diff -- /var/www/vhosts/3dshawn.com/crm.3dshawn.com/h.cgi
Diff

/var/www/vhosts/3dshawn.com/crm.3dshawn.com/h.cgi

added on local at 2026-07-01 15:02:46

Added
+52
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to fb3cd97fb5eb
Restore this content →
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.
1#!/usr/bin/perl
2#======================================================================
3# ContactForge -- /h.cgi heatmap ingest (clicks + scroll depth).
4# Same STDIN-first rule as c.cgi. Routes by payload {t} to
5# record_heatmap_click or record_heatmap_scroll.
6#======================================================================
7use strict;
8use warnings;
9use lib '/var/www/vhosts/3dshawn.com/crm.3dshawn.com';
10
11my $raw = '';
12if (($ENV{REQUEST_METHOD} || '') eq 'POST') {
13 my $len = int($ENV{CONTENT_LENGTH} || 0);
14 if ($len > 0 && $len < 1_048_576) {
15 read STDIN, $raw, $len;
16 }
17}
18
19use CGI;
20use MODS::DBConnect;
21use MODS::ContactForge::Config;
22use MODS::ContactForge::Tracking;
23use JSON::PP;
24
25my $cfg = MODS::ContactForge::Config->new;
26my $db = MODS::DBConnect->new;
27my $trk = MODS::ContactForge::Tracking->new;
28my $DB = $cfg->settings('database_name');
29
30print "Access-Control-Allow-Origin: *\n";
31print "Access-Control-Allow-Methods: POST, OPTIONS\n";
32print "Access-Control-Allow-Headers: Content-Type\n";
33print "Cache-Control: no-store\n";
34
35if (($ENV{REQUEST_METHOD} || '') eq 'OPTIONS') {
36 print "Content-Type: text/plain\n\nok"; exit;
37}
38print "Content-Type: application/json\n\n";
39
40my $body = eval { JSON::PP::decode_json($raw) } || {};
41# Default to click row if the caller didn't tag it.
42$body->{t} ||= 'hm';
43
44my $dbh = $db->db_connect();
45unless ($dbh) { print '{"ok":0}'; exit; }
46
47$body->{ip} = $ENV{HTTP_X_FORWARDED_FOR} || $ENV{REMOTE_ADDR} || '';
48$body->{user_agent} = $ENV{HTTP_USER_AGENT} || '';
49
50eval { $trk->ingest_heatmap($db, $dbh, $DB, $body) };
51$db->db_disconnect($dbh);
52print '{"ok":1}';
Keyboard: j next diff k previous diff g top G bottom r restore c compile-check ? help