<?php

use Mtc\Modules\BasketRecovery\Classes\BasketRecoveryEmail as Email;
use Mtc\Modules\BasketRecovery\Classes\BasketRecoveryLog as Log;

$path = '../../../';
require $path.'core/includes/header.inc.php';
$image_file = __DIR__.'/blank.gif';

header('Content-type: image/gif');
$fp = fopen($image_file, 'r');
fpassthru($fp);
fclose($fp);

// If the data doesn't match, then take 'em back to the homepage.
if (!isset($_GET['id']) || !isset($_GET['hash']) || $_GET['hash'] != Email::generateRecoveryHash($_GET['id']._.$_GET['recovery_id'])) {
    exit();
}

if ($_GET['id'] > 0) {
    Log::insert([
        'basket_recovery_id' => (int) $_GET['recovery_id'],
        'basket_id' => (int) $_GET['id'],
        'action' => 'read',
        'value' => null,
        ]);
}
