Пример #1
0
         }
     }
 }
 $plugin = C::t('common_plugin')->fetch_by_identifier($pluginarray['plugin']['identifier']);
 if ($plugin) {
     cpmsg('plugins_import_identifier_duplicated', 'action=plugins', 'error', array('plugin_name' => $plugin['name']));
 }
 if (!empty($pluginarray['checkfile']) && preg_match('/^[\\w\\.]+$/', $pluginarray['checkfile'])) {
     $filename = DISCUZ_ROOT . './source/plugin/' . $_GET['dir'] . '/' . $pluginarray['checkfile'];
     if (file_exists($filename)) {
         loadcache('pluginlanguage_install');
         $installlang = $pluginarray['language']['installlang'];
         @(include $filename);
     }
 }
 if (empty($_GET['ignoreversion']) && !versioncompatible($pluginarray['version'])) {
     if (isset($dir)) {
         cpmsg('plugins_import_version_invalid_confirm', 'action=plugins&operation=import&ignoreversion=yes&dir=' . $dir . '&installtype=' . $installtype . '&license=' . $license, 'form', array('cur_version' => $pluginarray['version'], 'set_version' => $_G['setting']['version']), '', true, ADMINSCRIPT . '?action=plugins');
     } else {
         cpmsg('plugins_import_version_invalid', 'action=plugins', 'error', array('cur_version' => $pluginarray['version'], 'set_version' => $_G['setting']['version']));
     }
 }
 $pluginid = plugininstall($pluginarray, $installtype);
 updatemenu('plugin');
 if (!empty($dir) && !empty($pluginarray['installfile']) && preg_match('/^[\\w\\.]+$/', $pluginarray['installfile'])) {
     dheader('location: ' . ADMINSCRIPT . '?action=plugins&operation=plugininstall&dir=' . $dir . '&installtype=' . $installtype . '&pluginid=' . $pluginid);
 }
 cloudaddons_clear('plugin', $dir);
 if (!empty($dir)) {
     cpmsg('plugins_install_succeed', 'action=plugins&hl=' . $pluginid, 'succeed');
 } else {
function import_block($xmlurl, $clientid, $xmlkey = '', $signtype = '', $ignoreversion = 1, $update = 0)
{
    global $_G, $importtxt;
    $_GET['importtype'] = $_GET['importtxt'] = '';
    $xmlurl = strip_tags($xmlurl);
    $clientid = strip_tags($clientid);
    $xmlkey = strip_tags($xmlkey);
    $parse = parse_url($xmlurl);
    if (!empty($parse['host'])) {
        $queryarr = explode('&', $parse['query']);
        $para = array();
        foreach ($queryarr as $value) {
            $k = $v = '';
            list($k, $v) = explode('=', $value);
            if (!empty($k) && !empty($v)) {
                $para[$k] = $v;
            }
        }
        $para['clientid'] = $clientid;
        $para['op'] = 'getconfig';
        $para['charset'] = CHARSET;
        $signurl = create_sign_url($para, $xmlkey, $signtype);
        $pos = strpos($xmlurl, '?');
        $pos = $pos === false ? strlen($xmlurl) : $pos;
        $signurl = substr($xmlurl, 0, $pos) . '?' . $signurl;
        $importtxt = @dfsockopen($signurl);
    } else {
        $importtxt = @implode('', file($xmlurl));
    }
    $blockarrays = getimportdata('Discuz! Block', 0);
    if (empty($blockarrays['name']) || empty($blockarrays['fields']) || empty($blockarrays['getsetting'])) {
        cpmsg(cplang('import_data_typeinvalid') . cplang($importtxt), '', 'error');
    }
    if (empty($ignoreversion) && !versioncompatible($blockarrays['version'])) {
        cpmsg(cplang('blockxml_import_version_invalid'), '', 'error', array('cur_version' => $blockarrays['version'], 'set_version' => $_G['setting']['version']));
    }
    $data = array('name' => dhtmlspecialchars($blockarrays['name']), 'version' => dhtmlspecialchars($blockarrays['version']), 'url' => $xmlurl, 'clientid' => $clientid, 'key' => $xmlkey, 'signtype' => !empty($signtype) ? 'MD5' : '', 'data' => serialize($blockarrays));
    if (!$update) {
        C::t('common_block_xml')->insert($data);
    } else {
        C::t('common_block_xml')->update($update, $data);
    }
}