| 1 |
<?php /** @noinspection PhpCSValidationInspection */ |
| 2 |
/** |
| 3 |
* Generates an QR code for bitcoin. |
| 4 |
* |
| 5 |
* @package Shariff Wrapper |
| 6 |
*/ |
| 7 |
|
| 8 |
// prevent external use (as is requested by the automated Plugin Check) |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', __DIR__ . '/' ); } |
| 10 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
// Includes php class for QR code generation. |
| 13 |
require './includes/phpqrcode.php'; |
| 14 |
|
| 15 |
// Gets the bitcoin address. |
| 16 |
$bitcoinaddress = htmlspecialchars( $_GET['bitcoinaddress'] ); |
| 17 |
// real plausi check on valid address and nothing else |
| 18 |
if ( ! preg_match( '/^([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[ac-hj-np-z02-9]{11,87})$/', $bitcoinaddress ) ) { http_response_code(400); die(); } |
| 19 |
|
| 20 |
// Creates the page. |
| 21 |
echo '<html lang="en"><head><title>Bitcoin</title></head><body>'; |
| 22 |
echo '<div style="text-align:center;"><h1>Bitcoin</h1></div>'; |
| 23 |
echo '<p style="text-align:center;"><a href="bitcoin:' . $bitcoinaddress . '">bitcoin:' . $bitcoinaddress . '</a></p>'; |
| 24 |
echo '<p style="text-align:center;">'; |
| 25 |
QRcode::svg( $bitcoinaddress, false, 'h', 5 ); |
| 26 |
echo '</p>'; |
| 27 |
echo '<p style="text-align:center;">Information: <a href="https://www.bitcoin.org" target="_blank">bitcoin.org</a></p>'; |
| 28 |
echo '</body></html>'; |
| 29 |
|