qrconst.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * PHP QR Code encoder
  4. *
  5. * Common constants
  6. *
  7. * Based on libqrencode C library distributed under LGPL 2.1
  8. * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi <fukuchi@megaui.net>
  9. *
  10. * PHP QR Code is distributed under LGPL 3
  11. * Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
  12. *
  13. * This library is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU Lesser General Public
  15. * License as published by the Free Software Foundation; either
  16. * version 3 of the License, or any later version.
  17. *
  18. * This library is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. * Lesser General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Lesser General Public
  24. * License along with this library; if not, write to the Free Software
  25. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  26. */
  27. // Encoding modes
  28. define('QR_MODE_NUL', -1);
  29. define('QR_MODE_NUM', 0);
  30. define('QR_MODE_AN', 1);
  31. define('QR_MODE_8', 2);
  32. define('QR_MODE_KANJI', 3);
  33. define('QR_MODE_STRUCTURE', 4);
  34. // Levels of error correction.
  35. define('QR_ECLEVEL_L', 0);
  36. define('QR_ECLEVEL_M', 1);
  37. define('QR_ECLEVEL_Q', 2);
  38. define('QR_ECLEVEL_H', 3);
  39. // Supported output formats
  40. define('QR_FORMAT_TEXT', 0);
  41. define('QR_FORMAT_PNG', 1);
  42. class qrstr {
  43. public static function set(&$srctab, $x, $y, $repl, $replLen = false) {
  44. $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
  45. }
  46. }