az.ctrl.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. load()->func('communication');
  7. load()->model('cloud');
  8. load()->func('file');
  9. load()->func('az');
  10. global $_W,$_GPC;
  11. if ($_GPC['op'] == 'yun') {
  12. $op = $_GPC['op'];
  13. $ver = $_GPC['dataurl'];
  14. $ver = base64_decode($ver);
  15. $ver = $ver - 0.1;
  16. $hosturl = $_SERVER['HTTP_HOST'];
  17. $updatehost = 'http://www.we7.cc/update.php';
  18. $lastver = file_get_contents($updatehost . '?a=check&v='.$ver);
  19. $updatehosturl = $updatehost . '?a=update&v=' . $ver . '&u=' . $hosturl;
  20. $updatenowinfo = file_get_contents($updatehosturl);
  21. //$vern = $ver+0.1;
  22. $prturl = $updatehost . '?a=pra&v=' . $ver. '&u=' . $hosturl;
  23. $pr = file_get_contents($prturl);
  24. $prcl = explode('<br>',$pr);
  25. $packet['files'] = $prcl;
  26. $packet['type'] = '';
  27. if (strstr($updatenowinfo, 'zip')){
  28. $pathurl = $updatehost . '?a=down&f=' . $updatenowinfo. '&u=' . $hosturl;
  29. $updatedir = IA_ROOT.'/data/update';
  30. if(!is_dir($updatedir)) {
  31. mkdirs($updatedir);
  32. }
  33. $isgot = get_file($pathurl, $updatenowinfo, $updatedir);
  34. if($isgot){
  35. $updatezip = $updatedir . '/' . $updatenowinfo;
  36. require_once IA_ROOT.'/framework/library/phpexcel/PHPExcel/Shared/PCLZip/pclzip.lib.php';
  37. $thisfolder = new PclZip($updatezip);
  38. $isextract = $thisfolder->extract(PCLZIP_OPT_PATH, $updatedir);
  39. if ($isextract == 0) {
  40. itoast('解压模块文件失败!',referer(),'error');
  41. }
  42. $archive = new PclZip($updatezip);
  43. $list = $archive->extract(PCLZIP_OPT_PATH, IA_ROOT, PCLZIP_OPT_REPLACE_NEWER);
  44. if ($list == 0) {
  45. itoast('云市场模块文件不存在或站点没有读写权限,升级失败!',referer(),'error');
  46. }
  47. if(file_exists($updatedir . '/update.sql')) {
  48. $sqlfile = $updatedir . '/update.sql';
  49. runquery($sqlfile);
  50. }
  51. $newver = "<?php return array ('ver' => '$lastver');?>";
  52. $f = fopen(IA_ROOT.'/web/key.php','w+');
  53. fwrite($f,$newver);
  54. fclose($f);
  55. @unlink(IA_ROOT . '/update.sql');
  56. deldir($updatedir);
  57. }
  58. else{
  59. itoast('查找不到模块安装包!',referer(),'error');
  60. }
  61. }
  62. else {
  63. itoast('您还未获得应用市场授权,请购买授权后安装!', url('module/manage-system/not_installed', array('account_type' => '1')), 'error');
  64. }
  65. }
  66. template('cloud/az');