{$lang_pluginmgr_php['i_plugins']} |
{$lang_pluginmgr_php['operation']} |
EOT;
$installed_count = 0;
foreach ($CPG_PLUGINS as $thisplugin) {
$installed_count++;
unset($extra_info);
unset($install_info);
include('./plugins/'.$thisplugin->path.'/configuration.php');
$safename = addslashes(str_replace(' ', '', $name));
$extra = (isset($install_info)) ? ($install_info):(null);
if (sizeof($thisplugin->error) > 0) {
$error = $thisplugin->error['desc'];
$extra = ''.
'Error: '.$error.''.
' |
'.$extra;
}
echo <<
{$lang_pluginmgr_php['name']} $name {$lang_pluginmgr_php['vers']}$version |
$extra |
{$lang_pluginmgr_php['author']} $author |
{$lang_pluginmgr_php['desc']} $description |
|
EOT;
if ($thisplugin->index > 0 && count($CPG_PLUGINS) > 1) {
echo <<
EOT;
} else {
echo ' | ';
}
if ($thisplugin->index < (count($CPG_PLUGINS)-1)) {
echo <<
EOT;
} else {
echo ' | ';
}
echo <<
|
EOT;
}
if ($installed_count == 0) {
echo (''.$lang_pluginmgr_php['none_installed'].' |
');
}
endtable();
echo('
');
echo('');
endtable();
}
// Delete a directory and its contents
function deldir($dir) {
$handle = opendir($dir);
// Remove all files
while (false!==($FolderOrFile = readdir($handle))) {
if($FolderOrFile != "." && $FolderOrFile != "..") {
if(is_dir("$dir/$FolderOrFile")) {
deldir("$dir/$FolderOrFile");
} else {
unlink("$dir/$FolderOrFile");
}
}
}
closedir($handle);
// If directory was removed return true
if(rmdir($dir)) {
return true;
}
return false;
}
/**
* Main code
*/
/**
* Plugin manager events
*
* Executes manager events
*/
$op = @$_GET['op'];
switch ($op) {
case 'uninstall':
$plugin_id = $_GET['p'];
if (!is_numeric($_GET['p'])) {
$plugin_id = CPGPluginAPI::installed($plugin_id);
}
$uninstalled = CPGPluginAPI::uninstall($plugin_id);
break;
case 'install':
$installed = CPGPluginAPI::install($_GET['p']);
break;
case 'delete':
$path = $_GET['p'];
if (is_bool(strpos('/',$path))) {
deldir('./plugins/'.$path);
}
break;
case 'moveu':
$thisplugin = @$CPG_PLUGINS[$_GET['p']];
if (isset($thisplugin) && ($priority = $thisplugin->priority) > 0) {
// Move the plugin above down
$sql = 'update '.$CONFIG['TABLE_PLUGINS'].' set priority='.$priority.' where priority='.($priority-1).';';
cpg_db_query($sql);
// Move this plugin up
$sql = 'update '.$CONFIG['TABLE_PLUGINS'].' '.
'set priority='.($priority-1).' where plugin_id='.$thisplugin->plugin_id.';';
cpg_db_query($sql);
}
break;
case 'moved':
$thisplugin = @$CPG_PLUGINS[$_GET['p']];
if (isset($thisplugin) && ($priority = $thisplugin->priority) < (count($CPG_PLUGINS)-1)) {
// Move the plugin below up
$sql = 'update '.$CONFIG['TABLE_PLUGINS'].' set priority='.($priority).' where priority='.($priority+1).';';
cpg_db_query($sql);
// Move this plugin down
$sql = 'update '.$CONFIG['TABLE_PLUGINS'].' '.
'set priority='.($priority+1).' where plugin_id='.$thisplugin->plugin_id.';';
cpg_db_query($sql);
}
break;
case 'upload':
if (is_uploaded_file($_FILES['plugin']['tmp_name'])) {
$file =& $_FILES['plugin'];
$info = pathinfo($file['name']);
if (strtolower($info['extension'] != 'zip')) {
cpg_die(CRITICAL_ERROR,$lang_pluginmgr_php['not_plugin_package'],__FILE__,__LINE__);
}
if (!is_dir('./plugins/receive')) {
$mask = umask(0);
mkdir('./plugins/receive',0777);
umask($mask);
}
if (!move_uploaded_file($file['tmp_name'],'./plugins/receive/'.$file['name'])) {
cpg_die(CRITICAL_ERROR,$lang_pluginmgr_php['copy_error'],__FILE__,__LINE__);
}
require_once('./include/zip.lib.php');
$zip =& new Zip();
$zip->Extract('./plugins/receive/'.$file['name'],'./plugins',array(-1));
unlink('./plugins/receive/'.$file['name']);
}
break;
}
pageheader($lang_pluginmgr_php['pmgr']);
echo <<
function confirmUninstall(text)
{
return confirm("{$lang_pluginmgr_php['confirm_uninstall']} (" + text + ") ?");
}
function confirmDel(text)
{
return confirm("{$lang_pluginmgr_php['confirm_delete']} (" + text + ") ?");
}
EOT;
/**
* Display the manager page or execute plugin_configure action
*/
// Plugin isn't being configured; Display the plugin list
if ((($op != 'install') && ($op != 'uninstall')) || (is_bool($installed) && $installed) || (is_bool($uninstalled) && $uninstalled)) {
// Refresh the page; An operation was just performed
if (isset($op)) {
header('Location: pluginmgr.php');
}
display_plugin_list();
// Plugin is being configured; Execute 'plugin_configure' action
} elseif ($op == 'install') {
// Display configure page table header
starttable('100%',$lang_pluginmgr_php['configure_plugin'] . ': ' . $CPG_PLUGINS['new']->name);
echo <<< EOT
EOT;
// Execute 'plugin_configure' action on the new plugin
CPGPluginAPI::action('plugin_configure',$installed,CPG_EXEC_NEW);
echo <<< EOT
|
EOT;
// End the table
endtable();
} else {
// Display cleanup page table header
starttable('100%',$lang_pluginmgr_php['cleanup_plugin'] . ': ' . $CPG_PLUGINS[$plugin_id]->name);
echo <<< EOT
EOT;
// Execute 'plugin_cleanup' action on the plugin
CPGPluginAPI::action('plugin_cleanup',$uninstalled,$plugin_id);
echo <<< EOT
|
EOT;
// End the table
endtable();
}
echo "
\n";
pagefooter();
ob_end_flush();
?>