-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcoes.php
43 lines (38 loc) · 1009 Bytes
/
funcoes.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
<?php
function caminho(){
$folder = 'paginas/';
$scanDir = array_diff(scandir($folder), array('..', '.'));
$rota = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$patch = explode("/", $rota['path']);
$X = array_filter($patch);
$file = end($X);
if(!is_file($folder.$file)){
$order = $file;
$file = array_pop($X);
$file = end($X);
}
if(is_dir('../'.$file.'/') == true){
$file = 'home';
};
if(in_array($file.'.php',$scanDir)){
return 'paginas/'.$file.'.php';
}else{
return 'paginas/'.'404.php';
}
};
/* FUNÇÃO PARA ORDENAR LISTA*/
function ordenaArray($arrayClientes){
$rota = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$patch = explode("/", $rota['path']);
//PEGO O ULTIMO ELEMENTO VALIDO DO ARRAY E VERIFICO SE ELE NÃO É UMA PASTA
$X = array_filter ($patch);
$order = end($X);
if($order == 'a-z'){
ksort($arrayClientes);
}
if($order == 'z-a'){
krsort($arrayClientes);
}
return $arrayClientes;
}
?>