Initial Commit
This commit is contained in:
63
include/bd_pdo.php
Normal file
63
include/bd_pdo.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
require_once "{$_SERVER['DOCUMENT_ROOT']}/vendor/autoload.php";
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv->load();
|
||||
use \SeinopSys\PostgresDb;
|
||||
|
||||
# Connect to the database
|
||||
try {
|
||||
// Postgres
|
||||
$pdo = new PDO("pgsql:host=" . $_ENV['DB_HOST'] . ";dbname=" . $_ENV['DB_NAME'], $_ENV['DB_USER'], $_ENV['DB_PASS']);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$db = new PostgresDb();
|
||||
$db->setConnection($pdo);
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
|
||||
// check recursivelly if the array has only empty strings
|
||||
function is_response_empty($array)
|
||||
{
|
||||
foreach ($array as $value) {
|
||||
if (is_array($value)) {
|
||||
if (!is_response_empty($value)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!empty($value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// SQL function
|
||||
function query(string $sql, array $params = null, bool $single = true)
|
||||
{
|
||||
global $pdo;
|
||||
try {
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$response = $single ? $stmt->fetch(PDO::FETCH_ASSOC) : $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $response;
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
return false;
|
||||
} finally {
|
||||
$stmt->closeCursor();
|
||||
$stmt = null;
|
||||
}
|
||||
}
|
||||
|
||||
function queryAll(string $sql, array $params = null)
|
||||
{
|
||||
return query($sql, $params, false);
|
||||
}
|
||||
|
||||
function toSQLArray(array $array): string
|
||||
{
|
||||
return sprintf("{%s}", implode(", ", $array));
|
||||
}
|
||||
63
include/bd_pdo_rest.php
Normal file
63
include/bd_pdo_rest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
require_once "/saa_dsk/www/vendor/autoload.php";
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv->load();
|
||||
use \SeinopSys\PostgresDb;
|
||||
|
||||
# Connect to the database
|
||||
try {
|
||||
// Postgres
|
||||
$pdo = new PDO("pgsql:host=" . $_ENV['DB_HOST'] . ";dbname=" . $_ENV['DB_NAME'], $_ENV['DB_USER'], $_ENV['DB_PASS']);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$db = new PostgresDb();
|
||||
$db->setConnection($pdo);
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
|
||||
// check recursivelly if the array has only empty strings
|
||||
function is_response_empty($array)
|
||||
{
|
||||
foreach ($array as $value) {
|
||||
if (is_array($value)) {
|
||||
if (!is_response_empty($value)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!empty($value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// SQL function
|
||||
function query(string $sql, array $params = null, bool $single = true)
|
||||
{
|
||||
global $pdo;
|
||||
try {
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$response = $single ? $stmt->fetch(PDO::FETCH_ASSOC) : $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $response;
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
return false;
|
||||
} finally {
|
||||
$stmt->closeCursor();
|
||||
$stmt = null;
|
||||
}
|
||||
}
|
||||
|
||||
function queryAll(string $sql, array $params = null)
|
||||
{
|
||||
return query($sql, $params, false);
|
||||
}
|
||||
|
||||
function toSQLArray(array $array): string
|
||||
{
|
||||
return sprintf("{%s}", implode(", ", $array));
|
||||
}
|
||||
146
include/constantes.php
Normal file
146
include/constantes.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
$ICO =[
|
||||
"mas"=>'<span class="ing-mas ing-fw"></span>',
|
||||
"menos"=>'<span class="ing-menos ing-fw"></span>',
|
||||
"editar"=>'<span class="ing-editar ing-fw"></span>',
|
||||
"borrar"=>'<span class="ing-borrar ing-fw"></span>',
|
||||
"borrar2"=>'<span class="ing-basura ing-fw"></span>',
|
||||
"cancelar"=>'<span class="ing-cancelar ing-fw"></span>',
|
||||
"buscar"=>'<span class="ing-buscar ing-fw"></span>',
|
||||
"descargar"=>'<span class="ing-descarga ing-fw"></span>',
|
||||
"cargar"=>'<span class="ing-carga-archivo ing-fw"></span>',
|
||||
"ver"=>'<span class="ing-ver ing-fw"></span>',
|
||||
"cambiar"=>'<span class="ing-cambiar ing-fw"></span>',
|
||||
"circulo"=>'<span class="ing-bullet ing-fw"></span>',
|
||||
"aceptar"=>'<span class="ing-aceptar ing-fw"></span>',
|
||||
"alerta"=>'<span class="ing-importante ing-fw"></span>',
|
||||
"calendario"=>'<span class="ing-eventos ing-fw"></span>',
|
||||
"ojo"=>'<span class="ing-ojo ing-fw"></span>',
|
||||
"profesor"=>'<span class="ing-formacion ing-fw"></span>',
|
||||
|
||||
"lista"=>'<span class="fas fa-list fa-fw"></span>',
|
||||
"lista_check"=>'<span class="ing-listado-menus ing-fw"></span>',
|
||||
"abajo"=>'<span class="ing-caret ing-fw"></span>',
|
||||
"arriba"=>'<span class="ing-caret ing-rotate-180 ing-fw"></span>',
|
||||
"izquierda"=>'<span class="ing-caret ing-rotate-90 ing-fw"></span>',
|
||||
"derecha"=>'<span class="ing-caret ing-rotate-270 ing-fw"></span>',
|
||||
];
|
||||
$ICO_LG =[
|
||||
"mas"=>'<span class="ing-mas ing-fw ing-lg"></span>',
|
||||
"menos"=>'<span class="ing-menos ing-fw ing-lg"></span>',
|
||||
"editar"=>'<span class="ing-editar ing-fw ing-lg"></span>',
|
||||
"borrar"=>'<span class="ing-borrar ing-fw ing-lg"></span>',
|
||||
"borrar2"=>'<span class="ing-basura ing-fw ing-lg"></span>',
|
||||
"cancelar"=>'<span class="ing-cancelar ing-fw ing-lg"></span>',
|
||||
"buscar"=>'<span class="ing-buscar ing-fw ing-lg"></span>',
|
||||
"descargar"=>'<span class="ing-descarga ing-fw ing-lg"></span>',
|
||||
"cargar"=>'<span class="ing-carga-archivo ing-fw ing-lg"></span>',
|
||||
"ver"=>'<span class="ing-reporte-resultados ing-fw ing-lg"></span>',
|
||||
"cambiar"=>'<span class="ing-cambiar ing-fw ing-lg"></span>',
|
||||
"circulo"=>'<span class="ing-bullet ing-fw ing-lg"></span>',
|
||||
"aceptar"=>'<span class="ing-aceptar ing-fw ing-lg"></span>',
|
||||
"alerta"=>'<span class="ing-importante ing-fw ing-lg"></span>',
|
||||
"calendario"=>'<span class="ing-eventos ing-fw ing-lg"></span>',
|
||||
"ojo"=>'<span class="ing-ojo ing-fw ing-lg"></span>',
|
||||
"profesor"=>'<span class="ing-formacion ing-fw ing-lg"></span>',
|
||||
|
||||
"lista"=>'<span class="fas fa-list fa-fw ing-lg"></span>',
|
||||
"lista_check"=>'<span class="ing-listado-menus ing-fw ing-lg"></span>',
|
||||
"abajo"=>'<span class="ing-caret ing-fw ing-lg"></span>',
|
||||
"arriba"=>'<span class="ing-caret ing-rotate-180 ing-fw ing-lg"></span>',
|
||||
|
||||
/*
|
||||
"insert"=>'<span class="fas fa-plus fa-fw fa-lg"></span>',
|
||||
"update"=>'<span class="fas fa-pen fa-fw fa-lg"></span>',
|
||||
"delete"=>'<span class="fas fa-trash-alt fa-fw fa-lg"></span>',
|
||||
"search"=>'<span class="fas fa-search fa-fw fa-lg"></span>',
|
||||
"insert_box"=>'<span class="fas fa-plus-square fa-fw fa-lg"></span>',
|
||||
"update_box"=>'<span class="fas fa-pen-square fa-fw fa-lg"></span>',
|
||||
"delete_box"=>'<span class="fas fa-minus-square fa-fw fa-lg"></span>',
|
||||
"error"=>'<span class="fas fa-times fa-fw fa-lg"></span>',
|
||||
"error_circle"=>'<span class="fas fa-times-circle fa-fw fa-lg"></span>',
|
||||
"ok"=>'<span class="fas fa-check fa-fw fa-lg"></span>',
|
||||
"ok_circle"=>'<span class="fas fa-check-circle fa-fw fa-lg"></span>',
|
||||
"list"=>'<span class="fas fa-list fa-fw fa-lg"></span>',
|
||||
"circulo"=>'<span class="ing-bullet fa-fw fa-lg"></span>',
|
||||
"question_circle"=>'<span class="fas fa-question-circle fa-fw fa-lg"></span>',
|
||||
"info_circle"=>'<span class="fas fa-info-circle fa-fw fa-lg"></span>',
|
||||
"square_check"=>'<span class="fas fa-circle fa-fw fa-lg"></span>',
|
||||
"square_empty"=>'<span class="far fa-circle fa-fw fa-lg"></span>',
|
||||
"eraser"=>'<span class="fas fa-eraser fa-fw fa-lg"></span>',*/
|
||||
];
|
||||
|
||||
$ICO_RND =[
|
||||
"right"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="icon icon-right fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
"left"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="icon icon-left fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
"error"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="fas fa-times fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
"error_circle"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="icon icon-error fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
"ok_circle"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="icon icon-correct fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
"ok"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="icon icon-chk fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
"close"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="icon icon-close fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
"next"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="icon icon-arrow fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
"back"=>'<span class="fa-stack float-right">
|
||||
<i class="fas fa-circle fa-stack-2x"></i>
|
||||
<i class="icon icon-arrowprev fa-stack-1x" style="color:white"></i>
|
||||
</span>',
|
||||
];
|
||||
|
||||
//Sistemas registrados
|
||||
define("APSA", 1);
|
||||
define("GEMA", 2);
|
||||
define("CIDIT", 3);
|
||||
define("CONSTANCIA", 5);
|
||||
define("EXPOING", 7);
|
||||
|
||||
define("MAX_ROWS", 30);
|
||||
|
||||
define("HORA_INICIO", 6);//hora inicial de horario
|
||||
define("HORA_FINAL", 22);//hora final de horario
|
||||
define("FRACCION_HORA", 4);//fracciones en una hora
|
||||
|
||||
define("DURACION_MIN", 60);//hora inicial de horario
|
||||
define("DURACION_MAX", 360);//hora final de horario
|
||||
define("DURACION_STEP", 15);//fracciones en una hora
|
||||
|
||||
define("FACULTAD", "Facultad de Ingeniería");
|
||||
//define("NOMBRE_DIRECTOR", "Ing. Edmundo G. Barrera Monsiváis");
|
||||
|
||||
define("PE_INI", "PE_INI$");
|
||||
define("PE_INI_Y", "PE_INI_Y$");
|
||||
define("PE_FIN", "PE_FIN$");
|
||||
define("PE_FIN_Y", "PE_FIN_Y$");
|
||||
|
||||
define("PR_INI", "PR_INI$");
|
||||
define("PR_INI_Y", "PR_INI_Y$");
|
||||
define("PR_FIN", "PR_FIN$");
|
||||
define("PR_FIN_Y", "PR_FIN_Y$");
|
||||
|
||||
define("EX_INI", "EX_INI$");
|
||||
define("EX_INI_Y", "EX_INI_Y$");
|
||||
define("EX_FIN", "EX_FIN$");
|
||||
define("EX_FIN_Y", "EX_FIN_Y$");
|
||||
?>
|
||||
BIN
include/db/postgrest
Executable file
BIN
include/db/postgrest
Executable file
Binary file not shown.
20
include/db/postgrest.conf
Normal file
20
include/db/postgrest.conf
Normal file
@@ -0,0 +1,20 @@
|
||||
# postgrest.conf
|
||||
|
||||
# The standard connection URI format, documented at
|
||||
# https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
|
||||
db-uri = "postgres://postgres:4ud1t0rf4lt4$$@localhost:5432/paad"
|
||||
|
||||
# The database role to use when no client authentication is provided.
|
||||
# Should differ from authenticator
|
||||
db-anon-role = "postgres"
|
||||
|
||||
# The secret to verify the JWT for authenticated requests with.
|
||||
# Needs to be 32 characters minimum.
|
||||
jwt-secret = "reallyreallyreallyreallyverysafe"
|
||||
jwt-secret-is-base64 = false
|
||||
|
||||
# Port the postgrest process is listening on for http requests
|
||||
server-port = 3000
|
||||
|
||||
# the location root is /api
|
||||
server-host = "*"
|
||||
55
include/fun_fecha.php
Normal file
55
include/fun_fecha.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* Funciones de utilidad
|
||||
*/
|
||||
|
||||
function fechaGuion($fechaTxt){//convierte fecha a guiones
|
||||
$fechaTxt = trim($fechaTxt);
|
||||
if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
|
||||
$fechaArr = explode("/", $fechaTxt);
|
||||
return $fechaArr[2]."-".$fechaArr[1]."-".$fechaArr[0];
|
||||
}
|
||||
if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-")// aaaa-mm-dd
|
||||
return $fechaTxt;
|
||||
return "";
|
||||
}
|
||||
function fechaSlash($fechaTxt){//convierte fecha a /
|
||||
$fechaTxt = trim($fechaTxt);
|
||||
if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
|
||||
return $fechaTxt;
|
||||
}
|
||||
if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-"){// aaaa-mm-dd
|
||||
$fechaArr = explode("-", $fechaTxt);
|
||||
return $fechaArr[2]."/".$fechaArr[1]."/".$fechaArr[0];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function fechaTexto($fechaTxt, $showYear = true){//convierte fecha a cadena de texto
|
||||
$fechaTxt = trim($fechaTxt);
|
||||
if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
|
||||
$fechaArr = explode("/", $fechaTxt);
|
||||
if($showYear)
|
||||
return intval($fechaArr[0])." de ".mesNombre($fechaArr[1])." de ".$fechaArr[2];
|
||||
else
|
||||
return intval($fechaArr[0])." de ".mesNombre($fechaArr[1]);
|
||||
}
|
||||
if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-"){// aaaa-mm-dd
|
||||
$fechaArr = explode("-", $fechaTxt);
|
||||
if($showYear)
|
||||
return intval($fechaArr[2])." de ".mesNombre($fechaArr[1])." de ".$fechaArr[0];
|
||||
else
|
||||
return intval($fechaArr[2])." de ".mesNombre($fechaArr[1]);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function mesNombre($num){
|
||||
$meses=array(1=>"enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre");
|
||||
return $meses[intval($num)];
|
||||
}
|
||||
|
||||
function diaNombre($num){
|
||||
$dias=array("domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado");
|
||||
return $dias[intval($num)];
|
||||
}
|
||||
165
include/func_excel.php
Normal file
165
include/func_excel.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
|
||||
require_once "../vendor/autoload.php";
|
||||
require_once "../include/bd_pdo.php";
|
||||
|
||||
$columnas = array(
|
||||
"SALÓN",
|
||||
"GRUPO",
|
||||
"CLAVE",
|
||||
"DOCENTE",
|
||||
"MATERIA",
|
||||
"LUNES",
|
||||
"MARTES",
|
||||
"MIÉRCOLES",
|
||||
"JUEVES",
|
||||
"VIERNES",
|
||||
"SÁBADO",
|
||||
"DURACIÓN",
|
||||
);
|
||||
|
||||
$cl = ['salon', 'grupo', 'clave', 'maestro', 'materia',];
|
||||
|
||||
define('HORARIO', 5);
|
||||
define('COLUMNA_MAXIMA', chr(count($columnas) + ord('A') - 1));
|
||||
function columna_nombre(string $columna): array
|
||||
{
|
||||
$nombre = "";
|
||||
$datos_nombre = explode(" ", str_replace(array("\n", chr(10), chr(13)), " ", trim(preg_replace('/_x([0-9a-fA-F]{4})_/', ' ', $columna))));
|
||||
$temp_nombre = explode(".", $datos_nombre[0]);
|
||||
if (count($temp_nombre) > 1) {
|
||||
$nombre .= $temp_nombre[1] . " ";
|
||||
$grado = $temp_nombre[0] . ".";
|
||||
array_shift($datos_nombre);
|
||||
} else
|
||||
$grado = strpos($datos_nombre[0], ".") !== false ? array_shift($datos_nombre) : null;
|
||||
|
||||
$email = strpos($columna, "@") !== false ? array_pop($datos_nombre) : null;
|
||||
$nombre .= implode(" ", $datos_nombre);
|
||||
|
||||
return array(
|
||||
"grado" => $grado,
|
||||
"nombre" => trim($nombre),
|
||||
"correo" => $email,
|
||||
);
|
||||
}
|
||||
###
|
||||
function validar_columnas(object $sheet): void
|
||||
{
|
||||
global $columnas;
|
||||
$diff = array_diff(array_map(fn ($col) => trim($col), get_columns($sheet)), $columnas);
|
||||
#array clean
|
||||
if (!empty($diff)) {
|
||||
$diff = array_filter($diff, fn ($col) => !empty($col));
|
||||
throw new Exception("Error en el formato del archivo: " . (empty($diff) ? "Columnas vacías" : "Columnas incorrectas: [" . implode(", ", $diff) . "]"));
|
||||
}
|
||||
}
|
||||
###
|
||||
function get_columns(object $sheet)
|
||||
{
|
||||
global $columnas;
|
||||
$columns = array();
|
||||
foreach ($sheet->getRowIterator(1, 1) as $row)
|
||||
foreach ($row->getCellIterator() as $index => $cell) {
|
||||
$columns[$index] = mb_strtoupper($cell->getValue() ?? "");
|
||||
if ($index == COLUMNA_MAXIMA) break;
|
||||
}
|
||||
return $columns;
|
||||
}
|
||||
###
|
||||
function foreach_sheet(object $workbook, callable $callback = null): void
|
||||
{
|
||||
|
||||
$sheets = $workbook->getSheetNames();
|
||||
// validate columns
|
||||
foreach ($sheets as $sheet) {
|
||||
$worksheet = $workbook->getSheetByName($sheet);
|
||||
validar_columnas($worksheet);
|
||||
foreach_register($worksheet, $callback, $sheet);
|
||||
}
|
||||
}
|
||||
###
|
||||
function foreach_register(object $worksheet, callable $callback = null, string $sheet): void
|
||||
{
|
||||
foreach ($worksheet->getRowIterator(2) as $key => $row) {
|
||||
$row_data = array();
|
||||
foreach ($row->getCellIterator() as $index => $cell) {
|
||||
$row_data[] = str_replace(' ', '', $cell->getValue() ?? "");
|
||||
if ($index == COLUMNA_MAXIMA) break;
|
||||
}
|
||||
|
||||
if ($callback !== null) {
|
||||
$callback($row_data, $key, $sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function horario(array &$row, int $fila, string $sheet): string
|
||||
{
|
||||
global $cl, $db;
|
||||
date_default_timezone_set('UTC');
|
||||
$horario_tostring = "";
|
||||
for ($i = HORARIO; $i < count($row) - 1; $i++) {
|
||||
// echo $row[$i] . " $i\n";
|
||||
if (!empty(trim($row[$i] ?? ""))) {
|
||||
$row[$i] = str_replace(array(" -", "- ", " - "), "-", $row[$i]);
|
||||
$separar_por_espacios = EXPLODE(" ", trim(preg_replace('!\s+!', ' ', $row[$i])));
|
||||
foreach ($separar_por_espacios as $horario) {
|
||||
$hora = // if string includes : then is string else is excel date
|
||||
(strpos($horario, ":") === false)
|
||||
? \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($horario)->format('H:i')
|
||||
: preg_replace('/[^0-9:]/', '', str_replace('.', ':', trim((strpos($horario, "-") !== false) ? explode("-", $horario)[0] : $horario)));
|
||||
|
||||
if (
|
||||
$hora > "22:00" || $hora < "07:00" || explode(":", $hora)[1] % 15 !== 0
|
||||
) {
|
||||
throw new Exception("Error en el formato del archivo: Hora incorrecta [$hora] en la fila $fila, hoja $sheet.");
|
||||
}
|
||||
|
||||
$duración = end($row);
|
||||
if ($duración <= 180 and $duración >= 30 and $duración % 15 == 0)
|
||||
$bloques = $duración / 15;
|
||||
else if ($duración <= 3 and $duración >= 0.5)
|
||||
$bloques = $duración * 60 / 15;
|
||||
else
|
||||
throw new Exception("Error en el formato del archivo: Duración [$duración] incorrecta en la fila $fila, hoja $sheet.");
|
||||
|
||||
$duraciónID = $db->where("duracion_bloques", $bloques)->get("duracion", 1, "duracion_id")[0]["duracion_id"];
|
||||
$horario_tostring .= ($i - 4) . ",$hora,$duraciónID;";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$row = array_combine($cl, array_intersect_key($row, array_keys($cl)));
|
||||
$horario_tostring = substr($horario_tostring, 0, -1);
|
||||
if (empty($horario_tostring))
|
||||
throw new Exception("Error en el formato del archivo: No se encontró horario en la fila $fila, hoja $sheet.");
|
||||
|
||||
return $horario_tostring;
|
||||
}
|
||||
|
||||
function validar_registro(array $row, int $fila): void
|
||||
{
|
||||
$tiene_horario = false;
|
||||
for ($i = 0; $i < HORARIO - 1; $i++)
|
||||
if (empty(trim($row[$i])))
|
||||
throw new Exception("Error faltan datos en la fila $fila de la hoja");
|
||||
|
||||
for ($i = HORARIO; $i < COLUMNA_MAXIMA; $i++)
|
||||
if ($tiene_horario = !empty($row[$i]))
|
||||
break;
|
||||
|
||||
if (!$tiene_horario)
|
||||
throw new Exception("Error en el formato del archivo: No se encontró horario en la fila $fila.");
|
||||
}
|
||||
|
||||
|
||||
function renglón_vacío(array $row)
|
||||
{
|
||||
foreach ($row as $columna)
|
||||
if (!empty($columna))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
10
include/func_string.php
Normal file
10
include/func_string.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace utils;
|
||||
function simpify_string(string $string): string
|
||||
{
|
||||
$string = mb_strtolower($string);
|
||||
|
||||
$string_without_accents = str_replace(array('á', 'é', 'í', 'ó', 'ú', 'ñ'), array('a', 'e', 'i', 'o', 'u', 'n'), $string);
|
||||
$string_without_spaces = str_replace(' ', '', $string_without_accents);
|
||||
return $string_without_spaces;
|
||||
}
|
||||
14
include/nocache.php
Normal file
14
include/nocache.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* Headers apra evitar caché de la página
|
||||
*/
|
||||
//no index
|
||||
header("X-Robots-Tag: noindex, nofollow", true);
|
||||
//no caché
|
||||
header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
date_default_timezone_set('America/Mexico_City');
|
||||
?>
|
||||
50
include/phpmailer/PHPMailerAutoload.php
Normal file
50
include/phpmailer/PHPMailerAutoload.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPMailer SPL autoloader.
|
||||
* PHP Version 5
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2014 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailer SPL autoloader.
|
||||
* @param string $classname The name of the class to load
|
||||
*/
|
||||
function PHPMailerAutoload($classname)
|
||||
{
|
||||
//Can't use __DIR__ as it's only in PHP 5.3+
|
||||
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
|
||||
if (is_readable($filename)) {
|
||||
require $filename;
|
||||
}
|
||||
}
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
|
||||
//SPL autoloading was introduced in PHP 5.1.2
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
spl_autoload_register('PHPMailerAutoload', true, true);
|
||||
} else {
|
||||
spl_autoload_register('PHPMailerAutoload');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Fall back to traditional autoload for old PHP versions
|
||||
* @param string $classname The name of the class to load
|
||||
*/
|
||||
spl_autoload_register($classname);
|
||||
/*function __autoload($classname)
|
||||
{
|
||||
PHPMailerAutoload($classname);
|
||||
}*/
|
||||
}
|
||||
3884
include/phpmailer/class.phpmailer.php
Normal file
3884
include/phpmailer/class.phpmailer.php
Normal file
File diff suppressed because it is too large
Load Diff
1181
include/phpmailer/class.smtp.php
Normal file
1181
include/phpmailer/class.smtp.php
Normal file
File diff suppressed because it is too large
Load Diff
127
include/util.php
Normal file
127
include/util.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/*
|
||||
* Funciones de utilidad
|
||||
*/
|
||||
|
||||
function fechaGuion($fechaTxt, $showDay = true){//convierte fecha a guiones
|
||||
$fechaTxt = trim($fechaTxt);
|
||||
if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
|
||||
$fechaArr = explode("/", $fechaTxt);
|
||||
if($showDay)
|
||||
return $fechaArr[2]."-".$fechaArr[1]."-".$fechaArr[0];
|
||||
else
|
||||
return $fechaArr[2]."-".$fechaArr[1]."-01";
|
||||
}
|
||||
if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-"){// aaaa-mm-dd
|
||||
if($showDay)
|
||||
return $fechaTxt;
|
||||
$fechaArr = explode("-", $fechaTxt);
|
||||
return $fechaArr[0]."-".$fechaArr[1]."-01";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
function fechaSlash($fechaTxt, $showDay = true){//convierte fecha a /
|
||||
$fechaTxt = trim($fechaTxt);
|
||||
if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
|
||||
if($showDay)
|
||||
return $fechaTxt;
|
||||
|
||||
$fechaArr = explode("/", $fechaTxt);
|
||||
return "01/".$fechaTxt[1]."/".$fechaTxt[2];
|
||||
}
|
||||
if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-"){// aaaa-mm-dd
|
||||
$fechaArr = explode("-", $fechaTxt);
|
||||
if($showDay)
|
||||
return $fechaArr[2]."/".$fechaArr[1]."/".$fechaArr[0];
|
||||
else
|
||||
return "01/".$fechaArr[1]."/".$fechaArr[0];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
function fechaTexto($fechaTxt, $showYear = true){//convierte fecha a cadena de texto
|
||||
$fechaTxt = trim($fechaTxt);
|
||||
if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
|
||||
$fechaArr = explode("/", $fechaTxt);
|
||||
if($showYear)
|
||||
return intval($fechaArr[0])." de ".mesNombre($fechaArr[1])." de ".$fechaArr[2];
|
||||
else
|
||||
return intval($fechaArr[0])." de ".mesNombre($fechaArr[1]);
|
||||
}
|
||||
if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-"){// aaaa-mm-dd
|
||||
$fechaArr = explode("-", $fechaTxt);
|
||||
if($showYear)
|
||||
return intval($fechaArr[2])." de ".mesNombre($fechaArr[1])." de ".$fechaArr[0];
|
||||
else
|
||||
return intval($fechaArr[2])." de ".mesNombre($fechaArr[1]);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
function fechaMonthPicker($fechaTxt){
|
||||
$meses=array(1=>"ene", "feb", "mar", "abr", "may", "jun", "jul", "ago", "sep", "oct", "nov", "dic");
|
||||
$fechaTxt = trim($fechaTxt);
|
||||
if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
|
||||
$fechaArr = explode("/", $fechaTxt);
|
||||
return $meses[intval($fechaArr[1])].", ".$fechaArr[2];
|
||||
}
|
||||
if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-"){// aaaa-mm-dd
|
||||
$fechaArr = explode("-", $fechaTxt);
|
||||
return $meses[intval($fechaArr[1])].", ".$fechaArr[0];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
function fechaMes($fechaTxt){
|
||||
$fechaTxt = trim($fechaTxt);
|
||||
if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
|
||||
$fechaArr = explode("/", $fechaTxt);
|
||||
return intval(mesNombre($fechaArr[1])." ".$fechaArr[2]);
|
||||
}
|
||||
if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-"){// aaaa-mm-dd
|
||||
$fechaArr = explode("-", $fechaTxt);
|
||||
return intval(mesNombre($fechaArr[2])." ".$fechaArr[1]);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function mesNombre($num){
|
||||
$meses=array(1=>"enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre");
|
||||
return $meses[intval($num)];
|
||||
}
|
||||
|
||||
function diaNombre($num){
|
||||
$dias=array("domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado");
|
||||
return $dias[intval($num)];
|
||||
}
|
||||
|
||||
function horaMin($arr, $campo = "Horario_hora"){
|
||||
$min = "";
|
||||
foreach($arr as $horario){
|
||||
if($min == "" || date('H:i', strtotime($horario[$campo])) < date('H:i', strtotime($min))){
|
||||
$min = $horario[$campo];
|
||||
}
|
||||
}
|
||||
return date('H:i', strtotime($min));
|
||||
}
|
||||
|
||||
function horaMax($arr, $campo = "Horario_hora_final"){
|
||||
$max = "";
|
||||
foreach($arr as $horario){
|
||||
if($max == "" || date('H:i', strtotime($horario[$campo])) > date('H:i', strtotime($max))){
|
||||
$max = $horario[$campo];
|
||||
}
|
||||
}
|
||||
return date('H:i', strtotime($max));
|
||||
}
|
||||
function duracionMinutos($fechahora_i, $fechahora_f){
|
||||
return round((strtotime($fechahora_f) - strtotime($fechahora_i)) / 60,2);
|
||||
}
|
||||
|
||||
function validaPassword($pass){
|
||||
$expr = '/^\S*(?=\S{5,})(?=\S*[a-zA-Z])(?=\S*[\d])(?=\S*[\W])\S*$/';
|
||||
return preg_match($expr, $pass);
|
||||
}
|
||||
Reference in New Issue
Block a user