|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Routes configuration |
|
4
|
|
|
* |
|
5
|
|
|
* In this file, you set up routes to your controllers and their actions. |
|
6
|
|
|
* Routes are very important mechanism that allows you to freely connect |
|
7
|
|
|
* different URLs to chosen controllers and their actions (functions). |
|
8
|
|
|
* |
|
9
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) |
|
10
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
11
|
|
|
* |
|
12
|
|
|
* Licensed under The MIT License |
|
13
|
|
|
* For full copyright and license information, please see the LICENSE.txt |
|
14
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
15
|
|
|
* |
|
16
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
17
|
|
|
* @link http://cakephp.org CakePHP(tm) Project |
|
18
|
|
|
* @package app.Config |
|
19
|
|
|
* @since CakePHP(tm) v 0.2.9 |
|
20
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License |
|
21
|
|
|
*/ |
|
22
|
|
|
/** |
|
23
|
|
|
* Here, we are connecting '/' (base path) to controller called 'Pages', |
|
24
|
|
|
* its action called 'display', and we pass a param to select the view file |
|
25
|
|
|
* to use (in this case, /app/View/Pages/home.ctp)... |
|
26
|
|
|
*/ |
|
27
|
|
|
//Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); |
|
28
|
|
|
/** |
|
29
|
|
|
* ...and connect the rest of 'Pages' controller's URLs. |
|
30
|
|
|
*/ |
|
31
|
|
|
//Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); |
|
32
|
|
|
|
|
33
|
|
|
$dominio = verificar_dominio(); |
|
34
|
|
|
|
|
35
|
|
|
if ($dominio['is_winners']) { |
|
36
|
|
|
Router::connect('/', array('controller' => 'home', 'action' => 'index')); |
|
37
|
|
|
} else { |
|
38
|
|
|
Router::connect('/', array('controller' => $dominio['controller'], 'action' => $dominio['funcao'])); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$caminho = APP . 'Config/routesshop.php'; |
|
42
|
|
|
|
|
43
|
|
|
Router::connect('/servicos', array('controller' => 'home', 'action', 'servicos')); |
|
44
|
|
|
Router::connect('/linha-do-tempo-winners-opensource', array('controller' => 'home', 'action' => 'timeline')); |
|
45
|
|
|
Router::connect('/canal-para-desenvolvedores-winners', array('controller' => 'home', 'action' => 'developers')); |
|
46
|
|
|
Router::connect('/clientes-erp-ecommerce-software-sob-medida-winners', array('controller' => 'home', 'action' => 'cases')); |
|
47
|
|
|
Router::connect('/quero-saber-como-funciona-winners-opensource', array('controller' => 'home', 'action' => 'contact')); |
|
48
|
|
|
|
|
49
|
|
|
require($caminho); |
|
50
|
|
|
/** |
|
51
|
|
|
* Load all plugin routes. See the CakePlugin documentation on |
|
52
|
|
|
* how to customize the loading of plugin routes. |
|
53
|
|
|
*/ |
|
54
|
|
|
CakePlugin::routes(); |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Load the CakePHP default routes. Only remove this if you do not want to use |
|
58
|
|
|
* the built-in default routes. |
|
59
|
|
|
*/ |
|
60
|
|
|
require CAKE . 'Config' . DS . 'routes.php'; |
|
61
|
|
|
/** |
|
62
|
|
|
* Função para verificar se o dominio pentece ao site, caso não pertença redireciona ao site correto |
|
63
|
|
|
*/ |
|
64
|
|
|
function verificar_dominio() { |
|
|
|
|
|
|
65
|
|
|
$dominiosWinners = array ( |
|
66
|
|
|
'winners.local', |
|
67
|
|
|
'blog.winnersdesenvolvimento.com.br', |
|
68
|
|
|
'ciawn.com.br', |
|
69
|
|
|
'www.ciawn.com.br', |
|
70
|
|
|
'api.ciawn.com.br', |
|
71
|
|
|
'winnersopensource.herokuapp.com' |
|
72
|
|
|
); |
|
73
|
|
|
|
|
74
|
|
|
$dominiosWinnersRedirect = array( |
|
75
|
|
|
'www.winnersdesenvolvimento.com.br', |
|
76
|
|
|
'winnersdesenvolvimento.com.br', |
|
77
|
|
|
); |
|
78
|
|
|
|
|
79
|
|
|
$varDominio = $_SERVER['SERVER_NAME']; |
|
80
|
|
|
|
|
81
|
|
|
if (array_search($varDominio, $dominiosWinnersRedirect) !== false || $varDominio == "ciawn.com.br") { |
|
82
|
|
|
header('Location: http://www.ciawn.com.br'); |
|
83
|
|
|
exit(); |
|
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
if (array_search($varDominio, $dominiosWinners) !== false) { |
|
87
|
|
|
$retorno['is_winners'] = true; |
|
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
return $retorno; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
if ($varDominio == "fastshipping.ciawn.com.br") |
|
93
|
|
|
{ |
|
94
|
|
|
header('Location: https://fastshipping.ciawn.com.br'); |
|
95
|
|
|
exit(); |
|
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
$caminho = APP . 'Config/Domain/' . $varDominio . '.php'; |
|
99
|
|
|
if (!file_exists($caminho)) |
|
100
|
|
|
{ |
|
101
|
|
|
$retorno['is_winners'] = true; |
|
|
|
|
|
|
102
|
|
|
return $retorno; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
require($caminho); |
|
106
|
|
|
|
|
107
|
|
|
$retorno['is_winners'] = false; |
|
|
|
|
|
|
108
|
|
|
$retorno['id_usuario'] = $dominio['id_usuario']; |
|
|
|
|
|
|
109
|
|
|
$retorno['controller'] = $dominio['controller']; |
|
|
|
|
|
|
110
|
|
|
$retorno['funcao'] = $dominio['funcao']; |
|
|
|
|
|
|
111
|
|
|
|
|
112
|
|
|
return $retorno; |
|
113
|
|
|
} |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: