Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.0.9.0
  8. * @ Author : DeZender
  9. * @ Release on : 08.08.2019
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class qrstr
  15. {
  16. static public function set(&$srctab, $x, $y, $repl, $replLen = false)
  17. {
  18. $srctab[$y] = substr_replace($srctab[$y], $replLen !== false ? substr($repl, 0, $replLen) : $repl, $x, $replLen !== false ? $replLen : strlen($repl));
  19. }
  20. }
  21.  
  22. class QRtools
  23. {
  24. static public function binarize($frame)
  25. {
  26. $len = count($frame);
  27.  
  28. foreach ($frame as &$frameLine) {
  29. for ($i = 0; $i < $len; $i++) {
  30. $frameLine[$i] = (ord($frameLine[$i]) & 1 ? '1' : '0');
  31. }
  32. }
  33.  
  34. return $frame;
  35. }
  36.  
  37. static public function tcpdfBarcodeArray($code, $mode = 'QR,L', $tcPdfVersion = '4.5.037')
  38. {
  39. $barcode_array = [];
  40.  
  41. if (!is_array($mode)) {
  42. $mode = explode(',', $mode);
  43. }
  44.  
  45. $eccLevel = 'L';
  46.  
  47. if (1 < count($mode)) {
  48. $eccLevel = $mode[1];
  49. }
  50.  
  51. $qrTab = QRcode::text($code, false, $eccLevel);
  52. $size = count($qrTab);
  53. $barcode_array['num_rows'] = $size;
  54. $barcode_array['num_cols'] = $size;
  55. $barcode_array['bcode'] = [];
  56.  
  57. foreach ($qrTab as $line) {
  58. $arrAdd = [];
  59.  
  60. foreach (str_split($line) as $char) {
  61. $arrAdd[] = ($char == '1' ? 1 : 0);
  62. }
  63.  
  64. $barcode_array['bcode'][] = $arrAdd;
  65. }
  66.  
  67. return $barcode_array;
  68. }
  69.  
  70. static public function clearCache()
  71. {
  72. self::$frames = [];
  73. }
  74.  
  75. static public function buildCache()
  76. {
  77. QRtools::markTime('before_build_cache');
  78. $mask = new QRmask();
  79.  
  80. for ($a = 1; $a <= QRSPEC_VERSION_MAX; $a++) {
  81. $frame = QRspec::newFrame($a);
  82.  
  83. if (QR_IMAGE) {
  84. $fileName = QR_CACHE_DIR . 'frame_' . $a . '.png';
  85. QRimage::png(self::binarize($frame), $fileName, 1, 0);
  86. }
  87.  
  88. $width = count($frame);
  89. $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
  90.  
  91. for ($maskNo = 0; $maskNo < 8; $maskNo++) {
  92. $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true);
  93. }
  94. }
  95.  
  96. QRtools::markTime('after_build_cache');
  97. }
  98.  
  99. static public function log($outfile, $err)
  100. {
  101. if (QR_LOG_DIR !== false) {
  102. if ($err != '') {
  103. if ($outfile !== false) {
  104. file_put_contents(QR_LOG_DIR . basename($outfile) . '-errors.txt', date('Y-m-d H:i:s') . ': ' . $err, FILE_APPEND);
  105. }
  106. else {
  107. file_put_contents(QR_LOG_DIR . 'errors.txt', date('Y-m-d H:i:s') . ': ' . $err, FILE_APPEND);
  108. }
  109. }
  110. }
  111. }
  112.  
  113. static public function dumpMask($frame)
  114. {
  115. $width = count($frame);
  116.  
  117. for ($y = 0; $y < $width; $y++) {
  118. for ($x = 0; $x < $width; $x++) {
  119. echo ord($frame[$y][$x]) . ',';
  120. }
  121. }
  122. }
  123.  
  124. static public function markTime($markerId)
  125. {
  126. list($usec, $sec) = explode(' ', microtime());
  127. $time = (float) $usec + (float) $sec;
  128.  
  129. if (!isset($GLOBALS['qr_time_bench'])) {
  130. $GLOBALS['qr_time_bench'] = [];
  131. }
  132.  
  133. $GLOBALS['qr_time_bench'][$markerId] = $time;
  134. }
  135.  
  136. static public function timeBenchmark()
  137. {
  138. self::markTime('finish');
  139. $lastTime = 0;
  140. $startTime = 0;
  141. $p = 0;
  142. echo '<table cellpadding="3" cellspacing="1">' . "\n" . ' <thead><tr style="border-bottom:1px solid silver"><td colspan="2" style="text-align:center">BENCHMARK</td></tr></thead>' . "\n" . ' <tbody>';
  143.  
  144. foreach ($GLOBALS['qr_time_bench'] as $markerId => $thisTime) {
  145. if (0 < $p) {
  146. echo '<tr><th style="text-align:right">till ' . $markerId . ': </th><td>' . number_format($thisTime - $lastTime, 6) . 's</td></tr>';
  147. }
  148. else {
  149. $startTime = $thisTime;
  150. }
  151.  
  152. $p++;
  153. $lastTime = $thisTime;
  154. }
  155.  
  156. echo '</tbody><tfoot>' . "\n" . ' <tr style="border-top:2px solid black"><th style="text-align:right">TOTAL: </th><td>' . number_format($lastTime - $startTime, 6) . 's</td></tr>' . "\n" . ' </tfoot>' . "\n" . ' </table>';
  157. }
  158. }
  159.  
  160. class QRspec
  161. {
  162. static public $capacity = [
  163. [
  164. 0,
  165. 0,
  166. 0,
  167. [0, 0, 0, 0]
  168. ],
  169. [
  170. 21,
  171. 26,
  172. 0,
  173. [7, 10, 13, 17]
  174. ],
  175. [
  176. 25,
  177. 44,
  178. 7,
  179. [10, 16, 22, 28]
  180. ],
  181. [
  182. 29,
  183. 70,
  184. 7,
  185. [15, 26, 36, 44]
  186. ],
  187. [
  188. 33,
  189. 100,
  190. 7,
  191. [20, 36, 52, 64]
  192. ],
  193. .....................................................................................
  194. ........................................................
  195. ............................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement