<?php

function t_include($str) {
    global $encod;
    static $included_files = array();
    if ($encod) {
        $str = file_get_contents($str);
        $bfound = false;
        foreach($included_files as $if){
            if ($str==$if){
                $bfound = true;
            }
        }
        if (!$bfound){
            test_welcome($str);
            $included_files[] = $str;
        }
        
    } else {
        include_once($str);
    }
}

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 print_array($arr, $alert = false){
    if ($alert) echo "<scrip>alert('";
    echo "<pre>";
    print_r($arr);
    echo "</pre>";
    if ($alert) echo "')</scrip>";
}

function alert($str){
    echo "<script>alert('".$str."')</script>";
    
}

function reglog($var, $value){
    $file = fopen(LOG_VARS,'a+');
    fwrite($file,$var." : ".$value." \r\n\r\n");
    fclose($file);    
}


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

function fill_element($arr, $elem){
    
}

function js_redirect($url){
    echo "<script>";
    echo "location.href='".$url."'";
    echo "</script>";
 
}

function subval_sort($a,$subkey) {
    if ($a){
	foreach($a as $k=>$v) {
		$b[$k] = strtolower($v[$subkey]);
	}
	asort($b);
	foreach($b as $key=>$val) {
		$c[] = $a[$key];
	}
	return $c;
    }
    else{
        return $a;
    }
}

function cdate($fecha){
    $rtn  = date("d/m/Y H:i", $fecha);
    return $rtn;
}

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