コード例 #1
1
 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 . '" />';
 }
コード例 #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;
}
コード例 #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;
 }
コード例 #4
0
 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);
 }
コード例 #5
0
ファイル: QrCode.php プロジェクト: sysatom/workflow
 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');
 }
コード例 #6
0
 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;
 }
コード例 #7
0
ファイル: qrcode.php プロジェクト: nukeplus/nuke
<?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;
}
コード例 #8
0
ファイル: BitCoinQrCode.php プロジェクト: phpsmith/IS4C
{
}
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();
}
コード例 #9
0
 /**
  * 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();
 }
コード例 #10
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);
 }