plugins->moduleExists($plugin_id)) { throw new Exception(__('No such plugin.')); } $plugin = $core->plugins->getModules($plugin_id); $plugin['id'] = $plugin_id; if (!preg_match('!^'.$p_path_pat.'!', $plugin['root'])) { throw new Exception(__('You don\'t have permissions to delete this plugin.')); } # --BEHAVIOR-- pluginBeforeDelete $core->callBehavior('pluginsBeforeDelete', $plugin); $core->plugins->deleteModule($plugin_id); # --BEHAVIOR-- pluginAfterDelete $core->callBehavior('pluginsAfterDelete', $plugin); } else { $core->plugins->deleteModule($plugin_id,true); } http::redirect('plugins.php?removed=1'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Deactivate plugin elseif ($plugin_id && !empty($_POST['deactivate'])) { try { if (!$core->plugins->moduleExists($plugin_id)) { throw new Exception(__('No such plugin.')); } $plugin = $core->plugins->getModules($plugin_id); $plugin['id'] = $plugin_id; if (!$plugin['root_writable']) { throw new Exception(__('You don\'t have permissions to deactivate this plugin.')); } # --BEHAVIOR-- pluginBeforeDeactivate $core->callBehavior('pluginsBeforeDeactivate', $plugin); $core->plugins->deactivateModule($plugin_id); # --BEHAVIOR-- pluginAfterDeactivate $core->callBehavior('pluginsAfterDeactivate', $plugin); http::redirect('plugins.php'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Activate plugin elseif ($plugin_id && !empty($_POST['activate'])) { try { $p = $core->plugins->getDisabledModules(); if (!isset($p[$plugin_id])) { throw new Exception(__('No such plugin.')); } # --BEHAVIOR-- pluginBeforeActivate $core->callBehavior('pluginsBeforeActivate', $plugin_id); $core->plugins->activateModule($plugin_id); # --BEHAVIOR-- pluginAfterActivate $core->callBehavior('pluginsAfterActivate', $plugin_id); http::redirect('plugins.php'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Plugin upload elseif ((!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file'])) || (!empty($_POST['fetch_pkg']) && !empty($_POST['pkg_url']))) { try { if (empty($_POST['your_pwd']) || !$core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY,$_POST['your_pwd']))) { throw new Exception(__('Password verification failed')); } if (!empty($_POST['upload_pkg'])) { files::uploadStatus($_FILES['pkg_file']); $dest = $p_path.'/'.$_FILES['pkg_file']['name']; if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'],$dest)) { throw new Exception(__('Unable to move uploaded file.')); } } else { $url = urldecode($_POST['pkg_url']); $dest = $p_path.'/'.basename($url); try { $client = netHttp::initClient($url,$path); $client->setUserAgent('Dotclear - http://www.dotclear.org/'); $client->useGzip(false); $client->setPersistReferers(false); $client->setOutput($dest); $client->get($path); } catch( Exception $e) { throw new Exception(__('An error occurred while downloading the file.')); } unset($client); } # --BEHAVIOR-- pluginBeforeAdd $core->callBehavior('pluginsBeforeAdd', $plugin_id); $ret_code = $core->plugins->installPackage($dest,$core->plugins); # --BEHAVIOR-- pluginAfterAdd $core->callBehavior('pluginsAfterAdd', $plugin_id); http::redirect('plugins.php?added='.$ret_code); } catch (Exception $e) { $core->error->add($e->getMessage()); $default_tab = 'addplugin'; } } } # Plugin install $plugins_install = $core->plugins->installModules(); /* DISPLAY Main page -------------------------------------------------------- */ dcPage::open(__('Plugins management'), dcPage::jsLoad('js/_plugins.js'). dcPage::jsPageTabs($default_tab) ); echo '

'.__('Plugins management').'

'; if (!empty($_GET['removed'])) { dcPage::message(__('Plugin has been successfully deleted.')); } if (!empty($_GET['added'])) { dcPage::message(($_GET['added'] == 2 ? __('Plugin has been successfully upgraded') : __('Plugin has been successfully installed.'))); } # Plugins install messages if (!empty($plugins_install['success'])) { echo '
'.__('Following plugins have been installed:').'
'; } if (!empty($plugins_install['failure'])) { echo '
'.__('Following plugins have not been installed:').'
'; } # List all active plugins echo '

