merge.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. * PHP QR Code encoder
  4. *
  5. * Tool for merging all library files into one, simpler to incorporate.
  6. *
  7. * MAKE SURE THAT RESULTING PHPQRCode.php (and its dir) ARE WRITABLE!
  8. *
  9. * PHP QR Code is distributed under LGPL 3
  10. * Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
  11. *
  12. * This library is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 3 of the License, or any later version.
  16. *
  17. * This library is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with this library; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  25. */
  26. $QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
  27. $QR_TOOLSDIR = dirname(__FILE__).DIRECTORY_SEPARATOR;
  28. $outputFile = $QR_BASEDIR.'phpqrcode.php';
  29. // Required libs
  30. $fileList = array(
  31. $QR_BASEDIR.'qrconst.php',
  32. $QR_TOOLSDIR.'merged_config.php',
  33. $QR_BASEDIR.'qrtools.php',
  34. $QR_BASEDIR.'qrspec.php',
  35. $QR_BASEDIR.'qrimage.php',
  36. $QR_BASEDIR.'qrinput.php',
  37. $QR_BASEDIR.'qrbitstream.php',
  38. $QR_BASEDIR.'qrsplit.php',
  39. $QR_BASEDIR.'qrrscode.php',
  40. $QR_BASEDIR.'qrmask.php',
  41. $QR_BASEDIR.'qrencode.php'
  42. );
  43. $headerFile = $QR_TOOLSDIR.'merged_header.php';
  44. $versionFile = $QR_BASEDIR.'VERSION';
  45. $outputCode = '';
  46. foreach($fileList as $fileName) {
  47. $outputCode .= "\n\n".'//---- '.basename($fileName).' -----------------------------'."\n\n";
  48. $anotherCode = file_get_contents($fileName);
  49. $anotherCode = preg_replace ('/^<\?php/', '', $anotherCode);
  50. $anotherCode = preg_replace ('/\?>\*$/', '', $anotherCode);
  51. $outputCode .= "\n\n".$anotherCode."\n\n";
  52. }
  53. $versionDataEx = explode("\n", file_get_contents($versionFile));
  54. $outputContents = file_get_contents($headerFile);
  55. $outputContents .= "\n\n/*\n * Version: ".trim($versionDataEx[0])."\n * Build: ".trim($versionDataEx[1])."\n */\n\n";
  56. $outputContents .= $outputCode;
  57. file_put_contents($outputFile, $outputContents);