找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 4783|回复: 0

解决微擎框架出现Could not resolve: cloud.zhifun.cc

[复制链接]
发表于 2020-11-5 01:03:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×

解决微擎框架出现Could not resolve: cloud.zhifun.cc (Domain name not found)问题
最近这段时间,大家在安装微擎的时候会遇到:模块安装失败的问题,提示Could not resolve: cloud.zhifun.cc (Domain name not found),这个问题是因为cloud.zhifun.cc云服务挂了。我们只需要去替换或者注释这个云服务就行。
你可以将下面的代码复制到\framework\model目录下的cloud.mod.php文件,覆盖掉原有文件,问题就解决了,希望对大家有帮助!

  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. $_URLTYPE = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
  8. define('CLOUD_GATEWAY_URL', $_URLTYPE.$_SERVER['HTTP_HOST']);
  9. define('CLOUD_GATEWAY_URL_NORMAL', $_URLTYPE.$_SERVER['HTTP_HOST']);
  10. function cloud_client_define() {
  11.     return array(
  12.         '/framework/function/communication.func.php',
  13.         '/framework/model/cloud.mod.php',
  14.         '/web/source/cloud/upgrade.ctrl.php',
  15.         '/web/source/cloud/process.ctrl.php',
  16.         '/web/source/cloud/dock.ctrl.php',
  17.         '/web/themes/default/cloud/upgrade.html',
  18.         '/web/themes/default/cloud/process.html'
  19.     );
  20. }


  21. function _cloud_build_params($must_authorization_host = true) {
  22.     global $_W;
  23.     $pars = array();
  24.     $pars['host'] = strexists($_SERVER['HTTP_HOST'], ':') ? parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST'];
  25.     if (is_array($_W['setting']['site']) && !empty($_W['setting']['site']['url']) && $must_authorization_host) {
  26.         $pars['host'] = parse_url($_W['setting']['site']['url'], PHP_URL_HOST);
  27.     }
  28.     $pars['https'] = $_W['ishttps'] ? 1 : 0;
  29.     $pars['family'] = IMS_FAMILY;
  30.     $pars['version'] = IMS_VERSION;
  31.     $pars['php_version'] = PHP_VERSION;
  32.     $pars['current_host'] = $_SERVER['HTTP_HOST'];
  33.     $pars['release'] = IMS_RELEASE_DATE;
  34.     if (!empty($_W['setting']['site'])) {
  35.         $pars['key'] = $_W['setting']['site']['key'];
  36.         $pars['password'] = md5($_W['setting']['site']['key'] . $_W['setting']['site']['token']);
  37.     }
  38.     $clients = cloud_client_define();
  39.     $string = '';
  40.     foreach($clients as $cli) {
  41.         $string .= md5_file(IA_ROOT . $cli);
  42.     }
  43.     $pars['client'] = md5($string);
  44.     return $pars;
  45. }

  46. function _cloud_shipping_parse($dat, $file) {
  47.         /*if (is_error($dat)) {
  48.         return error(-1, '网络传输故障,详情: ' . (strpos($dat['message'], 'Connection reset by peer') ? '云服务瞬时访问过大而导致网络传输中断,请稍后重试。' : $dat['message']));
  49.     }
  50.     $tmp = iunserializer($dat['content']);
  51.     if (is_array($tmp) && is_error($tmp)) {
  52.         if ($tmp['errno'] == '-2') {
  53.             file_put_contents(IA_ROOT . '/framework/version.inc.php', str_replace("'x'", "'v'", file_get_contents(IA_ROOT . '/framework/version.inc.php')));
  54.         }
  55.         return $tmp;
  56.     }
  57.     if ($dat['content'] == 'patching') {
  58.         return error(-1, '补丁程序正在更新中,请稍后再试!');
  59.     }
  60.     if ($dat['content'] == 'frequent') {
  61.         return error(-1, '更新操作太频繁,请稍后再试!');
  62.     }
  63.     if ($dat['content'] == 'blacklist') {
  64.         return error(-1, '抱歉,您的站点已被列入云服务黑名单,云服务一切业务已被禁止,请联系微擎客服!');
  65.     }
  66.     if ($dat['content'] == 'install-theme-protect' || $dat['content'] == 'install-module-protect') {
  67.         return error('-1', '此' . ($dat['content'] == 'install-theme-protect' ? '模板' : '模块') . '已设置版权保护,您只能通过云平台来安装,请先删除该模块的所有文件,购买后再行安装。');
  68.     }

  69.     $content = json_decode($dat['content'], true);
  70.     if (!empty($content['error'])) {
  71.         return error(-1, $content['error']);
  72.     }
  73.     if (!empty($content) && is_array($content)) {
  74.         return $content;
  75.     }

  76.     if (strlen($dat['content']) != 32) {
  77.         $dat['content'] = iunserializer($dat['content']);
  78.         if (is_array($dat['content']) && isset($dat['content']['files'])) {
  79.             if (!empty($dat['content']['manifest'])) {
  80.                 $dat['content']['manifest'] = base64_decode($dat['content']['manifest']);
  81.             }
  82.             if (!empty($dat['content']['scripts'])) {
  83.                 $dat['content']['scripts'] = base64_decode($dat['content']['scripts']);
  84.             }
  85.             return $dat['content'];
  86.         }
  87.         if (is_array($dat['content']) && isset($dat['content']['data'])) {
  88.             $data = $dat['content'];
  89.         } else {
  90.             return error(-1, '云服务平台向您的服务器传输数据过程中出现错误,详情:' . $dat['content']);
  91.         }
  92.     } else {
  93.         $data = @file_get_contents($file);
  94.         @unlink($file);
  95.     }
  96.      
  97.     $ret = @iunserializer($data);
  98.     if (empty($data) || empty($ret)) {
  99.         return error(-1, '云服务平台向您的服务器传输的数据校验失败,请稍后重试.');
  100.     }
  101.     $ret = iunserializer($ret['data']);
  102.     if (is_array($ret) && is_error($ret)) {
  103.         if ($ret['errno'] == '-2') {
  104.             file_put_contents(IA_ROOT . '/framework/version.inc.php', str_replace("'x'", "'v'", file_get_contents(IA_ROOT . '/framework/version.inc.php')));
  105.         }
  106.         if ($ret['errno'] == '-3') {            return array(
  107.                 'errno' => $ret['errno'],
  108.                 'message' => $ret['message'],
  109.                 'cloud_id' => $ret['data'],
  110.             );
  111.         }
  112.     }
  113.     if (!is_error($ret) && is_array($ret)) {
  114.         if (!empty($ret) && $ret['state'] == 'fatal') {
  115.             return error($ret['errorno'], '发生错误: ' . $ret['message']);
  116.         }
  117.         return $ret;
  118.     } else {
  119.         return error($ret['errno'], "发生错误: {$ret['message']}");
  120.     }*/
  121.     return array();
  122. }

  123. function cloud_request($url, $post = '', $extra = array(), $timeout = 60) {
  124.     global $_W;
  125.     load()->func('communication');
  126.     if (!empty($_W['setting']['cloudip']['ip']) && empty($extra['ip'])) {
  127. //  $extra['ip'] = $_W['setting']['cloudip']['ip'];
  128.         $extra['ip'] = $_SERVER['HTTP_HOST'];
  129.     }
  130. /*  if (strexists($url, 's.w7.cc')) {
  131.         $extra = array();
  132.     }
  133.     $response = ihttp_request($url, $post, $extra, $timeout);
  134.     if (is_error($response)) {
  135.         setting_save(array(), 'cloudip');
  136.     }
  137.     return $response;
  138. */
  139.     return array();
  140. }
  141. function local_salt($length = 8) {
  142.     $result = '';
  143.     while(strlen($result) < $length) {
  144.         $result .= sha1(uniqid('', true));
  145.     }
  146.     return substr($result, 0, $length);
  147. }

  148. function cloud_api($method, $data = array(), $extra = array(), $timeout = 60) {
  149.     if ($method == 'site/register/profile') {
  150.         $pars = _cloud_build_params();
  151.                 $_URLTYPE = $pars['https'] ? 'https://' : 'http://';
  152.                 $tmp1 =  $pars['key'] ? $pars['key'] : local_salt(6);
  153.                 $tmp2 =  $_URLTYPE . $pars['host'];
  154.                 $site_tmp = array (  'key' => $tmp1,  'token' => md5($tmp1),  'url' => $tmp2,  'version' => $pars['version'],  'family' => $pars['family'],  'type' => 'register',);
  155.                 //$site_tmp = serialize($site_tmp);
  156.                 pdo_update('core_settings', array('value' => iserializer($site_tmp)), array('key' => 'site'));
  157.                 cache_updatecache();

  158.     }
  159. /*  $cache_key = cache_system_key('cloud_api', array('method' => md5($method . implode('', $data))));
  160.     $cache = cache_load($cache_key);
  161.     if (!empty($cache) && !$extra['nocache']) {
  162.         return $cache;
  163.     }
  164.     $api_url = 'http://api.w7.cc/%s';
  165.     $must_authorization_host = !in_array($method, array('module/setting/index', 'module/setting/save'));
  166.     $pars = _cloud_build_params($must_authorization_host);
  167.     if ($method != 'site/token/index') {
  168.         $pars['token'] = cloud_build_transtoken();
  169.     }
  170.     $data = array_merge($pars, $data);
  171.     if ($GLOBALS['_W']['config']['setting']['development'] == 3) {
  172.         $extra['CURLOPT_USERAGENT'] = 'development';
  173.     }
  174.     $response = ihttp_request(sprintf($api_url, $method), $data, $extra, $timeout);
  175.     $file = IA_ROOT . '/data/' . (!empty($data['file']) ? $data['file'] : $data['method']);
  176.     $file = $file . cache_random();
  177.     $ret = _cloud_shipping_parse($response, $file);
  178.     if (!is_error($ret) && !empty($ret)) {
  179.         cache_write($cache_key, $ret, CACHE_EXPIRE_MIDDLE);
  180.     }
  181.     return $ret;
  182. */
  183.     return null;
  184. }

  185. function cloud_prepare() {
  186.     global $_W;
  187.     setting_load();
  188. /*  if(empty($_W['setting']['site']['key']) || empty($_W['setting']['site']['token'])) {
  189.         return error('-1', '站点注册信息丢失, 请通过"重置站点ID和通信密钥"重新获取 !');
  190.     }
  191.     */
  192.     return true;
  193. }

  194. function cloud_build($nocache = false) {
  195. /*
  196.     $pars['method'] = 'application.build4';
  197.     $pars['file'] = 'application.build';
  198.     $extra = $nocache ? array('nocache' => $nocache) : array();
  199.     $ret = cloud_api('site/build/index', $pars, $extra);
  200.     if (is_error($ret)) {
  201.         return $ret;
  202.     }

  203.     if($ret['state'] == 'warning') {
  204.         $ret['files'] = cloud_client_define();
  205.         unset($ret['schemas']);
  206.         unset($ret['scripts']);
  207.     } else {
  208.         $patch_path = sprintf('%s/data/patch/upgrade/%s', IA_ROOT, date('Ymd'));
  209.         if (!is_dir($patch_path)) {
  210.             mkdirs($patch_path);
  211.         }

  212.         $files = $files_allowed = array();
  213.         if(!empty($ret['files'])) {
  214.             foreach($ret['files'] as $file) {
  215.                 $entry = IA_ROOT . $file['path'];
  216.                 if(!is_file($entry) || md5_file($entry) != $file['checksum']) {
  217.                     $files_allowed[] = $file['path'];
  218.                 }

  219.                 $entry = $patch_path . $file['path'];
  220.                 if (!is_file($entry)) {
  221.                     $entry = IA_ROOT . $file['path'];
  222.                 }
  223.                 if(!is_file($entry) || md5_file($entry) != $file['checksum']) {
  224.                     $files[] = $file['path'];
  225.                 }
  226.             }
  227.         }
  228.         $ret['files'] = $files;
  229.         if (!empty($ret['files'])) {
  230.             cloud_bakup_files($ret['files']);
  231.         } else {
  232.             if (!empty($files_allowed)) {
  233.                 foreach ($files_allowed as $file) {
  234.                     $dir = pathinfo(IA_ROOT . $file, PATHINFO_DIRNAME);
  235.                     if (!is_dir($dir)) {
  236.                         mkdirs($dir);
  237.                     }
  238.                     file_put_contents(IA_ROOT . $file, file_get_contents($patch_path . $file));
  239.                 }
  240.                 rmdirs($patch_path);
  241.             }
  242.         }
  243.         $schemas = array();
  244.         if(!empty($ret['schemas'])) {
  245.             load()->func('db');
  246.             foreach($ret['schemas'] as $remote) {
  247.                 $name = substr($remote['tablename'], 4);
  248.                 $local = db_table_schema(pdo(), $name);
  249.                 unset($remote['increment']);
  250.                 unset($local['increment']);
  251.                 if(empty($local)) {
  252.                     $schemas[] = $remote;
  253.                 } else {
  254.                     $sqls = db_table_fix_sql($local, $remote);
  255.                     if(!empty($sqls)) {
  256.                         $schemas[] = $remote;
  257.                     }
  258.                 }
  259.             }
  260.         }
  261.         $ret['schemas'] = $schemas;
  262.     }

  263.     if (IMS_FAMILY != $ret['family']) {
  264.         $update_version_success = setting_upgrade_version($ret['family'], IMS_VERSION, IMS_RELEASE_DATE);
  265.         if (empty($update_version_success)) {
  266.             message('切换版本失败,请修改 /framework/version.inc.php 文件权限为 User 可写或是 777', 'refresh', 'error');
  267.         } else {
  268.             message('更新系统正在为您自动切换版本', 'refresh');
  269.         }
  270.     }
  271.     $ret['upgrade'] = false;
  272.     if(!empty($ret['files']) || !empty($ret['schemas']) || !empty($ret['scripts'])) {
  273.         $ret['upgrade'] = true;
  274.     }

  275.     return $ret;
  276. */
  277.     return null;
  278. }

  279. function cloud_schema() {
  280.     $pars['method'] = 'application.schema';
  281.     $pars['file'] = 'application.schema';
  282.     $ret = cloud_api('site/schema/index', $pars);
  283.      
  284.     if(!is_error($ret)) {
  285.         $schemas = array();
  286.         if(!empty($ret['schemas'])) {
  287.             load()->func('db');
  288.             foreach($ret['schemas'] as $remote) {
  289.                 $name = substr($remote['tablename'], 4);
  290.                 $local = db_table_schema(pdo(), $name);
  291.                 unset($remote['increment']);
  292.                 unset($local['increment']);
  293.                 if(empty($local)) {
  294.                     $schemas[] = $remote;
  295.                 } else {
  296.                     $diffs = db_schema_compare($local, $remote);
  297.                     if(!empty($diffs)) {
  298.                         $schemas[] = $remote;
  299.                     }
  300.                 }
  301.             }
  302.         }
  303.         $ret['schemas'] = $schemas;
  304.     }
  305.     return $ret;
  306. }

  307. function cloud_download($path, $type = '') {
  308.     global $_W;
  309.     $pars = _cloud_build_params();
  310.     $pars['method'] = 'application.shipping';
  311.     $pars['path'] = $path;
  312.     $pars['type'] = $type;
  313.     $pars['gz'] = function_exists('gzcompress') && function_exists('gzuncompress') ? 'true' : 'false';
  314.     $pars['download'] = 'true';
  315.     $headers = array('content-type' => 'application/x-www-form-urlencoded');
  316.     $_URLTYPE = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
  317.     $dat = cloud_request($_URLTYPE.$_SERVER['HTTP_HOST'], $pars, $headers, 300);
  318.     if(is_error($dat)) {
  319.         return error(-1, '网络存在错误, 请稍后重试。' . $dat['message']);
  320.     }
  321.     if($dat['content'] == 'success') {
  322.         return true;
  323.     }
  324.     $ret = @json_decode($dat['content'], true);
  325.     if (isset($ret['error'])) {
  326.         return error(1, $ret['error']);
  327.     }
  328.     if(is_error($ret)) {
  329.         return $ret;
  330.     } else {
  331.         $post = $dat['content'];
  332.         $data = base64_decode($post);
  333.         if (base64_encode($data) !== $post) {
  334.             $data = $post;
  335.         }
  336.         $ret = iunserializer($data);
  337.         $gz = function_exists('gzcompress') && function_exists('gzuncompress');
  338.         $file = base64_decode($ret['file']);
  339.         if($gz) {
  340.             $file = gzuncompress($file);
  341.         }
  342.         $_W['setting']['site']['token'] = authcode(cache_load(cache_system_key('cloud_transtoken')), 'DECODE');
  343.         $string = (md5($file) . $ret['path'] . $_W['setting']['site']['token']);
  344.         if(!empty($_W['setting']['site']['token']) && md5($string) === $ret['sign']) {
  345.             $error_file_list = array();
  346.             if (!cloud_file_permission_pass($error_file_list)) {
  347.                 return error(-1, '请修复下列文件读写权限 : ' . implode('; ', $error_file_list));
  348.             }
  349.                         if ($type == 'module' || $type == 'theme') {
  350.                 $patch_path = IA_ROOT;
  351.             } else {
  352.                 $patch_path = sprintf('%s/data/patch/upgrade/%s', IA_ROOT, date('Ymd'));
  353.             }
  354.             $path = $patch_path . $ret['path'];
  355.             load()->func('file');
  356.             @mkdirs(dirname($path));
  357.             if (file_put_contents($path, $file)) {
  358.                 return true;
  359.             } else {
  360.                 return error(-1, '写入失败,请检查是否有写入权限或是否磁盘已满!');
  361.             }
  362.         }
  363.         return error(-1, '写入失败!');
  364.     }
  365. }

  366. function cloud_m_prepare($name) {
  367. /*  $ret = cloud_api('module/check', array(
  368.         'method' => 'module.check',
  369.         'module' => $name,
  370.     ));
  371.     if (is_error($ret)) {
  372.         return $ret;
  373.     }*/
  374.     return true;
  375. }


  376. function cloud_m_build($modulename, $type = ''){
  377. /*  $type = in_array($type, array('uninstall', 'upgrade', 'install')) ? $type : '';
  378.     if (empty($modulename)) {
  379.         return array();
  380.     }
  381.     if ($type == 'upgrade') {
  382.         $module_info = cloud_m_info($modulename);
  383.         if (is_error($module_info)) {
  384.             return $module_info['message'];
  385.         }
  386.         $module = array('version' => $module_info['version']['version']);
  387.     } else {
  388.         $module = table('modules')->getByName($modulename);
  389.     }
  390.     $pars['module'] = $modulename;
  391.     $pars['type'] = $type;
  392.     if (!empty($module)) {
  393.         $pars['module_version'] = $module['version'];
  394.     }
  395.      
  396.     $pars['file'] = 'module.build';
  397.     $ret = cloud_api('module/build', $pars);

  398.     if (!is_error($ret)) {
  399.         $dir = IA_ROOT . '/addons/' . $modulename;
  400.         $files = array();
  401.         if (!empty($ret['files'])) {
  402.             foreach ($ret['files'] as $file) {
  403.                 if ($file['path'] == '/map.json') {
  404.                     continue;
  405.                 }
  406.                 $entry = $dir . $file['path'];
  407.                 if (!is_file($entry) || md5_file($entry) != $file['checksum']) {
  408.                     $files[] = '/' . $modulename . $file['path'];
  409.                 }
  410.             }
  411.         }
  412.         $ret['files'] = $files;
  413.         $schemas = array();
  414.         if (!empty($ret['schemas'])) {
  415.             load()->func('db');
  416.             foreach ($ret['schemas'] as $remote) {
  417.                 $name = substr($remote['tablename'], 4);
  418.                 $local = db_table_schema(pdo(), $name);
  419.                 unset($remote['increment']);
  420.                 unset($local['increment']);
  421.                 if (empty($local)) {
  422.                     $schemas[] = $remote;
  423.                 } else {
  424.                     $diffs = db_table_fix_sql($local, $remote);
  425.                     if (!empty($diffs)) {
  426.                         $schemas[] = $remote;
  427.                     }
  428.                 }
  429.             }
  430.         }
  431.         $ret['upgrade'] = true;
  432.         $ret['type'] = 'module';
  433.         $ret['schemas'] = $schemas;
  434.                 if (empty($module)) {
  435.             $ret['install'] = 1;
  436.         }
  437.     }
  438.     return $ret;
  439.     */
  440.     return null;
  441. }


  442. function cloud_m_query($module = array(), $page = 1) {
  443. /*  $pars['method'] = 'module.query';
  444.     if (empty($module)) {
  445.         $module = cloud_extra_module();
  446.     }
  447.     if (!is_array($module)) {
  448.         $module = array($module);
  449.     }
  450.     $pars['page'] = max(1, intval($page));
  451.     $pars['module'] = base64_encode(iserializer($module));
  452.     $ret = cloud_api('module/query', $pars);
  453.     if (isset($ret['error'])) {
  454.         return error(1, $ret['error']);
  455.     }
  456.     if (!is_error($ret)) {
  457.         $pirate_apps = $ret['pirate_apps'];
  458.         unset($ret['pirate_apps']);
  459.         $support_names = array('app', 'wxapp', 'webapp', 'system_welcome', 'android', 'ios', 'xzapp', 'aliapp', 'baiduapp', 'toutiaoapp');
  460.         $record_module = array();
  461.         foreach ($ret['data'] as $modulename => &$info) {
  462.             if ($info['is_record']) {
  463.                 $record_module[] = $info['name'];
  464.             }
  465.             if (empty($info['site_branch'])) {
  466.                 continue;
  467.             }
  468.             foreach ($support_names as $support) {
  469.                 if (in_array($support, $info['site_branch']['bought']) && !empty($info['site_branch']["{$support}_support"]) && $info['site_branch']["{$support}_support"] == 2) {
  470.                     $info['site_branch']["{$support}_support"] = 2;
  471.                 } else {
  472.                     $info['site_branch']["{$support}_support"] = 1;
  473.                 }
  474.             }
  475.         }
  476.         $ret['pirate_apps'] = $pirate_apps;
  477.         if (!empty($record_module)) {
  478.             table('modules')->where(array('name IN' => $record_module))->fill(array('cloud_record' => STATUS_ON))->save();
  479.         }
  480.     } */
  481.     //return $ret;
  482.     return array();
  483. }

  484. function cloud_m_info($name) {
  485.     $pars['method'] = 'module.info';
  486.     $pars['module'] = $name;
  487.     $ret = cloud_api('module/info', $pars);
  488.     if (empty($ret)) {
  489.         return array();
  490.     }   
  491.     return $ret;
  492. }


  493. function cloud_m_upgradeinfo($modulename) {
  494.     load()->model('module');

  495.     $module = module_fetch($modulename);

  496.     $pars['method'] = 'module.info';
  497.     $pars['module'] = $modulename;
  498.     $pars['curversion'] = $module['version'];
  499.     $pars['isupgrade'] = 1;
  500.     $ret = cloud_api('module/info', $pars);

  501.     if (empty($ret)) {
  502.         return array();
  503.     }
  504.     if (is_error($ret)) {
  505.         return $ret;
  506.     }
  507.     if (version_compare($ret['version']['version'], $module['version'], '>')) {
  508.         $ret['upgrade'] = true;
  509.     }
  510.         $ret['site_branch'] = $ret['branches'][$ret['version']['branch_id']];
  511.         $ret['from'] = 'cloud';
  512.         foreach ($ret['branches'] as &$branch) {
  513.         if ($branch['displayorder'] > $ret['site_branch']['displayorder'] || ($branch['displayorder'] == $ret['site_branch']['displayorder'] && $ret['site_branch']['id'] < intval($branch['id']))) {
  514.             $ret['new_branch'] = true;
  515.             }
  516.         $branch['id'] = intval($branch['id']);
  517.         $branch['version']['description'] = preg_replace('/\n/', '<br/>', htmlspecialchars_decode($branch['version']['description']));
  518.         $branch['displayorder'] = intval($branch['displayorder']);
  519.         $branch['day'] = intval(date('d', $branch['version']['createtime']));
  520.         $branch['month'] = date('Y.m', $branch['version']['createtime']);
  521.         $branch['hour'] = date('H:i', $branch['version']['createtime']);
  522.     }
  523.     unset($branch);
  524.     return $ret;
  525. }

  526. function cloud_t_prepare($name){
  527. /*  $pars['method'] = 'theme.check';
  528.     $pars['theme'] = $name;
  529.     $dat = cloud_api('theme/check', $pars);
  530.     if (is_error($dat)) {
  531.         return $dat;
  532.     }

  533. */
  534.     return true;
  535. }


  536. function cloud_t_query(){
  537. /*
  538.     $pars['method'] = 'theme.query';
  539.     $pars['theme'] = cloud_extra_theme();
  540.     $ret = cloud_api('theme/query', $pars);
  541.     return $ret;
  542.     */
  543.     return null;
  544. }

  545. function cloud_t_info($name){
  546. /*  
  547.     $pars['method'] = 'theme.info';
  548.     $pars['theme'] = $name;
  549.     $ret = cloud_api('theme/info', $pars);
  550.     return $ret;

  551. */
  552.     return null;
  553. }

  554. function cloud_t_build($name) {
  555.     if (empty($name)) {
  556.         return array();
  557.     }
  558.     $theme = table('site_templates')->getByName(trim($name));
  559.     $pars['method'] = 'theme.build';
  560.     $pars['theme'] = $name;
  561.     if(!empty($theme)) {
  562.         $pars['themeversion'] = $theme['version'];
  563.     }
  564.     $ret = cloud_api('theme/build', $pars);
  565.     if (empty($ret)) {
  566.         return array();
  567.     }   
  568.     if(!is_error($ret)) {
  569.         $dir = IA_ROOT . '/app/themes/' . $name;
  570.         $files = array();
  571.         if(!empty($ret['files'])) {
  572.             foreach($ret['files'] as $file) {
  573.                 $entry = $dir . $file['path'];
  574.                 if(!is_file($entry) || md5_file($entry) != $file['checksum']) {
  575.                     $files[] = '/'. $name . $file['path'];
  576.                 }
  577.             }
  578.         }
  579.         $ret['files'] = $files;
  580.         $ret['upgrade'] = true;
  581.         $ret['type'] = 'theme';
  582.                 if(empty($theme)) {
  583.             $ret['install'] = 1;
  584.         }
  585.     }
  586.     return $ret;
  587. }


  588. function cloud_t_upgradeinfo($name) {
  589.     if (empty($name)) {
  590.         return array();
  591.     }
  592.     $theme = table('site_templates')->getByName(trim($name));
  593.     if (empty($theme)) {
  594.         return array();
  595.     }
  596.     return cloud_api('theme/upgrade', array(
  597.         'method' => 'theme.upgrade',
  598.         'theme' => $theme['name'],
  599.         'version' => $theme['version'],
  600.         'isupgrade' => 1,
  601.     ));
  602. }

  603. function cloud_sms_send($mobile, $content, $postdata = array(), $custom_sign = '', $use_system_balance = false) {
  604.     global $_W;
  605.     if(!preg_match('/^1\d{10}$/', $mobile) || empty($content)) {
  606.         return error(1, '发送短信失败, 原因: 手机号错误或内容为空.');
  607.     }
  608.     $uniacid = empty($use_system_balance) ? $_W['uniacid'] : 0;

  609.     if (empty($uniacid)) {
  610.         $sms_info = cloud_sms_info();
  611.         $balance = empty($sms_info['sms_count']) ? 0 : $sms_info['sms_count'];
  612.         if (!empty($custom_sign)) {
  613.             $sign = $custom_sign;
  614.         }
  615.     } else {
  616.         $row = pdo_get('uni_settings' , array('uniacid' => $uniacid), array('notify'));
  617.         $row['notify'] = @iunserializer($row['notify']);

  618.         $config = $row['notify']['sms'];
  619.         $balance = intval($config['balance']);
  620.          
  621.         $sign = empty($custom_sign) ? $config['signature'] : $custom_sign;
  622.         $account_name = empty($_W['account']['type_name']) ? '' : $_W['account']['type_name'];
  623.         $account_name .= empty($_W['account']['name']) ? '' : " [{$_W['account']['name']}] ";
  624.     }
  625.     if(empty($sign) || $sign == 'null') {
  626.                 $sign = '短信宝';
  627.         }
  628.         //判断剩余条数
  629.       if($balance<1){
  630.                 return error(-1, '短信发送失败, 原因:余额不足');
  631.         }
  632.         //短信宝账号
  633.        // $smsbao_info=pdo_get('uni_settings' , array('uniacid' => $_W['uniacid']), array('copyright'));
  634.         //$smsbao_info=setting_load($key = 'copyright');
  635.         $sms_param['u']=$_W['setting']['copyright']['sms_name'];
  636.         $sms_param['p']=md5($_W['setting']['copyright']['sms_password']);
  637.         $sms_param['m']=$mobile;
  638.         $sms_param['c']='【'.$sign.'】'.$content;
  639.         $response = file_get_contents("http://api.smsbao.com/sms?".http_build_query($sms_param));
  640.         if (trim($response)!='0') {
  641.         return error($response['errno'], '短信发送失败, 原因:'.$response['message']);
  642.         }
  643.   
  644.         if (trim($response)=='0') {
  645.         if (!empty($uniacid)) {
  646.             $row['notify']['sms']['balance'] = $row['notify']['sms']['balance'] - 1;
  647.             if ($row['notify']['sms']['balance'] < 0) {
  648.                 $row['notify']['sms']['balance'] = 0;
  649.             }
  650.             pdo_update('uni_settings', array('notify' => iserializer($row['notify'])), array('uniacid' => $uniacid));
  651.             uni_setting_save('notify', $row['notify']);
  652.         } else {
  653.             $sms_info['sms_count'] = $sms_info['sms_count'] - 1;
  654.             if ($sms_info['sms_count'] < 0) {
  655.                 $sms_info['sms_count'] = 0;
  656.             }
  657.             setting_save($sms_info, 'sms.info');
  658.         }
  659.     }
  660.     return true;
  661. }


  662. function cloud_sms_info() {
  663.         global $_W;
  664.   
  665.         $data=array();
  666.         //返回短信的剩余条数以及签名
  667.         $sms_name=$_W['setting']['copyright']['sms_name'];
  668.         $sms_password=md5($_W['setting']['copyright']['sms_password']);
  669.         $res=file_get_contents("http://api.smsbao.com/query?u={$sms_name}&p={$sms_password}");
  670.         $retArr = explode("\n", $res);
  671.         $balanceArr = explode(",", $retArr[1]);
  672.     $data['sms_count']=$retArr[0] == 0 ? $balanceArr[1]:0;
  673.         return $data;
  674. }
  675. function cloud_sms_count_remained(){
  676.     $cache_key = cache_system_key('cloud_api', array('method' => md5('cloud_sms_count_remained')));
  677.     $cache = cache_load($cache_key);
  678.     if (!empty($cache) && $cache['expire'] > TIMESTAMP) {
  679.         return $cache['cloud_sms_count_remained'];
  680.     }
  681.     $sms_info = cloud_sms_info();
  682.     if (is_error($sms_info)){
  683.         return $sms_info;
  684.     }
  685.     $sms_count = $sms_info['sms_count'];
  686.     $sms_accounts = table('uni_settings')->select(array('uniacid', 'notify'))->where(array('notify LIKE' => '%sms%'))->getall();
  687.     $setting_sms_blance = setting_load('system_sms_balance');
  688.     $system_sms_balance = !empty($setting_sms_blance['system_sms_balance']) ? $setting_sms_blance['system_sms_balance'] : 0;
  689.     $sms_count -= $system_sms_balance;
  690.     if (empty($sms_accounts)){
  691.         return $sms_count;
  692.     }
  693.     foreach ($sms_accounts as $sms_account) {
  694.         $notify = iunserializer($sms_account['notify']);
  695.         $sms_count -= $notify['sms']['balance'];
  696.     }
  697.     $sms_count = max(0, $sms_count);
  698.     $cache_data = array(
  699.         'cloud_sms_count_remained' => $sms_count
  700.     );
  701.     cache_write($cache_key, $cache_data, CACHE_EXPIRE_MIDDLE);
  702.     return $sms_count;
  703. }

  704. function cloud_extra_account() {
  705.     $data = array();
  706.     $data['accounts'] = pdo_fetchall("SELECT name, account, original FROM ".tablename('account_wechats') . " GROUP BY account");
  707.     return serialize($data);
  708. }


  709. function cloud_extra_module() {
  710.     load()->model('module');
  711.     $module_support_type = array_keys(module_support_type());
  712.     $installed = table('modules')->getInstalled();
  713.     $recycle = table('modules_recycle')->where('type', 2)->getall('name');

  714.     $result = array();
  715.     foreach($installed as $install_module) {
  716.         if ($install_module['cloud_record']) {
  717.             continue;
  718.         }
  719.         $result[$install_module['name']] = array(
  720.             'name' => $install_module['name'],
  721.             'version' => $install_module['version'],
  722.         );
  723.         $all_uninstall = true;
  724.         foreach ($module_support_type as $support) {
  725.             $type = str_replace('_support', '', $support);
  726.             if ($install_module[$support] == 2) {
  727.                 $all_uninstall = false;
  728.                 $result[$install_module['name']]['support'][$type]['is_install'] = 2;
  729.             }
  730.         }
  731.         if ($all_uninstall) {
  732.             unset($result[$install_module['name']]);
  733.         }
  734.     }
  735.     $result = array_slice($result, 0, 100, true);
  736.     foreach($recycle as $recycle_module) {
  737.         if (empty($result[$recycle_module['name']])) {
  738.             $result[$recycle_module['name']] = array(
  739.                 'name' => $recycle_module['name'],
  740.             );
  741.         }
  742.         $in_recycle = false;
  743.         foreach ($module_support_type as $support) {
  744.             $type = str_replace('_support', '', $support);
  745.             if ($recycle_module[$support]) {
  746.                 $in_recycle = true;
  747.                 $result[$recycle_module['name']]['support'][$type] = array(
  748.                     'is_recycle' => 2
  749.                 );
  750.             }
  751.         }
  752.         if (!$in_recycle) {
  753.             unset($result[$recycle_module['name']]);
  754.         }
  755.     }
  756.     return $result;
  757. }


  758. function cloud_extra_theme() {
  759.     $sql = 'SELECT `name` FROM ' . tablename('site_templates') . ' WHERE `name` <> :name';
  760.     $themes = pdo_fetchall($sql, array(':name' => 'default'), 'name');
  761.     if (!empty($themes)) {
  762.         return base64_encode(iserializer(array_keys($themes)));
  763.     } else {
  764.         return '';
  765.     }
  766. }


  767. function cloud_extra_webtheme() {
  768.     $sql = 'SELECT `name` FROM ' . tablename('webtheme_templates') . ' WHERE `name` <> :name';
  769.     $themes = pdo_fetchall($sql, array(':name' => 'default'), 'name');
  770.     if (!empty($themes)) {
  771.         return base64_encode(iserializer(array_keys($themes)));
  772.     } else {
  773.         return '';
  774.     }
  775. }

  776. function cloud_module_setting($acid, $module) {
  777.     $pars = array(
  778.         'acid' => $acid,
  779.         'module_name' => $module['name'],
  780.         'module_version' => $module['version'],
  781.     );
  782.     return cloud_api('module/setting/index', $pars);
  783. }

  784. function cloud_module_setting_save($acid, $module_name, $setting) {
  785.     $pars = array(
  786.         'acid' => $acid,
  787.         'module_name' => $module_name,
  788.         'setting' => $setting,
  789.     );
  790.     return cloud_api('module/setting/save', $pars);
  791. }
  792. function cloud_module_list($title, $support_type, $page = 1, $per_page = 20) {
  793.     $pars = array(
  794.         'title' => $title,
  795.         'support_type' => $support_type,
  796.         'page' => $page,
  797.         'per_page' => $per_page,
  798.     );
  799.     return cloud_api('module/list', $pars);
  800. }


  801. function cloud_cron_create($cron) {
  802.     $pars = array(
  803.         'cron' => base64_encode(iserializer($cron)),
  804.     );
  805.     return cloud_api('site/cron/save', $pars);
  806. }


  807. function cloud_cron_update($cron) {
  808.     return cloud_cron_create($cron); }


  809. function cloud_cron_get($cron_id) {
  810.     $pars = array(
  811.         'cron_id' => $cron_id,
  812.     );
  813.     return cloud_api('site/cron/get', $pars);
  814. }


  815. function cloud_cron_change_status($cron_id, $status) {
  816.     $pars = array(
  817.         'cron_id' => $cron_id,
  818.         'status' => $status,
  819.     );
  820.     return cloud_api('site/cron/status', $pars);
  821. }


  822. function cloud_cron_remove($cron_id) {
  823.     $pars = array(
  824.         'cron_id' => $cron_id,
  825.     );
  826.     return cloud_api('site/cron/remove', $pars);
  827. }

  828. function cloud_site_info() {
  829.     return cloud_api('site/info');
  830. }

  831. function cloud_reset_siteinfo() {
  832.     global $_W;
  833.     return cloud_api('site/register/profile', array('url' => $_W['siteroot']));
  834. }


  835. function cloud_auth_url($forward, $data = array()){
  836.     global $_W;
  837.     if (!empty($_W['setting']['site']['url']) && !strexists($_W['siteroot'], $_W['setting']['site']['url'])) {
  838.         $url = $_W['setting']['site']['url'];
  839.     } else {
  840.         $url = rtrim($_W['siteroot'], '/');
  841.     }
  842.     $auth = array();
  843.     $auth['key'] = '';
  844.     $auth['password'] = '';
  845.     $auth['url'] = $url;
  846.     $auth['referrer'] = intval($_W['config']['setting']['referrer']);
  847.     $auth['version'] = IMS_VERSION;
  848.     $auth['forward'] = $forward;
  849.     $auth['family'] = IMS_FAMILY;

  850.     if(!empty($_W['setting']['site']['key']) && !empty($_W['setting']['site']['token'])) {
  851.         $auth['key'] = $_W['setting']['site']['key'];
  852.         $auth['password'] = md5($_W['setting']['site']['key'] . $_W['setting']['site']['token']);
  853.     }
  854.     if ($data && is_array($data)) {
  855.         $auth = array_merge($auth, $data);
  856.     }
  857.     $query = base64_encode(json_encode($auth));
  858.     $_URLTYPE = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
  859.     $auth_url = $_URLTYPE.$_SERVER['HTTP_HOST'] . $query;

  860.     return $auth_url;
  861. }


  862. function cloud_module_setting_prepare($module, $binding) {
  863.     global $_W;
  864.     $auth = _cloud_build_params();
  865.     $auth['arguments'] = array(
  866.         'binding' => $binding,
  867.         'acid' => $_W['uniacid'],
  868.         'type' => 'module',
  869.         'module' => $module,
  870.     );
  871.     $iframe_auth_url = cloud_auth_url('module', $auth);

  872.     return $iframe_auth_url;
  873. }


  874. function cloud_resource_to_local($uniacid, $type, $url){
  875.     global $_W;

  876.     load()->func('file');

  877.     $setting = $_W['setting']['upload'][$type];
  878.     if (substr($url, 0, 2) == '//') {
  879.         $url = 'http:' . $url;
  880.     }

  881.     if (!file_is_image($url)) {
  882.         return error(1, '远程图片后缀非法,请重新上传');
  883.     }
  884.     $pathinfo = pathinfo($url);
  885.     $extension = $pathinfo['extension'];

  886.     if ($uniacid == 0) {
  887.         $setting['folder'] = "{$type}s/global/".date('Y/m/');
  888.     } else {
  889.         $setting['folder'] = "{$type}s/{$uniacid}/".date('Y/m/');
  890.     }

  891.     $originname = pathinfo($url, PATHINFO_BASENAME);
  892.     $filename = file_random_name(ATTACHMENT_ROOT .'/'. $setting['folder'], $extension);
  893.     $pathname = $setting['folder'] . $filename;
  894.     $fullname = ATTACHMENT_ROOT . $pathname;

  895.     mkdirs(dirname($fullname));

  896.     load()->func('communication');
  897.     $response = ihttp_get($url);
  898.     if (is_error($response)) {
  899.         return error(1, $response['message']);
  900.     }
  901.     if (file_put_contents($fullname, $response['content']) == false) {
  902.         return error(1, '提取文件失败');
  903.     }

  904.     if (!empty($_W['setting']['remote']['type'])) {
  905.         $remotestatus = file_remote_upload($pathname);
  906.         if (is_error($remotestatus)) {
  907.             return error(1, '远程附件上传失败,请检查配置并重新上传');
  908.         } else {
  909.             file_delete($pathname);
  910.         }
  911.     }

  912.     $data = array(
  913.         'uniacid' => $uniacid,
  914.         'uid' => intval($_W['uid']),
  915.         'filename' => $originname,
  916.         'attachment' => $pathname,
  917.         'type' => $type == 'image' ? 1 : 2,
  918.         'createtime' => TIMESTAMP,
  919.     );
  920.     pdo_insert('core_attachment', $data);

  921.     $data['url'] = tomedia($pathname);
  922.     $data['id'] = pdo_insertid();

  923.     return $data;
  924. }

  925. function cloud_bakup_files($files) {
  926.     global $_W;
  927.     if (empty($files)) {
  928.         return false;
  929.     }
  930.     $map = json_encode($files);
  931.     $hash  = md5($map.$_W['config']['setting']['authkey']);
  932.     if ($handle = opendir(IA_ROOT . '/data/patch/backup/' . date('Ymd'))) {
  933.         while (false !== ($patchpath = readdir($handle))) {
  934.             if ($patchpath != '.' && $patchpath != '..') {
  935.                 if (strexists($patchpath, $hash)) {
  936.                     return false;
  937.                 }
  938.             }
  939.         }
  940.     }

  941.     $path = IA_ROOT . '/data/patch/backup/' . date('Ymd') . '/' . date('Hi') . '_' . $hash;
  942.     load()->func('file');
  943.     if (!is_dir($path) && mkdirs($path)) {
  944.         foreach ($files as $file) {
  945.             if (file_exists(IA_ROOT . $file)) {
  946.                 mkdirs($path . '/' . dirname($file));
  947.                 file_put_contents($path . '/' . $file, file_get_contents(IA_ROOT . $file));
  948.             }
  949.         }
  950.         file_put_contents($path . '/' . 'map.json', $map);
  951.     }
  952.     return false;
  953. }

  954. function cloud_build_transtoken() {
  955.     $pars['method'] = 'application.token';
  956.     $pars['file'] = 'application.build';
  957.     $ret = cloud_api('site/token/index', $pars);
  958.     cache_write(cache_system_key('cloud_transtoken'), authcode($ret['token'], 'ENCODE'));
  959.     return $ret['token'];
  960. }

  961. function cloud_build_schemas($schemas) {
  962.     $database = array();
  963.     if (empty($schemas) || !is_array($schemas)) {
  964.         return $database;
  965.     }
  966.     foreach ($schemas as $remote) {
  967.         $row = array();
  968.         $row['tablename'] = $remote['tablename'];
  969.         $name = substr($remote['tablename'], 4);
  970.         $local = db_table_schema(pdo(), $name);
  971.         unset($remote['increment']);
  972.         unset($local['increment']);
  973.         if (empty($local)) {
  974.             $row['new'] = true;
  975.         } else {
  976.             $row['new'] = false;
  977.             $row['fields'] = array();
  978.             $row['indexes'] = array();
  979.             $diffs = db_schema_compare($local, $remote);
  980.             if (!empty($diffs['fields']['less'])) {
  981.                 $row['fields'] = array_merge($row['fields'], $diffs['fields']['less']);
  982.             }
  983.             if (!empty($diffs['fields']['diff'])) {
  984.                 $row['fields'] = array_merge($row['fields'], $diffs['fields']['diff']);
  985.             }
  986.             if (!empty($diffs['indexes']['less'])) {
  987.                 $row['indexes'] = array_merge($row['indexes'], $diffs['indexes']['less']);
  988.             }
  989.             if (!empty($diffs['indexes']['diff'])) {
  990.                 $row['indexes'] = array_merge($row['indexes'], $diffs['indexes']['diff']);
  991.             }
  992.             $row['fields'] = implode($row['fields'], ' ');
  993.             $row['indexes'] = implode($row['indexes'], ' ');
  994.         }
  995.         $database[] = $row;
  996.     }
  997.     return $database;
  998. }


  999. function cloud_file_permission_pass(&$error_file_list = array()) {
  1000.     $cache_key = cache_system_key('cloud_file_permission_pass');
  1001.     $cache = cache_load($cache_key);
  1002.     if ($cache) {
  1003.         return true;
  1004.     }
  1005.     $check_path = array(
  1006.         '/api',
  1007.         '/app/common',
  1008.         '/app/resource',
  1009.         '/app/source',
  1010.         '/app/themes/default',
  1011.         '/web/common',
  1012.         '/web/resource',
  1013.         '/web/source',
  1014.         '/web/themes/default',
  1015.         '/web/themes/black',
  1016.         '/web/themes/classical',
  1017.         '/web/themes/2.0',
  1018.         '/framework/builtin',
  1019.         '/framework/class',
  1020.         '/framework/model',
  1021.         '/framework/function',
  1022.         '/framework/table',
  1023.         '/framework/library',
  1024.         '/payment',
  1025.     );

  1026.     $check_file = array(
  1027.         '/web/index.php',
  1028.         '/framework/bootstrap.inc.php',
  1029.         '/framework/version.inc.php',
  1030.         '/framework/const.inc.php',
  1031.     );
  1032.     $sub_paths = array();
  1033.     foreach ($check_path as $path) {
  1034.         $file_list = cloud_file_tree(IA_ROOT . $path);
  1035.         if (!empty($file_list)) {
  1036.             foreach ($file_list as $file) {
  1037.                 if (is_file($file)) {
  1038.                     $sub_path = pathinfo($file, PATHINFO_DIRNAME);
  1039.                     if (empty($sub_paths[$sub_path])) {
  1040.                         if (!cloud_path_is_writable($sub_path)) {
  1041.                             $error_file_list[] = str_replace(IA_ROOT, '', $sub_path);
  1042.                         }
  1043.                         $sub_paths[$sub_path] = $sub_path;
  1044.                     }
  1045.                 }
  1046.                 if (!is_writable($file)) {
  1047.                     $error_file_list[] = str_replace(IA_ROOT, '', $file);
  1048.                 }
  1049.             }
  1050.         }
  1051.     }

  1052.     foreach ($check_file as $file) {
  1053.         if (!is_writable(IA_ROOT . $file)) {
  1054.             $error_file_list[] = str_replace(IA_ROOT, '', $file);
  1055.         }
  1056.     }
  1057.     if (empty($error_file_list)) {
  1058.         cache_write($cache_key, true, 600);
  1059.         return true;
  1060.     }
  1061.     return false;
  1062. }

  1063. function cloud_file_tree($path, $include = array()) {
  1064.     $files = array();
  1065.     if (!empty($include)) {
  1066.         $ds = glob($path . '/{' . implode(',', $include) . '}', GLOB_BRACE);
  1067.     } else {
  1068.         $ds = glob($path . '/*');
  1069.     }
  1070.     if (is_array($ds)) {
  1071.         foreach ($ds as $entry) {
  1072.             if (is_file($entry)) {
  1073.                 $files[] = $entry;
  1074.             }
  1075.             if (is_dir($entry)) {
  1076.                 $rs = cloud_file_tree($entry);
  1077.                 foreach ($rs as $f) {
  1078.                     $files[] = $f;
  1079.                 }
  1080.             }
  1081.         }
  1082.     }
  1083.     return $files;
  1084. }

  1085. function cloud_path_is_writable($dir) {
  1086.     $writeable = false;
  1087.     if (!is_dir($dir)) {
  1088.         @mkdir($dir, 0755);
  1089.     }
  1090.     if (is_dir($dir)) {
  1091.         if($fp = fopen("$dir/test.txt", 'w')) {
  1092.             fclose($fp);
  1093.             unlink("$dir/test.txt");
  1094.             $writeable = true;
  1095.         } else {
  1096.             $writeable = false;
  1097.         }
  1098.     }
  1099.     return $writeable;
  1100. }


  1101. function cloud_get_store_notice() {
  1102.     load()->classs('cloudapi');
  1103.     $api = new CloudApi();
  1104.     $result = $api->get('store', 'official_dynamics');
  1105.     return $result;
  1106. }

  1107. function cloud_v_to_xs($url) {
  1108.     if (empty($url)) {
  1109.         return false;
  1110.     }
  1111.     /*$pars = _cloud_build_params();
  1112.     $pars['method'] = 'module.query';
  1113.     $pars['url'] = urlencode($url);
  1114.     cloud_request('http://api.w7.cc/site/pirate/index', $pars);
  1115.     */
  1116.     return true;
  1117. }

  1118. function cloud_workorder() {
  1119.     $result = cloud_api('work-order/status/index');
  1120.     return $result;
  1121. }
  1122. function cloud_account_info() {
  1123.     $site_info = cloud_site_info();
  1124.     $account_num = max(0, intval($site_info['quantity']));
  1125.     return $account_num;
  1126. }


  1127. function cloud_w7_request_token($js_secret, $nocache = false) {
  1128.     global $_W;
  1129.     if (empty($_W['setting']['site']) || empty($_W['setting']['site']['key'])) {
  1130.         return '';
  1131.     }
  1132.     if (!$nocache) {
  1133.         $cache_key = cache_system_key('cloud_w7_request_token');
  1134.         $cache = cache_load($cache_key);
  1135.         if ($cache) {
  1136.             return $cache;
  1137.         }
  1138.     }
  1139.     $js_token = authcode($js_secret, 'ENCODE', $_W['setting']['site']['key']);
  1140.     $data = array('js_token' => $js_token);
  1141.     $ret = cloud_api('site/accesstoken/with-js-token', $data);
  1142.     if (is_error($ret)) {
  1143.         return '';
  1144.     }
  1145.     cache_write($cache_key, $ret['access_token'], $ret['expire_time']);
  1146.     return $ret['access_token'];
  1147. }
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|芮城帮 ( 晋ICP备18003122号-4 )

GMT+8, 2024-5-9 01:18

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表