public static function getQrCodeImg($qrCodeText, $size = 200, $padding = 10, $errCorrection = 'middle')
 {
     $qrCode = new Endroid\QrCode\QrCode();
     $qrCode->setText($qrCodeText)->setSize($size)->setPadding($padding)->setErrorCorrection($errCorrection)->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0));
     $imageUri = $qrCode->getDataUri();
     return '<img src="' . $imageUri . '" />';
 }
Ejemplo n.º 2
1
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;
}
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 5
0
 protected function execute(array $arguments)
 {
     if (isset($arguments[0])) {
         if (strlen($arguments[0]) > 140) {
             throw new InvalidArgumentException('String too long');
         }
         global $config;
         // dir
         $qr_dir = 'temp/qr/' . date('Y/m/d');
         $qr_abs_dir = public_path() . '/' . $qr_dir;
         if (!Filesystem::isDirectory($qr_dir)) {
             Filesystem::makeDirectory($qr_dir, 0755, true);
         }
         $qr_file_name = md5('qr-code' . $arguments[0]) . '.png';
         $qr_path = $qr_abs_dir . '/' . $qr_file_name;
         // QR
         $qrCode = new \Endroid\QrCode\QrCode();
         $qrCode->setText($arguments[0])->setSize(300)->setPadding(10)->setErrorCorrection('high')->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))->save($qr_path);
         return $config->application->domain . '/' . $qr_dir . '/' . $qr_file_name;
     }
     throw new InvalidArgumentException('strings invalid');
 }
 public static function downloadQrCode($url, $alias, $size = 300)
 {
     $urlDecoded = base64_decode($url);
     if ($size > 300) {
         $errorCorrection = 'high';
     } elseif ($size > 100) {
         $errorCorrection = 'medium';
     } else {
         $errorCorrection = 'low';
     }
     if (empty($alias)) {
         $alias = $urlDecoded;
         $slashPos = strrpos($urlDecoded, '.de/');
         if ($slashPos !== false) {
             $alias = substr($urlDecoded, $slashPos + strlen('.de/'));
         } else {
             $slashPos = strrpos($urlDecoded, '/');
             if ($slashPos !== false) {
                 $alias = substr($urlDecoded, $slashPos + 1);
             }
         }
     }
     $qrCode = new Endroid\QrCode\QrCode();
     $qrCode->setText($urlDecoded)->setSize($size)->setPadding(10)->setErrorCorrection($errorCorrection)->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0));
     $image = $qrCode->get();
     $filename = preg_replace('#[^A-Za-z0-9._-]#', '', $alias) . '_' . $size . '.png';
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . $filename);
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-Length: ' . strlen($image));
     print $image;
     exit;
 }
Ejemplo n.º 7
0
<?php

/**
 * @Project NUKEVIET 4.x
 * @Author VINADES.,JSC (contact@vinades.vn)
 * @Copyright (C) 2014 VINADES.,JSC. All rights reserved
 * @License GNU/GPL version 2 or any later version
 * @Createdate 12/29/2009 20:7
 */
if (!defined('NV_MAINFILE')) {
    die('Stop!!!');
}
if ($nv_Request->get_string('second', 'get') == 'qr') {
    $url = $nv_Request->get_string('u', 'get', '');
    $level = $nv_Request->get_title('l', 'get', 'M');
    $ModuleSize = $nv_Request->get_int('ppp', 'get', 4);
    $outer_frame = $nv_Request->get_int('of', 'get', 1);
    $_ErrorCorrection = array('L' => 'low', 'M' => 'medium', 'Q' => 'quartile', 'H' => 'high');
    if (!empty($url) and isset($_ErrorCorrection[$level]) and ($ModuleSize > 0 and $ModuleSize < 13) and ($outer_frame > 0 and $outer_frame < 6)) {
        // Readmore: https://github.com/endroid/QrCode and http://www.qrcode.com/en/about/version.html
        $qrCode = new Endroid\QrCode\QrCode();
        header('Content-type: image/png');
        $qrCode->setText($url)->setErrorCorrection($_ErrorCorrection[$level])->setModuleSize($ModuleSize)->setImageType('png')->render();
    }
    exit;
}
Ejemplo n.º 8
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();
}
Ejemplo n.º 9
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
use Xoops\Core\Request;
/**
 * @author    Richard Griffith <*****@*****.**>
 * @copyright 2013-2014 XOOPS Project (http://xoops.org)
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @link      http://xoops.org
 */
