EncodePetconf.php 520 B

12345678910111213141516
  1. #! php.exe
  2. # PHP CLI code, to encode config.json with gzcompress and base64
  3. # gzcompress can smaller the string 10 times or more, base64 can make sure that
  4. # the data can be saved and transfered safely by http.
  5. # author: gwang
  6. # version: 1.0
  7. <?php
  8. $filename = $argv[1];
  9. $handle = fopen($filename, "rb");
  10. $contents = fread($handle, filesize($filename));
  11. fclose($handle);
  12. // 将json串先压缩 再进行base64编码
  13. $str = base64_decode(gzdeflate($contents));
  14. // $str = base64_encode(gzcompress($contents));
  15. echo $str;