当前位置: 首页>>代码示例>>PHP>>正文


PHP QRtools类代码示例

本文整理汇总了PHP中QRtools的典型用法代码示例。如果您正苦于以下问题:PHP QRtools类的具体用法?PHP QRtools怎么用?PHP QRtools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QRtools类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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();    
	}
开发者ID:noikiy,项目名称:ejia,代码行数:27,代码来源:index.php

示例2: encodeMask

 public function encodeMask(QRinput $input, $mask)
 {
     if ($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
         throw new Exception('wrong version');
     }
     if ($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) {
         throw new Exception('wrong level');
     }
     $raw = new QRrawcode($input);
     QRtools::markTime('after_raw');
     $version = $raw->version;
     $width = QRspec::getWidth($version);
     $frame = QRspec::newFrame($version);
     $filler = new FrameFiller($width, $frame);
     if (is_null($filler)) {
         return null;
     }
     // inteleaved data and ecc codes
     for ($i = 0; $i < $raw->dataLength + $raw->eccLength; $i++) {
         $code = $raw->getCode();
         $bit = 0x80;
         for ($j = 0; $j < 8; $j++) {
             $addr = $filler->next();
             $filler->setFrameAt($addr, 0x2 | ($bit & $code) != 0);
             $bit = $bit >> 1;
         }
     }
     QRtools::markTime('after_filler');
     unset($raw);
     // remainder bits
     $j = QRspec::getRemainder($version);
     for ($i = 0; $i < $j; $i++) {
         $addr = $filler->next();
         $filler->setFrameAt($addr, 0x2);
     }
     $frame = $filler->frame;
     unset($filler);
     // masking
     $maskObj = new QRmask();
     if ($mask < 0) {
         if (QR_FIND_BEST_MASK) {
             $masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel());
         } else {
             $masked = $maskObj->makeMask($width, $frame, (int) QR_DEFAULT_MASK % 8, $input->getErrorCorrectionLevel());
         }
     } else {
         $masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
     }
     if ($masked == null) {
         return null;
     }
     QRtools::markTime('after_mask');
     $this->version = $version;
     $this->width = $width;
     $this->data = $masked;
     return $this;
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:57,代码来源:QRcode.php

示例3: buildCache

 public static function buildCache()
 {
     QRtools::markTime('before_build_cache');
     $mask = new QRmask();
     for ($a = 1; $a <= QRSPEC_VERSION_MAX; $a++) {
         $frame = QRspec::newFrame($a);
         if (QR_IMAGE) {
             $fileName = QR_CACHE_DIR . 'frame_' . $a . '.png';
             QRimage::png(self::binarize($frame), $fileName, 1, 0);
         }
         $width = count($frame);
         $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
         for ($maskNo = 0; $maskNo < 8; $maskNo++) {
             $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true);
         }
     }
     QRtools::markTime('after_build_cache');
 }
开发者ID:norain2050,项目名称:xingkang,代码行数:18,代码来源:qrtools.php

示例4: encodePNG

 public function encodePNG($intext, $outfile = false, $saveandprint = false)
 {
     try {
         ob_start();
         $tab = $this->encode($intext);
         $err = ob_get_contents();
         ob_end_clean();
         if ($err != '') {
             QRtools::log($outfile, $err);
         }
         $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin));
         QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $saveandprint);
     } catch (Exception $e) {
         QRtools::log($outfile, $e->getMessage());
     }
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:16,代码来源:QRencode.php

示例5: die

    if (trim($_REQUEST['data']) == '') {
        die('data cannot be empty! <a href="?">back</a>');
    }
    // user data
    $filename = $PNG_TEMP_DIR . 'test' . md5($_REQUEST['data'] . '|' . $errorCorrectionLevel . '|' . $matrixPointSize) . '.png';
    QRcode::png($_REQUEST['data'], $filename, $errorCorrectionLevel, $matrixPointSize, 2);
} else {
    //default data
    echo 'You can provide data in GET parameter: <a href="?data=like_that">like that</a><hr/>';
    QRcode::png('PHP QR Code :)', $filename, $errorCorrectionLevel, $matrixPointSize, 2);
}
//display generated file
echo '<img src="' . $PNG_WEB_DIR . basename($filename) . '" /><hr/>';
//config form
echo '<form action="index.php" method="post">
        Data:&nbsp;<input name="data" value="' . (isset($_REQUEST['data']) ? htmlspecialchars($_REQUEST['data']) : 'PHP QR Code :)') . '" />&nbsp;
        ECC:&nbsp;<select name="level">
            <option value="L"' . ($errorCorrectionLevel == 'L' ? ' selected' : '') . '>L - smallest</option>
            <option value="M"' . ($errorCorrectionLevel == 'M' ? ' selected' : '') . '>M</option>
            <option value="Q"' . ($errorCorrectionLevel == 'Q' ? ' selected' : '') . '>Q</option>
            <option value="H"' . ($errorCorrectionLevel == 'H' ? ' selected' : '') . '>H - best</option>
        </select>&nbsp;
        Size:&nbsp;<select name="size">';
