国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.6KB

  1. <?php
  2. define('AJAXLOGIN', TRUE);
  3. define('DEDEADMIN', str_replace("\\", '/', dirname(__FILE__)));
  4. require_once(DEDEADMIN.'/../system/common.inc.php');
  5. require_once(DEDEINC.'/userlogin.class.php');
  6. AjaxHead();
  7. $action = isset($action) && in_array($action, array('is_need_check_code','has_new_version','get_changed_files','update_backup','get_update_versions'))? $action : '';
  8. /**
  9. * 登录鉴权
  10. *
  11. * @return void
  12. */
  13. function checkLogin()
  14. {
  15. $cuserLogin = new userLogin();
  16. if ($cuserLogin->getUserID() <= 0 || $cuserLogin->getUserType() != 10) {
  17. echo json_encode(array(
  18. "code" => -1,
  19. "msg" => "当前操作需要登录超级管理员账号",
  20. "data" => null,
  21. ));
  22. exit;
  23. }
  24. }
  25. if ($action === 'is_need_check_code') {
  26. $cuserLogin = new userLogin();
  27. $isNeed = $cuserLogin->isNeedCheckCode($userid);
  28. echo json_encode(array(
  29. "code" => 0,
  30. "msg" => "",
  31. "data" => array(
  32. "isNeed" => $isNeed,
  33. ),
  34. ));
  35. exit;
  36. } else if ($action === 'has_new_version'){
  37. require_once(DEDEINC.'/libraries/dedehttpdown.class.php');
  38. checkLogin();
  39. //是否存在更新版本
  40. $offUrl = DEDEBIZURL."/version?version={$cfg_version_detail}&formurl={$nurl}&phpver={$phpv}&os={$sp_os}&mysqlver={$mysql_ver}{$add_query}&json=1";
  41. $dhd = new DedeHttpDown();
  42. $dhd->OpenUrl($offUrl);
  43. $data = $dhd->GetHtml();
  44. echo $data;
  45. } else if ($action === 'get_changed_files'){
  46. require_once(DEDEINC.'/libraries/dedehttpdown.class.php');
  47. checkLogin();
  48. // 获取本地更改过的文件
  49. $hashUrl = DEDEBIZCDN.'/release/'.$cfg_version_detail.'.json';
  50. $dhd = new DedeHttpDown();
  51. $dhd->OpenUrl($hashUrl);
  52. $data = $dhd->GetJSON();
  53. $changedFiles = array();
  54. foreach ($data as $file) {
  55. $realFile = DEDEROOT. str_replace("\\", '/', $file->filename);
  56. if ( file_exists($realFile) && md5_file($realFile) !== $file->hash) {
  57. $changedFiles[] = $file;
  58. continue;
  59. }
  60. }
  61. echo json_encode(array(
  62. "code" => 0,
  63. "msg" => "",
  64. "data" => array(
  65. "files" => $changedFiles,
  66. ),
  67. ));
  68. exit;
  69. } else if($action === 'update_backup'){
  70. require_once(DEDEINC.'/libraries/dedehttpdown.class.php');
  71. checkLogin();
  72. // 获取本地更改过的文件
  73. $hashUrl = DEDEBIZCDN.'/release/'.$cfg_version_detail.'.json';
  74. $dhd = new DedeHttpDown();
  75. $dhd->OpenUrl($hashUrl);
  76. $data = $dhd->GetJSON();
  77. $changedFiles = array();
  78. $enkey = substr(md5(substr($cfg_cookie_encode, 0, 5)), 0, 10);
  79. $backupPath = DEDEDATA."/backupfile_{$enkey}";
  80. RmRecurse($backupPath);
  81. mkdir($backupPath);
  82. foreach ($data as $file) {
  83. $realFile = DEDEROOT. str_replace("\\", '/', $file->filename);
  84. if ( file_exists($realFile) && md5_file($realFile) !== $file->hash) {
  85. // 备份文件
  86. $dstFile = $backupPath.'/'.str_replace("\\", '/', $file->filename);
  87. @MkdirAll(dirname($dstFile),777);
  88. copy($realFile, $dstFile);
  89. }
  90. }
  91. echo json_encode(array(
  92. "code" => 0,
  93. "msg" => "",
  94. "data" => array(
  95. "backupdir" => "data/backupfile_{$enkey}",
  96. ),
  97. ));
  98. exit;
  99. } else if($action === 'get_update_versions'){
  100. require_once(DEDEINC.'/libraries/dedehttpdown.class.php');
  101. checkLogin();
  102. // 获取本地更改过的文件
  103. $offUrl = DEDEBIZURL."/versions?version={$cfg_version_detail}";
  104. $dhd = new DedeHttpDown();
  105. $dhd->OpenUrl($offUrl);
  106. $data = $dhd->GetHtml();
  107. echo $data;
  108. exit;
  109. }
  110. ?>