PHP Classes

File: .history/routes/routes_20241112130909.php

Recommend this page to a friend!
  Classes of António Lira Fernandes   Web Service PHP JSON   .history/routes/routes_20241112130909.php   Download  
File: .history/routes/routes_20241112130909.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Web Service PHP JSON
API example that stores information in JSON files
Author: By
Last change:
Date: 21 days ago
Size: 3,152 bytes
 

Contents

Class file image Download
<?php
use src\Route as Route;
use
classes\authentication\Authentication;

Route::get('/', function(){require _CAMINHO_TEMPLATE. "index.html";});
Route::get('/batatas', function(){require _CAMINHO_TEMPLATE. "index.html";});
Route::get('/timeline', function(){require _CAMINHO_TEMPLATE. "timeline.html";});

Route::get(['set' => '/base/index', 'as' => 'base.index'], 'Controller@index');
Route::get(['set' => '/base/show/{id}', 'as' => 'base.show'], 'Controller@show');

//carros
Route::get(['set' => '/api/carros', 'as' => 'carros.getAll'], 'ControllerCarros@getAll');
Route::get(['set' => '/api/carros/{id}', 'as' => 'carros.getById'], 'ControllerCarros@getById');
Route::post(['set' => '/api/carros/create', 'as' => 'carros.create'], 'ControllerCarros@create');
Route::put(['set' => '/api/carros/update', 'as' => 'carros.update'], 'ControllerCarros@update');
Route::delete(['set' => '/api/carros/delete/{id}', 'as' => 'carros.index'], 'ControllerCarros@delete');

//Zona sem autenticação
//Artigos
Route::get(['set' => '/artigos/numeros', 'as' => 'artigos.contarArtigos'], 'ControllerArtigos@contarArtigos');
Route::get(['set' => '/artigo/{id}/ver', 'as' => 'artigos.ArtigoVer'], 'ControllerArtigos@ArtigoVer'); //web service
Route::get('/artigo/ver/{id}', function(){ require _CAMINHO_TEMPLATE1. "artigo.php";}); //ver artigo
Route::get('/artigo/ver/', function(){ require _CAMINHO_TEMPLATE1. "artigo.php";}); //ver artigo

//Users
Route::get(['set' => '/users/contar', 'as' => 'users.contarUsers'], 'ControllerUser@contarUsers');
Route::get(['set' => '/users/lista', 'as' => 'users.listOfUsers'], 'ControllerUser@listOfUsers');

//Autenticação
$aut=new Authentication();
if (
$aut->isLoged()){
 
//Zona com autenticação

 
Route::get('/admin/json', function(){require _CAMINHO_TEMPLATE. "tabelaCarros.html.html";});
 
 
 
//Users
 
Route::get('/users', function(){ require _CAMINHO_ADMIN. "utilizadoresGere.php";}); //mostra todos os users
 
Route::post('/users', function(){ require _CAMINHO_ADMIN. "utilizadoresGere.php";});
 
 
//Artigos
 
Route::get('/artigos', function(){ require _CAMINHO_ADMIN. "artigosGerir.php";}); //mostra os últimos artigos
 
Route::post('/artigos', function(){ require _CAMINHO_ADMIN. "artigosGerir.php";});
 
Route::post(['set' => '/artigo/add', 'as' => 'artigos.addArtigo'], 'ControllerArtigos@addArtigo');
 
Route::get(['set' => '/artigo/add', 'as' => 'artigos.addArtigo'], 'ControllerArtigos@addArtigo');
}else{
 
//echo "Não tem acesso";
  //header('Location: https://www.esmonserrate.org/public/semAcesso');
  //exit;
 
Route::get('/{any}', function(){ require _CAMINHO_ERROS. "erro401.php";});
 
Route::get('/{any}/{any}', function(){ require _CAMINHO_ERROS. "erro401.php";});
 
Route::get('/{any}/{any}/{any}', function(){ require _CAMINHO_ERROS. "erro401.php";});
}

Route::get('/{any}', function(){ require _CAMINHO_ERROS. "erro404.php";});
Route::get('/{any}/{any}', function(){ require _CAMINHO_ERROS. "erro404.php";});
Route::get('/{any}/{any}/{any}', function(){ require _CAMINHO_ERROS. "erro404.php";});

?>