!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/wincloud_gateway/node_modules/strapi/lib/core/   drwxr-xr-x
Free 13.1 GB of 57.97 GB (22.6%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     load-hooks.js (3.07 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
'use strict';

// Dependencies.
const path = require('path');
const fs = require('fs-extra');
const _ = require('lodash');
const glob = require('../load/glob');
const findPackagePath = require('../load/package-path');

/**
 * Load hooks
 */
module.exports = async function({ installedHooks, installedPlugins, appPath }) {
  let hooks = {};

  await Promise.all([
    loadHookDependencies(installedHooks, hooks),
    // local middleware
    loadLocalHooks(appPath, hooks),
    // admin hooks
    loadAdminHooks(hooks),
    // plugins middlewares
    loadPluginsHooks(installedPlugins, hooks),
    // local plugin middlewares
    loadLocalPluginsHooks(appPath, hooks),
  ]);

  return hooks;
};

const loadHooksInDir = async (dir, hooks) => {
  const files = await glob('*/*(index|defaults).*(js|json)', {
    cwd: dir,
  });

  files.forEach(f => {
    const name = f.split('/')[0];
    mountHooks(name, [path.resolve(dir, f)], hooks);
  });
};

const loadLocalHooks = (appPath, hooks) => loadHooksInDir(path.resolve(appPath, 'hooks'), hooks);

const loadPluginsHooks = async (plugins, hooks) => {
  for (let pluginName of plugins) {
    const dir = path.resolve(findPackagePath(`strapi-plugin-${pluginName}`), 'hooks');
    await loadHooksInDir(dir, hooks);
  }
};

const loadAdminHooks = async hooks => {
  const hooksDir = 'hooks';
  const dir = path.resolve(findPackagePath('strapi-admin'), hooksDir);
  await loadHooksInDir(dir, hooks);

  // load ee admin hooks if they exist
  if (process.env.STRAPI_DISABLE_EE !== 'true' && strapi.EE) {
    await loadHooksInDir(`${dir}/../ee/${hooksDir}`, hooks);
  }
};

const loadLocalPluginsHooks = async (appPath, hooks) => {
  const pluginsDir = path.resolve(appPath, 'plugins');
  if (!fs.existsSync(pluginsDir)) return;

  const pluginsNames = await fs.readdir(pluginsDir);

  for (let pluginName of pluginsNames) {
    // ignore files
    const stat = await fs.stat(path.resolve(pluginsDir, pluginName));
    if (!stat.isDirectory()) continue;

    const dir = path.resolve(pluginsDir, pluginName, 'hooks');
    await loadHooksInDir(dir, hooks);
  }
};

const loadHookDependencies = async (installedHooks, hooks) => {
  for (let hook of installedHooks) {
    const hookDir = path.dirname(require.resolve(`strapi-hook-${hook}`));

    const files = await glob('*(index|defaults).*(js|json)', {
      cwd: hookDir,
      absolute: true,
    });

    mountHooks(hook, files, hooks);
  }
};

const mountHooks = (name, files, hooks) => {
  files.forEach(file => {
    hooks[name] = hooks[name] || { loaded: false };

    let dependencies = [];
    try {
      dependencies = _.get(require(`strapi-hook-${name}/package.json`), 'strapi.dependencies', []);
    } catch (err) {
      // Silent
    }

    if (_.endsWith(file, 'index.js') && !hooks[name].load) {
      Object.defineProperty(hooks[name], 'load', {
        configurable: false,
        enumerable: true,
        get: () => require(file)(strapi),
      });
      hooks[name].dependencies = dependencies;
      return;
    }

    if (_.endsWith(file, 'defaults.json')) {
      hooks[name].defaults = require(file);
      return;
    }
  });
};

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0251 ]--