-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
103 lines (71 loc) · 1.46 KB
/
functions.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
<?php
error_reporting(E_ALL & ~E_NOTICE);
function privateFuntion()
{
if(empty($_SESSION["email"]))
{
send(null,"Tu sesion ha expirado. Vuelve a loguearte","error");
}
else
{
UpdateUserSession($_SESSION["email"]);
}
}
function getData()
{
$json = json_decode(file_get_contents('php://input'), true);
return $json["data"];
}
function connect()
{
$mysqli = new mysqli("localhost", "vnezuela_jose", "a4367433*", "vnezuela_estacionamiento");
if ($mysqli->connect_errno)
{
echo "Fallo al conectar a MySQL: " . $mysqli->connect_error;
}
else
{
if (!$mysqli->set_charset("utf8"))
{
printf("Error cargando el conjunto de caracteres utf8: %s\n", $this->enlace->error);
}
else
{
return $mysqli;
}
}
}
function emailExists($email,$id=0)
{
$mysqli = connect();
if($id!=0)
{
$sql="SELECT * FROM users where email='".$email."' and id<>$id";
}
else
{
$sql="SELECT * FROM users where email='".$email."'";
}
$myArray = array();
if ($result = $mysqli->query($sql))
{
$numberRows=$result->num_rows;
if($numberRows>0)
{
$result = true;
}
else
{
$result = false;
}
}
$mysqli->close();
return $result;
}
function send($data,$msj=false,$result="success")
{
$myArray=array("data"=>$data, "msj"=>$msj, "result"=>$result);
echo json_encode($myArray);
exit();
}
?>