merge.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. $QR_BASEDIR.'qrvect.php'
  43. );
  44. $headerFile = $QR_TOOLSDIR.'merged_header.php';
  45. $versionFile = $QR_BASEDIR.'VERSION';
  46. $outputCode = '';
  47. foreach($fileList as $fileName) {
  48. $outputCode .= "\n\n".'//---- '.basename($fileName).' -----------------------------'."\n\n";
  49. $anotherCode = file_get_contents($fileName);
  50. $anotherCode = preg_replace ('/^<\?php/', '', $anotherCode);
  51. $anotherCode = preg_replace ('/\?>\*$/', '', $anotherCode);
  52. $outputCode .= "\n\n".$anotherCode."\n\n";
  53. }
  54. $versionDataEx = explode("\n", file_get_contents($versionFile));
  55. $outputContents = file_get_contents($headerFile);
  56. $outputContents .= "\n\n/*\n * Version: ".trim($versionDataEx[0])."\n * Build: ".trim($versionDataEx[1])."\n */\n\n";
  57. $outputContents .= $outputCode;
  58. file_put_contents($outputFile, $outputContents);