use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
include("mail.class.php");
require("PHPMailer/src/PHPMailer.php");
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/SMTP.php';
include("browser_class_inc.php");
include("asido_nuevo/class.asido.php");
function convertidor($valor, $decimales=2)
{
return number_format($valor, $decimales, ',', '.');
}
function convertidor_float($valor)
{
return str_replace(",", ".", $valor);
}
// Redondea un numero decimal a tantos '$decimales'
function redondea($numero, $decimales=2){
$factor = pow(10, $decimales);
return (round($numero*$factor)/$factor);
}
function rellena_ceros($valor, $cuantos=4)
{
$longitud = strlen($valor);
if($longitud < $cuantos)
{
for($i=0;$i<($cuantos-$longitud);$i++) $valor = "0".$valor;
return $valor;
}
return floor($valor);
}
function fceil($val, $pressision=2){
$p = pow(10,$pressision);
$val = $val*$p;
$val = ceil($val);
return $val /$p;
}
function millares($valor)
{
if(is_numeric($valor))
{
$result = number_format($valor);
}
else
{
$partes = explode('.',$valor);
$tam = count($partes)-1;
$result = 0;
for($i=0;$i<=$tam;$i++)
{
$multiplicador = 1;
for($j=0;$j<$tam-$i;$j++)
{
$multiplicador = $multiplicador*1000;
}
if($i==$tam)
{
$coma = explode(',',$partes[$i]);
$tam2 = count($coma);
if($tam2>1)
{
$result += (int)$coma[0];
$result += (float)$coma[1]/1000;
}
else
{
$result += (int)$partes[$i];
}
}
else
{
$result += (int)$partes[$i]*$multiplicador;
}
}
//$result = number_format($result);
}
return $result;
}
function encriptar($str)
{
if (function_exists('sha1')) // Only in PHP 4.3.0+
return sha1($str);
else if (function_exists('mhash')) // Only if Mhash library is loaded
return bin2hex(mhash(MHASH_SHA1, $str));
else
return md5($str);
}
function enviar_mail($to, $subject, $message, $from, $attach='', $tipo_attach='')
{
// Limpiamos los parametros
$to = trim(preg_replace('#[\n\r]+#s', '', $to));
$subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
$from = trim(preg_replace('#[\n\r:]+#s', '', $from));
/*$m = new Mail;
$m->From($from);
$m->To($to);
$m->Subject($subject);
$m->Body($message, "ISO-8859-1");
$m->Priority(3);
if(!empty($attach)) $m->Attach($attach, $tipo_attach);
error_log("RDEV enviar_mail ".$from." ".$to);
$m->Send();*/
$mail = new PHPMailer(true);
//$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = "smtp.fempatramita.com";
$mail->Username = "no-reply@fempatramita.com";
$mail->Password = "Mia131f4";
$mail->From = "no-reply@fempatramita.com";
$mail->Port = 25;
$mail->Body = $message;
$mail->FromName = "FEMPATRAMITA";
$mail->addAddress($to);
$mail->SMTPAuth = true;
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
$mail->addReplyTo("no-reply@fempatramita.com", "no-reply");
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->send();
//$mail->AltBody = "This is the plain text version of the email content";
}
function pun_enviar_mail($to, $subject, $message, $from)
{
// Limpiamos los parametros
$to = trim(preg_replace('#[\n\r]+#s', '', $to));
$subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
$from = trim(preg_replace('#[\n\r:]+#s', '', $from));
$headers = 'From: '.$from."\r\n".'Date: '.date('r')."\r\n".'MIME-Version: 1.0'."\r\n".'Content-transfer-encoding: 8bit'."\r\n".'Content-type: text/plain; charset=UFT-8'."\r\n".'X-Mailer: PunBB Mailer';
$message = str_replace(array("\n", "\0"), array("\r\n", ''), pun_linebreaks($message));
mail($to, $subject, $message, $headers);
}
function get_remote_address(){
$s_hxff = $_SERVER['HTTP_X_FORWARDED_FOR'];
$s_ra = $_SERVER['REMOTE_ADDR'];
$e_ra = $_ENV['REMOTE_ADDR'];
$client_ip = empty($s_ra)?(empty($e_ra)?"unknown":$e_ra):$s_ra;
if ($s_hxff) {
// los proxys van a�adiendo al final de esta cabecera
// las direcciones ip que van "ocultando". Para localizar la ip real
// del usuario se comienza a mirar por el principio hasta encontrar
// una direcci�n ip que no sea del rango privado. En caso de no
// encontrarse ninguna se toma como valor el REMOTE_ADDR
$entries = explode('[, ]', $s_hxff);
reset($entries);
while (list(, $entry) = each($entries)) {
$entry = trim($entry);
if (preg_match('/^([0-9]+.[0-9]+.[0-9]+.[0-9]+)/', $entry, $client_ip)) {
// http://www.faqs.org/rfcs/rfc1918.html
$private_ip = array(
'/^(00)?0./',
'/^127.(00)?0.(00)?0.(00)?1/',
'/^192.168..*/',
'/^172.0?((1[6-9])|(2[0-9])|(3[0-1]))..*/',
'/^0?10..*/'
);
$found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
if ($client_ip != $found_ip) {
$client_ip = $found_ip;
break;
}
}
}
}
return addslashes($client_ip);
}
function pun_linebreaks($str)
{
return str_replace("\r", "\n", str_replace("\r\n", "\n", $str));
}
function createRandomPassword ($long = 5, $letras_min = true, $letras_max = false, $num = true) {
/*
* Permite generar contrasenhas de manera aleatoria.
*
* @$long: Especifica la longitud de la contrasenha
* @$letras_min: Podra usar letas en minusculas
* @$letras_max: Podra usar letas en mayusculas
* @$num: Podra usar numeros
*
* return string
*/
$salt = $letras_min?'abchefghknpqrstuvwxyz':'';
$salt .= $letras_max?'ACDEFHKNPRSTUVWXYZ':'';
$salt .= $num?(strlen($salt)?'2345679':'0123456789'):'';
if (strlen($salt) == 0) return '';
$i = 0;
$str = '';
srand((double)microtime()*1000000);
while ($i < $long) {
$num = rand(0, strlen($salt)-1);
$str .= substr($salt, $num, 1);
$i++;
}
return $str;
}
function query_navegador($user_agent) {
$navegadores = array(
'Chrome' => '/Chrome/i',
'Opera' => '/Opera/i',
'IE7 en Windows 7' => '@(Mozilla[/]4.0 [(]compatible; MSIE 7.[0-9]; Windows NT 6.1)([^/]+)@i',
'IE8 en Windows 7' => '@(Mozilla[/]4.0 [(]compatible; MSIE 8.[0-9]; Windows NT 6.1)([^/]+)@i',
'IE9 en Windows 7' => '@(Mozilla[/]5.0 [(]compatible; MSIE 9.[0-9]; Windows NT 6.1)([^/]+)@i',
'Mozilla en Windows' => '@(Mozilla[/]5.0 [(]Windows NT 5.1*)([^/]+)@i',
'Mozilla en Windows 7' => '@(Mozilla[/]5.0 [(]Windows NT 6.1*)([^/]+)@i',
'Mozilla Firefox 3+'=> '/(Firefox\/3\.[0-9]+)/i',
'Mozilla Firefox Versión Obsoleta'=> '/(Firebird)',
'Galeon' => '/Galeon/i',
'MyIE'=>'/MyIE/i',
'Lynx' => '/Lynx/i',
'Konqueror'=>'/Konqueror/i',
'Internet Explorer 9' => '/(MSIE 9\.[0-9]+)/i',
'Internet Explorer 8' => '/(MSIE 8\.[0-9]+)/i',
'Internet Explorer 7' => '/(MSIE 7\.[0-9]+)/i',
'Internet Explorer 6' => '/(MSIE 6\.[0-9]+)/i',
'Internet Explorer 5' => '/(MSIE 5\.[0-9]+)/i',
'Internet Explorer 4' => '/(MSIE 4\.[0-9]+)/i');
foreach($navegadores as $navegador=>$pattern){
//TODO VICENTE if (ereg($pattern, $user_agent))
if (preg_match($pattern, $user_agent))
return $navegador;
}
//return 'Desconocido';
return $user_agent;
}
function validar_navegador($url)
{
$b = new browser();
$aCual = $b->whatBrowser();
if($aCual['browsertype'] == "Firefox" && $aCual['platform'] == "Windows" && $aCual['bit'] == "64") redirect($url."?nav=".$aCual['browsertype']." ".$aCual['bit']." bits");
if($aCual['browsertype'] == "MSPIE" || $aCual['browsertype'] == "MSIE")
{
//if($aCual['version'] == "7.0;" && $aCual['bit'] == "64") redirect($url."?nav=".$aCual['browsertype']." ".$aCual['bit']." bits");
if($aCual['version'] == "6.0;") redirect($url."?nav=".$aCual['browsertype']);
if($aCual['version'] == "5.0;") redirect($url."?nav=".$aCual['browsertype']);
}
if($aCual['browsertype'] == "Lynx") redirect($url."?nav=".$aCual['browsertype']);
return $aCual;
}
function navegador_is_ie()
{
$navegadores = array(
'Internet Explorer 10' => '/(MSIE 10\.[0-9]+)/i',
'Internet Explorer 9' => '/(MSIE 9\.[0-9]+)/i',
'Internet Explorer 8' => '/(MSIE 8\.[0-9]+)/i',
'Internet Explorer 7' => '/(MSIE 7\.[0-9]+)/i',
'Internet Explorer 6' => '/(MSIE 6\.[0-9]+)/i',
'Internet Explorer 5' => '/(MSIE 5\.[0-9]+)/i',
'Internet Explorer 4' => '/(MSIE 4\.[0-9]+)/i');
foreach($navegadores as $navegador=>$pattern){
//TODO VICENTE if (ereg($pattern, $user_agent))
if (preg_match($pattern, $_SERVER['HTTP_USER_AGENT']))
return 1;
}
return 0;
}
function navegador_is_chrome()
{
$navegadores = array(
'Chrome' => '/(Chrome)/i');
foreach($navegadores as $navegador=>$pattern){
//TODO VICENTE if (ereg($pattern, $user_agent))
if (preg_match($pattern, $_SERVER['HTTP_USER_AGENT']))
return 1;
}
return 0;
}
function navegador_is_mozilla()
{
$navegadores = array(
'Mozilla' => '/(Mozilla)/i');
foreach($navegadores as $navegador=>$pattern)
{
if(navegador_is_ie()) return 0;
if (preg_match($pattern, $_SERVER['HTTP_USER_AGENT']))
return 1;
}
return 0;
}
function navegador_is_64bits()
{
$navegadores = array(
'WOW64' => '/(WOW64)/i');
foreach($navegadores as $navegador=>$pattern){
//TODO VICENTE if (ereg($pattern, $user_agent))
if (preg_match($pattern, $_SERVER['HTTP_USER_AGENT']))
return 1;
}
return 0;
}
function is_windows7()
{
$navegadores = array(
'W7' => '/(Windows NT 6.1)/i');
foreach($navegadores as $navegador=>$pattern){
//TODO VICENTE if (ereg($pattern, $user_agent))
if (preg_match($pattern, $_SERVER['HTTP_USER_AGENT']))
return 1;
}
return 0;
}
function navegador_is_ie_viejo()
{
$navegadores = array(
'Internet Explorer 8' => '/(MSIE 8\.[0-9]+)/i',
'Internet Explorer 7' => '/(MSIE 7\.[0-9]+)/i',
'Internet Explorer 6' => '/(MSIE 6\.[0-9]+)/i',
'Internet Explorer 5' => '/(MSIE 5\.[0-9]+)/i',
'Internet Explorer 4' => '/(MSIE 4\.[0-9]+)/i');
foreach($navegadores as $navegador=>$pattern){
//TODO VICENTE if (ereg($pattern, $user_agent))
if (preg_match($pattern, $_SERVER['HTTP_USER_AGENT']))
return 1;
}
return 0;
}
function redirect($url="")
{
if (empty($url)){
$url = 'http://www.fempa.es';
}
if (!headers_sent()){
header("Location: ".$url);
}
else {
echo "\r\n";
}
}
function fecha($donde){
$ingles = array("Monday","Tuesday","Wednesday","Thursday", "Friday", "Saturday", "Sunday", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$espanol = array("Lunes","Martes","Miércoles","Jueves","Viernes","Sábado","Domingo", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
$mes = str_replace($ingles, $espanol, date('F'));
$sRes = $donde.", ".date('d')." de ".$mes." de ".date('Y');
return $sRes;
}
function sube_fichero($fichero, $destino){
if(move_uploaded_file($fichero['tmp_name'], $destino))
return 1;
else
return 0;
}
function escalar_imagen($imagen, $destino, $size=0, $target='x'){
Asido::Driver('gd');
$im = Asido::Image($imagen, $destino);
if($target == 'x') Asido::Width($im, $size);
else Asido::Height($im, $size);
$im->Save(ASIDO_OVERWRITE_ENABLED);
return 1;
}
// Sube imagen al servidor y la redimensiona. Si x o y es cero, hace una escalada conservando proporciones
function sube_foto($imagen,$url_destino,$nombre,$x=0,$y=0) {
if($imagen == NULL) return 0;
if(!is_dir($url_destino)) return -1;
// Construimos la URL
if ($url_destino[strlen($url_destino)-1]=='/') $c = "";
else $c = "/";
$destino = $url_destino.$c.$nombre;
$im = new Imagick();
$im->readImage($imagen['tmp_name']);
if(!$im->valid()) return -2;
// Redimensionamos
if ($x>0 && $y>0) {
if($im->resizeImage($x, $y) == false) return -3;
}
if($im->writeImage($destino) == false) return -4;
$im->destroy();
chmod($destino, 0644);
return 1;
}/* sube_foto() */
/** Funci�n que devuelve una cadena con un array en JS.
* @param $arr :: array con los elementos que se desean insertar
* @returns $salida :: Cadena con estructura de Array
*/
function arrayPHPaJS($arr) {
$salida = "new Array(";
for ($i=0;$i Array a ordenar
* $field -> Campo del array por el que queremos ordenarlo (entre comillas).
* $inverse -> Su valor ser� true o false. El valor true lo ordenar� de manera descendente y el false (valor por defecto) lo ordenar� de manera ascendente.
*/
function orderMultiDimensionalArray ($toOrderArray, $field, $inverse = false)
{
$position = array();
$newRow = array();
foreach ($toOrderArray as $key => $row) {
$position[$key] = $row[$field];
$newRow[$key] = $row;
}
if ($inverse) {
arsort($position);
}
else {
asort($position);
}
$returnArray = array();
foreach ($position as $key => $pos) {
$returnArray[] = $newRow[$key];
}
return $returnArray;
}
function utf8_converter($array)
{
array_walk_recursive($array, function(&$item, $key){
if(!mb_detect_encoding($item, 'utf-8', true)){
$item = utf8_encode($item);
}
});
return $array;
}
function utf8_decoder($array)
{
array_walk_recursive($array, function(&$item, $key){
if(mb_detect_encoding($item, 'utf-8', true)){
$item = utf8_decode($item);
}
});
return $array;
}
/** Funci�n que convierte acentos en formato HTML tipo acute
* @param string $str : cadena a transformar
* @return string : cadena con acentos en HTML
* @author Ra�l Hussein Galindo (raul@globalmetanoia.com)
* @version 1 (16-02-2010)
*/
function cambiaAcentos($str)
{
if(is_utf($str))
{
$str = utf8_decode($str);
}
$str = htmlentities($str);
$str = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde|lig|cedil);/','$1',$str);
return html_entity_decode($str);
}
function query_extension_fichero($fichero)
{
return strtolower(substr($fichero, strrpos($fichero, '.')+1));
}
function fusiona_pdfs($pdf_a, $pdf_b, $pdf_resultado='')
{
if(empty($pdf_a) || empty($pdf_b)) return 0;
if(is_file(DOWNLOAD.$pdf_a) || is_file(DOWNLOAD.$pdf_b)) return 0;
if(query_extension_fichero(DOWNLOAD.$pdf_a) != "pdf" || query_extension_fichero(DOWNLOAD.$pdf_a) != "pdf") return 0;
if(empty($pdf_resultado)) $pdf_resultado = $pdf_a;
//TODO ES NECESARIO $oPdf =& new concat_pdf();
$oPdf =& new concat_pdf();
//$oPdf = new concat_pdf();
$oPdf->setFiles(array($pdf_a, $pdf_b));
$oPdf->concat();
$oPdf->Output($pdf_resultado, "F");
return 1;
}
function numberOfDecimals($value)
{
/*if ((int)$value == $value)
{
return 0;
}
else if (! is_numeric($value))
{
// throw new Exception('numberOfDecimals: ' . $value . ' is not a number!');
return 0;
}*/
if(strrpos($value, '.')) return strlen($value) - strrpos($value, '.') - 1;
if(strrpos($value, ',')) return strlen($value) - strrpos($value, ',') - 1;
return 0;
}
function rule_file_base64($filename)
{
if(!file_exists($filename)) return 0;
$binary = fread(fopen($filename, "r"), filesize($filename));
return base64_encode($binary);
}
?>Output has already been sent to the browser at /var/www/html/library/functions.inc.php:680.
Please make sure the command $xajax->processRequest() is placed before this.