<?php

function myfloat($num){
    return floatval(preg_replace("/[^-0-9\.]/","", $num ));
}

function encrypt($str, $token = false)
{
    $key = "K3Dx";
    if ($token) $key = substr($token, 0,4);

    $block = mcrypt_get_block_size('des', 'ecb');
    $pad = $block - (strlen($str) % $block);
    $str .= str_repeat(chr($pad), $pad);
    return urlencode(mcrypt_encrypt(MCRYPT_DES, $key, $str, MCRYPT_MODE_ECB));
}

function decrypt($str, $token = false)
{
    $key = "K3Dx";
    if ($token) $key = substr($token, 0,4);

    $str = mcrypt_decrypt(MCRYPT_DES, $key, urldecode($str), MCRYPT_MODE_ECB);
    $block = mcrypt_get_block_size('des', 'ecb');
    $pad = ord($str[($len = strlen($str)) - 1]);
    return substr($str, 0, strlen($str) - $pad);
}

function timequery(){
   static $querytime_begin;
   list($usec, $sec) = explode(' ',microtime());
       if(!isset($querytime_begin))
      {
         $querytime_begin= ((float)$usec + (float)$sec);
      }
      else
      {
         $querytime = (((float)$usec + (float)$sec)) - $querytime_begin;
         return sprintf('%01.5f', $querytime);
      }
}

function log_this($file, $var){
    $pfile = fopen($file,'a+');
    fwrite($pfile,$var." \r\n\r\n");
    fclose($pfile);
}

function decs($var, $dec = 2){
          
   $float_redondeado=round($var * pow(10,$dec) ) / pow(10,$dec);
   return $float_redondeado;
}

function get_mes($mes){
    $meses = array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
    return $meses[$mes-1];
}



?>