/**
  * Run script: Search for SUPEE-6788 affected files, auto-patch if needed.
  * 
  * @return void
  */
 public function run()
 {
     $dryRun = null;
     if (isset($this->_args['analyze'])) {
         $dryRun = true;
     } elseif (isset($this->_args['fix'])) {
         $dryRun = false;
     }
     if (!is_null($dryRun)) {
         static::log('-------------------------------------------------------------------');
         static::log('---- SUPEE-6788 Developer Toolbox by ParadoxLabs ------------------');
         static::log('  https://github.com/rhoerr/supee-6788-toolbox');
         static::log('  Time: ' . date('c'));
         if (isset($this->_args['loadWhitelists'])) {
             static::log('---- Loading whitelists -------------------------------------------');
             $this->_loadWhitelistsFromFile();
         }
         $this->_findModules();
         static::log('---- Searching config for bad routers -----------------------------');
         $configAffectedModules = $this->_fixBadAdminhtmlRouter($dryRun);
         static::log('---- Moving controllers for bad routers to avoid conflicts --------');
         $this->_moveAdminControllers($configAffectedModules, $dryRun);
         static::log('---- Searching files for bad routes -------------------------------');
         $this->_fixBadAdminRoutes($dryRun);
         static::log('---- Searching for whitelist problems -----------------------------');
         $whitelist = new TemplateVars();
         $whitelist->execute();
         sort($this->_modifiedFiles);
         static::log('---- Summary ------------------------------------------------------');
         static::log(sprintf("Affected Modules:\n  %s", implode("\n  ", $configAffectedModules)));
         static::log(sprintf("Replace Patterns: %s", print_r($this->_fileReplacePatterns, 1)));
         static::log(sprintf("Corrected Files:\n  %s", implode("\n  ", $this->_modifiedFiles)));
         static::log(sprintf("Errors:\n  %s", implode("\n  ", static::$_errors)));
         static::log('See var/log/fixSUPEE6788.log for a record of all results.');
         if (isset($this->_args['recordAffected'])) {
             file_put_contents(Mage::getBaseDir('var') . DS . 'log' . DS . 'fixSUPEE6788-modules.log', implode("\n", $configAffectedModules));
             static::log('Wrote affected modules to var/log/fixSUPEE6788-modules.log');
             file_put_contents(Mage::getBaseDir('var') . DS . 'log' . DS . 'fixSUPEE6788-files.log', implode("\n", $this->_modifiedFiles));
             static::log('Wrote affected files to var/log/fixSUPEE6788-files.log');
         }
     } else {
         echo $this->usageHelp();
     }
 }
Example #2
0
require_once __DIR__ . '/app/bootstrap.php';
if (!isset($_GET['action'])) {
    die("No action set.");
}
if (!isset($_GET['db'])) {
    die("No db set.");
}
$action = $_GET['action'];
$active_db = $_GET['db'];
$active_table = false;
if ($action == 'show_menu') {
    $db = new Database($active_db);
    $tables = $db->getTables();
    if ($active_table == false) {
        if (isset($tables[0])) {
            $active_table = $tables[0];
        }
    }
    $curr_table = $db->getTable($active_table);
    // Build default menu for active_db.
    $lm = new ListMenu();
    $lm->setItems($tables);
    $lm->setColumnMax(3);
    TemplateVars::set('tables', $lm->toString($active_table));
    if (count($tables) == 0) {
        die("<em>This database is empty.</em>");
    }
    require_once './app/templates/partials/menu_display.phtml';
    exit;
}
 /**
  * Initialize: Load whitelist entries from the database if possible.
  */
 public function __construct()
 {
     $this->_resource = Mage::getSingleton('core/resource');
     $this->_read = $this->_resource->getConnection('core_read');
     $this->_write = $this->_resource->getConnection('core_write');
     try {
         $this->_blocksTable = $this->_resource->getTableName('admin/permission_block');
         if ($this->_read->isTableExists($this->_blocksTable)) {
             self::$blocksWhitelist = array();
             $sql = "SELECT * FROM " . $this->_blocksTable . " WHERE is_allowed=1";
             $permissions = $this->_read->fetchAll($sql);
             foreach ($permissions as $permission) {
                 self::$blocksWhitelist[] = $permission['block_name'];
             }
         } else {
             $this->_blocksTable = null;
         }
     } catch (Exception $e) {
         // Exception means the whitelist doesn't exist yet, or we otherwise failed to read it in. That's okay. Move on.
         $this->_blocksTable = null;
     }
     try {
         $this->_varsTable = $this->_resource->getTableName('admin/permission_variable');
         if ($this->_read->isTableExists($this->_varsTable)) {
             self::$varsWhitelist = array();
             $sql = "SELECT * FROM " . $this->_varsTable . " WHERE is_allowed=1";
             $permissions = $this->_read->fetchAll($sql);
             foreach ($permissions as $permission) {
                 self::$varsWhitelist[] = $permission['variable_name'];
             }
         } else {
             $this->_varsTable = null;
         }
     } catch (Exception $e) {
         // Exception means the whitelist doesn't exist yet, or we otherwise failed to read it in. That's okay. Move on.
         $this->_varsTable = null;
     }
 }
Example #4
0
require_once __DIR__ . '/app/bootstrap.php';
$active_db = DEFAULT_DATABASE;
$active_table = false;
if (isset($_GET['db'])) {
    $active_db = strip_junk($_GET['db']);
}
if (isset($_GET['table'])) {
    $active_table = strip_junk($_GET['table']);
}
$db = new Database($active_db);
$tables = $db->getTables();
if ($active_table == false) {
    $active_table = $tables[0];
}
$curr_table = $db->getTable($active_table);
// Build default menu for active_db.
$lm = new ListMenu();
$lm->setItems($tables);
$lm->setColumnMax(3);
TemplateVars::set('tables', $lm->toString($active_table));
// Grab database listing
TemplateVars::set('dbs', Database::getAllDatabases());
TemplateVars::set('active_db', $active_db);
require_once './app/templates/header.phtml';
$data = $curr_table->getRows(0, 10, $return_res = true);
TemplateVars::set('table', $active_table);
TemplateVars::set('schema', $curr_table->getFields($return_res = true));
TemplateVars::set('schema_sql', $curr_table->getSQL());
TemplateVars::set('table_data', $data);
require_once './app/templates/show_table.phtml';
require_once './app/templates/footer.phtml';