\n"; $headers .= "Reply-To: " . "".mb_encode_mimeheader (mb_convert_encoding($from_email,"ISO-8859-1","AUTO")) ."" . "<".$from_email."> \n"; $headers .= "Content-Type: text/html;charset=ISO-8859-1 \n"; $email = explode(".", $email); $texto = ""; foreach($email as $linea){ $encoding = mb_detect_encoding($linea, 'ASCII,UTF-8,ISO-8859-1'); if ($encoding == "UTF-8") { $texto .= utf8_decode($linea); }else{ $texto .= $linea; } } return mail($direccion, $asunto, $texto, $headers); } /* Envía un correo */ function envia_correo_empleados($direccion, $asunto, $email){ $headers = "MIME-Version: 1.0 \n" ; $from_email = constante("email_rrhh"); $headers .= "From: " . "".mb_encode_mimeheader (mb_convert_encoding($from_email,"ISO-8859-1","AUTO")) ."" . "<".$from_email."> \n"; $headers .= "Reply-To: " . "".mb_encode_mimeheader (mb_convert_encoding($from_email,"ISO-8859-1","AUTO")) ."" . "<".$from_email."> \n"; $headers .= "Content-Type: text/html;charset=ISO-8859-1 \n"; $email = explode(".", $email); $texto = ""; foreach($email as $linea){ $encoding = mb_detect_encoding($linea, 'ASCII,UTF-8,ISO-8859-1'); if ($encoding == "UTF-8") { $texto .= utf8_decode($linea); }else{ $texto .= $linea; } } return mail($direccion, $asunto, $texto, $headers); } /* Consulta a la base de datos */ function consultar($cadena) { if ($puntero = conectar()){ if ($resultado = mysql_query($cadena, $puntero)) return $resultado; else return false; } else return false; } /* Devuelve el valor de una constante de sistema */ function constante($nombre){ if ($link = conectar()){ if ($resultado = mysql_query("select * from sistema where id='$nombre'",$link)){ $cont = mysql_num_rows($resultado); $row = mysql_fetch_array($resultado); $valor = $row["valor"]; } } return $valor; } /* Devuelve si la tabla está siendo modificada */ //function ocupado ($oid, $tabla){ // $seguimos = false; // if ($link = conectar()){ // if ($resultado = mysql_query("select mutex,tiempo from $tabla where oid = '".$oid."'",$link)){ // while ($row = mysql_fetch_array($resultado)){ // $mutex = $row["mutex"]; // $fecha = $row["tiempo"]; // $seguimos = true; // } // } // } // // //Si está bloqueado por el usuario que tiene sesión no se considera ocupado y puede entrar. // if($mutex == $_SESSION["oid"]) return false; // // if ($seguimos && ($mutex > 0)){ // /* Ahora tenemos que comparar la fecha almacenada con la actual. Si // la diferencia es mayor de 20 minutos, volvemos a poner el mutex a 0 // */ // list($a_m_d, $h_m_s) = split(" ",$fecha); // list($anio, $mes, $dia) = split("-",$a_m_d); // list($hora, $minuto, $segundo) = split(":",$h_m_s); // // $fecha_mutex = mktime($hora,$minuto,$segundo,$mes,$dia,$anio); // $fecha_ahora = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")); // // //Han pasado 1200 segundos? // $diferencia = $fecha_ahora - $fecha_mutex; // if ($diferencia >= 1200){ // //Ha caducado el semáforo, lo ponemos a cero // // if ($resultado = mysql_query("update $tabla set mutex=0 where oid = '".$oid."'",$link)){ // return false; // } // else return false; // } // else return true; // } // else{ // return false; // } // //} function formulario_campos(){ $contenido = ''; return $contenido; } function formulario_tablas(){ $contenido = ''; return $contenido; } /* Comprueba y libera un semáforo */ function liberacion(){ $liberar = stripinput($_GET["liberar"]); $tabla = stripinput($_POST["tabla_lib"]); $oid = stripinput($_POST["oid"]); if ($liberar == "si") $salida = liberar($oid, $tabla); } ///* Libera el semáforo de modificar tabla */ //function liberar ($oid, $tabla){ // $seguimos = false; // if ($link = conectar()){ // if ($resultado = mysql_query("select mutex,tiempo from $tabla where oid = '".$oid."'",$link)){ // while ($row = mysql_fetch_array($resultado)){ // $mutex = $row["mutex"]; // $fecha = $row["tiempo"]; // $seguimos = true; // } // } // } // // //No se pueden liberar semáforos de otros usuarios. // if($mutex != $_SESSION["oid"]) return false; // // if ($link = conectar()){ // if ($resultado = mysql_query("update $tabla set mutex=0 where oid = '".$oid."'",$link)){ // return true; // } // else return false; // } // else return false; //} // // ///** Bloquea el semáforo */ //function bloquear($oid, $tabla){ // if ($link = conectar()){ // $usr = $_SESSION["oid"]; // $consulta = "update ".$tabla." set mutex = '".$usr."' ,tiempo=now() where oid = '".$oid."'"; // // if ($resultado = mysql_query($consulta,$link)){ // return true; // } // else return false; // } // else return false; //} // Comprueba si un usuario tiene permisos para realizar una función. //TODO Deprecated function comprobar_permisos($right) { if ((in_array($right, explode(".", $_SESSION["permisos"]))) || (in_array($right, explode(".", $_SESSION["permisos_rol"])))) { return true; } else { return false; } } function menu_rol($rol){ if($link = conectar()){ $resultado = mysql_query("select * from opciones where menu='$rol'", $link); while($rows = mysql_fetch_array($resultado)){ $add = false; $permisos = explode(".", $rows['permisos']); foreach($permisos as $permiso){ if(comprobar_permisos($permiso)){ if($add == false){ echo '
!['.$rows['nombre'].'](css/'.$rows['img'].'.gif)
'.$rows['nombre'].'