-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrace.php
More file actions
41 lines (35 loc) · 1.46 KB
/
trace.php
File metadata and controls
41 lines (35 loc) · 1.46 KB
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
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tracking pixel endpoint.
*
* @package local_bbcomailing
* @copyright 2026 David Herney @ BambuCo
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Require_login is not needed here.
// phpcs:disable moodle.Files.RequireLogin.Missing
require_once('../../config.php');
require_once($CFG->libdir . '/filelib.php');
$code = required_param('code', PARAM_ALPHANUMEXT);
$record = $DB->get_record('local_bbcomailing_send', ['code' => $code], 'id, viewtime');
if ($record && empty($record->viewtime)) {
$DB->set_field('local_bbcomailing_send', 'viewtime', time(), ['id' => $record->id]);
}
// Always return a 1x1 transparent pixel PNG.
$img = $CFG->dirroot . '/local/bbcomailing/pix/trace.png';
send_file($img, 'trace.png', null, 0, false, false, 'image/png');
exit;