示例#1
0
$opens = array('mobile');
require_once libfile('function/plugin');
require_once libfile('function/admincp');
foreach ($plugins as $pluginid) {
    $importfile = DISCUZ_ROOT . './source/plugin/' . $pluginid . '/discuz_plugin_' . $pluginid . '.xml';
    if (!file_exists($importfile)) {
        continue;
    }
    $importtxt = @implode('', file($importfile));
    $pluginarray = getimportdata('Discuz! Plugin', $importtxt);
    $plugin = C::t('common_plugin')->fetch_by_identifier($pluginid);
    if ($plugin) {
        $modules = unserialize($plugin['modules']);
        if ($modules['system'] > 0) {
            if ($pluginarray['plugin']['version'] != $plugin['version']) {
                pluginupgrade($pluginarray, '');
                if ($pluginarray['upgradefile']) {
                    $plugindir = DISCUZ_ROOT . './source/plugin/' . $pluginarray['plugin']['directory'];
                    if (file_exists($plugindir . '/' . $pluginarray['upgradefile'])) {
                        @(include_once $plugindir . '/' . $pluginarray['upgradefile']);
                    }
                }
            }
            if ($modules['system'] != 2) {
                $modules['system'] = 2;
                $modules = serialize($modules);
                C::t('common_plugin')->update($plugin['pluginid'], array('modules' => $modules));
            }
            continue;
        }
        C::t('common_plugin')->delete_by_identifier($pluginid);
示例#2
0
                    cpmsg('plugins_upgrade_var_invalid', '', 'error');
                }
            }
        }
        if (!empty($pluginarray['checkfile']) && preg_match('/^[\\w\\.]+$/', $pluginarray['checkfile'])) {
            if (!empty($pluginarray['language'])) {
                $installlang[$pluginarray['plugin']['identifier']] = dstripslashes($pluginarray['language']['installlang']);
            }
            $filename = DISCUZ_ROOT . './source/plugin/' . $plugin['directory'] . $pluginarray['checkfile'];
            if (file_exists($filename)) {
                loadcache('pluginlanguage_install');
                $installlang = $_G['cache']['pluginlanguage_install'][$plugin['identifier']];
                @(include $filename);
            }
        }
        pluginupgrade($pluginarray, $installtype);
        if (!empty($plugin['directory']) && !empty($pluginarray['upgradefile']) && preg_match('/^[\\w\\.]+$/', $pluginarray['upgradefile'])) {
            dheader('location: ' . ADMINSCRIPT . '?action=plugins&operation=pluginupgrade&dir=' . $dir . '&installtype=' . $modules['extra']['installtype'] . '&fromversion=' . $plugin['version']);
        }
        $toversion = $pluginarray['plugin']['version'];
        cpmsg('plugins_upgrade_succeed', "action=plugins", 'succeed', array('toversion' => $toversion));
    }
} elseif ($operation == 'config') {
    if (empty($pluginid) && !empty($do)) {
        $pluginid = $do;
    }
    $plugin = DB::fetch_first("SELECT * FROM " . DB::table('common_plugin') . " WHERE " . ($_G['gp_identifier'] ? "identifier='{$_G['gp_identifier']}'" : "pluginid='{$pluginid}'"));
    if (!$plugin) {
        cpmsg('plugin_not_found', '', 'error');
    } else {
        $pluginid = $plugin['pluginid'];
示例#3
0
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));
}