本文整理汇总了PHP中QRcode类的典型用法代码示例。如果您正苦于以下问题:PHP QRcode类的具体用法?PHP QRcode怎么用?PHP QRcode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QRcode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: genqrm
public static function genqrm($nombre, $ap, $am, $com, $filename)
{
$QR_TEMP_DIR = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'qrimg' . DIRECTORY_SEPARATOR;
$HTML_TEMP_DIR = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR;
$QR_WEB_DIR = "qrimg/";
$HTML_WEB_DIR = "html/";
include "phpqrcode.php";
if (!file_exists($QR_TEMP_DIR)) {
mkdir($QR_TEMP_DIR);
}
if (!file_exists($HTML_TEMP_DIR)) {
mkdir($HTML_TEMP_DIR);
}
$fileimg = $QR_TEMP_DIR . 'test.png';
$errorCorrectionLevel = 'Q';
$matrixPointSize = 6;
$filenameqr = $QR_WEB_DIR . $filename;
$filenamehtml = $HTML_WEB_DIR . $filename;
$fileimg = $filenameqr . '.png';
$filehtml = $filenamehtml . '.html';
$filehtmlqr = "192.168.1.5/demo/qr/" . $filehtml;
QRcode::png($filehtmlqr, $fileimg, $errorCorrectionLevel, $matrixPointSize, 2);
$mensaje = "\n\n <!DOCTYPE html>\n <html>\n <head>\n\n <title></title>\n </head>\n <body>\n\n Nombre: '{$nombre}' '{$ap}' '{$am}' <br><br>\n Comentario: '{$com}'\n\n </body>\n </html>\n\n ";
if ($archivo = fopen($filehtml, "a")) {
fwrite($archivo, $mensaje);
fclose($archivo);
}
echo '<img src="' . $QR_WEB_DIR . basename($fileimg) . '" />
<br>Datos guardados <a href="./index.php">Regresar</a><br>';
return $fileimg;
}
示例2: logo
public function logo()
{
Vendor("phpqrcode.phpqrcode");
$QRcode = new \QRcode();
$path = "data/rq/";
$value = 'http://' . $_SERVER['HTTP_HOST'] . '/index.php?token=' . session('token');
$fileName = $path . session('token') . '_emall.png';
$QR_Logo = $path . session('token') . '_emall_Logo.png';
$errorCorrectionLevel = 'H';
$matrixPointSize = 10;
$QRcode->png($value, $fileName, $errorCorrectionLevel, $matrixPointSize, 2);
$logo = $path . 'weixinlogo.jpg';
$QR = $fileName;
if ($logo !== FALSE) {
$QR = imagecreatefromstring(file_get_contents($QR));
$logo = imagecreatefromstring(file_get_contents($logo));
$QR_width = imagesx($QR);
$QR_height = imagesy($QR);
$logo_width = imagesx($logo);
$logo_height = imagesy($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);
}
imagepng($QR, $QR_Logo);
$this->assign('QR_Logo', $QR_Logo);
$this->display();
if (IS_AJAX) {
$response = $this->fetch();
$this->ajaxReturn(1, '', $response);
}
}
示例3: qrcode
public function qrcode()
{
Vendor('Phpqrcode.phpqrcode');
$url = I("url");
$size = I("size") ? I("size") : 6;
$object = new \QRcode();
$object->png($url, false, 3, $size, 2);
}
示例4: twofactors_getQR
function twofactors_getQR()
{
global $srcdir;
require_once $srcdir . '/libs/phpqrcode/phpqrcode.php';
$text = sprintf("otpauth://totp/%s@%s?secret=%s&issuer=LATEB", $_SESSION['user']['user_name'], $_SERVER['HTTP_HOST'], $_SESSION['user']['GoogleAuthenticator']);
$qrcode = new QRcode();
$qrcode->png($text, false, QR_ECLEVEL_M, 5);
quit();
}
示例5: qrcode
/**
* host 生成链接地址
* level 容错级别
* size 图片大小
*/
public function qrcode($url = 'http://www.jihexian.com', $level = 3, $size = 4)
{
Vendor('phpqrcode.phpqrcode');
$errorCorrectionLevel = intval($level);
//容错级别
$matrixPointSize = intval($size);
//生成图片大小
//生成二维码图片
//echo $_SERVER['REQUEST_URI'];
$object = new \QRcode();
$object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2);
}
示例6: get_qr_image
public function get_qr_image($qrfile_prefix = 'qr_', $size = 4, $outer_margin = 2)
{
$url = wpl_global::get_full_url();
$file_name = $qrfile_prefix . md5($url) . '.png';
$file_path = wpl_global::get_upload_base_path() . 'qrcode' . DS . $file_name;
if (!wpl_file::exists($file_path)) {
if (!wpl_file::exists(dirname($file_path))) {
wpl_folder::create(dirname($file_path));
}
$QRcode = new QRcode();
$QRcode->png($url, $file_path, 'L', $size, $outer_margin);
}
return wpl_global::get_upload_base_url() . 'qrcode/' . $file_name;
}
示例7: createQR
public function createQR()
{
$info = collectinfo(__METHOD__, '', array());
$qr = M('qr');
//先取一个tempuid
$tmpuid = time() . rand(10, 99);
//加上随机数几乎是杜绝了统一时间一起产生的临时uid的可能性
$this->assign('tmpuid', $tmpuid);
$isscan = 0;
$openid = '';
$data = array('tmpuid' => $tmpuid, 'isscan' => $isscan, 'openid' => $openid);
$qr->data($data)->add();
$pic = './Public/img/qr/' . $tmpuid . '.png';
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx682ad2cc417fe8b9&redirect_uri=http://www.evchar.cn/evcpc/oauth2_openid.php&response_type=code&scope=snsapi_base&state=" . $tmpuid . "&connect_redirect=1#wechat_redirect";
include "phpqrcode.php";
$c = $url;
$data = 'http://www.baidu.com';
// 纠错级别:L、M、Q、H
$level = 'L';
// 点的大小:1到10,用于手机端4就可以了
$size = 4;
// 下面注释了把二维码图片保存到本地的代码,如果要保存图片,用$fileName替换第二个参数false
//$path = "images/";
// 生成的文件名
//$fileName = $path.$size.'.png';
//只认从根目录去找的。。
QRcode::png($c, $pic, $level, $size);
$this->assign('pic', $pic);
return createarrok('ok', $pic, '', $info);
}
示例8: QRcode
public function QRcode()
{
include './PigCms/Lib/ORG/phpqrcode.php';
$viewUrl = C('site_url') . U('Wap/Index/index', array('token' => $this->token));
$url = urldecode($viewUrl);
QRcode::png($url, false, 0, 8);
}
示例9: mark_phpqrcode
function mark_phpqrcode($filename = "", $thisurl = '')
{
$uid = $this->Session->read('User.uid');
if (empty($filename)) {
$filename = SYS_PATH_PHOTOS . 'qcody' . DS . $uid . DS . $filename;
}
include SYS_PATH . 'inc/phpqrcode.php';
// 二维码数据
$issubscribe = 0;
if (empty($thisurl)) {
if ($uid > 0) {
$sql = "SELECT is_subscribe FROM `{$this->App->prefix()}user` WHERE user_id = '{$uid}' LIMIT 1";
$issubscribe = $this->App->findvar($sql);
}
if ($issubscribe == '0') {
$to_wecha_id = $this->get_user_parent_uid();
$thisurl = ADMIN_URL . "?toid=" . $to_wecha_id . "&tid=" . $uid;
} else {
$thisurl = ADMIN_URL . "?tid=" . $uid;
}
}
// 生成的文件名
Import::fileop()->checkDir($filename);
// 纠错级别:L、M、Q、H
$errorCorrectionLevel = 'L';
// 点的大小:1到10
$matrixPointSize = 6;
QRcode::png($thisurl, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
}
示例10: index
/**
* Account sign up
*
* @access public
* @return void
*/
function index()
{
// Enable SSL?
maintain_ssl($this->config->item("ssl_enabled"));
// Redirect signed in users to homepage
if ($this->authentication->is_signed_in()) {
redirect('');
}
// Check recaptcha
$recaptcha_result = $this->recaptcha->check();
// Store recaptcha pass in session so that users only needs to complete captcha once
if ($recaptcha_result === TRUE) {
$this->session->set_userdata('sign_up_recaptcha_pass', TRUE);
}
// Setup form validation
$this->form_validation->set_error_delimiters('<span class="field_error">', '</span>');
$this->form_validation->set_rules(array(array('field' => 'sign_up_username', 'label' => 'lang:sign_up_username', 'rules' => 'trim|required|alpha_dash|min_length[2]|max_length[24]'), array('field' => 'sign_up_password', 'label' => 'lang:sign_up_password', 'rules' => 'trim|required|min_length[6]'), array('field' => 'sign_up_email', 'label' => 'lang:sign_up_email', 'rules' => 'trim|required|valid_email|max_length[160]')));
// Run form validation
if ($this->form_validation->run() === TRUE && $this->config->item("sign_up_enabled")) {
// Check if user name is taken
if ($this->username_check($this->input->post('sign_up_username')) === TRUE) {
$data['sign_up_username_error'] = lang('sign_up_username_taken');
} elseif ($this->email_check($this->input->post('sign_up_email')) === TRUE) {
$data['sign_up_email_error'] = lang('sign_up_email_exist');
} elseif (!($this->session->userdata('sign_up_recaptcha_pass') == TRUE || $recaptcha_result === TRUE) && $this->config->item("sign_up_recaptcha_enabled") === TRUE) {
$data['sign_up_recaptcha_error'] = $this->input->post('recaptcha_response_field') ? lang('sign_up_recaptcha_incorrect') : lang('sign_up_recaptcha_required');
} else {
// Remove recaptcha pass
$this->session->unset_userdata('sign_up_recaptcha_pass');
// Create user
$user_id = $this->account_model->create($this->input->post('sign_up_username', TRUE), $this->input->post('sign_up_email', TRUE), $this->input->post('sign_up_password', TRUE));
// Add user details (auto detected country, language, timezone)
$this->account_details_model->update($user_id);
// Create folder for specific user if not found
if (!file_exists(RES_DIR . "/user/" . $user_id)) {
mkdir(RES_DIR . "/user/" . $user_id);
copy(RES_DIR . "/user/index.html", RES_DIR . "/user/" . $user_id . "/index.html");
}
// Generate QR Code
if (!file_exists(RES_DIR . "/user/" . $user_id . "/qr-" . $user_id . ".png")) {
include RES_DIR . '/adminlte/plugins/qrcode/phpqrcode/qrlib.php';
QRcode::png("#" . $user_id . "#" . $this->input->post('sign_up_username', TRUE) . "#" . $this->input->post('sign_up_email', TRUE), RES_DIR . "/user/" . $user_id . "/qr-" . $user_id . ".png", "H", 10, 2);
}
// Auto sign in?
if ($this->config->item("sign_up_auto_sign_in")) {
// Run sign in routine
$this->authentication->sign_in($user_id);
}
redirect('account/sign_in');
}
}
// Load recaptcha code
if ($this->config->item("sign_up_recaptcha_enabled") === TRUE) {
if ($this->session->userdata('sign_up_recaptcha_pass') != TRUE) {
$data['recaptcha'] = $this->recaptcha->load($recaptcha_result, $this->config->item("ssl_enabled"));
}
}
// Load sign up view
$this->load->view('sign_up', isset($data) ? $data : NULL);
}
示例11: qrAction
public function qrAction()
{
$url = I('get.raw');
$url = base64_decode($url);
import_third('qrcode.phpqrcode');
\QRcode::png($url, false, QR_ECLEVEL_Q, 8);
}
示例12: init
public function init(){
//ofcourse we need rights to create temp dir
if (!file_exists($this->pngTempDir))
mkdir($this->pngTempDir);
if ($this->date != 'shopnc') {
// user data
if ($this->pngTempName != '') {
$filename = $this->pngTempDir.$this->pngTempName;
} else {
$filename = $this->pngTempDir.'test'.md5($this->date.'|'.$this->errorCorrectionLevel.'|'.$this->matrixPointSize).'.png';
}
QRcode::png($this->date, $filename, $this->errorCorrectionLevel, $this->matrixPointSize, 2);
} else {
//default data
QRcode::png('http://www.ejiao2o.com', $filename, $this->errorCorrectionLevel, $this->matrixPointSize, 2);
}
//display generated file
return basename($filename);
QRtools::timeBenchmark();
}
示例13: execute
/**
* function description
*
* @param
* @return void
*/
public function execute($request)
{
$id = $request->id;
if (empty($id)) {
header("Location: " . SP_URL_HOME);
exit;
}
$data = Sp_Account_Attendee::getAttendeeBySn($id);
if (empty($data)) {
header("Location: " . SP_URL_HOME);
exit;
}
if ($request->type == 'code') {
include LIB_ROOT . 'third/phpqrcode/qrlib.php';
$errorCorrectionLevel = "L";
$matrixPointSize = "6";
QRcode::png($id, false, $errorCorrectionLevel, $matrixPointSize);
} else {
$active = Sp_Active_Active::getActiveById($data['activeId']);
if (empty($active)) {
$this->show404();
}
$data['sn'] = $this->formatSn($data['signId']);
$view = new Sp_View();
$view->assign('data', $data);
$view->assign('active', $active);
$view->display("attendee/code.html");
}
}
示例14: build
public function build($text, $prefix, $token, $args = array())
{
$matrixPointSize = 5;
$targetFolder = $this->png_dir . $token . '/d2/';
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . $this->png_dir)) {
mkdir($_SERVER['DOCUMENT_ROOT'] . $this->png_dir);
}
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . $this->png_dir . $token)) {
mkdir($_SERVER['DOCUMENT_ROOT'] . $this->png_dir . $token);
}
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . $this->png_dir . $token . '/d2/')) {
mkdir($_SERVER['DOCUMENT_ROOT'] . $this->png_dir . $token . '/d2/');
}
$filename = 'qr_' . $prefix . '_' . $matrixPointSize . '_' . md5($text . '|' . $this->error_correction_level . '|' . $matrixPointSize . '|' . $token) . '.png';
$this->dest_url = $targetFolder . $filename;
Log::write('path:' . $this->dest_url);
if ($args) {
if (!isset($args['out_file'])) {
$args['out_file'] = $_SERVER['DOCUMENT_ROOT'] . $targetFolder . $filename;
}
create_qr($text, $args);
} else {
QRcode::png($text, $_SERVER['DOCUMENT_ROOT'] . $targetFolder . $filename, $this->error_correction_level, $matrixPointSize, 2);
}
}
示例15: qrcode
public function qrcode()
{
import('Com.Wxpay.example.phpqrcode.phpqrcode', LIB_PATH, '.php');
$url = base64_decode($_GET["data"]);
\QRcode::png($url, false, QR_ECLEVEL_L, 9, 2);
exit;
}