HEX
Server: Apache
System: Linux web2213.uni5.net 5.4.282-1.el8.elrepo.x86_64 #1 SMP Mon Aug 19 18:33:22 EDT 2024 x86_64
User: clinicamaciel (596848)
PHP: 7.3.33
Disabled: apache_child_terminate,c99_buff_prepare,c99_sess_put,dl,eval,exec,leak,link,myshellexec,openlog,passthru,pclose,pcntl_exec,php_check_syntax,php_strip_whitespace,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,symlink,system,socket_listen,socket_create_listen,putenv
Upload Files
File: /home/clinicamaciel/www/wp-content/plugins/motopress-content-editor/includes/ce/Access.php
<?php
/**
 * Description of MPCEAccess
 *
 * @author dima
 */
class MPCEAccess {
    private $capabilities = array(
        'read' => false,
        //'unfiltered_html' => false,
        'upload_files' => false,
        'post' => array(
            'edit_posts' => false
            /*
            'delete_posts' => false,
            'read_private_posts' => false,
            'edit_private_posts' => false,
            'delete_private_posts' => false
            */
        ),
        'page' => array(
            'edit_pages' => false
            /*
            'delete_pages' => false,
            'read_private_pages' => false,
            'edit_private_pages' => false,
            'delete_private_pages' => false
            */
        )
    );

    public function __construct() {
        global $motopressCESettings;

        /*if (isset($motopressCESettings['demo']) && $motopressCESettings['demo']) {
            if (isset($this->capabilities['unfiltered_html'])) {
                unset($this->capabilities['unfiltered_html']);
            }
        }*/
    }

    /**
     * @return boolean
     */
    public function hasAccess($postId = false) {
        require_once ABSPATH . WPINC . '/pluggable.php';

        if (!$postId) $postId = get_the_ID();

        $postType = get_post_type($postId);
        if ($postType !== 'page') $postType = 'post';

        $this->checkCapabilities($postId);

        return (is_user_logged_in() && !in_array(false, $this->capabilities, true) && !in_array(false, $this->capabilities[$postType], true) && !$this->isCEDisabledForCurRole()) ? true : false;
    }

    /*
     * @return boolean
     */
    public function isCEDisabledForCurRole(){
        $disabledRoles = get_option('motopress-ce-disabled-roles', array());
        $currentUser = wp_get_current_user();
        $currentUserRoles = $currentUser->roles;

        if (is_super_admin()) return false;
        
        foreach ($currentUserRoles as $key => $role) {
            if ( !in_array($role, $disabledRoles)){
                return false;
            }
        }
        // in case if all user rules are disabled
        return true;
    }

    /**
     * @param int $postId
     */
    private function checkCapabilities($postId) {
        foreach ($this->capabilities as $key => $value) {
            if (is_bool($value)) {
                $this->capabilities[$key] = current_user_can($key, $postId);
            } elseif (is_array($value)) {
                foreach ($value as $k => $v) {
                    $this->capabilities[$key][$k] = current_user_can($k, $postId);
                }
            }
        }
    }
}