function exportarray($array, $method) { $tmp = $array; if ($method) { foreach ($array as $k => $v) { if (is_array($v)) { $tmp[$k] = exportarray($v, 1); } else { $uv = unserialize($v); if ($uv && is_array($uv)) { $tmp['__' . $k] = exportarray($uv, 1); unset($tmp[$k]); } else { $tmp[$k] = $v; } } } } else { foreach ($array as $k => $v) { if (is_array($v)) { if (substr($k, 0, 2) == '__') { $tmp[substr($k, 2)] = serialize(exportarray($v, 0)); unset($tmp[$k]); } else { $tmp[$k] = exportarray($v, 0); } } else { $tmp[$k] = $v; } } } return $tmp; }
function pick_install() { global $_G; $tmpdir = DISCUZ_ROOT . './data/download/dxc_temp'; if (!is_dir($tmpdir)) { cpmsg(milu_lang('cloudaddons_download_error'), '', 'error'); //数据下载错误 } $_GET['type'] = 'plugin'; $_GET['key'] = 'milu_pick'; $to_version = $_GET['version']; $to_version_dateline = $_GET['version_dateline']; if (!libfile('function/cloudaddons')) { exit('error01:file not found'); } require_once libfile('function/cloudaddons'); $descdir = DISCUZ_ROOT . 'source/plugin/'; $subdir = 'milu_pick'; $unwriteabledirs = cloudaddons_dirwriteable($descdir, $subdir, $tmpdir); if ($unwriteabledirs) { //目录不可写 showtips(milu_lang('cloudaddons_unwriteabledirs', array('basedir' => 'source/plugin', 'unwriteabledirs' => implode(', ', $unwriteabledirs)))); exit; } $descdir .= $subdir; cloudaddons_comparetree($tmpdir, $descdir, $tmpdir, $_GET['key'] . '.' . $_GET['type'] . 'vip', 1); if (!empty($_G['treeop']['oldchange']) && empty($_GET['confirmed'])) { cpmsg(milu_lang('cloudaddons_install_files_changed', array('files' => implode('<br />', $_G['treeop']['oldchange']))), '', 'form', ''); } cloudaddons_copytree($tmpdir, $descdir); $client_info = get_client_info(); $_GET['end'] = 'Status=End&ID=milu_pick_vip.plugin&SN=' . $client_info['domain'] . '&RevisionID=' . $client_info['domain'] . '&RevisionDateline=' . $client_info['domain']; cloudaddons_savemd5($_GET['key'] . '.' . $_GET['type'] . 'vip', $_GET['end'], $_G['treeop']['md5']); cloudaddons_deltree($tmpdir); //成功之后的一些动作 $set['pick_tips']['check_version'] = 0; pick_common_set($set); $charset = str_replace('-', '', strtoupper($_G['config']['output']['charset'])); $locale = ''; if ($charset == 'BIG5') { $locale = 'TC'; } elseif ($charset == 'GBK') { $locale = 'SC'; } elseif ($charset == 'UTF8') { if ($_G['config']['output']['language'] == 'zh_cn') { $locale = 'SC'; } elseif ($_G['config']['output']['language'] == 'zh_tw') { $locale = 'TC'; } } $xml_ext = 'discuz_plugin_milu_pick_' . $locale . '_' . $charset . '.xml'; $xml_file = $descdir . '/' . $xml_ext; if (!file_exists($xml_file)) { cpmsg(milu_lang('xml_no_found', array('f' => $xml_ext)), '', 'error'); } //xml文件丢失 require_once libfile('class/xml'); $data = file_get_contents($xml_file); $data_arr = xml2array($data); $xml_data = exportarray($data_arr['Data'], 0); $installtype = $locale . '_' . $charset; pluginupgrade($xml_data, $installtype); $auth_file = PICK_DIR . '/data/pick_auth.txt'; $upgrade_file = $descdir . '/upgrade.php'; if (file_exists($upgrade_file)) { $_GET['fromversion'] = PICK_VERSION; include $upgrade_file; if (!$finish) { cpmsg_error(milu_lang('up_fail')); } } @unlink($auth_file); cpmsg('plugins_upgrade_succeed', PICK_GO . "pick_info", 'succeed', array('toversion' => $to_version . ' ' . $to_version_dateline)); }