Add qrcode picture of short link
This commit is contained in:
parent
059ade3de9
commit
97f41dcc5e
3 changed files with 146 additions and 1 deletions
5
composer.json
Normal file
5
composer.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"require": {
|
||||
"endroid/qrcode": "^1.9"
|
||||
}
|
||||
}
|
||||
133
composer.lock
generated
Normal file
133
composer.lock
generated
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "fea912101c2320fcdc7bc2478a2b0001",
|
||||
"content-hash": "b1c8205e21c87a18c2ab35fc5b8f5f6c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "endroid/qrcode",
|
||||
"version": "1.9.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/endroid/QrCode.git",
|
||||
"reference": "ab09b42778ad67cfe850f9c23165f8d08b756680"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/endroid/QrCode/zipball/ab09b42778ad67cfe850f9c23165f8d08b756680",
|
||||
"reference": "ab09b42778ad67cfe850f9c23165f8d08b756680",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-gd": "*",
|
||||
"php": ">=5.4",
|
||||
"symfony/options-resolver": "^2.3|^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0|^5.0",
|
||||
"sensio/framework-extra-bundle": "^3.0",
|
||||
"symfony/browser-kit": "^2.3|^3.0",
|
||||
"symfony/framework-bundle": "^2.3|^3.0",
|
||||
"symfony/http-kernel": "^2.3|^3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Endroid\\QrCode\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeroen van den Enden",
|
||||
"email": "info@endroid.nl",
|
||||
"homepage": "http://endroid.nl/"
|
||||
}
|
||||
],
|
||||
"description": "Endroid QR Code",
|
||||
"homepage": "https://github.com/endroid/QrCode",
|
||||
"keywords": [
|
||||
"bundle",
|
||||
"code",
|
||||
"endroid",
|
||||
"qr",
|
||||
"qrcode",
|
||||
"symfony"
|
||||
],
|
||||
"time": "2017-01-03 11:02:14"
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
"version": "v3.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/options-resolver.git",
|
||||
"reference": "855429e3e9014b9dafee2a667de304c3aaa86fe6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/855429e3e9014b9dafee2a667de304c3aaa86fe6",
|
||||
"reference": "855429e3e9014b9dafee2a667de304c3aaa86fe6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\OptionsResolver\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony OptionsResolver Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"config",
|
||||
"configuration",
|
||||
"options"
|
||||
],
|
||||
"time": "2017-01-02 20:32:22"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
||||
|
|
@ -1,5 +1,9 @@
|
|||
<?php
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
use Endroid\QrCode\QrCode;
|
||||
|
||||
function smallHash($text)
|
||||
{
|
||||
$t = rtrim(base64_encode(hash('crc32', $text, true)), '=');
|
||||
|
|
@ -28,7 +32,10 @@ if (!empty($_GET['url'])) {
|
|||
|
||||
$shortUrl = 'http://'.$_SERVER['HTTP_HOST'].'/'.$_SERVER['SCRIPT_NAME'].'?'.$urlhash;
|
||||
|
||||
$content = '<a href="'.$shortUrl.'">'.$shortUrl.'</a>';
|
||||
$qrcode = (new QrCode())->setText($shortUrl);
|
||||
|
||||
$content = '<a href="'.$shortUrl.'">'.$shortUrl.'</a>'
|
||||
.'<img src="data:'.$qrcode->getContentType().';base64,'.base64_encode($qrcode->get()).'">';
|
||||
} elseif (!empty($_GET)) {
|
||||
$urlhash = key($_GET);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue