update.html.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php if (!defined('HTMLY')) die('HTMLy'); ?>
  2. <?php
  3. use \Kanti\HubUpdater;
  4. $CSRF = get_csrf();
  5. $updater = new HubUpdater(array(
  6. 'name' => 'danpros/htmly',
  7. 'prerelease' => config("prerelease"),
  8. ));
  9. $dir = 'cache/';
  10. if (!is_dir($dir)) {
  11. mkdir($dir, 0775, true);
  12. }
  13. if (defined("JSON_PRETTY_PRINT")) {
  14. file_put_contents(
  15. 'cache/installedVersion.json',
  16. json_encode(array(
  17. "tag_name" => constant('HTMLY_VERSION')
  18. ), JSON_PRETTY_PRINT), LOCK_EX);
  19. } else {
  20. file_put_contents(
  21. 'cache/installedVersion.json',
  22. json_encode(array(
  23. "tag_name" => constant('HTMLY_VERSION')
  24. )), LOCK_EX
  25. );
  26. }
  27. if (empty($updater->getNewestInfo())) {
  28. echo '<h2>'.i18n('Update').'</h2><hr>';
  29. echo "Can't check Github server for latest version. You are probably offline.";
  30. } else {
  31. if ($updater->able()) {
  32. $info = $updater->getNewestInfo();
  33. echo '<h2>'.i18n('Update_Available').'</h2><hr>';
  34. echo '<h4>'. $info['name'] .'</h4>';
  35. echo '<p>Version: <strong>'. $info['tag_name'] .'</strong></p>';
  36. echo '<h5>Release Notes</h5>';
  37. echo '<div>';
  38. echo \Michelf\MarkdownExtra::defaultTransform($info['body']);
  39. echo '</div>';
  40. echo '<p><strong>Important:</strong> Please always backup your files before upgrading to newer version.</p>';
  41. echo '<p><a class="btn btn-primary" href="' . site_url() . 'admin/update/now/' . $CSRF . '" alt="' . $info['name'] . '">'.i18n('Update_to').' '. $info['tag_name'] . ' '.i18n('now').'</a></p>';
  42. } else {
  43. echo '<h2>'.i18n('Congrats_You_have_the_latest_version_of_HTMLy').'</h2><hr>';
  44. $info = $updater->getCurrentInfo();
  45. echo '<h4>'. $info['name'] .'</h4>';
  46. echo '<p>Installed Version: <strong>'. $info['tag_name'] .'</strong></p>';
  47. echo '<h5>Release Notes: </h5>';
  48. echo '<div>';
  49. echo \Michelf\MarkdownExtra::defaultTransform($info['body']);
  50. echo '</div>';
  51. echo '<p><a class="btn btn-primary" target="_blank" href="' . $info['html_url'] . '">Read on Github</a></p>';
  52. if (config('show.version') == 'false') {
  53. if(file_exists('cache/installedVersion.json')) {
  54. unlink('cache/installedVersion.json');
  55. }
  56. }
  57. }
  58. }