function qr_gene($text, $size = 200, $padding = 10)
{
    require_once "vendor/autoload.php";
    header("Content-Type: image/png");
    $qr = new Endroid\QrCode\QrCode();
    $qr->setText($text);
    $qr->setSize($size);
    $qr->setPadding($padding);
    $qr->render();
    return $qr;
}
 public function codeAction()
 {
     $url = "";
     if ($this->getParam("name")) {
         $url = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost() . "/qr~-~code/" . $this->getParam("name");
     } elseif ($this->getParam("documentId")) {
         $doc = Document::getById($this->getParam("documentId"));
         $url = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost() . $doc->getFullPath();
     } elseif ($this->getParam("url")) {
         $url = $this->getParam("url");
     }
     $code = new \Endroid\QrCode\QrCode();
     $code->setText($url);
     $code->setPadding(0);
     $code->setSize(500);
     $hexToRGBA = function ($hex) {
         list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
         return ["r" => $r, "g" => $g, "b" => $b, "a" => 0];
     };
     if (strlen($this->getParam("foreColor", "")) == 7) {
         $code->setForegroundColor($hexToRGBA($this->getParam("foreColor")));
     }
     if (strlen($this->getParam("backgroundColor", "")) == 7) {
         $code->setBackgroundColor($hexToRGBA($this->getParam("backgroundColor")));
     }
     header("Content-Type: image/png");
     if ($this->getParam("download")) {
         $code->setSize(4000);
         header('Content-Disposition: attachment;filename="qrcode-' . $this->getParam("name", "preview") . '.png"', true);
     }
     $code->render();
     exit;
 }
 public function qr_generator($text)
 {
     $input = \Request::all();
     $size = isset($input['size']) ? $input['size'] : 200;
     $padding = isset($input['padding']) ? $input['padding'] : 10;
     header('Content-Type: image/png');
     $qr = new \Endroid\QrCode\QrCode();
     $qr->setText($text);
     $qr->setSize($size);
     $qr->setPadding($padding);
     $qr->render();
     // return imagejpeg($qr->image);
 }
Beispiel #4
0
{
}
if (!file_exists(dirname(__FILE__) . '/../../../../../vendor/endroid/qrcode/src/Endroid/QrCode')) {
    return;
}
include_once dirname(__FILE__) . '/../../../lib/AutoLoader.php';
// QR codegen via composer
if (!class_exists('\\Endroid\\QrCode\\Exceptions\\DataDoesntExistsException')) {
    include dirname(__FILE__) . '/../../../../../vendor/endroid/qrcode/src/Endroid/QrCode/Exceptions/DataDoesntExistsException.php';
}
if (!class_exists('\\Endroid\\QrCode\\Exceptions\\ImageFunctionUnknownException')) {
    include dirname(__FILE__) . '/../../../../../vendor/endroid/qrcode/src/Endroid/QrCode/Exceptions/ImageFunctionUnknownException.php';
}
if (!class_exists('\\Endroid\\QrCode\\Exceptions\\ImageSizeTooLargeException')) {
    include dirname(__FILE__) . '/../../../../../vendor/endroid/qrcode/src/Endroid/QrCode/Exceptions/ImageSizeTooLargeException.php';
}
if (!class_exists('\\Endroid\\QrCode\\Exceptions\\VersionTooLargeException')) {
    include dirname(__FILE__) . '/../../../../../vendor/endroid/qrcode/src/Endroid/QrCode/Exceptions/VersionTooLargeException.php';
}
if (!class_exists('\\Endroid\\QrCode\\QrCode')) {
    include dirname(__FILE__) . '/../../../../../vendor/endroid/qrcode/src/Endroid/QrCode/QrCode.php';
}
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__) && isset($_REQUEST['data'])) {
    header('Content-Type: image/png');
    $data = base64_decode($_REQUEST['data']);
    $qr = new \Endroid\QrCode\QrCode();
    $qr->setText($data);
    $qr->setSize(280);
    $qr->setPadding(10);
    $qr->render();
}