sendMemKeys.php 877 B

12345678910111213141516171819202122232425262728
  1. #! php.exe -q
  2. <?php
  3. include_once __DIR__ . '/SendData.php';
  4. /* *
  5. * PHP CLI code, to send cmem key with gzcompress and base64
  6. * gzcompress can smaller the string 10 times or more, base64 can make sure that
  7. * the data can be saved and transfered safely by http.
  8. * author: gwang (mail@wanggangzero.cn)
  9. * version: 1.0
  10. */
  11. // end class
  12. // do the work
  13. if (strtolower(php_sapi_name()) == "cli") { # 命令行模式下才执行这段逻辑
  14. if ($argv[1] == "-h" || $argc < 3) {
  15. exit("Usage: \n " . $argv[0] . " url zoneid filename \n ");
  16. } else {
  17. $url = $argv[1];
  18. $zoneid = $argv[2];
  19. $filename = $argv[3];
  20. $data = file_get_contents($filename);
  21. $key = basename($filename, ".txt");
  22. $value = $data;
  23. SendData::Send($zoneid, $url, $key, $value);
  24. }
  25. } else {
  26. exit("This program was designed for cli!");
  27. }