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
|
<?php
date_default_timezone_set('America/Sao_Paulo');
// Obter o ip do usuário $ip = getenv("REMOTE_ADDR");
// Data e Hora $data_hj = date("d-m-Y"); $data_hora = date("d-m-Y H:i:s"); $data_hora_eua = date("Y-m-d H:i:s");
function data_hora_intervalo($intervalo){ $hora = date("H"); $minuto = date("i"); if(date("i") < $intervalo){ if(date("H") == 01){ $minuto = 00; } else{ $hora--; $intervalo = $intervalo - $minuto; $minuto = 59; $minuto = $minuto - $intervalo; } } else{ $minuto = date("i") -$intervalo; } $data_hora_intervalo = date("Y-m-d "). $hora . ":" . $minuto . date(":s"); return $data_hora_intervalo; }
$dia_hj = date("d"); $mes_hj = date("m"); $ano_hj = date("Y");
function modalAlerta($titulo, $texto) { print("<script>$(function(){modalAlerta(\"$titulo\",\"$texto\");});</script>"); }
function eventAnalytics($categoria, $acao, $etiqueta) { print("<script>$(function(){ gtag('event', '$acao', { 'event_category': '$categoria', 'event_label': '$etiqueta'}); });</script>"); }
// Função de Eliminação de qalquer comando que possa invadir ou alterar o sistema de forma indevida function anti_injection($sql){ $sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"), "" ,$sql); // remove palavras que contenham sintaxe sql $sql = trim($sql); // limpa espaços vazios $sql = strip_tags($sql); // tira tags html e php $sql = addslashes($sql); // adiciona barras invertidas a um string return $sql; }
// Função de redirecionamento de página function redireciona($string){ print ("<script language='JavaScript'>self.location.href=\"$string\";</script>"); die; }
function limitarTexto($texto, $limite){ $contador = strlen($texto); if ( $contador >= $limite ) { $texto = substr($texto, 0, strrpos(substr($texto, 0, $limite), ' ')) . '...'; return $texto; } else{ return $texto; } }
function converteAbrevMes($mes){ if($mes == "Jan"){ return '01'; } else if($mes == "Feb"){ return '02'; } else if($mes == "Mar"){ return '03'; } else if($mes == "Apr"){ return '04'; } else if($mes == "May"){ return '05'; } else if($mes == "June"){ return '06'; } else if($mes == "July"){ return '07'; } else if($mes == "Aug"){ return '08'; } else if($mes == "Sept"){ return '09'; } else if($mes == "Oct"){ return '10'; } else if($mes == "Nov"){ return '11'; } else if($mes == "Dec"){ echo '12'; } }
function preco($preco){ if($preco > 0){ echo "R$" . number_format($preco, 2, ',', ''); } else{ echo "R$0,00"; } }
?>
|