// this is located in include, otherwise normal/anon users do not have authority to run
include dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
$xoops = Xoops::getInstance();
$xoops->logger()->quiet();
$text = Request::getString('text', 'error');
$configs = $xoops->getModuleConfigs('qrcode');
$qrCode = new Endroid\QrCode\QrCode($text);
$ecChar = $configs['qrcode_ecl'];
switch (strtoupper($ecChar)) {
    case 'H':
        $ec = Endroid\QrCode\QrCode::LEVEL_HIGH;
        break;
    case 'Q':
        $ec = Endroid\QrCode\QrCode::LEVEL_QUARTILE;
        break;
    case 'M':
        $ec = Endroid\QrCode\QrCode::LEVEL_MEDIUM;
        break;
    case 'L':
    default:
        $ec = Endroid\QrCode\QrCode::LEVEL_LOW;
        break;
 /**
  * Render provided information as QR code
  *
  * @param string $signed_zoi      Signed ZOI
  * @param string $tax_number      Tax number of the person liable
  * @param int    $issue_date_time Date and time of issuing the invoice (unix timestamp)
  * @param int    $size            Size of rendered QR (without padding); used for width and height
  * @param int    $padding         Padding, adds to rendered image's width and height;
  *                                used for left/right/top/bottom padding
  *
  * @return GD resource            Rendered QR code as a GD resource
  */
 public function renderQrCodeAsImage($signed_zoi, $tax_number, $issue_date_time, $size = 300, $padding = 10)
 {
     $value = str_pad($this->bigNumberHexToDecimal($signed_zoi), 39, '0', STR_PAD_LEFT) . $tax_number . date('ymdHis', $issue_date_time);
     $value .= $this->calculateModulo10($value);
     $qrCode = new \Endroid\QrCode\QrCode();
     return $qrCode->setText($value)->setSize($size)->setPadding($padding)->setErrorCorrection(\Endroid\QrCode\QrCode::LEVEL_MEDIUM)->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))->getImage();
 }
Ejemplo n.º 11
0
 /**
  * Leave param2 empty if you want to generate the qrcode yourself using the returned data
  * @param bool $returnimage
  * @return array
  * @throws \Endroid\QrCode\Exceptions\ImageFunctionUnknownException
  */
 public function createQrCode($returnimage = false)
 {
     // delete old qr codes
     $this->newBuilder()->delete('qr_activation')->where('ip = :ip')->setParameter('ip', filter_input(INPUT_SERVER, 'REMOTE_ADDR'))->execute();
     // Random code
     $new_code = \SecureFuncs\SecureFuncs::randomString(64);
     // insert qr code into the database
     $this->newBuilder()->insert('qr_activation')->values(array('ip' => ':ip', 'qr_code' => ':qr', 'expires' => ':expires'))->setParameter(':qr', $new_code)->setParameter(':ip', filter_input(INPUT_SERVER, 'REMOTE_ADDR'))->setParameter(':expires', date('Y-m-d H:i:s', strtotime('+30seconds')))->execute();
     if ($returnimage === true && !headers_sent()) {
         header('Content-type: image/png');
         $link = ADVANCEDLOGINSCRIPT_QR_PAGE;
         $link = str_replace('{code}', $new_code, $link);
         $qr_image = new \Endroid\QrCode\QrCode();
         $qr_image->setText($link)->setSize(300)->setPadding(20)->setErrorCorrection('high')->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))->setLabel('Valid for 30 seconds')->setLabelFontSize(16)->render();
     } else {
         $qr_image = false;
     }
     $_SESSION[ADVANCEDLOGINSCRIPT_QR_COOKIEKEY]['qr'] = $new_code;
     $this->destroyOldQrCodes();
     return array('qr' => $new_code, 'qr_image' => $qr_image);
 }