public function generate($params = array()) { if (isset($params['black']) && is_array($params['black']) && count($params['black']) == 3 && array_filter($params['black'], 'is_int') === $params['black']) { QRimage::$black = $params['black']; } if (isset($params['white']) && is_array($params['white']) && count($params['white']) == 3 && array_filter($params['white'], 'is_int') === $params['white']) { QRimage::$white = $params['white']; } $params['data'] = isset($params['data']) ? $params['data'] : 'QR Code Library'; if (isset($params['savename'])) { $level = 'L'; if (isset($params['level']) && in_array($params['level'], array('L', 'M', 'Q', 'H'))) { $level = $params['level']; } $size = 4; if (isset($params['size'])) { $size = min(max((int) $params['size'], 1), 10); } QRcode::png($params['data'], $params['savename'], $level, $size, 2); return $params['savename']; } else { $level = 'L'; if (isset($params['level']) && in_array($params['level'], array('L', 'M', 'Q', 'H'))) { $level = $params['level']; } $size = 4; if (isset($params['size'])) { $size = min(max((int) $params['size'], 1), 10); } QRcode::png($params['data'], NULL, $level, $size, 2); } }
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'); }
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()); } }
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()); } }
$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()); }