mirror of
https://git.bakhai.co.in/FbIN/libreqr.git
synced 2026-04-22 10:16:18 +05:30
Synced
Also now maintaining these upstream changes under synclog file.
This commit is contained in:
parent
d0cf31a918
commit
0ec7a7f93d
17 changed files with 343 additions and 192 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
|
@ -1,4 +1,3 @@
|
|||
/.directory
|
||||
/css/*
|
||||
!/css/.gitkeep
|
||||
/composer.lock
|
||||
/.php-cs-fixer.cache
|
||||
/.php-cs-fixer.php
|
||||
/phpstan.neon
|
||||
|
|
|
|||
26
.php-cs-fixer.dist.php
Normal file
26
.php-cs-fixer.dist.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
|
||||
return (new Config())
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PhpCsFixer:risky' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'echo_tag_syntax' => ['format' => 'short'],
|
||||
'semicolon_after_instruction' => false,
|
||||
'blank_line_before_statement' => false,
|
||||
'yoda_style' => false,
|
||||
'string_length_to_empty' => false,
|
||||
'declare_strict_types' => true,
|
||||
])
|
||||
->setIndent("\t")
|
||||
->setFinder(
|
||||
(new Finder())
|
||||
->in(__DIR__)
|
||||
->exclude(['locales'])
|
||||
)
|
||||
;
|
||||
|
|
@ -21,6 +21,7 @@ To ease with webserver configuration, `index.php` is now able to serve any HTTP
|
|||
### Fixed
|
||||
|
||||
* Clicking on a label opens the help text if available instead of focusing the related input field
|
||||
* Respond with `Content-Language` HTTP header
|
||||
|
||||
## 2.0.1 - 2023-07-08
|
||||
|
||||
|
|
|
|||
11
common.php
11
common.php
|
|
@ -1,3 +1,4 @@
|
|||
<?php declare(strict_types=1); ?>
|
||||
<div id="sideParams">
|
||||
<div class="param">
|
||||
<details>
|
||||
|
|
@ -7,10 +8,10 @@
|
|||
</p>
|
||||
</details>
|
||||
<select id="redundancy" name="main[redundancy]">
|
||||
<option <?php if ($_POST['main']['redundancy'] === "low") echo 'selected="" '; ?>value="low">L - 7%</option>
|
||||
<option <?php if ($_POST['main']['redundancy'] === "medium") echo 'selected="" '; ?>value="medium">M - 15%</option>
|
||||
<option <?php if ($_POST['main']['redundancy'] === "quartile") echo 'selected="" '; ?>value="quartile">Q - 25%</option>
|
||||
<option <?php if ($_POST['main']['redundancy'] === "high") echo 'selected="" '; ?>value="high">H - 30%</option>
|
||||
<option <?= $_POST['main']['redundancy'] === 'low' ? 'selected="" ' : '' ?>value="low">L - 7%</option>
|
||||
<option <?= $_POST['main']['redundancy'] === 'medium' ? 'selected="" ' : '' ?>value="medium">M - 15%</option>
|
||||
<option <?= $_POST['main']['redundancy'] === 'quartile' ? 'selected="" ' : '' ?>value="quartile">Q - 25%</option>
|
||||
<option <?= $_POST['main']['redundancy'] === 'high' ? 'selected="" ' : '' ?>value="high">H - 30%</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
|
@ -48,5 +49,5 @@
|
|||
</div>
|
||||
|
||||
<div class="centered">
|
||||
<input class="button" type="submit" value="<?= getIntlString('button_create', raw: true) ?>" />
|
||||
<input id="main-submit" class="button" type="submit" value="<?= getIntlString('button_create', raw: true) ?>">
|
||||
</div>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"require": {
|
||||
"endroid/qr-code": "^4.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"php": ">=8.5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
<?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
// This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
|
||||
|
||||
// LIBREQR SETTINGS
|
||||
|
||||
// Theme's directory name
|
||||
define("THEME", "libreqr");
|
||||
define('THEME', 'libreqr');
|
||||
|
||||
// Language used if those requested by the user are not available
|
||||
define("DEFAULT_LOCALE", "en");
|
||||
define('DEFAULT_LOCALE', 'en');
|
||||
|
||||
// Will be printed at the bottom of the interface
|
||||
define("CUSTOM_TEXT_ENABLED", true);
|
||||
define("CUSTOM_TEXT", "This LibreQR instance is hosted by <a href='https://git.flossboxin.org.in/FbIN/libreqr/'>FbIN</a>.");
|
||||
define('CUSTOM_TEXT_ENABLED', true);
|
||||
define('CUSTOM_TEXT', 'This LibreQR instance is hosted by <a href="https://git.flossboxin.org.in/FbIN/libreqr/">foo</a>.');
|
||||
|
||||
// Default values
|
||||
define("DEFAULT_REDUNDANCY", "high");
|
||||
define("DEFAULT_MARGIN", 20);
|
||||
define("DEFAULT_SIZE", 300);
|
||||
define("DEFAULT_BGCOLOR", "F8F8FF");
|
||||
define("DEFAULT_FGCOLOR", "7D8800");
|
||||
define('DEFAULT_REDUNDANCY', 'high');
|
||||
define('DEFAULT_MARGIN', '20');
|
||||
define('DEFAULT_SIZE', '300');
|
||||
define('DEFAULT_BGCOLOR', 'F8F8FF');
|
||||
define('DEFAULT_FGCOLOR', '7D8800');
|
||||
|
|
|
|||
236
index.php
236
index.php
|
|
@ -1,72 +1,80 @@
|
|||
<?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
// This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
|
||||
|
||||
use Endroid\QrCode\Builder\Builder;
|
||||
use Endroid\QrCode\Color\Color;
|
||||
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh;
|
||||
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow;
|
||||
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelMedium;
|
||||
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelQuartile;
|
||||
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh;
|
||||
use Endroid\QrCode\Color\Color;
|
||||
|
||||
require "config.inc.php";
|
||||
require "vendor/autoload.php";
|
||||
require 'config.inc.php';
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
const CONTRAST_THRESHOLD = 64;
|
||||
const LIBREQR_VERSION = '2.0.1+dev';
|
||||
const FbIN_QR_VERSION = '2.0.1+dev';
|
||||
|
||||
// Defines the locale to be used
|
||||
$locale = DEFAULT_LOCALE;
|
||||
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||
$clientLocales = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
$clientLocales = preg_replace("#[A-Z0-9]|q=|;|-|\.#", "", $clientLocales);
|
||||
$clientLocales = preg_replace('#[A-Z0-9]|q=|;|-|\.#', '', $clientLocales);
|
||||
$clientLocales = explode(',', $clientLocales);
|
||||
foreach (array_diff(scandir("locales"), array('..', '.')) as $key => $localeFile)
|
||||
$availableLocales[$key] = basename($localeFile, ".php");
|
||||
foreach (array_diff(scandir('locales'), ['.', '..']) as $key => $localeFile) {
|
||||
$availableLocales[$key] = basename($localeFile, '.php');
|
||||
}
|
||||
foreach ($clientLocales as $clientLocale) {
|
||||
if (in_array($clientLocale, $availableLocales)) {
|
||||
if (in_array($clientLocale, $availableLocales, true)) {
|
||||
$locale = $clientLocale;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
header('Content-Language: ' . $locale);
|
||||
|
||||
require "locales/" . $locale . ".php";
|
||||
require 'locales/' . $locale . '.php';
|
||||
$chosen_loc = $loc;
|
||||
|
||||
if ($locale != DEFAULT_LOCALE) {
|
||||
require "locales/" . DEFAULT_LOCALE . ".php";
|
||||
if ($locale !== DEFAULT_LOCALE) {
|
||||
require 'locales/' . DEFAULT_LOCALE . '.php';
|
||||
$default_loc = $loc;
|
||||
} else
|
||||
} else {
|
||||
$default_loc = $chosen_loc;
|
||||
}
|
||||
|
||||
require "locales/en.php";
|
||||
require 'locales/en.php';
|
||||
$english_loc = $loc;
|
||||
|
||||
// Function to get a specific string from the english file, fall back on default then template if missing
|
||||
// Function to get a specific string from the locale file, fall back on default then english if missing
|
||||
function getIntlString(
|
||||
$string_label,
|
||||
$raw = false
|
||||
) {
|
||||
string $string_label,
|
||||
bool $raw = false,
|
||||
): string {
|
||||
global $chosen_loc, $default_loc, $english_loc, $locale;
|
||||
|
||||
if (array_key_exists($string_label, $chosen_loc) AND $chosen_loc[$string_label] !== '')
|
||||
if (array_key_exists($string_label, $chosen_loc) && $chosen_loc[$string_label] !== '') {
|
||||
return $chosen_loc[$string_label];
|
||||
|
||||
if ($locale != DEFAULT_LOCALE AND array_key_exists($string_label, $default_loc) AND $default_loc[$string_label] !== '') {
|
||||
if ($raw)
|
||||
return $default_loc[$string_label];
|
||||
return "<span lang=\"" . DEFAULT_LOCALE . "\">" . $default_loc[$string_label] . "</span>";
|
||||
}
|
||||
|
||||
if ($raw)
|
||||
if ($locale !== DEFAULT_LOCALE && array_key_exists($string_label, $default_loc) && $default_loc[$string_label] !== '') {
|
||||
if ($raw) {
|
||||
return $default_loc[$string_label];
|
||||
}
|
||||
return '<span lang="' . DEFAULT_LOCALE . '">' . $default_loc[$string_label] . '</span>';
|
||||
}
|
||||
|
||||
if ($raw) {
|
||||
return $english_loc[$string_label];
|
||||
return "<span lang=\"en\">" . $english_loc[$string_label] . "</span>";
|
||||
}
|
||||
return '<span lang="en">' . $english_loc[$string_label] . '</span>';
|
||||
}
|
||||
|
||||
function getIntlStringInterpolated(
|
||||
$string_label,
|
||||
$vars = [],
|
||||
$raw = false,
|
||||
) {
|
||||
string $string_label,
|
||||
array $vars = [],
|
||||
bool $raw = false,
|
||||
): string {
|
||||
return vsprintf(getIntlString($string_label, $raw), $vars);
|
||||
}
|
||||
|
||||
|
|
@ -80,127 +88,130 @@ define('PAGE', match ($matches['page']) {
|
|||
define('ICONS_DIR', 'themes/' . THEME . '/icons');
|
||||
$icon_files = array_diff(scandir(ICONS_DIR), ['.', '..']);
|
||||
if (PAGE === 'unknown') {
|
||||
$allowed_filenames['LICENSE.html'] = 'text/html';
|
||||
$allowed_filenames['synclog.txt'] = 'text/html';
|
||||
$allowed_filenames['style.css'] = 'text/css';
|
||||
$allowed_filenames['themes/' . THEME . '/theme.css'] = 'text/css';
|
||||
$allowed_filenames['themes/' . THEME . '/logo-dark.png'] = 'image/png';
|
||||
$allowed_filenames['themes/' . THEME . '/logo-light.png'] = 'image/png';
|
||||
foreach ($icon_files as $icon_file)
|
||||
foreach ($icon_files as $icon_file) {
|
||||
$allowed_filenames[ICONS_DIR . '/' . $icon_file] = 'image/png';
|
||||
}
|
||||
foreach ($allowed_filenames as $filename => $type) {
|
||||
if (str_ends_with($_SERVER['REQUEST_URI'], $filename)) {
|
||||
header('Content-Type: ' . $type);
|
||||
echo file_get_contents($filename);
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
http_response_code(404);
|
||||
}
|
||||
|
||||
$_POST = [
|
||||
"form" => $_POST['form'] ?? NULL,
|
||||
"wifi" => [
|
||||
"ssid" => $_POST['wifi']['ssid'] ?? "",
|
||||
"password" => $_POST['wifi']['password'] ?? "",
|
||||
'wifi' => [
|
||||
'ssid' => (string) ($_POST['wifi']['ssid'] ?? ''),
|
||||
'password' => (string) ($_POST['wifi']['password'] ?? ''),
|
||||
],
|
||||
"main" => [
|
||||
"txt" => $_POST['main']['txt'] ?? "",
|
||||
"redundancy" => $_POST['main']['redundancy'] ?? DEFAULT_REDUNDANCY,
|
||||
"margin" => $_POST['main']['margin'] ?? DEFAULT_MARGIN,
|
||||
"size" => $_POST['main']['size'] ?? DEFAULT_SIZE,
|
||||
"bgColor" => $_POST['main']['bgColor'] ?? "#" . DEFAULT_BGCOLOR,
|
||||
"fgColor" => $_POST['main']['fgColor'] ?? "#" . DEFAULT_FGCOLOR,
|
||||
'main' => [
|
||||
'txt' => (string) ($_POST['main']['txt'] ?? ''),
|
||||
'redundancy' => $_POST['main']['redundancy'] ?? (string) DEFAULT_REDUNDANCY,
|
||||
'margin' => $_POST['main']['margin'] ?? (string) DEFAULT_MARGIN,
|
||||
'size' => $_POST['main']['size'] ?? (string) DEFAULT_SIZE,
|
||||
'bgColor' => $_POST['main']['bgColor'] ?? '#' . (string) DEFAULT_BGCOLOR,
|
||||
'fgColor' => $_POST['main']['fgColor'] ?? '#' . (string) DEFAULT_FGCOLOR,
|
||||
],
|
||||
];
|
||||
|
||||
if ($_POST['wifi']['ssid'] !== "") {
|
||||
if (!(strlen($_POST['wifi']['ssid']) >= 1 AND strlen($_POST['wifi']['ssid']) <= 4096)) {
|
||||
if ($_POST['wifi']['ssid'] !== '') {
|
||||
if (!(strlen($_POST['wifi']['ssid']) >= 1 && strlen($_POST['wifi']['ssid']) <= 4096)) {
|
||||
http_response_code(400);
|
||||
exit("Wrong value for ssid");
|
||||
exit('Wrong value for ssid');
|
||||
}
|
||||
$escaped_ssid = preg_replace("/([\\\;\,\"\:])/", "\\\\$1", $_POST['wifi']['ssid']);
|
||||
$escaped_ssid = preg_replace('/([\\\;\,"\:])/', '\\\$1', $_POST['wifi']['ssid']);
|
||||
|
||||
if ($_POST['wifi']['password'] === "")
|
||||
if ($_POST['wifi']['password'] === '') {
|
||||
$_POST['main']['txt'] = "WIFI:T:nopass;S:{$escaped_ssid};;";
|
||||
else {
|
||||
} else {
|
||||
if (strlen($_POST['wifi']['password']) > 4096) {
|
||||
http_response_code(400);
|
||||
exit("Wrong value for password");
|
||||
exit('Wrong value for password');
|
||||
}
|
||||
|
||||
$escaped_password = preg_replace("/([\\\;\,\"\:])/", "\\\\$1", $_POST['wifi']['password']);
|
||||
$escaped_password = preg_replace('/([\\\;\,"\:])/', '\\\$1', $_POST['wifi']['password']);
|
||||
|
||||
$_POST['main']['txt'] = "WIFI:T:WPA;S:{$escaped_ssid};P:{$escaped_password};;";
|
||||
}
|
||||
}
|
||||
|
||||
$qrCodeAvailable = NULL;
|
||||
$qrCodeAvailable = null;
|
||||
|
||||
if ($_POST['main']['txt'] !== "") {
|
||||
if ($_POST['main']['txt'] !== '') {
|
||||
$qrCodeAvailable = true;
|
||||
|
||||
if (!(strlen($_POST['main']['txt']) >= 1 AND strlen($_POST['main']['txt']) <= 4096)) {
|
||||
if (!(strlen($_POST['main']['txt']) >= 1 && strlen($_POST['main']['txt']) <= 4096)) {
|
||||
http_response_code(400);
|
||||
exit("Wrong value for txt");
|
||||
exit('Wrong value for txt');
|
||||
}
|
||||
|
||||
if (!in_array($_POST['main']['redundancy'], ["low", "medium", "quartile", "high"], strict: true)) {
|
||||
if (!in_array($_POST['main']['redundancy'], ['low', 'medium', 'quartile', 'high'], strict: true)) {
|
||||
http_response_code(400);
|
||||
exit("Wrong value for redundancy");
|
||||
exit('Wrong value for redundancy');
|
||||
}
|
||||
|
||||
if (!(is_numeric($_POST['main']['margin']) AND $_POST['main']['margin'] >= 0 AND $_POST['main']['margin'] <= 1024)) {
|
||||
if (!(is_numeric($_POST['main']['margin']) && $_POST['main']['margin'] >= 0 && $_POST['main']['margin'] <= 1024)) {
|
||||
http_response_code(400);
|
||||
exit("Wrong value for margin");
|
||||
exit('Wrong value for margin');
|
||||
}
|
||||
|
||||
if (!(is_numeric($_POST['main']['size']) AND $_POST['main']['size'] >= 21 AND $_POST['main']['size'] <= 4096)) {
|
||||
if (!(is_numeric($_POST['main']['size']) && $_POST['main']['size'] >= 21 && $_POST['main']['size'] <= 4096)) {
|
||||
http_response_code(400);
|
||||
exit("Wrong value for size");
|
||||
exit('Wrong value for size');
|
||||
}
|
||||
|
||||
if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['main']['bgColor']) === false) {
|
||||
if (preg_match('/^#[abcdefABCDEF0-9]{6}$/', $_POST['main']['bgColor']) === false) {
|
||||
http_response_code(400);
|
||||
exit("Wrong value for bgColor");
|
||||
exit('Wrong value for bgColor');
|
||||
}
|
||||
|
||||
if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['main']['fgColor']) === false) {
|
||||
if (preg_match('/^#[abcdefABCDEF0-9]{6}$/', $_POST['main']['fgColor']) === false) {
|
||||
http_response_code(400);
|
||||
exit("Wrong value for fgColor");
|
||||
exit('Wrong value for fgColor');
|
||||
}
|
||||
|
||||
$rgbBgColor = [
|
||||
'r' => hexdec(substr($_POST['main']['bgColor'],1,2)),
|
||||
'g' => hexdec(substr($_POST['main']['bgColor'],3,2)),
|
||||
'b' => hexdec(substr($_POST['main']['bgColor'],5,2)),
|
||||
'r' => hexdec(substr($_POST['main']['bgColor'], 1, 2)),
|
||||
'g' => hexdec(substr($_POST['main']['bgColor'], 3, 2)),
|
||||
'b' => hexdec(substr($_POST['main']['bgColor'], 5, 2)),
|
||||
];
|
||||
|
||||
$qrCode = Builder::create()
|
||||
->data($_POST['main']['txt'])
|
||||
->margin($_POST['main']['margin'])
|
||||
->size($_POST['main']['size'])
|
||||
->margin((int) $_POST['main']['margin'])
|
||||
->size((int) $_POST['main']['size'])
|
||||
->errorCorrectionLevel(match ($_POST['main']['redundancy']) {
|
||||
"low" => new ErrorCorrectionLevelLow(),
|
||||
"medium" => new ErrorCorrectionLevelMedium(),
|
||||
"quartile" => new ErrorCorrectionLevelQuartile(),
|
||||
"high" => new ErrorCorrectionLevelHigh(),
|
||||
'low' => new ErrorCorrectionLevelLow(),
|
||||
'medium' => new ErrorCorrectionLevelMedium(),
|
||||
'quartile' => new ErrorCorrectionLevelQuartile(),
|
||||
'high' => new ErrorCorrectionLevelHigh(),
|
||||
})
|
||||
->backgroundColor(new Color(
|
||||
$rgbBgColor['r'],
|
||||
$rgbBgColor['g'],
|
||||
$rgbBgColor['b'],
|
||||
(int) $rgbBgColor['r'],
|
||||
(int) $rgbBgColor['g'],
|
||||
(int) $rgbBgColor['b'],
|
||||
))
|
||||
->foregroundColor(new Color(
|
||||
hexdec(substr($_POST['main']['fgColor'],1,2)),
|
||||
hexdec(substr($_POST['main']['fgColor'],3,2)),
|
||||
hexdec(substr($_POST['main']['fgColor'],5,2)),
|
||||
));
|
||||
(int) hexdec(substr($_POST['main']['fgColor'], 1, 2)),
|
||||
(int) hexdec(substr($_POST['main']['fgColor'], 3, 2)),
|
||||
(int) hexdec(substr($_POST['main']['fgColor'], 5, 2)),
|
||||
))
|
||||
;
|
||||
|
||||
try {
|
||||
$result = $qrCode->build();
|
||||
} catch (Exception $ex) {
|
||||
http_response_code(500);
|
||||
$qrCodeAvailable = false;
|
||||
error_log("FbIN QR encountered an error while generating a QR code: " . $ex);
|
||||
error_log('FbIN QR encountered an error while generating a QR code: ' . $ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,13 +220,11 @@ if ($_POST['main']['txt'] !== "") {
|
|||
<html lang="<?= $locale ?>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?=
|
||||
match (PAGE) {
|
||||
'home' => 'FbIN QR · ' . getIntlString('subtitle'),
|
||||
'wifi' => 'FbIN QR · ' .getIntlString('tab_wifi_title'),
|
||||
'unknown' => 'FbIN QR · ' .getIntlString('error_404'),
|
||||
}
|
||||
?></title>
|
||||
<title><?= match (PAGE) {
|
||||
'home' => 'FbIN QR · ' . getIntlString('subtitle'),
|
||||
'wifi' => getIntlString('tab_wifi_title') . ' · FbIN QR',
|
||||
'unknown' => getIntlString('error_404') . ' · FbIN QR',
|
||||
} ?></title>
|
||||
<meta name="description" content="<?= getIntlString('description', raw: true) ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="color-scheme" content="dark light">
|
||||
|
|
@ -231,9 +240,10 @@ match (PAGE) {
|
|||
<link rel="stylesheet" media="screen" href="themes/<?= THEME ?>/theme.css">
|
||||
<?php
|
||||
natsort($icon_files);
|
||||
foreach($icon_files as $icon_file) {
|
||||
if (ctype_digit($icon_size = substr($icon_file, 0, -4)))
|
||||
foreach ($icon_files as $icon_file) {
|
||||
if (ctype_digit($icon_size = substr($icon_file, 0, -4))) {
|
||||
echo ' <link rel="icon" type="image/png" href="' . ICONS_DIR . '/' . $icon_size . '.png" sizes="' . $icon_size . 'x' . $icon_size . '">' . "\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
|
|
@ -252,8 +262,12 @@ foreach($icon_files as $icon_file) {
|
|||
<nav>
|
||||
<h2 class="sr-only">Type de code QR</h2>
|
||||
<ul>
|
||||
<li<?php if (PAGE == 'home') echo ' class="tab-selected"' ?>><a href="./"><div><?= getIntlString('tab_text') ?></div></a></li>
|
||||
<li<?php if (PAGE == 'wifi') echo ' class="tab-selected"' ?>><a href="./wifi"><div><?= getIntlString('tab_wifi') ?></div></a></li>
|
||||
<li<?php if (PAGE === 'home') {
|
||||
echo ' class="tab-selected"';
|
||||
} ?>><a href="./"><div><?= getIntlString('tab_text') ?></div></a></li>
|
||||
<li<?php if (PAGE === 'wifi') {
|
||||
echo ' class="tab-selected"';
|
||||
} ?>><a href="./wifi"><div><?= getIntlString('tab_wifi') ?></div></a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
|
@ -274,7 +288,7 @@ foreach($icon_files as $icon_file) {
|
|||
</div>
|
||||
<?php require 'common.php' ?>
|
||||
</form>
|
||||
<?php } else if (PAGE === 'home') { ?>
|
||||
<?php } elseif (PAGE === 'home') { ?>
|
||||
<form method="post" action="./#output" id="form">
|
||||
<div class="param textboxParam" id="txtParam">
|
||||
<details>
|
||||
|
|
@ -298,9 +312,9 @@ foreach($icon_files as $icon_file) {
|
|||
if ($qrCodeAvailable) {
|
||||
$dataUri = $result->getDataUri();
|
||||
|
||||
$qrSize = $_POST['main']['size'] + 2 * $_POST['main']['margin'];
|
||||
$qrSize = (int) ($_POST['main']['size']) + 2 * (int) ($_POST['main']['margin']);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
<section id="output">
|
||||
<div class="centered" id="downloadQR">
|
||||
|
|
@ -317,43 +331,49 @@ if ($qrCodeAvailable) {
|
|||
$css,
|
||||
);
|
||||
if (
|
||||
abs($rgbBgColor['r'] - hexdec(substr($css['bg_light'], -6, 2)))
|
||||
abs($rgbBgColor['r'] - hexdec(substr($css['bg_light'], -6, 2)))
|
||||
+ abs($rgbBgColor['g'] - hexdec(substr($css['bg_light'], -4, 2)))
|
||||
+ abs($rgbBgColor['b'] - hexdec(substr($css['bg_light'], -2, 2)))
|
||||
< CONTRAST_THRESHOLD
|
||||
)
|
||||
) {
|
||||
echo " class='needLightContrast'";
|
||||
}
|
||||
if (
|
||||
abs($rgbBgColor['r'] - hexdec(substr($css['bg_dark'], -6, 2)))
|
||||
abs($rgbBgColor['r'] - hexdec(substr($css['bg_dark'], -6, 2)))
|
||||
+ abs($rgbBgColor['g'] - hexdec(substr($css['bg_dark'], -4, 2)))
|
||||
+ abs($rgbBgColor['b'] - hexdec(substr($css['bg_dark'], -2, 2)))
|
||||
< CONTRAST_THRESHOLD
|
||||
)
|
||||
) {
|
||||
echo " class='needDarkContrast'";
|
||||
}
|
||||
|
||||
?> src="<?= $dataUri ?>"></a></output>
|
||||
?> src="<?= $dataUri ?>"></a></output>
|
||||
</div>
|
||||
<?php if (PAGE === "wifi") { ?>
|
||||
<?php if (PAGE === 'wifi') { ?>
|
||||
<p>
|
||||
<?= getIntlStringInterpolated('wifi_raw_content', ['<code>' . htmlspecialchars($_POST['main']['txt']) . '</code>']) ?>
|
||||
</p>
|
||||
<form method="POST" action="./">
|
||||
<?php foreach ($_POST['main'] as $name => $value) { ?>
|
||||
<input type="hidden" name="main[<?= htmlspecialchars($name) ?>]" value="<?= htmlspecialchars($value) ?>" />
|
||||
<input type="hidden" name="main[<?= htmlspecialchars($name) ?>]" value="<?= htmlspecialchars($value) ?>">
|
||||
<?php } ?>
|
||||
<input type="submit" value="<?= getIntlString('button_edit', raw: true) ?>" />
|
||||
<input type="submit" class="button" value="<?= getIntlString('button_edit', raw: true) ?>">
|
||||
</form>
|
||||
<?php } ?>
|
||||
</section>
|
||||
|
||||
<?php
|
||||
} else if ($qrCodeAvailable === false) {
|
||||
echo " <p><strong>" . getIntlString('error_generation') . "</strong></p></body></html>";
|
||||
} elseif ($qrCodeAvailable === false) {
|
||||
echo ' <p><strong>' . getIntlString('error_generation') . '</strong></p></body></html>';
|
||||
}
|
||||
?>
|
||||
|
||||
<footer>
|
||||
|
||||
<section id="info" class="metaText">
|
||||
<?= getIntlString('metaText_qr') ?>
|
||||
</section>
|
||||
|
||||
<?php if (CUSTOM_TEXT_ENABLED) { ?>
|
||||
<section class="metaText">
|
||||
<?= CUSTOM_TEXT ?>
|
||||
|
|
@ -361,7 +381,7 @@ if ($qrCodeAvailable) {
|
|||
<?php } ?>
|
||||
|
||||
<section class="metaText">
|
||||
<small><?= getIntlStringInterpolated('metaText_legal', [LIBREQR_VERSION]) ?></small>
|
||||
<small><?= getIntlStringInterpolated('metaText_legal', [FbIN_QR_VERSION]) ?></small>
|
||||
</section>
|
||||
|
||||
</footer>
|
||||
|
|
|
|||
|
|
@ -21,9 +21,14 @@ $loc = [
|
|||
'help_content' => "
|
||||
<p>You can encode whatever text you want.</p>
|
||||
<p>Software decoding these QR codes could suggest to open them with dedicated software, depending on their <a href='https://en.wikipedia.org/wiki/List_of_URI_schemes' hreflang='en' rel='help external noreferrer'>URI scheme</a>.</p>
|
||||
<p>For instance, to open a webpage: <code>https://www.example/</code></p>
|
||||
<p>To send an email: <code>mailto:contact@email.example</code></p>
|
||||
<p>To share geographic coordinates: <code>geo:48.867564,2.364057</code></p>
|
||||
<dl>
|
||||
<dt>For instance, to open a webpage</dt>
|
||||
<dd><code>https://www.example/</code></dd>
|
||||
<dt>To send an email</dt>
|
||||
<dd><code>mailto:contact@email.example</code></dd>
|
||||
<dt>To share geographic coordinates</dt>
|
||||
<dd><code>geo:48.867564,2.364057</code></dd>
|
||||
</dl>
|
||||
",
|
||||
'help_redundancy' => "Redundancy is the duplication of information in the QR code to correct errors during decoding. A higher rate will produce a bigger QR code, but will have a better chance of being decoded correctly.",
|
||||
'help_margin' => "Number of pixels in each white band around the QR code.",
|
||||
|
|
@ -35,10 +40,9 @@ $loc = [
|
|||
'alt_QR' => 'QR code meaning "%s"',
|
||||
'wifi_raw_content' => "This QR code contains: %s",
|
||||
'metaText_qr' => "
|
||||
\t\t<h3>What's a QR code?</h3>
|
||||
\t\tA QR code is a 2 dimensional barcode in which text is written in binary. It can be decoded with a device equipped with a photo sensor and adequate software.
|
||||
\t\t<a href='https://en.wikipedia.org/wiki/QR_code' hreflang='en' rel='help external noreferrer'>QR code on Wikipedia</a>.
|
||||
\t",
|
||||
<h2>What's a QR code?</h2>
|
||||
<p>A QR code is a 2 dimensional barcode in which text is written in binary. It can be decoded with a device equipped with a photo sensor and adequate software. <a href='https://en.wikipedia.org/wiki/QR_code' hreflang='en' rel='help external noreferrer'>QR code on Wikipedia</a>.</p>
|
||||
",
|
||||
'metaText_legal' => "LibreQR %s is free software whose <a href='https://git.flossboxin.org.in/FbIN/libreqr' rel='external noreferrer'>source code</a> is available under the terms of the <abbr title='GNU Affero General Public License version 3 or any later version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.",
|
||||
'error_generation' => "An error occurred while generating the QR code. Try with different parameters.",
|
||||
'error_404' => "This page doesn't exist.",
|
||||
|
|
|
|||
|
|
@ -13,9 +13,14 @@ $loc = [
|
|||
'help_content' => "
|
||||
<p>Nahi duzun testua kodetu dezakezu.</p>
|
||||
<p>QR kode horiek deskodetzen dituen softwareak software dedikatuarekin irekitzea iradoki lezake, <a href='https://en.wikipedia.org/wiki/List_of_URI_schemes' hreflang='en' rel='help external noreferrer'>URI eskema</a>ren arabera.</p>
|
||||
<p>Adibidez, webgune bat irekitzeko: <code>https://www.adibidea.eus/</code></p>
|
||||
<p>ePosta bidaltzeko: <code>mailto:lur_axpe@adibidea.eus</code></p>
|
||||
<p>Koordenatu geografikoak partekatzeko: <code>geo:42.895367,-2.167805</code></p>
|
||||
<dl>
|
||||
<dt>Adibidez, webgune bat irekitzeko</dt>
|
||||
<dd><code>https://www.adibidea.eus/</code></dd>
|
||||
<dt>ePosta bidaltzeko</dt>
|
||||
<dd><code>mailto:lur_axpe@adibidea.eus</code></dd>
|
||||
<dt>Koordenatu geografikoak partekatzeko</dt>
|
||||
<dd><code>geo:42.895367,-2.167805</code></dd>
|
||||
</dl>
|
||||
",
|
||||
'help_redundancy' => "Erredundantzia QR kodearen informazioa bikoiztean datza, deskodetzean akatsak zuzentzeko. Tasa altuagoak QR kode handiagoa sortuko du, baina behar bezala deskodetzeko aukera handiagoa izango du.",
|
||||
'help_margin' => "QR kodearen inguruko banda zuriaren pixel kopurua.",
|
||||
|
|
@ -25,10 +30,9 @@ $loc = [
|
|||
'title_showOnlyQR' => "Erakutsi QR kode hau bakarrik",
|
||||
'alt_QR' => 'QR kodearen esanahia "%s"',
|
||||
'metaText_qr' => "
|
||||
\t\t<h3>Zer da QR kode bat?</h3>
|
||||
\t\tQR kodea bi dimentsioko barra-kodea da, testua bitarrean idatzita duena. Argazki-sentsore bat eta software egokia dituen gailu batekin deskodetzen da.
|
||||
\t\t<a href='https://eu.wikipedia.org/wiki/QR_kode' hreflang='eu' rel='help external noreferrer'>QR kodea Wikipedian</a>.
|
||||
\t",
|
||||
<h2>Zer da QR kode bat?</h2>
|
||||
<p>QR kodea bi dimentsioko barra-kodea da, testua bitarrean idatzita duena. Argazki-sentsore bat eta software egokia dituen gailu batekin deskodetzen da. <a href='https://eu.wikipedia.org/wiki/QR_kode' hreflang='eu' rel='help external noreferrer'>QR kodea Wikipedian</a>.</p>
|
||||
",
|
||||
'metaText_legal' => "LibreQR %s software librea da, eta <a href='https://git.flossboxin.org.in/FbIN/libreqr' rel='external noreferrer'>iturburu-kodea</a> <abbr title='GNU Affero Lizentzia Publiko Orokorraren 3. bertsioaren edo ondorengo edozein bertsio'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>ren arabera dago eskuragarri.",
|
||||
'error_generation' => "Errorea gertatu da QR kodea sortzerakoan. Saiatu berriro parametro desberdinak erabiliz.",
|
||||
'label_wifi_password' => "",
|
||||
|
|
|
|||
|
|
@ -13,9 +13,14 @@ $loc = [
|
|||
'help_content' => "
|
||||
<p>Anda bisa mengenkode teks apa pun.</p>
|
||||
<p>Perangkat lunak yang mendekodekan kode QR tersebut bisa memberikan pilihan untuk membuka dengan perangkat lunak tertentu, tergantung pada <a href='https://en.wikipedia.org/wiki/List_of_URI_schemes' hreflang='en' rel='help external noreferrer'>Skema URI</a> mereka.</p>
|
||||
<p>Contohnya, untuk membuka halaman situs: <code>https://www.contoh.id/</code></p>
|
||||
<p>Untuk mengirim surel: <code>mailto:contact@email.example</code></p>
|
||||
<p>Untuk membagikan koordinat geografik: <code>geo:48.867564,2.364057</code></p>
|
||||
<dl>
|
||||
<dt>Contohnya, untuk membuka halaman situs</dt>
|
||||
<dd><code>https://www.contoh.id/</code></dd>
|
||||
<dt>Untuk mengirim surel</dt>
|
||||
<dd><code>mailto:contact@email.example</code></dd>
|
||||
<dt>Untuk membagikan koordinat geografik</dt>
|
||||
<dd><code>geo:48.867564,2.364057</code></dd>
|
||||
</dl>
|
||||
",
|
||||
'help_redundancy' => "Redundansi adalah duplikasi informasi di kode QR untuk memperbaiki galat saat pendekodean. Tingkat lebih besar akan menghasilkan kode QR yang lebih besar, tetapi akan dapat hasil lebih baik untuk didekodekan dengan benar.",
|
||||
'help_margin' => "Jumlah piksel di tepi putih di sekitar kode QR.",
|
||||
|
|
@ -25,10 +30,9 @@ $loc = [
|
|||
'title_showOnlyQR' => "Tampilkan kode QR ini saja",
|
||||
'alt_QR' => 'Arti kode QR "%s"',
|
||||
'metaText_qr' => "
|
||||
\t\t<h3>Apa itu Kode QR?</h3>
|
||||
\t\tKode QR adalah kode batang 2 dimensi yang mana teks ditulis dalam biner. Bisa didekodekan dengan perangkat yang memiliki sensor foto dan perangkat lunak yang memadai.
|
||||
\t\t<a href='https://id.wikipedia.org/wiki/Kode_QR' hreflang='id' rel='help external noreferrer'>Kode QR di Wikipedia</a>.
|
||||
\t",
|
||||
<h2>Apa itu Kode QR?</h2>
|
||||
<p>Kode QR adalah kode batang 2 dimensi yang mana teks ditulis dalam biner. Bisa didekodekan dengan perangkat yang memiliki sensor foto dan perangkat lunak yang memadai. <a href='https://id.wikipedia.org/wiki/Kode_QR' hreflang='id' rel='help external noreferrer'>Kode QR di Wikipedia</a>.</p>
|
||||
",
|
||||
'metaText_legal' => "LibreQR %s adalah perangkat lunak bebas yang <a href='https://git.flossboxin.org.in/FbIN/libreqr' rel='external noreferrer'>kode sumber</a> tersedia di bawah ketentuan <abbr title='GNU Affero General Public License versi 3 atau selanjutnya version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.",
|
||||
'error_generation' => "Galat terjadi ketika membuat kode QR. Coba dengan parameter yang berbeda.",
|
||||
'label_wifi_password' => "",
|
||||
|
|
|
|||
40
phpstan.dist.neon
Normal file
40
phpstan.dist.neon
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
parameters:
|
||||
level: 8
|
||||
paths:
|
||||
- .
|
||||
excludePaths:
|
||||
- vendor
|
||||
ignoreErrors:
|
||||
-
|
||||
identifier: variable.undefined
|
||||
rawMessage: 'Variable $loc might not be defined.'
|
||||
path: index.php
|
||||
-
|
||||
identifier: variable.undefined
|
||||
rawMessage: 'Variable $result might not be defined.'
|
||||
path: index.php
|
||||
-
|
||||
identifier: variable.undefined
|
||||
rawMessage: 'Variable $availableLocales might not be defined.'
|
||||
path: index.php
|
||||
-
|
||||
identifier: variable.undefined
|
||||
rawMessage: 'Variable $rgbBgColor might not be defined.'
|
||||
path: index.php
|
||||
-
|
||||
identifier: if.alwaysFalse
|
||||
rawMessage: 'If condition is always false.'
|
||||
path: index.php
|
||||
-
|
||||
rawMessage: 'Function getIntlStringInterpolated() has parameter $vars with no value type specified in iterable type array.'
|
||||
path: index.php
|
||||
-
|
||||
identifier: offsetAccess.notFound
|
||||
-
|
||||
identifier: 'argument.type'
|
||||
rawMessage: 'Parameter #2 $subject of function preg_match expects string, string|false given.'
|
||||
path: index.php
|
||||
-
|
||||
identifier: 'greaterOrEqual.alwaysTrue'
|
||||
rawMessage: 'Comparison operation ">=" between int<1, max> and 1 is always true.'
|
||||
|
||||
49
style.css
49
style.css
|
|
@ -109,6 +109,7 @@ label[for="ssid"] {
|
|||
code {
|
||||
font-family: monospace;
|
||||
user-select: all;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.helpText {
|
||||
|
|
@ -149,6 +150,10 @@ summary {
|
|||
padding: 8px 0 4px;
|
||||
}
|
||||
|
||||
.textboxParam summary {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
summary label {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
|
@ -196,26 +201,20 @@ summary label {
|
|||
}
|
||||
}
|
||||
|
||||
#output {
|
||||
padding: 0 6px;
|
||||
}
|
||||
|
||||
#output form,
|
||||
#output input[type="submit"],
|
||||
#output p {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#output input[type="submit"] {
|
||||
font-size: 20px;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
.centered {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
padding: 3px 10px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
header {
|
||||
text-align: center;
|
||||
padding-top: 12px;
|
||||
|
|
@ -283,10 +282,6 @@ h2 {
|
|||
background-color: var(--text);
|
||||
}
|
||||
|
||||
label[for="txt"] summary {
|
||||
margin-left: 22px;
|
||||
}
|
||||
|
||||
#colors {
|
||||
padding: 5px 0;
|
||||
display: flex;
|
||||
|
|
@ -339,14 +334,9 @@ small {
|
|||
|
||||
/* Inputs */
|
||||
|
||||
#redundancy,
|
||||
#margin,
|
||||
#ssid,
|
||||
#password,
|
||||
#txt,
|
||||
#size,
|
||||
input[type="color"],
|
||||
input[type="submit"],
|
||||
input,
|
||||
textarea,
|
||||
select,
|
||||
.button {
|
||||
border-width: 2px;
|
||||
border-style: solid;
|
||||
|
|
@ -438,7 +428,7 @@ input[type="color"] {
|
|||
scrollbar-color: var(--textarea-text) var(--bg-textarea);
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
#main-submit {
|
||||
cursor: pointer;
|
||||
font-size: 28px;
|
||||
padding: 10px;
|
||||
|
|
@ -446,13 +436,12 @@ input[type="submit"] {
|
|||
padding-right: 14px;
|
||||
}
|
||||
|
||||
#password::placeholder,
|
||||
#ssid::placeholder,
|
||||
#txt::placeholder {
|
||||
opacity: 1;
|
||||
font-family: system-ui, sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 1em;
|
||||
.button {
|
||||
padding: 5px 10px 3px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
::placeholder {
|
||||
color: var(--textarea-placeholder);
|
||||
}
|
||||
|
||||
|
|
|
|||
13
synclog.txt
Normal file
13
synclog.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Too many changes to write in a comment, so best to start using this.
|
||||
Previous: docs(changelog): Add Estonian localization (https://code.antopie.org/miraty/libreqr/commit/d43d0d96332a9485e05c672a0f31435f22b04e60)
|
||||
23.03.2026
|
||||
|
||||
fix(http): Respond with Content-Language header (https://code.antopie.org/miraty/libreqr/commit/d004ee57431b7de59a8e24a145fe48c3ccb2803c)
|
||||
fix(html): Enhance locales markup for help_content and metaText_qr (https://code.antopie.org/miraty/libreqr/commit/672619dc35ed2f3b7c3d9e2cb6ee476821a48393) && (https://code.antopie.org/miraty/libreqr/commit/bfbbf79c5f34a902ea0662f25481413d955956f9)
|
||||
fix(http): No more 404 on LICENSE.html (https://code.antopie.org/miraty/libreqr/commit/e6a2bf7f9e5dc3e08473f1af9b8b2cf16b9675ab)
|
||||
Translated using Weblate (Estonian) Currently translated at 100.0% (31 of 31 strings); Translation: LibreQR2/LibreQR; Translate-URL: https://translate.codeberg.org/projects/libreqr2/libreqr/et/ (https://code.antopie.org/miraty/libreqr/commit/be386a789acf25484a34f1c48645ab2834c80cad)
|
||||
refactor(css): Style new wifi-related elements (https://code.antopie.org/miraty/libreqr/commit/5a89b76d8fb9223c9bd0923495b88dc3a93454e0)
|
||||
test: Introduce tests: Tests include Stylelint, ShellCheck, curl and the Nu HTML Checker (https://code.antopie.org/miraty/libreqr/commit/898376e106d29523ea693d0629b80c5d768d9ba8)
|
||||
chore: Configure php-cs-fixer (https://code.antopie.org/miraty/libreqr/commit/f8a075e98f14b3ad8c2bfaa2d1ae45c9287e1c89)
|
||||
style: Use php-cs-fixer (https://code.antopie.org/miraty/libreqr/commit/a41796e85bdc771841c779929b2e641adbcd8e7d)
|
||||
test: Use strict typing everywhere (https://code.antopie.org/miraty/libreqr/commit/5bd7276042b9f4f9d8e072ac8c2df3ad58f0db12)
|
||||
2
tests/excludes
Normal file
2
tests/excludes
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Resource violates Content Security Policy (meta tag)
|
||||
Section lacks heading.
|
||||
BIN
tests/test.png
Normal file
BIN
tests/test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 487 B |
45
tests/tests.sh
Normal file
45
tests/tests.sh
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
shellcheck tests/tests.sh
|
||||
|
||||
stylelint style.css
|
||||
|
||||
php-cs-fixer check --diff
|
||||
|
||||
phpstan analyse
|
||||
|
||||
#echo "::1 libreqr.localhost" > /etc/hosts
|
||||
#php -S [::1]:8080 index.php
|
||||
|
||||
base_url="http://libreqr.localhost:8080"
|
||||
vnu="validatornu"
|
||||
|
||||
paths=("/" "/wifi")
|
||||
langs=("de" "en" "et" "eu" "fr" "id" "oc")
|
||||
|
||||
(
|
||||
for path in "${paths[@]}"
|
||||
do
|
||||
for lang in "${langs[@]}"
|
||||
do
|
||||
case $path in
|
||||
/)
|
||||
request="main%5Btxt%5D=WIFI%3AT%3AWPA%3BS%3Atest%3BP%3Atest%3B%3B&main%5Bredundancy%5D=medium&main%5Bmargin%5D=3&main%5Bsize%5D=29&main%5BbgColor%5D=%23543210&main%5BfgColor%5D=%23fedcba"
|
||||
;;
|
||||
/wifi)
|
||||
request="wifi%5Bssid%5D=test&wifi%5Bpassword%5D=test&main%5Bredundancy%5D=medium&main%5Bmargin%5D=3&main%5Bsize%5D=29&main%5BbgColor%5D=%23543210&main%5BfgColor%5D=%23fedcba"
|
||||
;;
|
||||
esac
|
||||
|
||||
html="$(curl --no-progress-meter --data "$request" --header "Accept-Language: $lang" "$base_url$path")"
|
||||
|
||||
if ! echo "$html" | grep --quiet "data:image/png;base64,$(base64 tests/test.png)"
|
||||
then
|
||||
echo "QR code not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$html" | "$vnu" - 2>&1 &
|
||||
done
|
||||
done
|
||||
) | grep --invert-match --file tests/excludes | sort --unique
|
||||
|
|
@ -1,36 +1,34 @@
|
|||
<?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/*
|
||||
A small script that can be used to generate LibreQR's icons
|
||||
*/
|
||||
// This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
|
||||
|
||||
if (php_sapi_name() == "cli") {
|
||||
// A small script that can be used to generate LibreQR's icons
|
||||
|
||||
if (PHP_SAPI === 'cli') {
|
||||
if (isset($argv[1])) {
|
||||
$done = array();
|
||||
$line = "";
|
||||
$done = [];
|
||||
$line = '';
|
||||
$theme = $argv[1];
|
||||
|
||||
for ($pow = 0; $pow <= 3; $pow++) {
|
||||
for ($mult = 1; $mult <= 4; $mult++) {
|
||||
$size = $mult * 2**(4+$pow);
|
||||
if (!in_array($size, $done)) {
|
||||
shell_exec("convert themes/" . $theme . "/icons/source.png -scale " . $size . "x" . $size . " themes/" . $theme . "/icons/" . $size . ".png");
|
||||
shell_exec("pngquant -f themes/" . $theme . "/icons/" . $size . ".png --output themes/" . $theme . "/icons/" . $size . ".png");
|
||||
for ($pow = 0; $pow <= 3; ++$pow) {
|
||||
for ($mult = 1; $mult <= 4; ++$mult) {
|
||||
$size = $mult * 2 ** (4 + $pow);
|
||||
if (!in_array($size, $done, true)) {
|
||||
shell_exec('convert themes/' . $theme . '/icons/source.png -scale ' . $size . 'x' . $size . ' themes/' . $theme . '/icons/' . $size . '.png');
|
||||
shell_exec('pngquant -f themes/' . $theme . '/icons/' . $size . '.png --output themes/' . $theme . '/icons/' . $size . '.png');
|
||||
$done[] = $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($done as $done) {
|
||||
$line = $line . ", " . $done;
|
||||
$line = $line . ', ' . $done;
|
||||
}
|
||||
|
||||
echo substr($line, 2) . "\n";
|
||||
|
||||
} else {
|
||||
echo "Usage: php themes/resize.php <theme name>\n";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "Available only via CLI for security reasons. Use 'php themes/resize.php <theme name>'";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue