protected function decode_remote_request($request) {

        $data = base64_decode($request, true);

        if ($data === false) {
            return false;
        }

        $data = json_decode($data);

        if (is_null($data)) {
            return false;
        }

        if (!isset($data->name) or !isset($data->component) or !isset($data->version)) {
            return false;
        }

        $data->name = s(strip_tags($data->name));

        if ($data->component !== clean_param($data->component, PARAM_COMPONENT)) {
            return false;
        }

        list($plugintype, $pluginname) = core_component::normalize_component($data->component);

        if ($plugintype === 'core') {
            return false;
        }

        if ($data->component !== $plugintype.'_'.$pluginname) {
            return false;
        }

        if (!core_component::is_valid_plugin_name($plugintype, $pluginname)) {
            return false;
        }

        $plugintypes = core_component::get_plugin_types();
        if (!isset($plugintypes[$plugintype])) {
            return false;
        }

        // Keep this regex in sync with the one used by the download.moodle.org/api/x.y/pluginfo.php
        if (!preg_match('/^[0-9]+$/', $data->version)) {
            return false;
        }

        return $data;
    }
protected function decode_remote_request($request) {

        $data = base64_decode($request, true);

        if ($data === false) {
            return false;
        }

        $data = json_decode($data);

        if (is_null($data)) {
            return false;
        }

        if (!isset($data->name) or !isset($data->component) or !isset($data->version)) {
            return false;
        }

        $data->name = s(strip_tags($data->name));

        if ($data->component !== clean_param($data->component, PARAM_COMPONENT)) {
            return false;
        }

        list($plugintype, $pluginname) = core_component::normalize_component($data->component);

        if ($plugintype === 'core') {
            return false;
        }

        if ($data->component !== $plugintype.'_'.$pluginname) {
            return false;
        }

        if (!core_component::is_valid_plugin_name($plugintype, $pluginname)) {
            return false;
        }

        $plugintypes = core_component::get_plugin_types();
        if (!isset($plugintypes[$plugintype])) {
            return false;
        }

        // Keep this regex in sync with the one used by the download.moodle.org/api/x.y/pluginfo.php
        if (!preg_match('/^[0-9]+$/', $data->version)) {
            return false;
        }

        return $data;
    }
protected function decode_remote_request ( $ request ) { $ data = base64_decode ( $ request , true ) ; if ( $ data === false ) { return false ; } $ data = json_decode ( $ data ) ; if ( is_null ( $ data ) ) { return false ; } if ( ! isset ( $ data -> name ) or ! isset ( $ data -> component ) or ! isset ( $ data -> version ) ) { return false ; } $ data -> name = s ( strip_tags ( $ data -> name ) ) ; if ( $ data -> component !== clean_param ( $ data -> component , PARAM_COMPONENT ) ) { return false ; } list ( $ plugintype , $ pluginname ) = core_component :: normalize_component ( $ data -> component ) ; if ( $ plugintype === 'core' ) { return false ; } if ( $ data -> component !== $ plugintype . '_' . $ pluginname ) { return false ; } if ( ! core_component :: is_valid_plugin_name ( $ plugintype , $ pluginname ) ) { return false ; } $ plugintypes = core_component :: get_plugin_types ( ) ; if ( ! isset ( $ plugintypes [ $ plugintype ] ) ) { return false ; } // Keep this regex in sync with the one used by the download.moodle.org/api/x.y/pluginfo.php if ( ! preg_match ( '/^[0-9]+$/' , $ data -> version ) ) { return false ; } return $ data ; }
Decode the request from the Moodle Plugins directory

@param string $request submitted via 'installaddonrequest' HTTP parameter
@return stdClass|bool false on error, object otherwise
Decode the request from the Moodle Plugins directory