관리-도구
편집 파일: easytoolbar2.php
<?php /** * Frontend Recovery Console ;) * * The purpose of this is to recover the backend.. * * This is because we need to include the plugin file unconditionally for validation. * If a parse error occurs, the backend will be unusable, until you 'disable' the * 'malicious Plugin' *some way* * @todo: need to find a way to validate php code prior to inclusion * * @version $Id: easytoolbar2.php 437 2008-01-03 03:40:12Z elkuku $ * @package EasyToolbar2 * @subpackage Frontend * @author EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org} * @author Nikolai Plath (elkuku) {@link http://www.nik-it.de NiK-IT.de} */ // no direct access defined( '_JEXEC' ) or die( ';)' ); /* * Make sure the user is authorized to view this page */ $user = & JFactory::getUser(); //if (!$user->authorize( 'com_easytoolbar2', 'manage' )) { // $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); //} /* teenytiny access_check * we grant access only to Super Admins * TODO : what to do to check access ? */ if( $user->usertype != 'Super Administrator' ) { $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); } /// we are getting the config............... jimport('joomla.application.component.model'); JModel::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_easytoolbar2'.DS.'models'); $model = JModel::getInstance( 'etb_config', 'EasyToolbar2Model' ); if( ! $model ) { echo '<span style="color: red">CONFIG NOT FOUND !</span>'; return FALSE; } $etb_CONFIG =& $model->getConfig(); // add css style sheet $document =& JFactory::getDocument(); $document->addStyleSheet('components/com_'.$etb_CONFIG->app_comname.'/assets/css/module.css'); //sry about this one... /** @todo other option to include standard html */ require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_easytoolbar2'.DS.'views'.DS.'etb_common.html.php'); /** * defined for cleaner html output * @ignore */ if( ! defined( 'NL' ) ) define( 'NL', "\n" ); /** * @ignore */ if( ! defined( 'TB' ) ) define( 'TB', "\t" ); // Include the Tooltips #JHTML::_('behavior.tooltip');//1.5b2 // Initialize some variables #$lang =& JFactory::getLanguage(); //get the plugin class $plugin_path = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_easytoolbar2'.DS.'plugins'; require_once( $plugin_path.DS.'plugin.class.php'); jimport('joomla.utilities.utility'); $etb_plugin = new etbPlugin( $plugin_path, FALSE ); if( ! $etb_plugin ) { echo 'PLUGINS NOT FOUND...fatal'; return; } #echo $plugins->__set_state->path; #echo JUtility::dump($plugins); $link_back = 'index.php?option=com_easytoolbar2'; #global $mainframe; switch( $task ) { case 'deactiv': $success = disablePlugin( $etb_plugin ); if( $success === TRUE ) { $mainframe->Redirect($link_back, JText::_('The Plugin has been disabled')); } else { $mainframe->Redirect($link_back, $success, 'error'); } break; case 'activ': $success = enablePlugin( $etb_plugin ); if( $success === TRUE ) { $mainframe->Redirect($link_back, JText::_('The Plugin has been enabled')); } else { $mainframe->Redirect($link_back, $success, 'error'); } break; default: listPlugins( $etb_plugin ); break; } /** * Disable selected Plugin */ function disablePlugin( $etb_plugin ) { $plugin_name=JRequest::getVar('plg', FALSE); if( ! $plugin_name ) { return JText::_('no plugin_name'); } $path = $etb_plugin->getPath(); if( ! is_dir($path.DS.$plugin_name)) { return JText::_('no such Plugin'); } else { /** * RENAME THE PLUGIN PHP FILE */ @rename($path.DS.$plugin_name.DS.$plugin_name.'.php', $path.DS.$plugin_name.DS.$plugin_name.'.phpx'); //success? if( file_exists($path.DS.$plugin_name.DS.$plugin_name.'.phpx')) { //yeah echo $path.DS.$plugin_name; return TRUE;//echo 'The Plugin has been disabled<br />'; } else { //permission problem ? echo $path.DS.$plugin_name; return JText::_('The Plugin could not be disabled (Permissions ?)'); } } }// function /** * Enable selected Plugin */ function enablePlugin( $etb_plugin ) { $plugin_name=JRequest::getVar('plg', FALSE); if( ! $plugin_name ) { return JText::_('no plugin_name'); } $path = $etb_plugin->getPath(); if( ! is_dir($path.DS.$plugin_name)) { return JText::_('no such Plugin'); } else { /** * RENAME THE PLUGIN PHP FILE */ @rename($path.DS.$plugin_name.DS.$plugin_name.'.phpx', $path.DS.$plugin_name.DS.$plugin_name.'.php'); //success? if( file_exists($path.DS.$plugin_name.DS.$plugin_name.'.php')) { //yeah # echo $path.DS.$plugin_name; return TRUE;//'The Plugin has been enabled<br />'; } else { //permission problem ? # echo $path.DS.$plugin_name; return JText::_('The Plugin could not be enabled (Permissions ?)'); } } }// function /** * List all Plugins with their states */ function listPlugins( $etb_plugin ) { global $Itemid; $link_disable='index.php?option=com_easytoolbar2&Itemid='.$Itemid.'&task=deactiv&plg='; $link_enable='index.php?option=com_easytoolbar2&Itemid='.$Itemid.'&task=activ&plg='; $plugins = $etb_plugin->getPlugins(); $path = $etb_plugin->getPath(); ?> <h3>EasyToolbar <?php echo JText::_('Recovery Console'); ?> ;)</h3> <h4><?php echo JText::_('Renaming Plugins to recover my backend'); ?></h4> <hr /> <?php foreach( $plugins as $plugin ) { echo $plugin['folder']; if( file_exists($path.DS.$plugin['folder'].DS.$plugin['folder'].'.phpx')) { echo '<strong style="color: red;"> DISABLED</strong>'; echo '<a href="'.$link_enable.$plugin['folder'].'"> --> ENABLE <--</a>'; } else { echo '<a href="'.$link_disable.$plugin['folder'].'"> --> DISABLE <--</a>'; } echo '<hr />'; }// foreach }// function