Exemple #1
0
$mpdf->SetTitle($pdf->title);
$mpdf->SetSubject('eLabFTW pdf');
$mpdf->SetKeywords($pdf->tags);
$mpdf->SetCreator('www.elabftw.net');
$mpdf->WriteHTML($pdf->content);
$mpdf->Output($pdf_path, 'F');
$trusted_timestamp = new Elabftw\Elabftw\TrustedTimestamps($provider, $pdf_path, null, $login, $password, null, $hash);
// if there was a problem during the timestamping, an error will be inside the $_SESSION['errors'] array
// and we want to stop there if that is the case.
if (is_array($_SESSION['errors'])) {
    header("Location: ../experiments.php?mode=view&id=" . $id);
    exit;
}
// REQUEST TOKEN
try {
    $token = $trusted_timestamp->getBinaryResponse();
} catch (Exception $e) {
    dblog("Error", $_SESSION['userid'], "File: " . $e->getFile() . ", line " . $e->getLine() . ": " . $e->getMessage());
    $msg_arr[] = _('There was an error with the timestamping. Experiment is NOT timestamped. Error has been logged.');
    $_SESSION['errors'] = $msg_arr;
    header("Location: ../experiments.php?mode=view&id=" . $id);
    exit;
}
$longname = hash("sha512", uniqid(rand(), true)) . ".asn1";
$file_path = ELAB_ROOT . 'uploads/' . $longname;
// save the timestamptoken
try {
    file_put_contents($file_path, $token);
} catch (Exception $e) {
    dblog('Error', $_SESSION['userid'], $e->getMessage());
    $msg_arr[] = _('There was an error with the timestamping. Experiment is NOT timestamped. Error has been logged.');