HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux aritmodecarnaval.es 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/www/torresncgolf/instalaciones/system_old/application/helpers/util_helper.php
<?php
function load_template($vista, $argumentos=array()) {
    $CI = &get_instance();
    
    if (!$CI->session->userdata('user_logged_in')) {
       registrar_evento('login', 'info', "Esta logeado:".$CI->session->userdata('user_logged_in') );
	//redirect('login'); 
	load_template_public($vista,$argumentos);
    }
    
    // Enlaces que siempre aparecen
    $enlaces = array("Inicio"=>"/", "Perfil"=>"/index.php/perfil");
    $who_is_logged = "";
    // Enlaces que sólo se ven cuando un usuario está logueado
    if ($CI->session->userdata('user_logged_in')) {
        $who_is_logged = $CI->session->userdata('alias');
        if ($who_is_logged) {
            $enlaces = array_merge($enlaces, array("Foro"=>"/index.php/foro"));
            $enlaces = array_merge($enlaces, array("Reservas"=>"/index.php/reservas"));
        }
		if ($CI->session->userdata('user_is_admin')){
            $enlaces = array_merge($enlaces, array("Administrar"=>"/index.php/admin"));
        }
    }
    
    $data = array("links"=>$enlaces, "who_is_logged"=>$who_is_logged);

    $CI->load->view('templates/links', $data);
    $CI->load->view('templates/header');

    $CI->load->view($vista, $argumentos);
    $CI->load->view('templates/footer');
}

function load_template_public($vista) {
    $CI = &get_instance();
    
    // Enlaces que siempre aparecen
    //$enlaces = array("Inicio"=>"#", "Final"=>"#");
    $enlaces = array("Inicio"=>"/");
    $who_is_logged = "";
    // Enlaces que sólo se ven cuando un usuario está logueado
    if ($CI->session->userdata('user_logged_in')) {
        $who_is_logged = $CI->session->userdata('alias');
        if ($who_is_logged) {
            $enlaces = array_merge($enlaces, array("Reservar"=>"/index.php/reservas"));
        }
    }
    
    $data = array("links"=>$enlaces, "who_is_logged"=>$who_is_logged);

    

    $CI->load->view('templates/links', $data);
	$CI->load->view('templates/header');
    $CI->load->view($vista);
    $CI->load->view('templates/footer');
}

function generatePassword($length = 9, $strength = 0) {
    $vowels = 'aeuy';
    $consonants = 'bdghjmnpqrstvz';
    if ($strength & 1) {
        $consonants .= 'BDGHJLMNPQRSTVWXZ';
    }
    if ($strength & 2) {
        $vowels .= "AEUY";
    }
    if ($strength & 4) {
        $consonants .= '23456789';
    }
    if ($strength & 8) {
        $consonants .= '@#$%';
    }
    
    $password = '';
    $alt = time() % 2;
    for ($i = 0; $i < $length; $i++) {
        if ($alt == 1) {
            $password .= $consonants[(rand() % strlen($consonants))];
            $alt = 0;
        } else {
            $password .= $vowels[(rand() % strlen($vowels))];
            $alt = 1;
        }
    }
    return $password;
}



function dejar_numericos($cadena){
	return preg_replace('/[^\d-]/', '', $cadena);
}


function dejar_alfanumericos($cadena){
	return preg_replace('/[^\w-_]/', '', $cadena);
}

function dejar_alfanumericos_y_espacios($cadena){
	return preg_replace('/[^\s\w-_]/', '', $cadena);
}

function registrar_evento($controlador, $tipo_evento, $descripcion ,$usuario_id=0, $reserva_id=0, $comentario_id=0){
        $CI = &get_instance();
        $fecha_ahora = new DateTime("now", new DateTimeZone('Europe/Madrid'));
        $timestamp_ahora = $fecha_ahora->format('U') + $fecha_ahora->format('Z');
		$horario_verano = $fecha_ahora->format('I');
        if ($horario_verano == 1){
          $timestamp_ahora+=3600;
        }
        $fecha_ahora_mysql = date('Y-m-d H:i:s',$timestamp_ahora);

        if ($CI->db->query('INSERT INTO log (fecha, controlador, tipo, descripcion, usuario_id, reserva_id, comentario_id) VALUES(\''.$fecha_ahora_mysql .'\',\''. $controlador .'\',\''.$tipo_evento.'\',\''. $descripcion .'\',\''. $usuario_id .'\',\''. $reserva_id .'\',\''. $comentario_id .'\')' )) {
            return 0;
        }else{
            return -1;
        }
}

?>