!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-database/lib/   drwxr-xr-x
Free 13.04 GB of 57.97 GB (22.49%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

const _ = require('lodash');

const { createQuery } = require('./queries');
const createConnectorRegistry = require('./connector-registry');
const constants = require('./constants');
const { validateModelSchemas } = require('./validation');
const createMigrationManager = require('./migration-manager');
const createLifecycleManager = require('./lifecycle-manager');

class DatabaseManager {
  constructor(strapi) {
    this.strapi = strapi;

    this.initialized = false;

    this.connectors = createConnectorRegistry({
      connections: strapi.config.get('database.connections'),
      defaultConnection: strapi.config.get('database.defaultConnection'),
    });

    this.queries = new Map();
    this.models = new Map();

    this.migrations = createMigrationManager(this);
    this.lifecycles = createLifecycleManager();
  }

  async initialize() {
    if (this.initialized === true) {
      throw new Error('Database manager already initialized');
    }

    this.initialized = true;

    this.connectors.load();

    validateModelSchemas({ strapi: this.strapi, manager: this });

    this.initializeModelsMap();

    await this.connectors.initialize();

    return this;
  }

  async destroy() {
    await Promise.all(this.connectors.getAll().map(connector => connector.destroy()));
  }

  initializeModelsMap() {
    Object.keys(this.strapi.models).forEach(modelKey => {
      const model = this.strapi.models[modelKey];
      this.models.set(model.uid, model);
    });

    Object.keys(this.strapi.admin.models).forEach(modelKey => {
      const model = this.strapi.admin.models[modelKey];
      this.models.set(model.uid, model);
    });

    Object.keys(this.strapi.plugins).forEach(pluginKey => {
      Object.keys(this.strapi.plugins[pluginKey].models).forEach(modelKey => {
        const model = this.strapi.plugins[pluginKey].models[modelKey];
        this.models.set(model.uid, model);
      });
    });
  }

  query(entity, plugin) {
    if (!entity) {
      throw new Error(`argument entity is required`);
    }

    const model = this.getModel(entity, plugin);

    if (!model) {
      throw new Error(`The model ${entity} can't be found.`);
    }

    if (this.queries.has(model.uid)) {
      return this.queries.get(model.uid);
    }

    const connectorQuery = this.connectors
      .get(model.orm)
      .queries({ model, modelKey: model.modelName, strapi });

    const query = createQuery({
      connectorQuery,
      model,
    });

    this.queries.set(model.uid, query);
    return query;
  }

  getModelFromStrapi(name, plugin) {
    const key = _.toLower(name);
    if (plugin === 'admin') {
      return _.get(strapi.admin, ['models', key]);
    }

    if (plugin) {
      return _.get(strapi.plugins, [plugin, 'models', key]);
    }

    return _.get(strapi, ['models', key]) || _.get(strapi, ['components', key]);
  }

  getModel(name, plugin) {
    const key = _.toLower(name);

    if (this.models.has(key)) {
      const { modelName, plugin: pluginName } = this.models.get(key);
      return this.getModelFromStrapi(modelName, pluginName);
    } else {
      return this.getModelFromStrapi(key, plugin);
    }
  }

  getModelByAssoc(assoc) {
    return this.getModel(assoc.collection || assoc.model, assoc.plugin);
  }

  getModelByCollectionName(collectionName) {
    return Array.from(this.models.values()).find(model => {
      return model.collectionName === collectionName;
    });
  }

  getModelByGlobalId(globalId) {
    return Array.from(this.models.values()).find(model => {
      return model.globalId === globalId;
    });
  }

  getModelsByAttribute(attr) {
    if (attr.type === 'component') {
      return [this.getModel(attr.component)];
    }
    if (attr.type === 'dynamiczone') {
      return attr.components.map(compoName => this.getModel(compoName));
    }
    if (attr.model || attr.collection) {
      return [this.getModelByAssoc(attr)];
    }

    return [];
  }

  getModelsByPluginName(pluginName) {
    if (!pluginName) {
      return strapi.models;
    }

    return pluginName === 'admin' ? strapi.admin.models : strapi.plugins[pluginName].models;
  }

  getReservedNames() {
    return {
      models: constants.RESERVED_MODEL_NAMES,
      attributes: [
        ...constants.RESERVED_ATTRIBUTE_NAMES,
        ...(strapi.db.connectors.default.defaultTimestamps || []),
      ],
    };
  }
}

function createDatabaseManager(strapi) {
  return new DatabaseManager(strapi);
}

module.exports = {
  createDatabaseManager,
};

:: 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.0107 ]--