dolibarr 18.0.6
qr.php
1<?php
2/* Copyright (C) 2020 Andreu Bisquerra <jove@bisquerra.com>
3 * Copyright (C) 2024 Laurent Destailleur <eldy@users.sourceforge.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19// This page return an image of a QR code of a public link
20// Note: Generating a QR code from a string, like done by this script, can be done with any online tool.
21
22if (!defined("NOLOGIN")) {
23 define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
24}
25if (!defined('NOIPCHECK')) {
26 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
27}
28if (!defined('NOREQUIRESOC')) {
29 define('NOREQUIRESOC', '1');
30}
31if (!defined('NOTOKENRENEWAL')) {
32 define('NOTOKENRENEWAL', '1');
33}
34if (!defined('NOREQUIREMENU')) {
35 define('NOREQUIREMENU', '1');
36}
37if (!defined('NOREQUIREHTML')) {
38 define('NOREQUIREHTML', '1');
39}
40if (!defined('NOREQUIREAJAX')) {
41 define('NOREQUIREAJAX', '1');
42}
43
44// Load Dolibarr environment
45require '../../main.inc.php'; // Load $user and permissions
46require '../../core/modules/barcode/doc/tcpdfbarcode.modules.php';
47
48$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
49$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
50
51if (!isModEnabled('takepos')) {
52 accessforbidden('Module not enabled');
53}
54
55
56/*
57 * View
58 */
59
60// The buildBarCode does not include the http headers but this is a page that just return an image.
61
62if (GETPOSTISSET("key")) {
63 $key = GETPOST('key');
64 $module = new modTcpdfbarcode();
65 $result = $module->buildBarCode($urlwithroot."/takepos/public/auto_order.php?key=".$key, 'QRCODE', 'Y');
66} else {
67 $module = new modTcpdfbarcode();
68 $result = $module->buildBarCode($urlwithroot."/takepos/public/menu.php", 'QRCODE', 'Y');
69}
Class to generate barcode images using tcpdf barcode generator.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.