2011-04-04 15:16:10 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
/* Verifica el formato de un correo electr<74>nico */
|
|
|
|
|
|
function verificar_mail ($cadena)
|
|
|
|
|
|
{
|
|
|
|
|
|
if($cadena == null) return false;
|
|
|
|
|
|
if (!strpos($cadena, "@")) return false;
|
|
|
|
|
|
if (!strpos($cadena, ".")) return false;
|
|
|
|
|
|
if (strlen($cadena) < 5) return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Verifica el formato de un cadena alfab<61>tica */
|
|
|
|
|
|
function verificar_alfabetico ($cadena)
|
|
|
|
|
|
{
|
|
|
|
|
|
//if (!ereg("^[a-zA-Záéíóú ]+$",$cadena)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Verifica el formato de un cadena de letras */
|
|
|
|
|
|
function verificar_letra ($cadena)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!ereg("^[a-zA-Z]+$",$cadena)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Verifica el formato de un n<>mero */
|
|
|
|
|
|
function verificar_numerico ($cadena, $dig)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!ereg("^[0-9]+$",$cadena)) return false;
|
|
|
|
|
|
if (strlen($cadena) != $dig) return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Verifica la longitud de una cadena */
|
|
|
|
|
|
function verificar_longitud ($cadena, $dig)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (strlen($cadena) != $dig) return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Verifica el formato de un n<>mero */
|
|
|
|
|
|
function es_numerico ($cadena)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!ereg("^[0-9]+$",$cadena)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Verifica que el dato forme parte de un posible estado del d<>a del parte de actividad.
|
|
|
|
|
|
function verificar_dato($dato){
|
|
|
|
|
|
if ((ereg("^[0-9]+(,[0-9]+)*$",$dato) && ($dato < 25)) || ereg("V",$dato) || ereg("AJ",$dato) || ereg("AN",$dato) || ereg("B",$dato) || ereg("VP",$dato)) return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Comprueba si existe alguien por un dni, nombre y apellidos y email
|
|
|
|
|
|
function existe($dni, $nombre, $apellidos, $email, $oid){
|
|
|
|
|
|
$existe = array();
|
2011-04-06 18:00:22 +00:00
|
|
|
|
$link = conectar();
|
|
|
|
|
|
|
2011-04-04 15:16:10 +00:00
|
|
|
|
/** EXISTENCIA DE DNI **/
|
|
|
|
|
|
|
|
|
|
|
|
//Si hay letra en la posici<63>n 7 es porque el DNI empezaba por cero y se le ha quitado
|
2011-04-06 18:00:22 +00:00
|
|
|
|
if (isset($dni)) {
|
|
|
|
|
|
if (!es_numerico($dni[7])) {
|
|
|
|
|
|
$letra = $dni[7];
|
|
|
|
|
|
$cont=8;
|
|
|
|
|
|
while(!verificar_letra($letra) && $cont < 11){
|
|
|
|
|
|
$letra = $dni[$cont];
|
|
|
|
|
|
$cont++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$nums = "0".substr($dni, 0, 7);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$letra = $dni[8];
|
|
|
|
|
|
$cont=9;
|
|
|
|
|
|
while(!verificar_letra($letra) && $cont < 12){
|
|
|
|
|
|
$letra = $dni[$cont];
|
|
|
|
|
|
$cont++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$nums = substr($dni, 0, 8);
|
2011-04-04 15:16:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-04-06 18:00:22 +00:00
|
|
|
|
$letra = strtoupper($letra);
|
2011-04-04 15:16:10 +00:00
|
|
|
|
|
2011-04-06 18:00:22 +00:00
|
|
|
|
$dni = $nums.$letra;
|
|
|
|
|
|
|
|
|
|
|
|
$resultado = mysql_query("select dni from usuarios where oid <> '$oid' and dni='$dni'",$link);
|
|
|
|
|
|
$num = mysql_num_rows($resultado);
|
2011-04-04 15:16:10 +00:00
|
|
|
|
|
2011-04-06 18:00:22 +00:00
|
|
|
|
if($num > 0){
|
|
|
|
|
|
$existe[0] = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$existe[0] = 0;
|
2011-04-04 15:16:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** EXISTENCIA DE CORREO ELECTR<54>NICO **/
|
2011-04-06 18:00:22 +00:00
|
|
|
|
if ((isset($dni)) && ($dni != '')) {
|
|
|
|
|
|
$resultado = mysql_query("select email from usuarios where oid <> '$oid' and email='$email'",$link);
|
|
|
|
|
|
$num = mysql_num_rows($resultado);
|
2011-04-04 15:16:10 +00:00
|
|
|
|
|
2011-04-06 18:00:22 +00:00
|
|
|
|
if($num > 0){
|
|
|
|
|
|
$existe[1] = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$existe[1] = 0;
|
2011-04-04 15:16:10 +00:00
|
|
|
|
}
|
2011-04-06 18:00:22 +00:00
|
|
|
|
|
2011-04-04 15:16:10 +00:00
|
|
|
|
|
|
|
|
|
|
/** EXISTENCIA DE NOMBRE Y APELLIDOS **/
|
|
|
|
|
|
|
|
|
|
|
|
if($nombre == "-"){
|
|
|
|
|
|
$dato = " ";
|
2011-04-06 18:00:22 +00:00
|
|
|
|
} else {
|
2011-04-04 15:16:10 +00:00
|
|
|
|
$dato = $nombre;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$total = trim($dato." ".$apellidos);
|
|
|
|
|
|
|
|
|
|
|
|
$consulta = "select email from usuarios where oid <> '$oid' and CONCAT(nombre,' ',apellidos)='$total' or apellidos='$total'";
|
|
|
|
|
|
$resultado = mysql_query($consulta,$link);
|
|
|
|
|
|
$num = mysql_num_rows($resultado);
|
|
|
|
|
|
|
|
|
|
|
|
if($num > 0){
|
|
|
|
|
|
$existe[2] = 1;
|
2011-04-06 18:00:22 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
$existe[2] = 0;
|
2011-04-04 15:16:10 +00:00
|
|
|
|
}
|
2011-04-06 18:00:22 +00:00
|
|
|
|
|
2011-04-04 15:16:10 +00:00
|
|
|
|
return $existe;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|