2020-07-01 20:47:02 +02:00
|
|
|
<?php require "inc.php"; ?>
|
2019-08-13 21:17:08 +02:00
|
|
|
<!--
|
2020-03-06 21:34:31 +01:00
|
|
|
_ _ _ ___ ____
|
|
|
|
| | (_| |__ _ __ ___ / _ \| _ \
|
|
|
|
| | | | '_ \| '__/ _ | | | | |_) |
|
|
|
|
| |___| | |_) | | | __| |_| | _ <
|
|
|
|
|_____|_|_.__/|_| \___|\__\_|_| \_\
|
2020-10-12 18:55:36 +02:00
|
|
|
A PHP Web interface for generating QR codes
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2021-10-19 17:07:51 +02:00
|
|
|
Source code: https://code.antopie.org/miraty/libreqr
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2020-10-12 18:55:36 +02:00
|
|
|
This file is part of LibreQR.
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2020-10-12 18:55:36 +02:00
|
|
|
LibreQR is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2020-10-12 18:55:36 +02:00
|
|
|
LibreQR 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.
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2020-10-12 18:55:36 +02:00
|
|
|
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2019-08-13 21:17:08 +02:00
|
|
|
-->
|
2020-03-06 21:34:31 +01:00
|
|
|
<?php
|
|
|
|
|
2021-07-11 14:00:35 +02:00
|
|
|
$params = array(
|
|
|
|
"txt" => "",
|
|
|
|
"redondancy" => DEFAULT_REDONDANCY,
|
|
|
|
"margin" => DEFAULT_MARGIN,
|
|
|
|
"size" => DEFAULT_SIZE,
|
|
|
|
"bgColor" => "#" . DEFAULT_BGCOLOR,
|
|
|
|
"mainColor" => "#" . DEFAULT_MAINCOLOR,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (
|
|
|
|
isset($_POST['txt'])
|
|
|
|
AND isset($_POST['redondancy'])
|
|
|
|
AND isset($_POST['margin'])
|
|
|
|
AND isset($_POST['size'])
|
|
|
|
AND isset($_POST['bgColor'])
|
|
|
|
AND isset($_POST['mainColor'])
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (strlen($_POST['txt']) >= 1 AND strlen($_POST['txt']) <= 4096)
|
|
|
|
$params['txt'] = $_POST['txt'];
|
2020-03-06 21:34:31 +01:00
|
|
|
else
|
2022-01-31 16:08:43 +01:00
|
|
|
{
|
|
|
|
http_response_code(400);
|
2021-07-11 14:00:35 +02:00
|
|
|
exit("Wrong value for txt");
|
2022-01-31 16:08:43 +01:00
|
|
|
}
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2021-07-11 14:00:35 +02:00
|
|
|
if ($_POST['redondancy'] === "L" OR $_POST['redondancy'] === "M" OR $_POST['redondancy'] === "Q" OR $_POST['redondancy'] === "H")
|
|
|
|
$params['redondancy'] = $_POST['redondancy'];
|
|
|
|
else
|
2022-01-31 16:08:43 +01:00
|
|
|
{
|
|
|
|
http_response_code(400);
|
2021-07-11 14:00:35 +02:00
|
|
|
exit("Wrong value for redondancy");
|
2022-01-31 16:08:43 +01:00
|
|
|
}
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2021-07-11 14:00:35 +02:00
|
|
|
if (is_numeric($_POST['margin']) AND $_POST['margin'] >= 0 AND $_POST['margin'] <= 128)
|
|
|
|
$params['margin'] = $_POST['margin'];
|
|
|
|
else
|
2022-01-31 16:08:43 +01:00
|
|
|
{
|
|
|
|
http_response_code(400);
|
2021-07-11 14:00:35 +02:00
|
|
|
exit("Wrong value for margin");
|
2022-01-31 16:08:43 +01:00
|
|
|
}
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2021-07-11 14:00:35 +02:00
|
|
|
if (is_numeric($_POST['size']) AND $_POST['size'] >= 1 AND $_POST['size'] <= 128)
|
|
|
|
$params['size'] = $_POST['size'];
|
|
|
|
else
|
2022-01-31 16:08:43 +01:00
|
|
|
{
|
|
|
|
http_response_code(400);
|
2021-07-11 14:00:35 +02:00
|
|
|
exit("Wrong value for size");
|
2022-01-31 16:08:43 +01:00
|
|
|
}
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2021-07-11 14:00:35 +02:00
|
|
|
if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['bgColor']))
|
|
|
|
$params['bgColor'] = $_POST['bgColor'];
|
|
|
|
else
|
2022-01-31 16:08:43 +01:00
|
|
|
{
|
|
|
|
http_response_code(400);
|
2021-07-11 14:00:35 +02:00
|
|
|
exit("Wrong value for bgColor");
|
2022-01-31 16:08:43 +01:00
|
|
|
}
|
2020-03-06 21:34:31 +01:00
|
|
|
|
2021-07-11 14:00:35 +02:00
|
|
|
if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['mainColor']))
|
|
|
|
$params['mainColor'] = $_POST['mainColor'];
|
|
|
|
else
|
2022-01-31 16:08:43 +01:00
|
|
|
{
|
|
|
|
http_response_code(400);
|
2021-07-11 14:00:35 +02:00
|
|
|
exit("Wrong value for mainColor");
|
2022-01-31 16:08:43 +01:00
|
|
|
}
|
2020-03-06 21:34:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
2020-07-01 20:47:02 +02:00
|
|
|
<html lang="<?= $locale ?>">
|
2019-01-26 14:23:19 +01:00
|
|
|
<head>
|
2019-08-13 21:17:08 +02:00
|
|
|
<meta charset="UTF-8">
|
2020-07-01 20:47:02 +02:00
|
|
|
<title>LibreQR · <?= $loc['subtitle'] ?></title>
|
|
|
|
<meta name="description" content="<?= $loc['description'] ?>">
|
2019-02-11 19:26:31 +01:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2019-03-28 22:44:06 +01:00
|
|
|
<link rel="manifest" href="manifest.php">
|
2021-07-11 14:00:35 +02:00
|
|
|
<link rel="search" type="application/opensearchdescription+xml" title="LibreQR" href="opensearch.php?redondancy=<?= $params['redondancy'] ?>&margin=<?= $params['margin'] ?>&size=<?= $params['size'] ?>&bgColor=<?= urlencode($params['bgColor']) ?>&mainColor=<?= urlencode($params['mainColor']) ?>">
|
|
|
|
<?php
|
2020-03-06 21:34:31 +01:00
|
|
|
// If style.min.css exists
|
2020-10-31 16:46:31 +01:00
|
|
|
if (file_exists("temp/style.min.css"))
|
2020-03-17 14:03:25 +01:00
|
|
|
// And if it's older than theme.php or config.inc.php (so not up to date)
|
2020-10-31 16:46:31 +01:00
|
|
|
if (filemtime("themes/" . $theme . "/theme.php") > filemtime("temp/style.min.css") OR filemtime("config.inc.php") > filemtime("temp/style.min.css"))
|
2020-03-06 21:34:31 +01:00
|
|
|
// Then delete it
|
2020-10-31 16:46:31 +01:00
|
|
|
unlink("temp/style.min.css");
|
2019-08-13 21:17:08 +02:00
|
|
|
|
2021-03-07 23:03:33 +01:00
|
|
|
require_once "less.php/lib/Less/Autoloader.php";
|
|
|
|
Less_Autoloader::register();
|
|
|
|
|
2021-10-19 17:07:51 +02:00
|
|
|
$options = array('cache_dir' => 'temp/', 'compress' => true);
|
|
|
|
$cssFileName = Less_Cache::Get(array("style.less" => ""), $options, $colorScheme);
|
2021-03-07 23:03:33 +01:00
|
|
|
|
2020-03-06 21:34:31 +01:00
|
|
|
?>
|
2021-03-07 23:03:33 +01:00
|
|
|
<link type="text/css" rel="stylesheet" href="temp/<?= $cssFileName ?>">
|
2021-07-11 14:00:35 +02:00
|
|
|
<?php
|
2020-07-01 20:47:02 +02:00
|
|
|
foreach($themeDimensionsIcons as $dimFav) { // Set all icons dimensions
|
2020-03-06 21:34:31 +01:00
|
|
|
echo ' <link rel="icon" type="image/png" href="themes/' . $theme . '/icons/' . $dimFav . '.png" sizes="' . $dimFav . 'x' . $dimFav . '">' . "\n";
|
|
|
|
} ?>
|
2019-01-26 14:23:19 +01:00
|
|
|
</head>
|
|
|
|
|
2020-03-06 21:34:31 +01:00
|
|
|
<body>
|
|
|
|
|
2020-07-01 20:47:02 +02:00
|
|
|
<main>
|
2019-01-26 14:23:19 +01:00
|
|
|
|
2019-03-17 16:03:43 +01:00
|
|
|
<header>
|
2020-10-25 18:02:57 +01:00
|
|
|
<a id="linkTitles" href="./">
|
|
|
|
<img alt="" id="logo" src="themes/<?php echo $theme; ?>/icons/128.png">
|
|
|
|
<div id="titles">
|
2021-10-23 18:34:52 +02:00
|
|
|
<h1>QRCode.libre-service.eu</h1>
|
2020-07-01 20:47:02 +02:00
|
|
|
<h2><?= $loc['subtitle'] ?></h2>
|
2020-03-06 21:34:31 +01:00
|
|
|
</div>
|
|
|
|
</a>
|
2019-03-17 16:03:43 +01:00
|
|
|
</header>
|
2019-08-13 21:17:08 +02:00
|
|
|
|
2021-07-11 14:00:35 +02:00
|
|
|
<form method="post" action="./">
|
2019-01-26 14:23:19 +01:00
|
|
|
|
2020-03-06 21:34:31 +01:00
|
|
|
<div id="firstWrapper">
|
2019-08-13 21:17:08 +02:00
|
|
|
|
2021-07-11 21:48:56 +02:00
|
|
|
<div class="param" id="txtParam">
|
2021-03-07 19:06:32 +01:00
|
|
|
<label for="txt">
|
|
|
|
<details>
|
|
|
|
<summary><?= $loc['label_content'] ?></summary>
|
|
|
|
<p class="helpText">
|
|
|
|
<?= $loc['help_content'] ?>
|
|
|
|
</p>
|
|
|
|
</details>
|
|
|
|
</label>
|
2021-07-11 14:00:35 +02:00
|
|
|
<textarea rows="8" required="" id="txt" placeholder="<?= $loc['placeholder'] ?>" name="txt" minlenght="5" maxlenght="50"><?= htmlspecialchars($params['txt']) ?></textarea>
|
2019-03-17 16:03:43 +01:00
|
|
|
</div>
|
|
|
|
|
2021-05-03 15:18:50 +02:00
|
|
|
<div id="sideParams">
|
2020-03-06 21:34:31 +01:00
|
|
|
|
|
|
|
<div class="param">
|
2021-03-07 19:06:32 +01:00
|
|
|
<label for="redondancy">
|
|
|
|
<details>
|
|
|
|
<summary><?= $loc['label_redondancy'] ?></summary>
|
|
|
|
<p class="helpText">
|
|
|
|
<?= $loc['help_redondancy'] ?>
|
|
|
|
</p>
|
|
|
|
</details>
|
|
|
|
</label>
|
2020-03-06 21:34:31 +01:00
|
|
|
<select id="redondancy" name="redondancy">
|
2021-07-11 14:00:35 +02:00
|
|
|
<option <?php if ($params['redondancy'] === "L") echo 'selected="" '; ?>value="L">L - 7%</option>
|
|
|
|
<option <?php if ($params['redondancy'] === "M") echo 'selected="" '; ?>value="M">M - 15%</option>
|
|
|
|
<option <?php if ($params['redondancy'] === "Q") echo 'selected="" '; ?>value="Q">Q - 25%</option>
|
|
|
|
<option <?php if ($params['redondancy'] === "H") echo 'selected="" '; ?>value="H">H - 30%</option>
|
2020-03-06 21:34:31 +01:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="param">
|
2021-03-07 19:06:32 +01:00
|
|
|
<label for="margin">
|
|
|
|
<details>
|
|
|
|
<summary><?= $loc['label_margin'] ?></summary>
|
|
|
|
<p class="helpText">
|
|
|
|
<?= $loc['help_margin'] ?>
|
|
|
|
</p>
|
|
|
|
</details>
|
|
|
|
</label>
|
2021-07-11 14:00:35 +02:00
|
|
|
<input type="number" id="margin" placeholder="2" name="margin" min="0" max="128" value="<?= htmlspecialchars($params['margin']) ?>">
|
2020-03-06 21:34:31 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="param">
|
2021-03-07 19:06:32 +01:00
|
|
|
<label for="size">
|
|
|
|
<details>
|
|
|
|
<summary><?= $loc['label_size'] ?></summary>
|
|
|
|
<p class="helpText">
|
|
|
|
<?= $loc['help_size'] ?>
|
|
|
|
</p>
|
|
|
|
</details>
|
|
|
|
</label>
|
2021-07-11 14:00:35 +02:00
|
|
|
<input type="number" id="size" placeholder="4" name="size" min="1" max="128" value="<?= htmlspecialchars($params['size']) ?>">
|
2020-03-06 21:34:31 +01:00
|
|
|
</div>
|
|
|
|
|
2019-03-17 16:03:43 +01:00
|
|
|
</div>
|
|
|
|
|
2020-03-06 21:34:31 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="colors">
|
|
|
|
|
2019-03-17 16:03:43 +01:00
|
|
|
<div class="param">
|
2020-07-01 20:47:02 +02:00
|
|
|
<label for="bgColor"><?= $loc['label_bgColor'] ?></label>
|
2020-10-25 18:02:57 +01:00
|
|
|
<div class="inputColorContainer">
|
2021-07-11 14:00:35 +02:00
|
|
|
<input type="color" name="bgColor" id="bgColor" value="<?= htmlspecialchars($params['bgColor']) ?>">
|
2020-03-06 21:34:31 +01:00
|
|
|
</div>
|
2019-03-17 16:03:43 +01:00
|
|
|
</div>
|
2019-01-26 14:23:19 +01:00
|
|
|
|
2020-03-06 21:34:31 +01:00
|
|
|
<div class="param">
|
2020-07-01 20:47:02 +02:00
|
|
|
<label for="mainColor"><?= $loc['label_mainColor'] ?></label>
|
2020-10-25 18:02:57 +01:00
|
|
|
<div class="inputColorContainer">
|
2021-07-11 14:00:35 +02:00
|
|
|
<input type="color" name="mainColor" id="mainColor" value="<?= htmlspecialchars($params['mainColor']) ?>">
|
2020-03-06 21:34:31 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-03-17 16:03:43 +01:00
|
|
|
</div>
|
2019-08-13 21:17:08 +02:00
|
|
|
|
2020-07-01 20:47:02 +02:00
|
|
|
<div class="centered">
|
2020-10-25 18:02:57 +01:00
|
|
|
<input class="button" type="submit" value="<?= $loc['button_create'] ?>" />
|
2019-03-17 16:03:43 +01:00
|
|
|
</div>
|
2019-02-11 19:26:31 +01:00
|
|
|
|
2019-03-17 16:03:43 +01:00
|
|
|
</form>
|
2019-02-11 19:26:31 +01:00
|
|
|
|
2021-07-11 21:48:56 +02:00
|
|
|
<section id="output">
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
if (!empty($params['txt'])) {
|
|
|
|
require "phpqrcode.php";
|
|
|
|
|
|
|
|
$imagePath = "temp/" . generateRandomString($fileNameLenght) . ".png";
|
|
|
|
QRcode::png(
|
|
|
|
$params['txt'],
|
|
|
|
$imagePath,
|
|
|
|
$params['redondancy'],
|
|
|
|
$params['size'],
|
|
|
|
$params['margin'],
|
|
|
|
false,
|
|
|
|
hexdec(substr($params['bgColor'], -6)),
|
|
|
|
hexdec(substr($params['mainColor'], -6))
|
|
|
|
);
|
|
|
|
?>
|
|
|
|
<div class="centered" id="downloadQR">
|
|
|
|
<a href="<?php echo $imagePath; ?>" class="button" download="<?= htmlspecialchars($params['txt']); ?>.png"><?= $loc['button_download'] ?></a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="centered" id="showOnlyQR">
|
|
|
|
<a title="<?= $loc['title_showOnlyQR'] ?>" href="<?= $imagePath; ?>"><img alt='<?= $loc['alt_QR_before'] ?><?= htmlspecialchars($params['txt']); ?><?= $loc['alt_QR_after'] ?>' id="qrCode" src="<?= $imagePath; ?>"/></a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
</section>
|
2019-02-11 19:26:31 +01:00
|
|
|
|
2020-10-25 18:02:57 +01:00
|
|
|
<footer>
|
2020-10-12 18:55:36 +02:00
|
|
|
|
2020-10-25 18:02:57 +01:00
|
|
|
<section id="info" class="metaText">
|
|
|
|
<?= $loc['metaText_qr'] ?>
|
|
|
|
</section>
|
2020-10-12 18:55:36 +02:00
|
|
|
|
2020-10-25 18:02:57 +01:00
|
|
|
<?php if ($customTextEnabled) { ?>
|
|
|
|
<section class="metaText">
|
|
|
|
<?= $customText ?>
|
|
|
|
</section>
|
2020-10-12 18:55:36 +02:00
|
|
|
<?php } ?>
|
2020-10-25 18:02:57 +01:00
|
|
|
|
|
|
|
<section class="metaText">
|
|
|
|
<?= $loc['metaText_legal'] ?>
|
|
|
|
</section>
|
|
|
|
|
2020-10-12 18:55:36 +02:00
|
|
|
</footer>
|
|
|
|
|
2020-07-01 20:47:02 +02:00
|
|
|
</main>
|
2019-02-11 19:26:31 +01:00
|
|
|
|
2019-03-17 16:03:43 +01:00
|
|
|
</body>
|
|
|
|
</html>
|