isfounder) { cpmsg('noaccess_isfounder', '', 'error'); } $pluginid = !empty($_GET['pluginid']) ? intval($_GET['pluginid']) : 0; $anchor = !empty($_GET['anchor']) ? $_GET['anchor'] : ''; $isplugindeveloper = isset($_G['config']['plugindeveloper']) && $_G['config']['plugindeveloper'] > 0; if(!empty($_GET['dir']) && !ispluginkey($_GET['dir'])) { unset($_GET['dir']); } require_once libfile('function/plugin'); if(!$operation) { if(!submitcheck('submit')) { loadcache('plugin'); shownav('plugin'); showsubmenu('nav_plugins', array( array('plugins_list', 'plugins'), $isplugindeveloper ? array('plugins_add', 'plugins&operation=add', 0) : array(), array('cloudaddons_plugin_link', 'cloudaddons'), ), ''.$lang['plugins_validator'].''); showformheader('plugins'); showtableheader('', 'psetting'); $outputsubmit = false; $plugins = $addonids = array(); $plugins = C::t('common_plugin')->fetch_all_data(); if(empty($_G['cookie']['addoncheck_plugin'])) { foreach($plugins as $plugin) { $addonids[$plugin['pluginid']] = $plugin['identifier'].'.plugin'; } $checkresult = dunserialize(cloudaddons_upgradecheck($addonids)); savecache('addoncheck_plugin', $checkresult); dsetcookie('addoncheck_plugin', 1, 43200); } else { loadcache('addoncheck_plugin'); $checkresult = $_G['cache']['addoncheck_plugin']; } $splitavailable = array(); foreach($plugins as $plugin) { $addonid = $plugin['identifier'].'.plugin'; $updateinfo = ''; list(, $newver, $sysver) = explode(':', $checkresult[$addonid]); if($sysver && $sysver > $plugin['version']) { $updateinfo = ''.$lang['plugins_find_newversion'].' '.$sysver.''; } elseif($newver) { $updateinfo = ''.$lang['plugins_find_newversion'].' '.$newver.''; } $plugins[] = $plugin['identifier']; $hookexists = FALSE; $plugin['modules'] = dunserialize($plugin['modules']); $submenuitem = array(); if(isset($_G['cache']['plugin'][$plugin['identifier']])) { $submenuitem[] = ''.$lang['config'].''; } if(is_array($plugin['modules'])) { foreach($plugin['modules'] as $k => $module) { if($module['type'] == 11) { $hookorder = $module['displayorder']; $hookexists = $k; } if($module['type'] == 3) { $submenuitem[] = ''.$module['menu'].''; } if($module['type'] == 29) { $submenuitem[] = ''.$module['menu'].''; } } } $outputsubmit = $hookexists !== FALSE && $plugin['available'] || $outputsubmit; $hl = !empty($_GET['hl']) && $_GET['hl'] == $plugin['pluginid']; $intro = $title = ''; if($updateinfo) { $order = 'updatelist'; } else { $order = $plugin['available'] ? 'open' : 'close'; } if($plugin['pluginid'] == $_GET['hl']) { $order = 'hightlight'; } else { if($plugin['available']) { if(empty($splitavailable[0])) { $title = ''.cplang('plugins_list_available').''; $splitavailable[0] = 1; } } else { if(empty($splitavailable[1])) { $title = ''.cplang('plugins_list_unavailable').''; $splitavailable[1] = 1; } } } $pluginlist[$order][$plugin['pluginid']] = $title.showtablerow('class="hover'.($hl ? ' hl' : '').'"', array('valign="top" style="width:45px"', 'valign="top"', 'align="right" valign="bottom" style="width:160px"'), array( '', ''.dhtmlspecialchars($plugin['name']).' '.dhtmlspecialchars($plugin['version']).' ('.$plugin['identifier'].')'.($updateinfo ? ' '.$updateinfo.'' : ''). ($plugin['description'] || $plugin['modules']['extra']['intro'] ? ''.cplang('plugins_home').'' : ''). '

'.($plugin['copyright'] ? cplang('author').': '.dhtmlspecialchars($plugin['copyright']).' | ' : ''). ''.$lang['plugins_visit'].'

'. '

'.implode(' | ', $submenuitem).'

', ($hookexists !== FALSE && $plugin['available'] ? $lang['display_order'].":

" : ''). (!$plugin['available'] ? "$lang[enable]  " : "$lang[closed]  "). "$lang[plugins_config_upgrade]  ". (!$plugin['modules']['system'] ? "$lang[plugins_config_uninstall]  " : ''). ($isplugindeveloper && !$plugin['modules']['system'] ? "$lang[plugins_editlink]  " : ''), ), true); } ksort($pluginlist); $pluginlist = (array)$pluginlist['hightlight'] + (array)$pluginlist['updatelist'] + (array)$pluginlist['open'] + (array)$pluginlist['close']; echo implode('', $pluginlist); if(empty($_GET['system'])) { $plugindir = DISCUZ_ROOT.'./source/plugin'; $pluginsdir = dir($plugindir); $newplugins = array(); showtableheader('', 'psetting'); $newlist = ''; while($entry = $pluginsdir->read()) { if(!in_array($entry, array('.', '..')) && is_dir($plugindir.'/'.$entry) && !in_array($entry, $plugins)) { $entrydir = DISCUZ_ROOT.'./source/plugin/'.$entry; $d = dir($entrydir); $filemtime = filemtime($entrydir); $entrytitle = $entry; $entryversion = $entrycopyright = $importtxt = ''; $extra = currentlang(); $extra = $extra ? '_'.$extra : ''; if(file_exists($entrydir.'/discuz_plugin_'.$entry.$extra.'.xml')) { $importtxt = @implode('', file($entrydir.'/discuz_plugin_'.$entry.$extra.'.xml')); } elseif(file_exists($entrydir.'/discuz_plugin_'.$entry.'.xml')) { $importtxt = @implode('', file($entrydir.'/discuz_plugin_'.$entry.'.xml')); } if($importtxt) { $pluginarray = getimportdata('Discuz! Plugin', 0, 1); if(!empty($pluginarray['plugin']['name'])) { $entrytitle = dhtmlspecialchars($pluginarray['plugin']['name']); $entryversion = dhtmlspecialchars($pluginarray['plugin']['version']); $entrycopyright = dhtmlspecialchars($pluginarray['plugin']['copyright']); } $file = $entrydir.'/'.$f; $newlist .= showtablerow('class="hover"', array('style="width:45px"', 'valign="top"', 'align="right" valign="bottom" style="width:160px"'), array( '', ''.$entrytitle.' '.$entryversion.($filemtime > TIMESTAMP - 86400 ? ' New!' : '').' ('.$entry.')'. '

'.($entrycopyright ? cplang('author').': '.$entrycopyright.' | ' : ''). ''.$lang['plugins_visit'].'

', ''.$lang['plugins_config_install'].'' ), true); } } } if($newlist) { showtitle('plugins_list_new'); echo $newlist; } } if($outputsubmit) { showsubmit('submit', 'submit', '', ''.cplang('cloudaddons_plugin_link').''); } else { showsubmit('', '', '', ''.cplang('cloudaddons_plugin_link').''); } showtablefooter(); showformfooter(); } else { foreach(C::t('common_plugin')->fetch_all_data(1) as $plugin) { if(!empty($_GET['displayordernew'][$plugin['pluginid']])) { $plugin['modules'] = dunserialize($plugin['modules']); $k = array_keys($_GET['displayordernew'][$plugin['pluginid']]); $v = array_values($_GET['displayordernew'][$plugin['pluginid']]); $plugin['modules'][$k[0]]['displayorder'] = $v[0]; C::t('common_plugin')->update($plugin['pluginid'], array('modules' => serialize($plugin['modules']))); } } updatecache(array('plugin', 'setting', 'styles')); cleartemplatecache(); cpmsg('plugins_edit_succeed', 'action=plugins', 'succeed'); } } elseif(FORMHASH == $_GET['formhash'] && ($operation == 'enable' || $operation == 'disable')) { $conflictplugins = ''; $plugin = C::t('common_plugin')->fetch($_GET['pluginid']); if(!$plugin) { cpmsg('plugin_not_found', '', 'error'); } $dir = substr($plugin['directory'], 0, -1); $modules = dunserialize($plugin['modules']); $file = DISCUZ_ROOT.'./source/plugin/'.$dir.'/discuz_plugin_'.$dir.($modules['extra']['installtype'] ? '_'.$modules['extra']['installtype'] : '').'.xml'; if(!file_exists($file)) { $pluginarray[$operation.'file'] = $modules['extra'][$operation.'file']; $pluginarray['plugin']['version'] = $plugin['version']; } else { $importtxt = @implode('', file($file)); $pluginarray = getimportdata('Discuz! Plugin'); } if(!empty($pluginarray[$operation.'file']) && preg_match('/^[\w\.]+$/', $pluginarray[$operation.'file'])) { $filename = DISCUZ_ROOT.'./source/plugin/'.$dir.'/'.$pluginarray[$operation.'file']; if(file_exists($filename)) { @include $filename; } } if($operation == 'enable') { require_once libfile('cache/setting', 'function'); list(,, $hookscript) = get_cachedata_setting_plugin($plugin['identifier']); $exists = array(); foreach($hookscript as $script => $modules) { foreach($modules as $module => $data) { foreach(array('funcs' => '', 'outputfuncs' => '_output', 'messagefuncs' => '_message') as $functype => $funcname) { foreach($data[$functype] as $k => $funcs) { $pluginids = array(); foreach($funcs as $func) { $pluginids[$func[0]] = $func[0]; } if(in_array($plugin['identifier'], $pluginids) && count($pluginids) > 1) { unset($pluginids[$plugin['identifier']]); foreach($pluginids as $pluginid) { $exists[$pluginid][$k.$funcname] = $k.$funcname; } } } } } } if($exists) { $plugins = array(); foreach(C::t('common_plugin')->fetch_all_by_identifier(array_keys($exists)) as $plugin) { $plugins[] = ''.$plugin['name'].':'. ' '.cplang('plugins_conflict_view').''. ' '.cplang('plugins_conflict_info').''. ''; } $conflictplugins = '
'.implode('
', $plugins).'
'; } } $available = $operation == 'enable' ? 1 : 0; C::t('common_plugin')->update($_GET['pluginid'], array('available' => $available)); updatecache(array('plugin', 'setting', 'styles')); cleartemplatecache(); updatemenu('plugin'); if($operation == 'enable') { if(!$conflictplugins) { cpmsg('plugins_enable_succeed', 'action=plugins'.(!empty($_GET['system']) ? '&system=1' : ''), 'succeed'); } else { cpmsg('plugins_conflict', 'action=plugins'.(!empty($_GET['system']) ? '&system=1' : ''), 'succeed', array('plugins' => $conflictplugins)); } } else { cpmsg('plugins_disable_succeed', 'action=plugins'.(!empty($_GET['system']) ? '&system=1' : ''), 'succeed'); } cpmsg('plugins_'.$operation.'_succeed', 'action=plugins'.(!empty($_GET['system']) ? '&system=1' : ''), 'succeed'); } elseif($operation == 'export' && $pluginid) { if(!$isplugindeveloper) { cpmsg('undefined_action', '', 'error'); } $plugin = C::t('common_plugin')->fetch($pluginid); if(!$plugin) { cpheader(); cpmsg('plugin_not_found', '', 'error'); } unset($plugin['pluginid']); $pluginarray = array(); $pluginarray['plugin'] = $plugin; $pluginarray['version'] = strip_tags($_G['setting']['version']); foreach(C::t('common_pluginvar')->fetch_all_by_pluginid($pluginid) as $var) { unset($var['pluginvarid'], $var['pluginid']); $pluginarray['var'][] = $var; } $modules = dunserialize($pluginarray['plugin']['modules']); if($modules['extra']['langexists'] && file_exists($file = DISCUZ_ROOT.'./data/plugindata/'.$pluginarray['plugin']['identifier'].'.lang.php')) { include $file; if(!empty($scriptlang[$pluginarray['plugin']['identifier']])) { $pluginarray['language']['scriptlang'] = $scriptlang[$pluginarray['plugin']['identifier']]; } if(!empty($templatelang[$pluginarray['plugin']['identifier']])) { $pluginarray['language']['templatelang'] = $templatelang[$pluginarray['plugin']['identifier']]; } if(!empty($installlang[$pluginarray['plugin']['identifier']])) { $pluginarray['language']['installlang'] = $installlang[$pluginarray['plugin']['identifier']]; } if(!empty($systemlang[$pluginarray['plugin']['identifier']])) { $pluginarray['language']['systemlang'] = $systemlang[$pluginarray['plugin']['identifier']]; } } unset($modules['extra']); $pluginarray['plugin']['modules'] = serialize($modules); $plugindir = DISCUZ_ROOT.'./source/plugin/'.$pluginarray['plugin']['directory']; if(file_exists($plugindir.'/install.php')) { $pluginarray['installfile'] = 'install.php'; } if(file_exists($plugindir.'/uninstall.php')) { $pluginarray['uninstallfile'] = 'uninstall.php'; } if(file_exists($plugindir.'/upgrade.php')) { $pluginarray['upgradefile'] = 'upgrade.php'; } if(file_exists($plugindir.'/check.php')) { $pluginarray['checkfile'] = 'check.php'; } if(file_exists($plugindir.'/enable.php')) { $pluginarray['enablefile'] = 'enable.php'; } if(file_exists($plugindir.'/disable.php')) { $pluginarray['disablefile'] = 'disable.php'; } exportdata('Discuz! Plugin', $plugin['identifier'], $pluginarray); } elseif($operation == 'import') { if(submitcheck('importsubmit') || isset($_GET['dir'])) { cloudaddons_validator($_GET['dir'].'.plugin'); if(!isset($_GET['installtype'])) { $pdir = DISCUZ_ROOT.'./source/plugin/'.$_GET['dir']; $d = dir($pdir); $xmls = ''; $count = 0; $noextra = false; $currentlang = currentlang(); while($f = $d->read()) { if(preg_match('/^discuz\_plugin_'.$_GET['dir'].'(\_\w+)?\.xml$/', $f, $a)) { $extratxt = $extra = substr($a[1], 1); if($extra) { if($currentlang && $currentlang == $extra) { dheader('location: '.ADMINSCRIPT.'?action=plugins&operation=import&dir='.$_GET['dir'].'&installtype='.rawurlencode($extra)); } } else { $noextra = true; } $url = ADMINSCRIPT.'?action=plugins&operation=import&dir='.$_GET['dir'].'&installtype='.rawurlencode($extra); $xmls .= '  '; $count++; } } if($count == 1 && $noextra) { dheader('location: '.ADMINSCRIPT.'?action=plugins&operation=import&dir='.$_GET['dir'].'&installtype='); } $xmls .= '

'; echo '

'.$lang['plugins_import_installtype_1'].' '.$_GET['dir'].' '.$lang['plugins_import_installtype_2'].' '.$count.' '.$lang['plugins_import_installtype_3'].'

'.$xmls.'
'; exit; } else { $installtype = $_GET['installtype']; $dir = $_GET['dir']; $license = $_GET['license']; $extra = $installtype ? '_'.$installtype : ''; $importfile = DISCUZ_ROOT.'./source/plugin/'.$dir.'/discuz_plugin_'.$dir.$extra.'.xml'; $importtxt = @implode('', file($importfile)); $pluginarray = getimportdata('Discuz! Plugin'); if(empty($license) && $pluginarray['license']) { require_once libfile('function/discuzcode'); $pluginarray['license'] = discuzcode(strip_tags($pluginarray['license']), 1, 0); echo '

'.$pluginarray['plugin']['name'].' '.$pluginarray['plugin']['version'].' '.$lang['plugins_import_license'].'

'.$pluginarray['license'].'


'. '  '. '
'; exit; } } if(!ispluginkey($pluginarray['plugin']['identifier'])) { cpmsg('plugins_edit_identifier_invalid', 'action=plugins', 'error'); } if(is_array($pluginarray['vars'])) { foreach($pluginarray['vars'] as $config) { if(!ispluginkey($config['variable'])) { cpmsg('plugins_import_var_invalid', 'action=plugins', 'error'); } } } $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 { cpmsg('plugins_import_succeed', 'action=plugins&hl='.$pluginid, 'succeed'); } } } elseif($operation == 'plugininstall' || $operation == 'pluginupgrade') { $finish = FALSE; $dir = $_GET['dir']; $installtype = str_replace('/', '', $_GET['installtype']); $extra = $installtype ? '_'.$installtype : ''; $xmlfile = 'discuz_plugin_'.$dir.$extra.'.xml'; $importfile = DISCUZ_ROOT.'./source/plugin/'.$dir.'/'.$xmlfile; if(!file_exists($importfile)) { cpmsg('plugin_file_error', '', 'error'); } $importtxt = @implode('', file($importfile)); $pluginarray = getimportdata('Discuz! Plugin'); if($operation == 'plugininstall') { $filename = $pluginarray['installfile']; } else { $filename = $pluginarray['upgradefile']; $toversion = $pluginarray['plugin']['version']; } loadcache('pluginlanguage_install'); $installlang = $_G['cache']['pluginlanguage_install'][$dir]; if(!empty($filename) && preg_match('/^[\w\.]+$/', $filename)) { $filename = DISCUZ_ROOT.'./source/plugin/'.$dir.'/'.$filename; if(file_exists($filename)) { @include_once $filename; } else { $finish = TRUE; } } else { $finish = TRUE; } if($finish) { updatecache('setting'); updatemenu('plugin'); if($operation == 'plugininstall') { cloudaddons_clear('plugin', $dir); cpmsg('plugins_install_succeed', 'action=plugins&hl='.$_GET['pluginid'], 'succeed'); } else { cloudaddons_clear('plugin', $dir); cpmsg('plugins_upgrade_succeed', "action=plugins", 'succeed', array('toversion' => $toversion)); } } } elseif($operation == 'upgrade') { $plugin = C::t('common_plugin')->fetch($pluginid); $modules = dunserialize($plugin['modules']); $dir = substr($plugin['directory'], 0, -1); if(!$_GET['confirmed']) { $file = DISCUZ_ROOT.'./source/plugin/'.$dir.'/discuz_plugin_'.$dir.($modules['extra']['installtype'] ? '_'.$modules['extra']['installtype'] : '').'.xml'; $upgrade = false; if(file_exists($file)) { $importtxt = @implode('', file($file)); $pluginarray = getimportdata('Discuz! Plugin'); $newver = !empty($pluginarray['plugin']['version']) ? $pluginarray['plugin']['version'] : 0; $upgrade = $newver > $plugin['version'] ? true : false; } $entrydir = DISCUZ_ROOT.'./source/plugin/'.$dir; $upgradestr = ''; if(file_exists($entrydir)) { $d = dir($entrydir); while($f = $d->read()) { if(preg_match('/^discuz\_plugin\_'.$plugin['identifier'].'(\_\w+)?\.xml$/', $f, $a)) { $extratxt = $extra = substr($a[1], 1); if(preg_match('/^SC\_GBK$/i', $extra)) { $extratxt = '简体中文版'; } elseif(preg_match('/^SC\_UTF8$/i', $extra)) { $extratxt = '简体中文UTF8版'; } elseif(preg_match('/^TC\_BIG5$/i', $extra)) { $extratxt = '繁體中文版'; } elseif(preg_match('/^TC\_UTF8$/i', $extra)) { $extratxt = '繁體中文UTF8版'; } if($modules['extra']['installtype'] == $extratxt) { continue; } $importtxt = @implode('', file($entrydir.'/'.$f)); $pluginarray = getimportdata('Discuz! Plugin'); $newverother = !empty($pluginarray['plugin']['version']) ? $pluginarray['plugin']['version'] : 0; $upgradestr .= $newverother > $plugin['version'] ? '   ' : ''; } } } if(!empty($pluginarray['checkfile']) && preg_match('/^[\w\.]+$/', $pluginarray['checkfile'])) { $filename = DISCUZ_ROOT.'./source/plugin/'.$plugin['identifier'].'/'.$pluginarray['checkfile']; if(file_exists($filename)) { loadcache('pluginlanguage_install'); $installlang = $_G['cache']['pluginlanguage_install'][$plugin['identifier']]; @include $filename; } } if($upgrade) { cpmsg('plugins_config_upgrade_confirm', 'action=plugins&operation=upgrade&pluginid='.$pluginid.'&confirm=yes', 'form', array('pluginname' => $plugin['name'], 'version' => $plugin['version'], 'toversion' => $newver)); } elseif($upgradestr) { echo '

'.cplang('discuz_message').'

'.cplang('plugins_config_upgrade_other', array('pluginname' => $plugin['name'], 'version' => $plugin['version'])).'


'.$upgradestr. '

'; } else { $addonid = $plugin['identifier'].'.plugin'; $checkresult = dunserialize(cloudaddons_upgradecheck(array($addonid))); list($return, $newver, $sysver) = explode(':', $checkresult[$addonid]); cloudaddons_installlog($pluginarray['plugin']['identifier'].'.plugin'); dsetcookie('addoncheck_plugin', '', -1); cloudaddons_clear('plugin', $dir); if($sysver && $sysver > $plugin['version']) { cpmsg('plugins_config_upgrade_new', '', 'succeed', array('newver' => $sysver, 'addonid' => $addonid)); } elseif($newver) { cpmsg('plugins_config_upgrade_new', '', 'succeed', array('newver' => $newver, 'addonid' => $addonid)); } else { cpmsg('plugins_config_upgrade_missed', 'action=plugins', 'succeed'); } } } else { $installtype = !isset($_GET['installtype']) ? $modules['extra']['installtype'] : (preg_match('/^\w+$/', $_GET['installtype']) ? $_GET['installtype'] : ''); $importfile = DISCUZ_ROOT.'./source/plugin/'.$dir.'/discuz_plugin_'.$dir.($installtype ? '_'.$installtype : '').'.xml'; if(!file_exists($importfile)) { cpmsg('plugin_file_error', '', 'error'); } cloudaddons_validator($dir.'.plugin'); $importtxt = @implode('', file($importfile)); $pluginarray = getimportdata('Discuz! Plugin'); if(!ispluginkey($pluginarray['plugin']['identifier']) || $pluginarray['plugin']['identifier'] != $plugin['identifier']) { cpmsg('plugins_edit_identifier_invalid', '', 'error'); } if(is_array($pluginarray['vars'])) { foreach($pluginarray['vars'] as $config) { if(!ispluginkey($config['variable'])) { cpmsg('plugins_upgrade_var_invalid', '', 'error'); } } } if(!empty($pluginarray['checkfile']) && preg_match('/^[\w\.]+$/', $pluginarray['checkfile'])) { if(!empty($pluginarray['language'])) { $installlang[$pluginarray['plugin']['identifier']] = $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']; cloudaddons_clear('plugin', $dir); cpmsg('plugins_upgrade_succeed', "action=plugins", 'succeed', array('toversion' => $toversion)); } } elseif($operation == 'config') { if(empty($pluginid) && !empty($do)) { $pluginid = $do; } if($_GET['identifier']) { $plugin = C::t('common_plugin')->fetch_by_identifier($_GET['identifier']); } else { $plugin = C::t('common_plugin')->fetch($pluginid); } if(!$plugin) { cpmsg('plugin_not_found', '', 'error'); } else { $pluginid = $plugin['pluginid']; } $plugin['modules'] = dunserialize($plugin['modules']); $pluginvars = array(); foreach(C::t('common_pluginvar')->fetch_all_by_pluginid($pluginid) as $var) { if(strexists($var['type'], '_')) { continue; } $pluginvars[$var['variable']] = $var; } if($pluginvars) { $submenuitem[] = array('config', "plugins&operation=config&do=$pluginid", !$_GET['pmod']); } if(is_array($plugin['modules'])) { foreach($plugin['modules'] as $module) { if($module['type'] == 3) { parse_str($module['param'], $param); if(!$pluginvars && empty($_GET['pmod'])) { $_GET['pmod'] = $module['name']; if($param) { foreach($param as $_k => $_v) { $_GET[$_k] = $_v; } } } if($param) { $m = true; foreach($param as $_k => $_v) { if(!isset($_GET[$_k]) || $_GET[$_k] != $_v) { $m = false; break; } } } else { $m = true; } $submenuitem[] = array($module['menu'], "plugins&operation=config&do=$pluginid&identifier=$plugin[identifier]&pmod=$module[name]".($module['param'] ? '&'.$module['param'] : ''), $_GET['pmod'] == $module['name'] && $m, !$_GET['pmod'] ? 1 : 0); } } } if(empty($_GET['pmod'])) { if(!submitcheck('editsubmit')) { $operation = ''; shownav('plugin', $plugin['name']); showsubmenuanchors($plugin['name'], $submenuitem); if($pluginvars) { showformheader("plugins&operation=config&do=$pluginid"); showtableheader(); showtitle($lang['plugins_config']); $extra = array(); foreach($pluginvars as $var) { if(strexists($var['type'], '_')) { continue; } $var['variable'] = 'varsnew['.$var['variable'].']'; if($var['type'] == 'number') { $var['type'] = 'text'; } elseif($var['type'] == 'select') { $var['type'] = "\n"; $var['variable'] = $var['value'] = ''; } elseif($var['type'] == 'selects') { $var['value'] = dunserialize($var['value']); $var['value'] = is_array($var['value']) ? $var['value'] : array($var['value']); $var['type'] = "\n"; $var['variable'] = $var['value'] = ''; } elseif($var['type'] == 'date') { $var['type'] = 'calendar'; $extra['date'] = ''; } elseif($var['type'] == 'datetime') { $var['type'] = 'calendar'; $var['extra'] = 1; $extra['date'] = ''; } elseif($var['type'] == 'forum') { require_once libfile('function/forumlist'); $var['type'] = ''; $var['variable'] = $var['value'] = ''; } elseif($var['type'] == 'forums') { $var['description'] = ($var['description'] ? (isset($lang[$var['description']]) ? $lang[$var['description']] : $var['description'])."\n" : '').$lang['plugins_edit_vars_multiselect_comment']."\n".$var['comment']; $var['value'] = dunserialize($var['value']); $var['value'] = is_array($var['value']) ? $var['value'] : array(); require_once libfile('function/forumlist'); $var['type'] = ''; foreach($var['value'] as $v) { $var['type'] = str_replace(''; } $var['value'] = is_array($var['value']) ? $var['value'] : array($var['value']); $query = C::t('common_usergroup')->range_orderby_credit(); $groupselect = array(); foreach($query as $group) { $group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type']; $groupselect[$group['type']] .= ''; } $var['type'] .= ''.$groupselect['member'].''. ($groupselect['special'] ? ''.$groupselect['special'].'' : ''). ($groupselect['specialadmin'] ? ''.$groupselect['specialadmin'].'' : ''). ''.$groupselect['system'].''; $var['variable'] = $var['value'] = ''; } elseif($var['type'] == 'extcredit') { $var['type'] = ''; $var['variable'] = $var['value'] = ''; } showsetting(isset($lang[$var['title']]) ? $lang[$var['title']] : dhtmlspecialchars($var['title']), $var['variable'], $var['value'], $var['type'], '', 0, isset($lang[$var['description']]) ? $lang[$var['description']] : nl2br(dhtmlspecialchars($var['description'])), dhtmlspecialchars($var['extra']), '', true); } showsubmit('editsubmit'); showtablefooter(); showformfooter(); echo implode('', $extra); } } else { if(is_array($_GET['varsnew'])) { foreach($_GET['varsnew'] as $variable => $value) { if(isset($pluginvars[$variable])) { if($pluginvars[$variable]['type'] == 'number') { $value = (float)$value; } elseif(in_array($pluginvars[$variable]['type'], array('forums', 'groups', 'selects'))) { $value = serialize($value); } $value = (string)$value; C::t('common_pluginvar')->update_by_variable($pluginid, $variable, array('value' => $value)); } } } updatecache(array('plugin', 'setting', 'styles')); cleartemplatecache(); cpmsg('plugins_setting_succeed', 'action=plugins&operation=config&do='.$pluginid.'&anchor='.$anchor, 'succeed'); } } else { $scriptlang[$plugin['identifier']] = lang('plugin/'.$plugin['identifier']); $modfile = ''; if(is_array($plugin['modules'])) { foreach($plugin['modules'] as $module) { if($module['type'] == 3 && $module['name'] == $_GET['pmod']) { $plugin['directory'] .= (!empty($plugin['directory']) && substr($plugin['directory'], -1) != '/') ? '/' : ''; $modfile = './source/plugin/'.$plugin['directory'].$module['name'].'.inc.php'; break; } } } if($modfile) { shownav('plugin', $plugin['name']); showsubmenu($plugin['name'], $submenuitem); if(!@include(DISCUZ_ROOT.$modfile)) { cpmsg('plugins_setting_module_nonexistence', '', 'error', array('modfile' => $modfile)); } else { exit(); } } else { cpmsg('plugin_file_error', '', 'error'); } } } elseif($operation == 'add') { if(!$isplugindeveloper) { cpmsg('undefined_action', '', 'error'); } if(!submitcheck('addsubmit')) { shownav('plugin'); showsubmenu('nav_plugins', array( array('plugins_list', 'plugins', 0), array('plugins_add', 'plugins&operation=add', 1), array('cloudaddons_plugin_link', 'cloudaddons'), )); showtips('plugins_add_tips'); showformheader("plugins&operation=add", '', 'configform'); showtableheader(); showsetting('plugins_edit_name', 'namenew', '', 'text'); showsetting('plugins_edit_version', 'versionnew', '', 'text'); showsetting('plugins_edit_copyright', 'copyrightnew', '', 'text'); showsetting('plugins_edit_identifier', 'identifiernew', '', 'text'); showsubmit('addsubmit'); showtablefooter(); showformfooter(); } else { $namenew = dhtmlspecialchars(trim($_GET['namenew'])); $versionnew = strip_tags(trim($_GET['versionnew'])); $identifiernew = trim($_GET['identifiernew']); $copyrightnew = dhtmlspecialchars($_GET['copyrightnew']); if(!$namenew) { cpmsg('plugins_edit_name_invalid', '', 'error'); } else { if(!ispluginkey($identifiernew) || C::t('common_plugin')->fetch_by_identifier($identifiernew)) { cpmsg('plugins_edit_identifier_invalid', '', 'error'); } } $data = array( 'name' => $namenew, 'version' => $versionnew, 'identifier' => $identifiernew, 'directory' => $identifiernew.'/', 'available' => 0, 'copyright' => $copyrightnew, ); $pluginid = C::t('common_plugin')->insert($data, true); updatecache(array('plugin', 'setting', 'styles')); cleartemplatecache(); cpmsg('plugins_add_succeed', "action=plugins&operation=edit&pluginid=$pluginid", 'succeed'); } } elseif($operation == 'edit') { if(!$isplugindeveloper) { cpmsg('undefined_action', '', 'error'); } if(empty($pluginid) ) { $pluginlist = ''; cpmsg('plugins_nonexistence', 'action=plugins&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $pluginlist); } else { $condition = !empty($uid) ? "uid='$uid'" : "username='$username'"; } $plugin = C::t('common_plugin')->fetch($pluginid); if(!$plugin) { cpmsg('plugin_not_found', '', 'error'); } $plugin['modules'] = dunserialize($plugin['modules']); if($plugin['modules']['system']) { cpmsg('plugin_donot_edit', '', 'error'); } if(!submitcheck('editsubmit')) { $adminidselect = array($plugin['adminid'] => 'selected'); shownav('plugin'); $anchor = in_array($_GET['anchor'], array('config', 'modules', 'vars')) ? $_GET['anchor'] : 'config'; showsubmenuanchors($lang['plugins_edit'].' - '.$plugin['name'].($plugin['available'] ? cplang('plugins_edit_available') : ''), array( array('plugins_list', 'plugins', 0, 1), array('config', 'config', $anchor == 'config'), array('plugins_config_module', 'modules', $anchor == 'modules'), array('plugins_config_vars', 'vars', $anchor == 'vars'), array('export', 'plugins&operation=export&pluginid='.$plugin['pluginid'], 0, 1), )); showtips('plugins_edit_tips'); showtagheader('div', 'config', $anchor == 'config'); showformheader("plugins&operation=edit&type=common&pluginid=$pluginid", '', 'configform'); showtableheader(); showsetting('plugins_edit_name', 'namenew', $plugin['name'], 'text'); showsetting('plugins_edit_version', 'versionnew', $plugin['version'], 'text'); if(!$plugin['copyright']) { showsetting('plugins_edit_copyright', 'copyrightnew', $plugin['copyright'], 'text'); } showsetting('plugins_edit_identifier', 'identifiernew', $plugin['identifier'], 'text'); showsetting('plugins_edit_directory', 'directorynew', $plugin['directory'], 'text'); showsetting('plugins_edit_description', 'descriptionnew', $plugin['description'], 'textarea'); showsetting('plugins_edit_langexists', 'langexists', $plugin['modules']['extra']['langexists'], 'radio'); showsubmit('editsubmit'); showtablefooter(); showformfooter(); showtagfooter('div'); showtagheader('div', 'modules', $anchor == 'modules'); showformheader("plugins&operation=edit&type=modules&pluginid=$pluginid", '', 'modulesform'); showtableheader('plugins_edit_modules'); showsubtitle(array('', 'plugins_edit_modules_type', 'plugins_edit_modules_name', 'plugins_edit_modules_menu', 'plugins_edit_modules_menu_url', 'plugins_edit_modules_adminid', 'display_order')); $moduleids = array(); if(is_array($plugin['modules'])) { foreach($plugin['modules'] as $moduleid => $module) { if($moduleid === 'extra' || $moduleid === 'system') { continue; } $module = dhtmlspecialchars($module); $adminidselect = array($module['adminid'] => 'selected'); $includecheck = empty($val['include']) ? $lang['no'] : $lang['yes']; $typeselect = ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''; showtablerow('', array('class="td25"', 'class="td28"'), array( "", "". ' '.cplang('plugins_module_sample').'', "", "", "", "", "" )); showtagheader('tbody', 'n_'.$moduleid); showtablerow('class="noborder"', array('', 'colspan="6"'), array( '', '   '.$lang['plugins_edit_modules_navtitle'].': '.$lang['plugins_edit_modules_navicon'].': '.$lang['plugins_edit_modules_navsubname'].': '.$lang['plugins_edit_modules_navsuburl'].': ', )); showtagfooter('tbody'); showtagheader('tbody', 'n2_'.$moduleid); showtablerow('class="noborder"', array('', 'colspan="6"'), array( '', '   '.$lang['plugins_edit_modules_param'].':', )); showtagfooter('tbody'); $moduleids[] = $moduleid; } } showtablerow('', array('class="td25"', 'class="td28"'), array( cplang('add_new'), '', '', '', '', '', '', )); showtagheader('tbody', 'n_n'); showtablerow('class="noborder"', array('', 'colspan="7"'), array( '', '   '.$lang['plugins_edit_modules_navtitle'].': '.$lang['plugins_edit_modules_navicon'].': '.$lang['plugins_edit_modules_navsubname'].': '.$lang['plugins_edit_modules_navsuburl'].': ', )); showtagfooter('tbody'); showtagheader('tbody', 'n2_n'); showtablerow('class="noborder"', array('', 'colspan="6"'), array( '', '   '.$lang['plugins_edit_modules_param'].':', )); showtagfooter('tbody'); showsubmit('editsubmit', 'submit', 'del'); showtablefooter(); showformfooter(); showtagfooter('div'); $shideinit = ''; foreach($moduleids as $moduleid) { $shideinit .= 'shide($("s_'.$moduleid.'"), \''.$moduleid.'\');'; } echo ''; showtagheader('div', 'vars', $anchor == 'vars'); showformheader("plugins&operation=edit&type=vars&pluginid=$pluginid", '', 'varsform'); showtableheader('plugins_edit_vars'); showsubtitle(array('', 'display_order', 'plugins_vars_title', 'plugins_vars_variable', 'plugins_vars_type', '')); foreach(C::t('common_pluginvar')->fetch_all_by_pluginid($plugin['pluginid']) as $var) { $var['type'] = $lang['plugins_edit_vars_type_'. $var['type']]; $var['title'] .= isset($lang[$var['title']]) ? '
'.$lang[$var['title']] : ''; showtablerow('', array('class="td25"', 'class="td28"'), array( "", "", $var['title'], $var['variable'], $var['type'], "$lang[detail]" )); } showtablerow('', array('class="td25"', 'class="td28"'), array( cplang('add_new'), '', '', '', ''; foreach(array('number', 'text', 'radio', 'textarea', 'select', 'selects', 'color', 'date', 'datetime', 'forum', 'forums', 'group', 'groups', 'extcredit', 'forum_text', 'forum_textarea', 'forum_radio', 'forum_select', 'group_text', 'group_textarea', 'group_radio', 'group_select') as $type) { $typeselect .= ''; } $typeselect .= ''; showformheader("plugins&operation=vars&pluginid=$pluginid&pluginvarid=$pluginvarid"); showtableheader(); showtitle($lang['plugins_edit_vars'].' - '.$pluginvar['title']); showsetting('plugins_edit_vars_title', 'titlenew', $pluginvar['title'], 'text'); showsetting('plugins_edit_vars_description', 'descriptionnew', $pluginvar['description'], 'textarea'); showsetting('plugins_edit_vars_type', '', '', $typeselect); showsetting('plugins_edit_vars_variable', 'variablenew', $pluginvar['variable'], 'text'); showtagheader('tbody', 'extra', $pluginvar['type'] == 'select' || $pluginvar['type'] == 'selects'); showsetting('plugins_edit_vars_extra', 'extranew', $pluginvar['extra'], 'textarea'); showtagfooter('tbody'); showsubmit('varsubmit'); showtablefooter(); showformfooter(); } else { $titlenew = cutstr(trim($_GET['titlenew']), 25); $descriptionnew = cutstr(trim($_GET['descriptionnew']), 255); $variablenew = trim($_GET['variablenew']); $extranew = trim($_GET['extranew']); if(!$titlenew) { cpmsg('plugins_edit_var_title_invalid', '', 'error'); } elseif($variablenew != $pluginvar['variable']) { if(!$variablenew || strlen($variablenew) > 40 || !ispluginkey($variablenew) || C::t('common_pluginvar')->check_variable($pluginid, $variablenew)) { cpmsg('plugins_edit_vars_invalid', '', 'error'); } } C::t('common_pluginvar')->update_by_pluginvarid($pluginid, $pluginvarid, array( 'title' => $titlenew, 'description' => $descriptionnew, 'type' => $_GET['typenew'], 'variable' => $variablenew, 'extra' => $extranew )); updatecache(array('plugin', 'setting', 'styles')); cleartemplatecache(); cpmsg('plugins_edit_vars_succeed', "action=plugins&operation=edit&pluginid=$pluginid&anchor=vars", 'succeed'); } } elseif($operation == 'upgradecheck') { if(empty($_GET['identifier'])) { $pluginarray = C::t('common_plugin')->fetch_all_data(); } else { $plugin = C::t('common_plugin')->fetch_by_identifier($_GET['identifier']); $pluginarray = $plugin ? array($plugin) : array(); } $plugins = $errarray = $newarray = $nowarray = array(); if(!$pluginarray) { cpmsg('plugin_not_found', '', 'error'); } else { $addonids = array(); foreach($pluginarray as $row) { if(ispluginkey($row['identifier'])) { $addonids[] = $row['identifier'].'.plugin'; } } $checkresult = dunserialize(cloudaddons_upgradecheck($addonids)); savecache('addoncheck_plugin', $checkresult); foreach($pluginarray as $row) { $addonid = $row['identifier'].'.plugin'; if(isset($checkresult[$addonid])) { list($return, $newver, $sysver) = explode(':', $checkresult[$addonid]); $result[$row['identifier']]['result'] = $return; if($sysver) { if($sysver > $row['version']) { $result[$row['identifier']]['result'] = 2; $result[$row['identifier']]['newver'] = $sysver; } else { $result[$row['identifier']]['result'] = 1; } } elseif($newver) { $result[$row['identifier']]['newver'] = $newver; } } $plugins[$row['identifier']] = $row['name'].' '.$row['version']; $modules = dunserialize($row['modules']); $file = DISCUZ_ROOT.'./source/plugin/'.$row['identifier'].'/discuz_plugin_'.$row['identifier'].($modules['extra']['installtype'] ? '_'.$modules['extra']['installtype'] : '').'.xml'; $upgrade = false; if(file_exists($file)) { $importtxt = @implode('', file($file)); $pluginarray = getimportdata('Discuz! Plugin', 0, 1); $newver = !empty($pluginarray['plugin']['version']) ? $pluginarray['plugin']['version'] : 0; if($newver > $row['version']) { $upgrade = true; $nowarray[] = ''.$plugins[$row['identifier']].' -> '.$newver.''; } } if(!$upgrade) { $entrydir = DISCUZ_ROOT.'./source/plugin/'.$row['identifier']; $upgradestr = ''; if(file_exists($entrydir)) { $d = dir($entrydir); while($f = $d->read()) { if(preg_match('/^discuz\_plugin\_'.$row['identifier'].'(\_\w+)?\.xml$/', $f, $a)) { $extratxt = $extra = substr($a[1], 1); if(preg_match('/^SC\_GBK$/i', $extra)) { $extratxt = '简体中文版'; } elseif(preg_match('/^SC\_UTF8$/i', $extra)) { $extratxt = '简体中文UTF8版'; } elseif(preg_match('/^TC\_BIG5$/i', $extra)) { $extratxt = '繁體中文版'; } elseif(preg_match('/^TC\_UTF8$/i', $extra)) { $extratxt = '繁體中文UTF8版'; } if($modules['extra']['installtype'] == $extratxt) { continue; } $importtxt = @implode('', file($entrydir.'/'.$f)); $pluginarray = getimportdata('Discuz! Plugin', 0, 1); $newverother = !empty($pluginarray['plugin']['version']) ? $pluginarray['plugin']['version'] : 0; if($newverother > $row['version']) { $nowarray[] = ''.$plugins[$row['identifier']].' -> '.$newverother.($extra ? ' ('.$extratxt.')' : '').''; } } } } } } } foreach($result as $id => $row) { if($row['result'] == 0) { $errarray[] = ''.$plugins[$id].''; } elseif($row['result'] == 2) { $newarray[] = ''.$plugins[$id].($row['newver'] ? ' -> '.$row['newver'] : '').''; } } if(!$nowarray && !$newarray && !$errarray) { cpmsg('plugins_validator_noupdate', '', 'error'); } else { shownav('plugin'); showsubmenu('nav_plugins', array( array('plugins_list', 'plugins', 0), $isplugindeveloper ? array('plugins_add', 'plugins&operation=add', 0) : array(), array('cloudaddons_plugin_link', 'cloudaddons'), ), ''.$lang['plugins_validator'].''); showtableheader(); if($nowarray) { showtitle('plugins_validator_nowupgrade'); foreach($nowarray as $row) { showtablerow('class="hover"', array(), array($row)); } } if($newarray) { showtitle('plugins_validator_newversion'); foreach($newarray as $row) { showtablerow('class="hover"', array(), array($row)); } } if($errarray) { showtitle('plugins_validator_error'); foreach($errarray as $row) { showtablerow('class="hover"', array(), array($row)); } } showtablefooter(); } } elseif($operation == 'sample') { $plugin = C::t('common_plugin')->fetch($pluginid); if(!$plugin) { cpmsg('plugin_not_found', '', 'error'); } $code = moduleample($_GET['typeid'], $_GET['module'], $plugin); if(!$code) { cpmsg('NO_OPERATION'); } dheader('Content-Disposition: attachment; filename='.$_GET['module'].$_GET['fn']); dheader('Content-Type: application/octet-stream'); ob_end_clean(); echo $code; define('FOOTERDISABLED' , 1); exit(); } function moduleample($typeid, $module, $plugin) { $samples = array( 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => ""); $types = array(1 => 1, 5 => 1, 27 => 1, 23 => 1, 25 => 1, 24 => 1, 7 => 2, 17 => 2, 19 => 2, 14 => 2, 26 => 2, 21 => 2, 15 => 2, 16 => 2, 3 => 3, 11 => 4, 28 => 5, 12 => 6); $code = $samples[$types[$typeid]]; $code = str_replace( array( '{DATE}', '{PLUGINID}', '{MODULE}', '{MODULENAME}', '{COPYRIGHT}', ), array( dgmdate(TIMESTAMP, 'Y'), $plugin['identifier'], $module, cplang('plugins_edit_modules_type_'.$typeid), $plugin['copyright'], ), $code); return $code; } ?>