public function actionIndex($text, $size = 5, $logo = false) { $tmpFileName = '/tmp/qrcode.png'; \PHPQRCode\QRcode::png($text, $tmpFileName, 'L', $size, 2); $QR = imagecreatefromstring(file_get_contents($tmpFileName)); if ($logo !== FALSE) { $logo = imagecreatefromstring(file_get_contents($logo)); $QR_width = imagesx($QR); //二维码图片宽度 $QR_height = imagesy($QR); //二维码图片高度 $logo_width = imagesx($logo); //logo图片宽度 $logo_height = imagesy($logo); //logo图片高度 $logo_qr_width = $QR_width / 5; $scale = $logo_width / $logo_qr_width; $logo_qr_height = $logo_height / $scale; $from_width = ($QR_width - $logo_qr_width) / 2; //重新组合图片并调整大小 imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height); } header('Content-type:image/png'); echo imagepng($QR); die; }
/** * 创建二维码 * @method create * @since 0.0.1 * @param {string} $data 数据 * @return {array} * @example \Yii::$app->qrcode->create($data); */ public function create($data) { $fileupload = \Yii::$app->fileupload; $file = $fileupload->createFile($this->ext, null, $this->pre); QRcode::png($data, $file['tmp'], $this->level, $this->size, $this->margin); return $fileupload->finalFile($file, 'images'); }
/** * Obtiene un enlace QR al YRI con token, en base64. * * @return string La representación base64 del gráfico QR del YRI. */ public function getYriConTokenQrBase64() { $ContenidoQr = $this->getYriConToken(true); ob_start(); \PHPQRCode\QRcode::png($ContenidoQr); $imagen_contenido = ob_get_contents(); ob_end_clean(); // PHPQRCode cambia el content-type a image/png... lo volvemos a html header("Content-type: text/html"); return base64_encode($imagen_contenido); }
/** * get image from base64 string * @return string image data */ public function actionCanvasDownload() { $url = $this->getQuery('url'); $name = $this->getQuery('name'); header('Content-Type:image/png'); header('Content-Disposition:attachment;filename=' . $name); $filePath = $this->_getFilePath($name); \PHPQRCode\QRcode::png($url, $filePath, Constants::QR_ECLEVEL_H, 8, 2); $image = file_get_contents($filePath); @unlink($filePath); // Output the actual image data echo $image; }
/** * @Route("/qrcode/{couponcode}.png", name="qrcode") * @Method({"GET"}) */ public function qrcodeAction($couponcode, Request $request) { $secret = $this->getParameter('secret'); $hash = $request->query->get('hash'); if ($hash !== sha1($secret . $couponcode)) { throw new HttpException(403, 'Zugriff verweigert.'); } ob_start(); @QRcode::png($couponcode); $image = ob_get_contents(); ob_end_clean(); return new Response($image, 200, array('Content-Type' => 'image/png')); }
/** * Twig extension aims to generate qrcode image * * @param string $string string used to generate QRCode * @param int $level Level of error correction (3 by default, should be at least 0, maximum 3) * @param int $size Size of QRCode image * @param int $margin Margin of QRCode image * @return bool|string false if error, QRCode image path otherwise */ public function generate($string, $level = Constants::QR_ECLEVEL_L, $size = 3, $margin = 4) { $level = abs((int) $level) > 3 ? Constants::QR_ECLEVEL_L : abs((int) $level); $fileName = md5($string . $level . $size . $margin) . self::IMAGEXTENSION; $filePath = trim(self::IMAGESDIR, '/') . '/' . $fileName; $fs = new Filesystem(); if (!$fs->exists($this->webRootDir . '/' . $fileName)) { QRcode::png($string, $this->webRootDir . '/' . $fileName, $level, $size, $margin); } if ($fs->exists($this->webRootDir . '/' . $fileName)) { return $filePath; } return false; }
/** * @Route("qr/") */ public function qrAction() { $id = $this->ObtenerVariable($request, 'id'); $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('Yacare' . $this->BundleName . 'Bundle:' . $this->EntityName)->find($id); if (!$entity) { throw $this->createNotFoundException('No se puede encontrar la entidad.'); } $ContenidoQr = $entity->getYri(true); ob_start(); \PHPQRCode\QRcode::png($ContenidoQr); $imagen_contenido = ob_get_contents(); ob_end_clean(); $response = new \Symfony\Component\HttpFoundation\Response($imagen_contenido, 200, array('Content-Type' => 'image/png', 'Content-Length' => strlen($imagen_contenido), 'Content-Disposition' => 'filename="' . 'Yacare' . $this->BundleName . 'Bundle_' . $this->EntityName . '_' . $entity->getId() . '.png"')); return $response; }
public function png($text, $size = 25, $watermark = '') { if (empty($watermark) || !file_exists(APPPATH . $watermark)) { return response()->stream(function () use($text, $size, $watermark) { echo QRcode::png($text, FALSE, Constants::QR_ECLEVEL_M, $size, 0); }, 200, ['Content-Type' => 'image/png']); } else { $watermark = APPPATH . $watermark; $tmp = tempnam(sys_get_temp_dir(), '.png'); QRcode::png($text, $tmp, Constants::QR_ECLEVEL_M, $size, 0); $img = Image::make($tmp); $wm = Image::make($watermark)->resize($img->width() * 0.2, $img->height() * 0.2); unlink($tmp); $img->insert($wm, 'center'); return $img->response('png'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $lock = new LockHandler('app:sendcoupons'); if (!$lock->lock()) { $output->writeln('The command is already running in another process.'); return 0; } $em = $this->getContainer()->get('doctrine')->getManager(); $repo = $em->getRepository('AppBundle\\Entity\\Customer'); $customers = $repo->findBy(['isActivated' => true, 'couponsHaveBeenSent' => false], ['datetimeActivation' => 'ASC'], 100); foreach ($customers as $customer) { $mapped = $this->getContainer()->get('couponmapper')->mapNToCustomer(6, $customer); if (!$mapped) { $output->writeln('Could not map coupon codes to customer ' . $customer->getId()); $lock->release(); return 1; } $couponcodesData = []; foreach ($customer->getCouponcodes() as $couponcode) { ob_start(); @QRcode::png($couponcode->getCode()); $imageData = ob_get_contents(); ob_end_clean(); $couponcodesData[] = base64_encode($imageData); } $useRemoteFont = true; if ($this->getContainer()->get('kernel')->getEnvironment() === 'test') { $useRemoteFont = false; // This decouples test runs from Internet connectivity } $pdfData = $this->getContainer()->get('knp_snappy.pdf')->getOutputFromHtml($this->getContainer()->get('templating')->render('AppBundle:coupons:index.html.twig', array('customer' => $customer, 'couponcodesData' => $couponcodesData, 'useRemoteFont' => $useRemoteFont))); if ($this->getContainer()->get('kernel')->getEnvironment() === 'dev') { file_put_contents('/var/tmp/coupon.pdf', $pdfData); } $fileLocator = $this->getContainer()->get('file_locator'); $brandsPdfPath = $fileLocator->locate('@AppBundle/Resources/other/Marken_Selbst_Vertragspartner_2015_09_24.pdf'); $message = \Swift_Message::newInstance()->setSubject('Ihre Rabattcodes für die Good Buy METRO Sonderaktion')->setFrom('*****@*****.**')->setTo($customer->getEmail())->setBody($this->getContainer()->get('templating')->render('Emails/couponCodes.html.twig', ['customer' => $customer]), 'text/html')->attach(\Swift_Attachment::newInstance($pdfData, 'Goodbye-Metro-Rabattcodes.pdf', 'application/pdf'))->attach(\Swift_Attachment::fromPath($brandsPdfPath, 'application/pdf')); $this->getContainer()->get('mailer')->send($message); $customer->setCouponsHaveBeenSent(true); $em->flush(); $output->writeln($customer->getEmail()); } $lock->release(); }
public function create($domain, $type, $associatedId, $accountId, $useDefaultDomain = true, $ecLevel = Constants::QR_ECLEVEL_H) { if ($useDefaultDomain) { $content = $domain . "/webapp/{$type}/{$associatedId}"; } else { $content = $domain; } $qrcodeId = new \MongoId(); $fileName = $qrcodeId . '.png'; $filePath = $this->_getFilePath($fileName); \PHPQRCode\QRcode::png($content, $filePath, $ecLevel, 4, 2); $uploadResult = $this->_upload($filePath, $fileName); if ($uploadResult) { $recordResult = $this->_record($qrcodeId, $type, $associatedId, $content, $fileName, $accountId); if ($recordResult) { return $recordResult; } } return false; }
/** * @see ControllerProviderInterface::connect */ public function connect(Application $app) { // Global layout $app->before(function () use($app) { $app['twig']->addGlobal('layout', $app['twig']->loadTemplate('layout.twig')); }); // Error management if (!$app['debug']) { $app->error(function (\Exception $e, $code) use($app) { if ($code >= 400 && $code < 500) { $message = $e->getMessage(); } else { $message = 'Whoops, looks like something went wrong.'; } // In case twig goes wrong, exemple: no route found means the // $app->before() wont be executed try { $app['user'] = false; $app['twig']->addGlobal('layout', $app['twig']->loadTemplate('layout.twig')); return $app['twig']->render('error.twig', array('message' => $message, 'code' => $code)); } catch (\Exception $e) { return new Response('Whoops, looks like something went very wrong.', $code); } }); } // creates a new controller based on the default route $controllers = $app['controllers_factory']; // Homepage + form handler $controllers->get('/', function (Request $request) use($app) { return $app['twig']->render('index.twig', array('form' => $app['short_url.form']->createView(), 'last' => $app['short_url']->getLastShorten(10))); })->bind('short_url_homepage'); // Handle the form submission $controllers->post('/', function (Request $request) use($app) { $form = $app['short_url.form']; $form->bind($request); if ($form->isValid()) { $data = $form->getData(); $email = $app['user']['email'] ? $app['user']['email'] : null; $id = $app['short_url']->add($data['url'], $email); $url_details = $app['short_url']->getById($id); $r_url = $app['url_generator']->generate('short_url_details', array('short_code' => $url_details['short_code'])); return $app->redirect($r_url); } else { return $app['twig']->render('index.twig', array('form' => $form->createView(), 'last' => $app['short_url']->getLastShorten(10))); } $app->abort(404, "Nothing found!"); }); // Details $controllers->get('/{short_code}/details', function ($short_code) use($app) { $url_details = $app['short_url']->getByShortCode($short_code); $last_redirects = $app['short_url']->getLastRedirects($url_details['id']); $redirects_counter = $app['short_url']->getRedirectCounter($url_details['id']); return $app['twig']->render('details.twig', array('long_url' => $url_details['url'], 'short_code' => $short_code, 'last_redirects' => $last_redirects, 'redirects_counter' => $redirects_counter)); })->bind('short_url_details'); // QRCode $controllers->get('/{short_code}.png', function ($short_code) use($app) { $url_details = $app['short_url']->getByShortCode($short_code); if ($url_details) { $short_url = $app['url_generator']->generate('short_url_redirect', array('short_code' => $short_code), true); $file = $_SERVER['DOCUMENT_ROOT'] . "/qr/{$short_code}.png"; if (!file_exists($file)) { QRcode::png($short_url, $file, 'L', 4, 2); } $stream = function () use($file) { readfile($file); }; return $app->stream($stream, 200, array('Content-Type' => 'image/png')); } $app->abort(404, "That shorten url does not exist!"); })->bind('short_url_qrcode'); // Shorten the url in the query string (?url=) $controllers->get('/shorten/', function (Request $request) use($app) { $url = rawurldecode($request->get('url')); $errors = $app['validator']->validateValue($url, new Assert\Url()); if ($url && !$errors->has(0)) { $id = $app['short_url']->add($url); $url_details = $app['short_url']->getById($id); $r_url = $app['url_generator']->generate('short_url_details', array('short_code' => $url_details['short_code'])); return $app->redirect($r_url); } else { $app->abort(404, $errors->get(0)->getMessage()); } $app->abort(404, "The url query string parameter is required."); })->bind('short_url_shorten'); // Redirects to the last shorten url $controllers->get('/last/', function () use($app) { $urls = $app['short_url']->getLastShorten(1); if ($urls[0]['id']) { $app['short_url']->incrementCounter($urls[0]['id']); return $app->redirect($urls[0]['url']); } $app->abort(404, "Nothing found!"); })->bind('short_url_last'); // Redirects to the corresponding url $controllers->get('/{short_code}', function ($short_code) use($app) { $url = $app['short_url']->getByShortCode($short_code); if ($url) { $app['short_url']->incrementCounter($url['id']); return $app->redirect($url['url']); } $app->abort(404, "That shorten url does not exist!"); })->bind('short_url_redirect'); // User's last shorten urls $controllers->get('/mine/', function () use($app) { if (!$app['user']['email']) { $app->abort(401, "You must be authenticated to access this page."); } return $app['twig']->render('mine.twig', array('last' => $app['short_url']->getLastShorten(10, $app['user']['email']))); })->bind('short_url_mine'); return $controllers; }
|-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('redirect/callback', ['as' => 'urlRedirectCallBack', 'uses' => 'SharkController@redirectCallback']); Route::get('default_page', ['as' => 'defaultPage', 'uses' => 'HomeController@defaultPage']); //二维码扫描跳转地址 Route::get('qr_url', ['as' => 'qrHandlerUrl', 'uses' => 'QRCodeController@urlHandler']); Route::get('/', function () { return redirect('/admin'); }); Route::get('/qr', function () { \PHPQRCode\QRcode::png("http://dev.device.dajiayao.cc/admin/devices?status=0", public_path() . "/upload/xxx.png", \PHPQRCode\Constants::QR_ECLEVEL_M, 4, 0); }); Route::get('home', 'HomeController@index'); Route::get('currentAvailableDevice', ['as' => 'getCurrentAvailableDevicesAjax', 'uses' => 'Admin\\DeviceController@currentAvailableDeviceAjax']); Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']); Route::get('login', ['as' => 'login', 'uses' => 'UserController@login']); Route::post('login', ['as' => 'loginPost', 'uses' => 'UserController@loginPost']); Route::get('logout', ['as' => 'logout', 'uses' => 'UserController@logout']); Route::group(['prefix' => 'admin', 'middleware' => ['auth']], function () { Route::get('/', ['as' => 'adminHome', 'uses' => 'Admin\\HomeController@index']); Route::group(['prefix' => 'devices'], function () { Route::get('/', ['as' => 'adminDevices', 'uses' => 'Admin\\DeviceController@index']); Route::post('add', ['as' => 'adminDevicesAdd', 'uses' => 'Admin\\DeviceController@addPost']); Route::get('alloc', ['as' => 'adminDevicesAlloc', 'uses' => 'Admin\\DeviceController@alloc']); Route::get('burnin', ['as' => 'adminDevicesBurnin', 'uses' => 'Admin\\DeviceController@burnin']); });
/** * * Generates QRCode for the ticket URL of a particular showtime. * @param $showtimeId * @return null|string the path to the QRCode PNG file on success. * @throws \DbTableException */ public function getPNGQrCode($showtimeId) { $cached = $this->checkCache($showtimeId, true); if ($cached) { return $cached; } $showtime = $this->showtimeManager->getEntity($showtimeId); if ($showtime && $showtime->url) { try { $shorten = $this->getBitly()->shorten($showtime->url, 'j.mp'); } catch (\Exception $e) { \SystemLogger::warn(get_class($e), $e->getTraceAsString()); } $l = $shorten ? $shorten['url'] : \SystemConfig::getInstance()->site['redirect_base'] . $showtimeId; $filename = $this->cacheName($showtimeId, true); QRcode::png($l, $filename, QR_ECLEVEL_L, 4, 1); return $filename; } return null; }
public static function generateQRCodeLayer($text, $size = 3, $margin = 4) { $path = tempnam(sys_get_temp_dir(), 'evathumber_qrcode'); PHPQRCode\QRcode::png($text, $path, 'L', $size, $margin); return $path; }
public function testQrCodeWithCorrectHash() { $client = static::createClient(); $kernel = $client->getKernel(); $secret = $kernel->getContainer()->getParameter('secret'); $client->request('GET', '/qrcode/9850012501010470001010009160cZjike0TCb7hv0c__0000000000000000002.png?hash=' . sha1($secret . '9850012501010470001010009160cZjike0TCb7hv0c__0000000000000000002')); $this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertEquals('image/png', $client->getResponse()->headers->get('Content-Type')); ob_start(); @QRcode::png('9850012501010470001010009160cZjike0TCb7hv0c__0000000000000000002'); $image = ob_get_contents(); ob_end_clean(); $this->assertSame($image, $client->getResponse()->getContent()); }
/** * Generate QR code * * @return void */ public function qrcodeTask() { $no_html = Request::getInt('no_html', 0); $code = Request::getVar('code'); if (!$code) { throw new Exception(Lang::txt('No code provided'), 500); } $url = rtrim(Request::base(), '/') . '/' . ltrim(Route::url('index.php?option=' . $this->_option . '&controller=courses&task=redeem&code=' . $code), '/'); if ($no_html) { echo QRcode::png($url); return; } echo QRcode::text($url); }
/** * 导出 PDF * @author Hanxiang */ public function genPDF() { $input = Input::only('ids'); if (sizeof($input['ids']) == 0) { return response()->json(['result' => 0, 'link' => "", 'msg' => '请选择要导出的设备']); } $snList = Device::findSNsByIds($input['ids']); $count = count($snList); $loader = new LoaderImpl(); $loader->setFontFile(public_path("pdf/style/fonts.xml")); $facade = FacadeBuilder::create($loader)->setEngineType('pdf')->build(); $documentFilename = public_path("pdf/style/table.xml"); $stylesheetFilename = public_path("pdf/style/table-style.xml"); if (!is_readable($documentFilename)) { return response()->json(['result' => 0, 'link' => ""]); } if (!is_readable($stylesheetFilename)) { return response()->json(['result' => 0, 'link' => ""]); } $i = 0; $xml = simplexml_load_file($documentFilename); $table = $xml->xpath('/pdf/dynamic-page/div/table')[0]; $pageCount = (int) ($count / 80) + 1; for ($p = 0; $p < $pageCount; $p++) { $tr = $table->addChild('tr'); $tr['class'] = 'head-foot'; for ($t = 0; $t < 10; $t++) { $td = $tr->addChild('td'); if ($t == 0 or $t == 9) { $td['class'] = "top-left-right"; } else { $td['class'] = "top-bottom"; } } for ($j = 0; $j < 10; $j++) { $tr = $table->addChild('tr'); for ($t = 0; $t < 10; $t++) { $td = $tr->addChild('td'); if ($t == 0 or $t == 9) { $td['class'] = "left-right"; } else { $td['class'] = 'content'; if ($i < $count) { $sn = $snList[$i]; $qrName = public_path() . "/pdf/qr/url_qr_" . $sn . ".png"; QRcode::png(Config::get("app.QR_URL") . '?sn=' . $sn, $qrName, Constants::QR_ECLEVEL_M, 4, 0); $this->fillTd($td, "SN:" . $sn, $qrName); $i++; } else { $div = $td->addChild('div'); $div->addChild('span', ''); } } } } $tr = $table->addChild('tr'); $tr['class'] = 'head-foot'; for ($t = 0; $t < 10; $t++) { $td = $tr->addChild('td'); if ($t == 0 or $t == 9) { $td['class'] = "bottom-left-right"; } else { $td['class'] = "top-bottom"; } } } $newName = "pdf/documents/" . time(); $tableXmlStr = $xml->asXML(); // $stylesheetXml = file_get_contents($stylesheetFilename); // $stylesheet = $stylesheetXml ? \PHPPdf\DataSource\DataSource::fromString($stylesheetXml) : null; $content = $facade->render($tableXmlStr, $stylesheetFilename); $newFilename = $newName . ".pdf"; file_put_contents(public_path($newFilename), $content); return response()->json(['result' => 1, 'link' => url($newFilename)]); }
/** * 创建二维码操作 * @name: create * @author: rickeryu <*****@*****.**> * @time: 16/7/22 下午9:25 */ public function create($data, $level = 2, $size = 10, $margin = 4) { return QRcode::png($data, false, $level, $size, $margin); }
// Load the Model $letter_model = new LettersIssued($dbo); $letter = $letter_model->fetchLetter($_GET['serial']); if (!$letter) { echo '<div style="text-align:center; font-size:1.5em; font-family: Segoe UI, Arial; margin-top: 2em;">Cette lettre n\'existe pas. No such letter exists :(</div>'; } else { $format = 'html'; if (isset($_GET['format']) && $_GET['format'] === 'pdf') { $format = 'pdf'; } if (isset($_GET['format']) && $_GET['format'] === 'pdf-email-attachment') { $format = 'pdf-email-attachment'; } //Generate QR code based on letter serial ob_start(); \PHPQRCode\QRcode::png("https://" . URL_STUDENT . "/letters-issued-fetch-as-pdf.php?serial={$letter['letter_serial']}", null); $qr = 'data:image/png;base64,' . base64_encode(ob_get_contents()); ob_end_clean(); //Generate PDF with QR code $html = '<!DOCTYPE html> <div style="width: 25%; padding: 10px; margin-right: 10px; float: left; text-align: center;"> <img src="//' . URL_IMAGES . '/uottawa_logo.png" style="width: 130px; margin-top: 2em;"> <address style="font-style: normal; font-weight: bold; font-family: Segoe UI, Arial; margin-top: 5em; text-align: left; padding-left: 20px;"> <h5 style="color: #800000; margin-bottom: 0.2em;">Université d\'Ottawa</h5> <h6 style="color: #6a584a; margin-top: 0.2em;"> Service d\'appui au succès scolaire (SASS)<br> Service d\'accès<br> Pavillon Desmarais<br> Pièce 3172<br> 55, av. Laurier Est<br> Ottawa ON K1N 6N5
/** * Entrem un Array de Localitats i generem les entrades... **/ public static function generaEntradaFromLocalitats($LlistatLocalitats, ComandaTableObject $CTO) { $mail = new Mail(); $html = ""; $htmlMail = ""; $PrimeraEntrada = true; //Per cada sessió,, agafem tots els seients i generem el QR amb el corresponent email foreach ($LlistatLocalitats as $idSessio => $D) { foreach ($D['Localitats'] as $id => $LTO) { $id = $LTO->getLocalitatIdString(); $QR = $LTO->getCodiQR(); $nomArxiu = $id; //Genero el QR \PHPQRCode\QRcode::png($QR, self::$URL_ENTRADES . $nomArxiu . '.png', \PHPQRCode\Constants::QR_ECLEVEL_L, 8, 1); //Afegim el QR del seient al correu que enviarem $mail->AddEmbeddedImage(self::$URL_ENTRADES . $nomArxiu . '.png', $id); //Genero l'entrada en HTML per aquest seient $html .= self::generaEntrada($D['SessioData'], $CTO, $nomArxiu, $QR, $LTO, $PrimeraEntrada); $htmlMail .= self::generaEntradaMail($QR, $id, $D['SessioData'], $LTO, $CTO); $PrimeraEntrada = false; } } //Si tenim alguna sessió, faig la impressió if (sizeof($LlistatLocalitats) > 0) { $html .= '</body></html>'; //Carrego l'html de la comanda per mail $htmlMailFinal = file_get_contents(BASEURL . '/app/templates/default/json/emailTemplate.html'); $htmlMailFinal = str_replace("%%ENTRADA%%", $htmlMail, $htmlMailFinal); //Genero el PDF de la comanda $dompdf = new \DOMPDF(); //Carrego l'HTML de les entrades $dompdf->load_html($html); //Ho guardo al disc en format PDF $dompdf->set_paper('a4', 'portrait'); $dompdf->render(); $output = $dompdf->output(); $FILE_URL = self::$URL_ENTRADES . $CTO->comanda['co_Codi'] . '.pdf'; $FILE_WEB = self::$URL_WEB . $CTO->comanda['co_Codi'] . '.pdf'; file_put_contents($FILE_URL, $output); //Carrego un mail per si el vull enviar $mail->addAddress($CTO->comanda['co_EmailCompra']); $mail->subject("La Gorga | Les seves entrades "); $mail->body($htmlMailFinal); $mail->AddAttachment($FILE_URL); return array('Mail' => $mail, "Html" => $html, "FILE_URL" => $FILE_URL, "FILE_WEB_URL" => $FILE_WEB); } }
/** * Returns the BezahlCode QR-Code as PNG image data. * * @return string Binary PNG image data */ public function getBezahlCode() { ob_start(); QRcode::png($this->getBezahlCodeURI(), false, $this->qrSettings['level'], $this->qrSettings['size'], $this->qrSettings['margin'], false); return ob_get_clean(); }
/** * 本地二维码生成函数 * @param $text * @param $localFileName * @param $errorCorrectionLevel * @param $matrixPointSize * @param $marginPadding * @return PHPQRCode */ public function localChatQrcode($text, $localFileName = false, $saveandprint = false, $errorCorrectionLevel = 'L', $matrixPointSize = 5, $marginPadding = 2) { return \PHPQRCode\QRcode::png($text, $localFileName, $errorCorrectionLevel, $matrixPointSize, $marginPadding, $saveandprint); }
/** * Generates an image based on the string passed. * * @param $strContent * @return string the filename relative to the document root. If you want to use the image in the web, add _webpath_ to the filename. */ public function getImageForString($strContent) { $strFilename = "qr" . md5($strContent . $this->strCorrectionLevel . $this->intSize . $this->intPadding) . ".png"; //caching based on the current filename if (is_file(_realpath_ . _images_cachepath_ . "/" . $strFilename)) { return _images_cachepath_ . "/" . $strFilename; } require_once __DIR__ . "/phpqrcode/vendor/autoload.php"; \PHPQRCode\QRcode::png($strContent, _realpath_ . _images_cachepath_ . "/" . $strFilename, $this->strCorrectionLevel, $this->intSize, $this->intPadding); return _images_cachepath_ . "/" . $strFilename; }