人人商城

az.ctrl.php 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_X_FOR .'www.sq.com/api/shop.php';
  18. $lastver = file_get_contents($updatehost . '?a=fbh&v='.$ver);
  19. $updatehosturl = $updatehost . '?a=update&v=' . $ver . '&u=' . $hosturl . '&name=' . $lastver;
  20. $updatenowinfo = file_get_contents($updatehosturl);
  21. if (strstr($updatenowinfo, 'zip')){
  22. $pathurl = $updatehost . '?a=down&f=' . $updatenowinfo. '&u=' . $hosturl;
  23. $updatedir = IA_ROOT.'/data/update';
  24. if(!is_dir($updatedir)) {
  25. mkdirs($updatedir);
  26. }
  27. //$vern = $ver+0.1;
  28. $prturl = $updatehost . '?a=pra&v=' . $ver. '&u=' . $hosturl;
  29. $pr = file_get_contents($prturl);
  30. $prcl = explode('<br>',$pr);
  31. $packet['files'] = $prcl;
  32. $packet['type'] = '';
  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($updatenowinfo, url('system/module/not_installed'), 'error');
  64. }
  65. }
  66. template('cloud/az');