> 1; } } $v = $vinf; for ($y = 0; $y < 6; $y++) { for ($x = 0; $x < 3; $x++) { $frame[$y][$x + ($width - 11)] = chr(136 | $v & 1); $v = $v >> 1; } } } $frame[$width - 8][8] = "\x81"; return $frame; } static public function debug($frame, $binary_mode = false) { if ($binary_mode) { foreach ($frame as &$frameLine) { $frameLine = join(' ', explode('0', $frameLine)); $frameLine = join('██', explode('1', $frameLine)); } echo ' '; echo '
'; echo join('
', $frame); echo '
';
echo join('
', $frame);
echo '';
}
}
static public function serial($frame)
{
return gzcompress(join('
', $frame), 9);
}
static public function unserial($code)
{
return explode('
', gzuncompress($code));
}
static public function newFrame($version)
{
if ($version < 1 || QRSPEC_VERSION_MAX < $version) {
return NULL;
}
if (!isset(self::$frames[$version])) {
$fileName = QR_CACHE_DIR . 'frame_' . $version . '.dat';
if (QR_CACHEABLE) {
if (file_exists($fileName)) {
self::$frames[$version] = self::unserial(file_get_contents($fileName));
}
else {
self::$frames[$version] = self::createFrame($version);
file_put_contents($fileName, self::serial(self::$frames[$version]));
}
}
else {
self::$frames[$version] = self::createFrame($version);
}
}
if (is_null(self::$frames[$version])) {
return NULL;
}
return self::$frames[$version];
}
static public function rsBlockNum($spec)
{
return $spec[0] + $spec[3];
}
static public function rsBlockNum1($spec)
{
return $spec[0];
}
static public function rsDataCodes1($spec)
{
return $spec[1];
}
static public function rsEccCodes1($spec)
{
return $spec[2];
}
static public function rsBlockNum2($spec)
{
return $spec[3];
}
static public function rsDataCodes2($spec)
{
return $spec[4];
}
static public function rsEccCodes2($spec)
{
return $spec[2];
}
static public function rsDataLength($spec)
{
return $spec[0] * $spec[1] + $spec[3] * $spec[4];
}
static public function rsEccLength($spec)
{
return ($spec[0] + $spec[3]) * $spec[2];
}
}
define('QRSPEC_VERSION_MAX', 40);
define('QRSPEC_WIDTH_MAX', 177);
define('QRCAP_WIDTH', 0);
define('QRCAP_WORDS', 1);
define('QRCAP_REMINDER', 2);
define('QRCAP_EC', 3);
?>