PHP Classes

File: backend/resposta.php

Recommend this page to a friend!
  Classes of carlos carvalho   yrprey PHP application   backend/resposta.php   Download  
File: backend/resposta.php
Role: Example script
Content type: text/plain
Description: Example script
Class: yrprey PHP application
Web app to learn about OWASP API vulnerabilities
Author: By
Last change:
Date: 3 months ago
Size: 2,429 bytes
 

Contents

Class file image Download
<?php

header
("Access-Control-Allow-Origin: *");

// Permitir métodos de solicitação específicos
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");

header("Access-Control-Allow-Headers: Content-Type");

// Definir o tempo de vida do cabeçalho CORS em cache (em segundos)
header("Access-Control-Max-Age: 86400");

header('Content-Type: application/json; charset=utf-8');

if (
$_SERVER['REQUEST_METHOD'] === 'POST') {
   
// Obtém o JSON enviado pelo cliente e converte em um objeto PHP
   
$jsonPayload = file_get_contents('php://input');
   
$data = json_decode($jsonPayload);

   
// Verifica se o JSON foi decodificado corretamente
   
if ($data === null) {
       
// Se houve um erro ao decodificar o JSON, envie uma resposta de erro
       
http_response_code(400); // Requisição inválida
       
echo json_encode(array('error' => 'JSON inválido'));
        exit;
    }

   
// Agora você pode acessar as propriedades do objeto como desejar
   
$v = $data->id;
   
}


for (
$i=0; $i <= $id; $i++) {

   
$output = array("results" => array());
   
       
$array = array(
       
'id' => "$v",
       
'image' => "https://yrprey.com/img/slide-beige.webp",
       
'username' => "test"
   
);
       
       
array_push($output["results"], $array);

       
$array = array(
           
'id' => "$v",
           
'image' => "https://yrprey.com/img/slide-blue.webp",
           
'username' => "test"
       
);
           
           
array_push($output["results"], $array);
           
           
$array = array(
               
'id' => "$v",
               
'image' => "https://yrprey.com/img/slide-cian.webp",
               
'username' => "test"
           
);
               
               
array_push($output["results"], $array);

               
$array = array(
                   
'id' => "$v",
                   
'image' => "https://yrprey.com/img/slide-red.webp",
                   
'username' => "test"
               
);
                   
                   
array_push($output["results"], $array);

                   
$array = array(
                       
'id' => "$v",
                       
'image' => "https://yrprey.com/img/slide-white.webp",
                       
'username' => "test"
                   
);
                       
                       
array_push($output["results"], $array);


    }
   
    echo
json_encode($output, 128);
   
   
?>