for ($i = 1; $i <= 10; $i++) {
    echo '<option value="' . $i . '"' . ($matrixPointSize == $i ? ' selected' : '') . '>' . $i . '</option>';
}
echo '</select>&nbsp;
        <input type="submit" value="GENERATE"></form><hr/>';
// benchmark
QRtools::timeBenchmark();
开发者ID:imbzd,项目名称:sessdw,代码行数:30,代码来源:index.php

示例6: svg

 public static function svg($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveandprint = FALSE, $back_color, $fore_color)
 {
     $vect = self::vectSVG($frame, $pixelPerPoint, $outerFrame, $back_color, $fore_color);
     if ($filename === false) {
         header("Content-Type: image/svg+xml");
         //header('Content-Disposition: attachment, filename="qrcode.svg"');
         echo $vect;
     } else {
         if ($saveandprint === TRUE) {
             QRtools::save($vect, $filename);
             header("Content-Type: image/svg+xml");
             //header('Content-Disposition: filename="'.$filename.'"');
             echo $vect;
         } else {
             QRtools::save($vect, $filename);
         }
     }
 }
开发者ID:AmphibiaWeb,项目名称:amphibian-disease-tracker,代码行数:18,代码来源:phpqrcode.php

示例7: qrtest

 public static function qrtest()
 {
     // Include only this file, remaining required files will be included from it
     if (!class_exists("qrstr", FALSE)) {
         require_once PATH_PHPQRCODE . "/qrlib.php";
     }
     //write code into file, Error corection lecer is lowest, L (one form: L,M,Q,H)
     //each code square will be 4x4 pixels (4x zoom)
     //code will have 2 code squares white boundary around
     if (1) {
         // Error correction level L : About 7% or less errors can be corrected.
         // Error correction level M : About 15% or less errors can be corrected.
         // Error correction level Q : About 25% or less errors can be corrected.
         // Error correction level H : About 30% or less errors can be corrected.
         $text = "http://www.nordita.org/guest/";
         $filetype = "png";
         // "png","svg","eps","txt"
         if (!in_array($filetype, array("png", "svg", "eps", "txt"))) {
             return FALSE;
         }
         $level = "H";
         // "L" (default) ,"M", "Q", "H"
         $pixelsize = 16;
         // pixel size of each code square
         $margin = 4;
         // boundary width in number of code squares
         $saveandprint = FALSE;
         // TRUE = save to file and display in browser; FALSE = save to file only; redundant if $outfile=FALSE
         $back_color = 0xffffff;
         $fore_color = 0x0;
         $cmyk = TRUE;
         $filename = "qrcode";
         $outfile = PATH_PHPQRCACHE . $filename . "." . $filetype;
         // full file path or FALSE (only output on screen)
         //$outfile      = FALSE;
         switch ($filetype) {
             case "png":
                 QRcode::png($text, $outfile, $level, $pixelsize, $margin, $saveandprint, $back_color, $fore_color);
                 break;
             case "eps":
                 QRcode::eps($text, $outfile, $level, $pixelsize, $margin, $saveandprint, $back_color, $fore_color, $cmyk);
                 break;
             case "svg":
                 QRcode::svg($text, $outfile, $level, $pixelsize, $margin, $saveandprint, $back_color, $fore_color);
                 break;
             case "txt":
                 QRcode::text($text, $outfile, $level, $pixelsize, $margin);
                 // black = "1", white = "0"
                 break;
         }
         // end switch
     }
     //same as above but outputs file directly into browser (with appr. header etc.)
     //all other settings are default
     //WARNING! it should be FIRST and ONLY output generated by script, otherwise
     //rest of output will land inside PNG binary, breaking it for sure
     if (0) {
         QRcode::png("PHP QR Code :)");
     }
     //show benchmark
     if (0) {
         QRtools::timeBenchmark();
     }
     //rebuild cache
     if (0) {
         QRtools::buildCache();
     }
     //code generated in text mode - as a binary table
     //then displayed out as HTML using Unicode block building chars :)
     if (0) {
         $qr = new QRencode();
         $tab = $qr->encode('PHP QR Code :)');
         QRspec::debug($tab, true);
     }
 }
开发者ID:,项目名称:,代码行数:75,代码来源:

