-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·139 lines (113 loc) · 4.99 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* Ecomais Webpage
* @see Ecomais GitHub project
* @author Marcio Alemão <[email protected]>
* @author Carlos Alberto <[email protected]>
* @author Renata Genora <[email protected]>
* @author Fernando Jesus <[email protected]>
* @author Emanuel Café <[email protected]>
* @copyright 2019 Ecomais
* @license
*/
/**
* Dependências do projeto
* @package coffeecode/router - Gerenciamento de rotas http
* @package phpmailer/phpmailer - Envio de emails
* @package league/plates - Criação de templates
* @package league/oauth2-google - Autenticação com a conta do Google
* @package coffeecode/uploader - Upload de imagens
* @package marcio1002/render-file - Renderizar arquivos js e css
*/
/*
* Rotas vista pelos usuários são mostrada em português (pt-BR)
*/
require_once __DIR__ . "/vendor/autoload.php";
require_once __DIR__ . "/src/config/config.php";
$router = new CoffeeCode\Router\Router(BASE_URL);
ob_start();
ob_clean();
/**
* @namespace Web
* @link pagina principal
* Paginas principais como home,login,cadastro etc.
*/
$router
->namespace("Ecomais\Web")
->group(null);
$router->get("/", "Redirect:home", "home");
$router->get("/login", "Redirect:login", "home.login");
$router->get("/cadastro", "Redirect:registerUser", "home.cadastro");
$router->get("/cadastro/empresa", "Redirect:registerCompany", "home.empresa");
$router->get("/recuperarsenha", "Redirect:recoverPasswd", "home.recuperarsenha");
$router->get("/recuperarsenha/novasenha/{token}", "Redirect:newPasswd", "home.novasenha");
$router->get("/politica-privacidade-e-termos", "Redirect:terms", "home.politicahp");
$router->get("/teste/{chv}", "Redirect:test");
$router->group("error");
$router->get("/{errCode}", "Redirect:typeError", "httperro");
/**
* @group Empresa
*/
$router->group("company");
$router->get("/", "Redirect:indexCompany", "company.index");
$router->get("/configuracoes", "Redirect:configCompany", "company.configuracoes");
$router->get("/cadastro-de-produtos", "Redirect:registerProduct", "company.cadastroprodutos");
$router->get("/perfil", "Redirect:perfilCompany", "company.perfil");
/**
* @group User
*/
$router->group("user");
$router->get("/", "Redirect:indexUser", "user.index");
$router->get("/listadeprodutos", "Redirect:listProduct", "user.listarprodutos");
/**
* @namespace Controller
*
* rotas para os métodos de manipulações e controllers dos dados
* */
$router
->namespace("Ecomais\Controllers")
->group("manager");
$router->post("/login", "Main:login","manager.login");
$router->get("/logoff", "Main:logoff","manager.logoff");
$router->get("/logingoogle", "Main:loginAuthGoogle","manager.loginauthgoogle");
$router->get("/registergoogle", "Main:registerAuthGoogle","manager.registerauthgoogle");
$router->post("/getoauthurl", "Main:getOauthUrl","manager.getoauthurl");
$router->post("/recoverByKey", "Main:recoverByKey","manager.recoverbykey");
$router->post("/recoverByMail", "Main:recoverByMail","manager.recoverbymail");
$router->put("/recoverpasswd", "Main:recoverPasswd","manager.recoverpasswd");
$router->post("/newsletter", "Main:newsLetter","manager.newsletter");
/** rotas para Usuários */
$router
->namespace("Ecomais\Controllers\User")
->group("manager");
$router->post("/addaccountpersonphysical", "AccountManagerUser:createAccount","manager.user.addaccountpersonphysical");
/** rotas para Empresas*/
$router
->namespace("Ecomais\Controllers\Company")
->group("manager");
$router->post("/addaccountpersonlegal", "AccountManagerCompany:createAccount","manager.company.createaccount");
$router->get("/listencompany", "AccountManagerCompany:findAll","manager.company.findall");
$router->post("/findcompany", "AccountManagerCompany:findByIdJSON","manager.company.findbyidjson");
$router->get("/listencompanypro", "AccountManagerCompany:listenCompanyPro","manager.company.listencompanypro");
$router->put("/updateinfocompany", "AccountManagerCompany:updateInfoCompany","manager.company.updateinfocompany");
$router->post("/updateimagecompany", "AccountManagerCompany:updateImageCompany","manager.company.updateimagecompany");
$router->post("/searchcompany", "AccountManagerCompany:searchCompany","manager.company.searchcompany");
$router
->namespace("Ecomais\Controllers\Product")
->group("manager");
$router->post("/addproduct", "ProductManager:createProduct","manager.product.createproduct");
$router->put("/setstatus", "ProductManager:setStatus","manager.product.setstatus");
$router->post("/searchproduct", "ProductManager:searchProd","manager.product.searchprod");
$router->dispatch();
if ($router->error()) $router->redirect("/error/{$router->error()}");
function renderUrl(string $url = "home", ?array $params = null): string
{
global $router;
$baseUrl = BASE_URL;
if (preg_match("/^[\w]+\.[\w+\.+]*[\w]$/", $url) || preg_match("/^(home)$/", $url))
return $router->route($url, $params);
else
return ($url <=> "home") == 0 ? $baseUrl : "$baseUrl$url";
}
ob_end_flush();
mb_http_output('UTF-8');