* the License, or (at your option) any later version. * * * * eLabFTW 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 Affero General Public License for more details. * * * * You should have received a copy of the GNU Affero General Public * * License along with eLabFTW. If not, see <http://www.gnu.org/licenses/>. * * * ********************************************************************************/ require_once '../inc/common.php'; // ID if (isset($_GET['id']) && !empty($_GET['id']) && is_pos_int($_GET['id'])) { $id = $_GET['id']; } else { display_message('error', _("The id parameter is not valid!")); require_once '../inc/footer.php'; exit; } // timestamping begins try { $ts = new Elabftw\Elabftw\TrustedTimestamps($id); $ts->timeStamp(); } catch (Exception $e) { $msg_arr = array(); $msg_arr[] = $e->getMessage(); $_SESSION['errors'] = $msg_arr; } // redirect header("Location: ../experiments.php?mode=view&id=" . $id);
if ($res) { $msg_arr[] = ">>> Added Universign.eu as RFC 3161 TSA for team #" . $team['team_id']; } else { die($die_msg); } } } // if Universign was used either globally or on a per team level, correct the recorded dates for the timestamps in the database if ($old_timestamping_global || $old_timestamping_teams) { // check if we have timestamped experiments $sql = "SELECT * FROM experiments"; $req = $pdo->prepare($sql); $req->execute(); while ($show = $req->fetch()) { if ($show['timestamped'] === '1') { $ts = new Elabftw\Elabftw\TrustedTimestamps(null, null, ELAB_ROOT . 'uploads/' . $show['timestamptoken']); $date = $ts->getResponseTime(); if ($show['timestampedwhen'] !== $date) { $sql_update = "UPDATE experiments SET timestampedwhen = :date WHERE id = :id"; $req_update = $pdo->prepare($sql_update); $res_update = $req_update->execute(array('date' => $date, 'id' => $show['id'])); if ($res_update) { $msg_arr[] = ">>> Corrected timestamp data for experiment #" . $show['id']; } else { die($die_msg); } } } } } // if Universign.eu was not used, a database update might still be needed; check for that
$provider = $stamp_params['stampprovider']; $cert = $stamp_params['stampcert']; $hash = $stamp_params['hash']; // generate the pdf to timestamp $pdf = new \Elabftw\Elabftw\MakePdf($id, 'experiments'); $mpdf = new mPDF(); $pdf_filename = hash("sha512", uniqid(rand(), true)) . ".pdf"; $pdf_path = ELAB_ROOT . 'uploads/' . $pdf_filename; $mpdf->SetAuthor($pdf->author); $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;