Warning: chmod(): Operation not permitted in /var/www/alexvillarreal/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 8
403WebShell
403Webshell
Server IP : 74.208.250.37  /  Your IP : 216.73.217.68
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ubuntu 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64
User : miferval ( 1000)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/brainwavemx/app/Controller/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/brainwavemx/app/Controller/api/ApiClientesController.php
<?php

declare(strict_types=1);

namespace App\Controller\Api;

use App\Model\ClientesModel;
use Mosaico\Controller\BaseController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class ApiClientesController extends BaseController
{
    /**
     * @var ClientesModel
     */
    protected $clientesModel;

    public function __construct()
    {
        $this->clientesModel = new ClientesModel();
    }

    /**
     * [clientes description]
     */
    public function getClientes(Request $request): Response
    {
        $token = $_REQUEST['token'] ?? '';
        $http_method = (string) $request->attributes->get('_method');
        ! empty($http_method) ?:
        $http_method = $_SERVER['REQUEST_METHOD'] ?? 'GET';

        if ($http_method == 'GET') {
            $this->auth();
        }
        if ($this->validateToken($token) == 0) {
            $response = new Response();
            $response->setContent('not authorized');
            $response->setStatusCode(401);
            return $response;
        }

        $clientes = $this->clientesModel->getClientes();
        $arrayClientes = $this->getArrayClientes($clientes);

        return $this->getResponse($http_method, $arrayClientes);
    }

    /**
     * [getArrayClientes description]
     * @return mixed
     */
    public function getArrayClientes(object $clientes)
    {
        $array = [];
        foreach ($clientes->rows as $cliente) {
            array_push($array, $cliente);
        }

        return $array;
    }

    /**
     * [getResponse description]
     */
    public function getResponse(string $method, string|array $content): Response
    {
        $request_method = $_SERVER['REQUEST_METHOD'] ?? '';
        if ($request_method !== $method) {
            $response = new Response();
            $response->setContent('wrong method' . $request_method);
        } else {
            $response = new JsonResponse();
            $response->setData($content);
        }
        return $response;
    }

    /**
     * [validateToken description]
     */
    public function validateToken(string $token): int
    {
        $validate = 0;

        if ($token === '1987654') {
            $validate = 1;
        }
        return $validate;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit