!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/beximco/mrp/mrp/.cache/admin/src/components/Roles/Permissions/utils/   drwxrwxrwx
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:     formatContentTypesPermissionToAPI.js (3.12 KB)      -rwxrwxrwx
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import { has, isObject } from 'lodash';
import { createArrayOfValues } from '../../utils';
import { createConditionsArray } from './formatSettingsPermissionsToAPI';

/**
 * Returns an array of property values
 * @param {object} propertyValue
 * @param {string} prefix
 * @returns {array<string>}
 */
const createPropertyArray = (propertyValue, prefix = '') => {
  return Object.entries(propertyValue).reduce((acc, current) => {
    const [name, value] = current;

    if (isObject(value)) {
      return [...acc, ...createPropertyArray(value, `${prefix}${name}.`)];
    }

    if (value && !isObject(value)) {
      acc.push(`${prefix}${name}`);
    }

    return acc;
  }, []);
};

/**
 *
 * @param {string} action
 * @param {string} subject
 * @param {object} param2
 * @config {object} conditions
 * @config {object} the name of the properties array we need to fill
 * @returns {object}
 */
const createPermissionWithProperties = (action, subject, { conditions, properties }) => {
  return Object.entries(properties).reduce(
    (acc, current) => {
      const [propertyName, propertyValue] = current;

      acc.properties[propertyName] = createPropertyArray(propertyValue);

      return acc;
    },
    { action, subject, conditions: createConditionsArray(conditions), properties: {} }
  );
};

/**
 *
 * @param {string} action The name of the action
 * @param {string} subject The name of the subject
 * @param {object} param2
 * @returns {object}
 */
const createPermissionWithoutProperties = (action, subject, { conditions }) => {
  return {
    action,
    subject,
    properties: {},
    conditions: createConditionsArray(conditions),
  };
};

/**
 *
 * @param {string} subject  The name of the subject
 * @param {object} actions The subject's actions
 * @returns {array<object>}
 */
const createSubjectPermissions = (subject, actions) => {
  const permissions = Object.entries(actions).reduce((acc, current) => {
    const [actionName, permissions] = current;
    const shouldCreatePermission = createArrayOfValues(permissions).some(val => val);

    if (!shouldCreatePermission) {
      return acc;
    }

    if (!has(permissions, 'properties.enabled')) {
      const createdPermissionsArray = createPermissionWithProperties(
        actionName,
        subject,
        permissions
      );

      return [...acc, createdPermissionsArray];
    }

    if (!permissions.properties.enabled) {
      return acc;
    }

    const permission = createPermissionWithoutProperties(actionName, subject, permissions);

    acc.push(permission);

    return acc;
  }, []);

  return permissions;
};

/**
 *
 * @param {object} contentTypesPermissions
 * @returns {array<object>}
 */
const formatContentTypesPermissionToAPI = contentTypesPermissions => {
  const permissions = Object.entries(contentTypesPermissions).reduce((allPermissions, current) => {
    const [subject, currentSubjectActions] = current;

    const permissions = createSubjectPermissions(subject, currentSubjectActions);

    return [...allPermissions, ...permissions];
  }, []);

  return permissions;
};

export default formatContentTypesPermissionToAPI;
export { createPropertyArray, createPermissionWithProperties };

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

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

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