isBlogAdmin($blogid); } else $isblogadmin = 0; if (!$member->isLoggedIn()) { $oPluginAdmin = new PluginAdmin('Paint'); $oPluginAdmin->start(); echo '

' . _PAINT_NeedLogin . '

'; $oPluginAdmin->end(); exit; } if (!($member->isAdmin() || $isblogadmin)) { $oPluginAdmin = new PluginAdmin('Paint'); $oPluginAdmin->start(); echo "

"._ERROR_DISALLOWED."

"; $oPluginAdmin->end(); exit; } $action = requestVar('action'); $aActionsNotToCheck = array( '', 'report', ); if (!in_array($action, $aActionsNotToCheck)) { if (!$manager->checkTicket()) doError(_ERROR_BADTICKET); } // create the admin area page $oPluginAdmin = new PluginAdmin('Paint'); $oPluginAdmin->start(); $fb =& new cles_Feedback($oPluginAdmin); $templateEngine =& new cles_Template(dirname(__FILE__).'/template'); define('NP_PAINT_TEMPLATEDIR_INDEX', 'index'); $tplVars = array( 'indexurl' => serverVar('PHP_SELF'), 'optionurl' => $CONF['AdminURL'] . 'index.php?action=pluginoptions&plugid=' . $oPluginAdmin->plugin->getid(), 'paintiniurl' => PAINT_INI_URL, 'paintplugindir' => PAINT_PLUGIN_DIR, 'ticket' => $manager->_generateTicket(), ); // get the plugin options; stored in the DB //$pbl_config['enabled'] = $oPluginAdmin->plugin->getOption('enabled'); // menu $menu = $templateEngine->fetch('menu', NP_PAINT_TEMPLATEDIR_INDEX); echo $templateEngine->fill($menu, $tplVars, false); //action switch ($action) { case 'help' : echo $templateEngine->fetch('help', NP_PAINT_TEMPLATEDIR_INDEX); break; case 'install' : if( requestVar('func') == 'ini' ){ $err = paint_plugin_download( PAINT_INI_URL, PAINT_PLUGIN_DIR); if($err){ echo '

Error: ' . _PAINT_canNotReadFile . ':' .PAINT_INI_URL . '

'; echo '

Reason: '.$err.'

'; break; } } echo "

"._PAINT_iniDownload."

"; echo "\n"; if( ! is_readable(PAINT_PLUGIN_DIR . '/paint.ini') ) break; $settings = parse_ini_file(PAINT_PLUGIN_DIR . '/paint.ini', true); if( ! $settings ){ echo '

Error: ' . _PAINT_canNotReadFile . ': ' .PAINT_INI_URL . '

'; break; } echo '

' . _PAINT_appletinstall. "( {$settings['paint']['version']}[{$settings['paint']['updated']}] )

"; if ($pluginName = getVar('plugin')) { $oPluginAdmin->plugin->_loadPlugin(); $plugin = $oPluginAdmin->plugin->disabledPlugin[$pluginName]; if ($plugin) { $zipurl = $settings[$pluginName]['zip']; if($zipurl) echo paint_plugin_install($zipurl); else echo '

Error:' ._PAINT_canNotAutoInstall . '

'; } else { echo '

Error:'. _PAINT_noSuchPlugin . '

'; } } $oPluginAdmin->plugin->_loadPlugin(false, true); ksort($oPluginAdmin->plugin->disabledPlugin); echo '

'._PAINT_autoInstall.'

'; echo "\n"; break; case 'report' : $oPluginAdmin->plugin->_loadPlugin(); $extra = ''; foreach ($oPluginAdmin->plugin->parsers as $key => $name) { $extra .= 'parser_'.$key.', '; } foreach ($oPluginAdmin->plugin->applets as $key => $name) { $extra .= 'applet_'.$key.', '; } foreach ($oPluginAdmin->plugin->palettes as $key => $name) { $extra .= 'palette_'.$key.', '; } foreach ($oPluginAdmin->plugin->viewers as $key => $name) { $extra .= 'viewer_'.$key.', '; } $fb->printForm($extra); break; default : break; } echo "
"; $oPluginAdmin->end(); function paint_plugin_install($url) { $err = paint_plugin_download($url, PAINT_PLUGIN_DIR); if ($err) return $err; $file = PAINT_PLUGIN_DIR . '/' . basename($url); $err = paint_plugin_extract($file, PAINT_PLUGIN_DIR); return $err; } function paint_plugin_extract($file, $dir) { $archive = new PclZip($file); if ($archive->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_SET_CHMOD, 0777) == 0) { return $archive->errorInfo(true); } return ''; } function paint_plugin_download($url, $dir) { if (!@ is_writable($dir) || !@ is_dir($dir)) { return _Paint_directoryNotWriteable . $dir; } $remote = fopen($url, "rb"); socket_set_timeout($remote, 10); if (!$remote) return _PAINT_fileOpen_failure . ': '.$url; $file = $dir.'/'.basename($url); $local = fopen($file, "wb"); socket_set_timeout($local, 5); if (!$local) return _PAINT_fileOpen_failure . ': '.$file; while (!feof($remote)) { $buffer = fgets($remote, 4096); fputs($local, $buffer); } fclose($remote); fclose($local); return ''; }