/** * Display upload form * * @param string $token Security token * @return string HTML for the upload form * */ function plugin_show_uploadform($token) { global $_CONF, $LANG28, $LANG32; $retval = ''; $retval .= COM_startBlock($LANG32[39], '', COM_getBlockTemplate('_admin_block', 'header')); // Check if all the requirements needed to upload a plugin are met $errors = plugin_upload_enabled(); if (count($errors) == 0) { // Show the upload form $retval .= '<p>' . $LANG32[40] . '</p>' . LB . '<form name="plugins_upload" action="' . $_CONF['site_admin_url'] . '/plugins.php" method="post" enctype="multipart/form-data">' . LB . '<div>' . $LANG28[29] . ': ' . '<input type="file" dir="ltr" name="plugin" size="40"' . XHTML . '> ' . LB . '<input type="submit" name="upload" value="' . $LANG32[41] . '"' . XHTML . '>' . LB . '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"' . XHTML . '>' . '</div>' . LB . '</form>' . LB; } else { // Show the errors $retval .= '<p>' . $LANG32[65] . '</p>' . LB . '<div><ul>' . LB; foreach ($errors as $key => $value) { $retval .= "<li>{$value}</li>"; } $retval .= '</ul></div>' . LB; } $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
/** * Show main plugin screen: installed and uninstalled plugins, upload form * * @param string $message (optional) message to display * @return string HTML for the plugin screen * */ function plugin_main($message = '') { global $LANG32; $retval = ''; $retval .= COM_siteHeader('menu', $LANG32[5]); if (!empty($message)) { $retval .= COM_showMessageText($message); } else { $retval .= COM_showMessageFromParameter(); } $token = SEC_createToken(); $retval .= listplugins($token); if (SEC_hasRights('plugin.install')) { $retval .= show_newplugins($token); } // If the web server will allow the user to upload a plugin if (plugin_upload_enabled() && SEC_hasRights('plugin.install,plugin.upload')) { $retval .= plugin_show_uploadform($token); } $retval .= COM_siteFooter(); return $retval; }