'.__('Plugins add new functionalities to Dotclear. '. 'Here you can activate or deactivate installed plugins.').'

'; echo (!$core->plugins->moduleExists('daInstaller') ? sprintf('

'.__('You can find additional plugins for your blog on %s.').'

', 'Dotaddict') : sprintf('

'.__('You can find additional plugins for your blog on %s or using the %s.').'

', 'Dotaddict', ''.__('DotAddict.org Installer').'')); if ($is_writable) { echo __('To install or upgrade a plugin you generally just need to upload it '. 'in "Install or upgrade a plugin" section.'); } else { echo __('To install or upgrade a plugin you just need to extract it in your plugins directory.'); } echo '

'; echo '
'; $p_available = $core->plugins->getModules(); uasort($p_available,create_function('$a,$b','return strcasecmp($a["name"],$b["name"]);')); if (!empty($p_available)) { echo '

'.__('Activated plugins').'

'. ''. ''. ''. ''. ''. ''; $distrib_plugins = array('aboutConfig','akismet','antispam','attachments','blogroll','blowupConfig','daInstaller', 'fairTrackbacks','importExport','maintenance','pages','pings','simpleMenu','tags','themeEditor','userPref','widgets'); $distrib_img = ''.__('Plugin from official distribution').''; foreach ($p_available as $k => $v) { $is_deletable = $is_writable && preg_match('!^'.$p_path_pat.'!',$v['root']); $is_deactivable = $v['root_writable']; $is_distrib = in_array($k, $distrib_plugins); echo ''. ''. ''. ''. ''. ''; } echo '
'.__('Plugin').''.__('Version').''.__('Details').''.__('Action').'
'.html::escapeHTML($k).''.html::escapeHTML($v['version']).''.html::escapeHTML(__($v['name'])).' '. '
'.html::escapeHTML(__($v['desc'])).($is_distrib ? ' '.$distrib_img : '').'
'; if ($is_deletable || $is_deactivable) { echo '
'. '
'. $core->formNonce(). form::hidden(array('plugin_id'),html::escapeHTML($k)). ($is_deactivable ? ' ' : ''). ($is_deletable ? ' ' : ''). '
'. '
'; } echo '
'; } $p_disabled = $core->plugins->getDisabledModules(); uksort($p_disabled,create_function('$a,$b','return strcasecmp($a,$b);')); if (!empty($p_disabled)) { echo '

'.__('Deactivated plugins').'

'. ''. ''. ''. ''; foreach ($p_disabled as $k => $v) { $is_deletable = $is_writable && preg_match('!^'.$p_path_pat.'!',$v['root']); $is_activable = $v['root_writable']; echo ''. ''. ''. ''; } echo '
'.__('Plugin').''.__('Action').'
'.html::escapeHTML($k).''; if ($is_deletable || $is_activable) { echo '
'. '
'. $core->formNonce(). form::hidden(array('plugin_id'),html::escapeHTML($k)). form::hidden(array('deactivated'),1). ($is_activable ? ' ' : ''). ($is_deletable ? ' ' : ''). '
'. '
'; } echo '
'; } echo '
'; # Add a new plugin echo '
'; if ($is_writable) { echo '

'.__('You can install plugins by uploading or downloading zip files.').'

'; # 'Upload plugin' form echo '
'. '
'. ''.__('Upload a zip file').''. '

'. '

'. ''. $core->formNonce(). '
'. '
'; # 'Fetch plugin' form echo '
'. '
'. ''.__('Download a zip file').''. '

'. '

'. ''. $core->formNonce(). '
'. '
'; } else { echo '

'. __('To enable this function, please give write access to your plugins directory.'). '

'; } echo '
'; if ($core->plugins->moduleExists('daInstaller')) { echo '

'.__('DotAddict.org Installer').'

'; } # --BEHAVIOR-- pluginsToolsTabs $core->callBehavior('pluginsToolsTabs',$core); dcPage::close(); ?>