示例8: _qr_img

 protected static function _qr_img($data)
 {
     require_once self::$o->core_dir . 'libs/phpqrcode/qrlib.php';
     require_once self::$o->core_dir . 'libs/phpqrcode/qsot-qrimage.php';
     ob_start();
     // create the encoder
     $enc = QRencode::factory('L', 3, 1);
     $outfile = false;
     try {
         // attempt to encode the data
         ob_start();
         $tab = $enc->encode($data);
         $err = ob_get_contents();
         ob_end_clean();
         // log any errors produced
         if ($err != '') {
             QRtools::log($outfile, $err);
         }
         // calculate the dimensions of the image
         $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $enc->margin));
         // render the image
         $img_data = QSOT_QRimage::jpg_base64($tab, 2.5, $enc->margin, 100);
     } catch (Exception $e) {
         $img_data = array('data:image/jpeg;base64,', 0, 0);
         // log any exceptions
         QRtools::log($outfile, $e->getMessage());
     }
     return $img_data;
 }
开发者ID:Jayriq,项目名称:opentickets-community,代码行数:29,代码来源:checkin.class.php

示例9: timeBenchmark

        }
        $GLOBALS['qr_time_bench'][$markerId] = $time;
    }
    //----------------------------------------------------------------------
    public static function timeBenchmark()
    {
        self::markTime('finish');
        $lastTime = 0;
        $startTime = 0;
        $p = 0;
        echo '<table cellpadding="3" cellspacing="1">
                    <thead><tr style="border-bottom:1px solid silver"><td colspan="2" style="text-align:center">BENCHMARK</td></tr></thead>
                    <tbody>';
        foreach ($GLOBALS['qr_time_bench'] as $markerId => $thisTime) {
            if ($p > 0) {
                echo '<tr><th style="text-align:right">till ' . $markerId . ': </th><td>' . number_format($thisTime - $lastTime, 6) . 's</td></tr>';
            } else {
                $startTime = $thisTime;
            }
            $p++;
            $lastTime = $thisTime;
        }
        echo '</tbody><tfoot>
                <tr style="border-top:2px solid black"><th style="text-align:right">TOTAL: </th><td>' . number_format($lastTime - $startTime, 6) . 's</td></tr>
            </tfoot>
            </table>';
    }
}
//##########################################################################
QRtools::markTime('start');
开发者ID:ahmedash95,项目名称:Lily,代码行数:30,代码来源:qrtools.php

示例10: encodeJPG

 public function encodeJPG($intext, $outfile = false, $q = 85, $rgb_color = '0,0,0', $rgb_bg_color = '255,255,255')
 {
     try {
         ob_start();
         $tab = $this->encode($intext);
         $err = ob_get_contents();
         ob_end_clean();
         if ($err != '') {
             QRtools::log($outfile, $err);
         }
         $maxSize = (int) (QR_JPG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin));
         QRimage::jpg($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $q, $rgb_color, $rgb_bg_color);
     } catch (Exception $e) {
         QRtools::log($outfile, $e->getMessage());
     }
 }
开发者ID:Calit2-UCI,项目名称:IoT_Map,代码行数:16,代码来源:qrencode.php

示例11: list

            $out[] = '';
        } else {
            $out[] = $matches[0][3];
        }
    }
    return $out;
}
// validate signature
list($key, $salt) = qsot_fetch_defines(array('NONCE_KEY', 'NONCE_SALT'), $d['p']);
$test = sha1($key . @json_encode($d) . $salt);
if ($test != $sig) {
    die($debug ? '<!-- hash mismatch : ' . $sig . ' / ' . $test . ' -->' : '');
}
// end abuse protection
include_once 'qrlib.php';
//QRCode::png($d, false, 'L', 3, 1);
$enc = QRencode::factory('L', 3, 1);
$outfile = false;
try {
    ob_start();
    $tab = $enc->encode($d['d']);
    $err = ob_get_contents();
    ob_end_clean();
    if ($err != '') {
        QRtools::log($outfile, $err);
    }
    $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $enc->margin));
    QRimage::jpg($tab, $outfile, 2.5, $enc->margin, 100);
} catch (Exception $e) {
    QRtools::log($outfile, $e->getMessage());
}
开发者ID:Jayriq,项目名称:opentickets-community,代码行数:31,代码来源:index.php

示例12: markTime

 public static function markTime($markerId)
 {
     list($usec, $sec) = explode(" ", microtime());
     $time = (double) $usec + (double) $sec;
     if (!isset($GLOBALS['qr_time_bench'])) {
         $GLOBALS['qr_time_bench'] = array();
     }
     $GLOBALS['qr_time_bench'][$markerId] = $time;
     if (!self::$timeBenchmarkStarted && $markerId != 'start') {
         self::$timeBenchmarkStarted = true;
         $GLOBALS['qr_time_bench']['start'] = $time;
     }
 }
开发者ID:RazorMarx,项目名称:izend,代码行数:13,代码来源:qrtools.php


注:本文中的QRtools类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。