VersionCheck.php 492 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Typemill\Models;
  3. class VersionCheck
  4. {
  5. function checkVersion($url)
  6. {
  7. $opts = array(
  8. 'http'=>array(
  9. 'method' => "GET",
  10. 'header' => "Referer: $url\r\n"
  11. )
  12. );
  13. $context = stream_context_create($opts);
  14. try {
  15. $version = file_get_contents('http://typemill.net/tma1/checkversion', false, $context);
  16. if ($version)
  17. {
  18. $version = json_decode($version);
  19. return $version->version;
  20. }
  21. } catch (Exception $e) {
  22. return false;
  23. }
  24. }
  25. }