| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  *
 | 
  
    | 4 |  * @category        admin
 | 
  
    | 5 |  * @package         admintools
 | 
  
    | 6 |  * @author          Ryan Djurovich, WebsiteBaker Project
 | 
  
    | 7 |  * @author          Werner v.d. Decken
 | 
  
    | 8 |  * @copyright       WebsiteBaker Org. e.V.
 | 
  
    | 9 |  * @link            http://websitebaker.org/
 | 
  
    | 10 |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
  
    | 11 |  * @platform        WebsiteBaker 2.8.3
 | 
  
    | 12 |  * @requirements    PHP 5.3.6 and higher
 | 
  
    | 13 |  * @version         $Id: tool.php 2 2017-07-02 15:14:29Z Manuela $
 | 
  
    | 14 |  * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/admin/admintools/tool.php $
 | 
  
    | 15 |  * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
 | 
  
    | 16 |  *
 | 
  
    | 17 |  */
 | 
  
    | 18 | if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
 | 
  
    | 19 | if ( !class_exists('admin', false) ) { require(WB_PATH.'/framework/class.admin.php'); }
 | 
  
    | 20 | require_once(WB_PATH.'/framework/functions.php');
 | 
  
    | 21 | 
 | 
  
    | 22 |     $toolDir = (isset($_GET['tool']) && (trim($_GET['tool']) != '') ? trim($_GET['tool']) : '');
 | 
  
    | 23 |     $doSave = (isset($_POST['save_settings']) || (isset($_POST['action']) && strtolower($_POST['action']) == 'save'));
 | 
  
    | 24 | // test for valid tool name
 | 
  
    | 25 | 
 | 
  
    | 26 |     if(preg_match('/^[a-z][a-z_\-0-9]{2,}$/i', $toolDir)) {
 | 
  
    | 27 |     // Check if tool is installed
 | 
  
    | 28 |         $sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` '.
 | 
  
    | 29 |                'WHERE `type`=\'module\' AND `function`=\'tool\' '.
 | 
  
    | 30 |                       'AND `directory`=\''.$database->escapeString($toolDir).'\'';
 | 
  
    | 31 |         if(($toolName = $database->get_one($sql))) {
 | 
  
    | 32 |         // create admin-object and print header if FTAN is NOT supported AND function 'save' is requested
 | 
  
    | 33 |             $admin_header = !(is_file(WB_PATH.'/modules/'.$toolDir.'/FTAN_SUPPORTED') && $doSave);
 | 
  
    | 34 |             $admin = new admin('admintools', 'admintools', $admin_header );
 | 
  
    | 35 |             if(!$doSave) {
 | 
  
    | 36 |             // show title if not function 'save' is requested
 | 
  
    | 37 |                 print '<h4><a href="'.ADMIN_URL.'/admintools/index.php" '.
 | 
  
    | 38 |                       'title="'.$HEADING['ADMINISTRATION_TOOLS'].'">'.
 | 
  
    | 39 |                       $HEADING['ADMINISTRATION_TOOLS'].'</a>'.
 | 
  
    | 40 |                       ' » '.$toolName.'</h4>'."\n";
 | 
  
    | 41 |             }
 | 
  
    | 42 |             // include modules tool.php
 | 
  
    | 43 |             require(WB_PATH.'/modules/'.$toolDir.'/tool.php');
 | 
  
    | 44 |             $admin->print_footer();
 | 
  
    | 45 |         }else {
 | 
  
    | 46 |         // no installed module found, jump to index.php of admintools
 | 
  
    | 47 |             header('location: '.ADMIN_URL.'/admintools/index.php');
 | 
  
    | 48 |             exit(0);
 | 
  
    | 49 |         }
 | 
  
    | 50 |     }else {
 | 
  
    | 51 |     // invalid module name requested, jump to index.php of admintools
 | 
  
    | 52 |         header('location: '.ADMIN_URL.'/admintools/index.php');
 | 
  
    | 53 |         exit(0);
 | 
  
    | 54 |     }
 |