checkupgrade.ctrl.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. set_time_limit(0);
  8. load()->model('cloud');
  9. load()->func('communication');
  10. load()->model('extension');
  11. $r = cloud_prepare();
  12. if(is_error($r)) {
  13. itoast($r['message'], url('cloud/profile'), 'error');
  14. }
  15. $do = !empty($_GPC['do']) && in_array($do, array('module', 'system')) ? $_GPC['do'] : exit('Access Denied');
  16. if ($do == 'system') {
  17. $lock = cache_load(cache_system_key('checkupgrade'));
  18. if (empty($lock) || (TIMESTAMP - 3600 > $lock['lastupdate'])) {
  19. $upgrade = cloud_build();
  20. if(!is_error($upgrade) && !empty($upgrade['upgrade'])) {
  21. $upgrade = array('version' => $upgrade['version'], 'release' => $upgrade['release'], 'upgrade' => 1, 'lastupdate' => TIMESTAMP);
  22. cache_write(cache_system_key('checkupgrade'), $upgrade);
  23. cache_delete(cache_system_key('cloud_transtoken'));
  24. iajax(0, $upgrade);
  25. } else {
  26. $upgrade = array('lastupdate' => TIMESTAMP);
  27. cache_delete(cache_system_key('cloud_transtoken'));
  28. cache_write(cache_system_key('checkupgrade'), $upgrade);
  29. }
  30. } else {
  31. iajax(0, $lock);
  32. }
  33. }