HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux Bradford-Sitios 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 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: /var/www/gestor-horarios.bradford/app/helpers/debug_helper.php
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

function pre($string)
{
	echo "<pre>";
	print_r($string);
	echo "</pre>";
}

function pre_die($string)
{
	echo "<pre>";
	print_r($string);
	echo "</pre>";
	die();
}



function valida_sesion($token, $redirect = false)
{
	if (!empty($token)) {
		$usuarios = get_row_by_where('usuarios', array('remember_token' => $token));
		if (!empty($usuarios)) {
			define('USUARIO_ID', $usuarios->id);
			define('USUARIO_USERNAME', $usuarios->username);
			define('USUARIO_ROL', $usuarios->perfiles_id);
			if ($redirect) {
				if ($usuarios->es_admin || $usuarios->admin) {
					redirect('dashboard');
				} else {
					redirect('logout');
				}
			}
		} else {
			redirect('login');
		}
	} else {
		redirect('login');
	}
}


function formateaRut($rut)
{
	$rutLimpio = str_replace('.', '', $rut);
	$rutLimpio = trim(str_replace('-', '', $rutLimpio));
	$dvRut = substr($rutLimpio, -1);
	$rutLimpio = substr($rutLimpio, 0, -1);
	$rutFormateado = formatear_miles($rutLimpio) . '-' . $dvRut;
	return $rutFormateado;
}
function formatear_miles($numero)
{
	if (!empty($numero)) {
		$pesos = '' . number_format($numero, 0, ',', '.');
	} else {
		$pesos = "No aplica";
	}
	return $pesos;
}

function strUpper($str)
{
	$str = strtoupper(trim($str));
	$str = str_replace('á', 'Á', $str);
	$str = str_replace('é', 'É', $str);
	$str = str_replace('í', 'Í', $str);
	$str = str_replace('ó', 'Ó', $str);
	$str = str_replace('ú', 'Ú', $str);
	$str = str_replace('ñ', 'Ñ', $str);
	return $str;
}

function strLower($str)
{
	$str = strtolower(trim($str));
	$str = str_replace('Á', 'á', $str);
	$str = str_replace('É', 'é', $str);
	$str = str_replace('Í', 'í', $str);
	$str = str_replace('Ó', 'ó', $str);
	$str = str_replace('Ú', 'ú', $str);
	$str = str_replace('Ñ', 'ñ', $str);
	return $str;
}
function LimpiarCaracter($str)
{

	$str = str_replace('Á', 'A', $str);
	$str = str_replace('É', 'E', $str);
	$str = str_replace('Í', 'I', $str);
	$str = str_replace('Ó', 'O', $str);
	$str = str_replace('Ú', 'U', $str);
	$str = str_replace('Ñ', 'ñ', $str);
	$str = str_replace('á', 'a', $str);
	$str = str_replace('é', 'e', $str);
	$str = str_replace('í', 'i', $str);
	$str = str_replace('ó', 'o', $str);
	$str = str_replace('ú', 'u', $str);
	$str = str_replace('ñ', 'ñ', $str);
	$str = str_replace('"', '', $str);
	$str = str_replace("'", '', $str);
	$str = str_replace("`", '', $str);
	$str = trim($str);
	return $str;
}
function saludo()
{
	$saludo = ' ';
	$hora = date('H');
	$horario_dia   = ['05', '06', '07', '08', '09', '10', '11'];
	$horario_tarde = ['12', '13', '14', '15', '16', '17', '18', '19', '20', '21'];
	$horario_noche = ['22', '23', '00', '01', '02', '03', '04'];
	if (in_array($hora, $horario_dia)) {
		$saludo = 'Buenos Días ';
	}
	if (in_array($hora, $horario_tarde)) {
		$saludo = 'Buenas Tardes ';
	}
	if (in_array($hora, $horario_noche)) {
		$saludo = 'Buenas Noches ';
	}
	return $saludo;
}

function crear_carpeta_upload($articulo_id, $prefix)
{
	$ruta_contenido = ROOT_PATH_BASE . '/uploads/' . $prefix . $articulo_id . '/';

	if (is_dir($ruta_contenido)) {
		return $ruta_contenido;
	} else {
		mkdir($ruta_contenido, 0755, TRUE);
		return $ruta_contenido;
	}
}

function limpiarNumero($str)
{
	$str = trim($str);
	$str = preg_replace('([^0-9,])', '', $str);
	return $str;
}


function validate_password($password)
{
	// Mensajes de error personalizados
	$errors = [];
	// Caracteres permitidos
	$upperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	$lowerCase = 'abcdefghijklmnopqrstuvwxyz';
	$numbers = '0123456789';
	$specialCharacters = '!@#$%^&*()_+-=[]{}|;:,.<>?';

	// Reglas de validación
	if (empty($password)) {
		$errors[] = 'Contraseña requerida';
	} elseif (!is_string($password)) {
		$errors[] = 'Contraseña debe ser una cadena de texto';
	} elseif (strlen($password) < 8) {
		$errors[] = 'Contraseña debe tener al menos 8 caracteres';
	} elseif (!contains_character($password, $upperCase)) {
		$errors[] = 'Contraseña debe contener al menos una letra mayúscula';
	} elseif (!contains_character($password, $lowerCase)) {
		$errors[] = 'Contraseña debe contener al menos una letra minúscula';
	} elseif (!contains_character($password, $numbers)) {
		$errors[] = 'Contraseña debe contener al menos un número';
	} elseif (!contains_character($password, $specialCharacters)) {
		$errors[] = 'Contraseña debe contener al menos un carácter especial';
	}

	// Devuelve los errores si los hay
	return empty($errors) ? true : $errors;
}

function contains_character($string, $characterSet)
{
	for ($i = 0; $i < strlen($string); $i++) {
		if (strpos($characterSet, $string[$i]) !== false) {
			return true;
		}
	}
	return false;
}