function subirArchivo($arch, $folder, $filename, $extensionesPermitidas, $maxFileSize, &$error, &$finalFilename) { $tmpfile = $arch["tmp_name"]; $partes_ruta = pathinfo(strtolower($arch["name"])); if (!in_array($partes_ruta["extension"], $extensionesPermitidas)) { $error = "El archivo debe tener alguna de las siguientes extensiones: ".implode(" o ", $extensionesPermitidas)."."; return false; } $filename = StringToLower($filename.".".$partes_ruta["extension"]); $finalFilename = $folder.$filename; if (!is_uploaded_file($tmpfile)) { $error = "El archivo no subió correctamente."; return false; } if (filesize($tmpfile) > $maxFileSize) { $error = "El archivo no puede ser mayor a ".tamanoArchivo($maxFileSize)."."; return false; } if (!move_uploaded_file($tmpfile, $folder.$filename)) { $error = "El archivo no pudo ser guardado."; return false; } return true; }
function uploadImagen($img, $folder, $id, &$imgPath) { $tempfile = $img["tmp_name"]; $filename = StringToLower($id . "_" . $img["name"], "."); $uploadOk = false; if (is_uploaded_file($tempfile)) { if (move_uploaded_file($tempfile, $folder . $filename)) { $uploadOk = true; $imgPath = $filename; } } if (!$uploadOk) { echo "<script>alert('Ocurrió un error al guardar la imagen.');</script>"; } return $uploadOk; }
function uploadFile($arch, $folder, $id, &$archPath) { $tempfile = $arch["tmp_name"]; $partes_ruta = pathinfo($arch["name"]); $filename = StringToLower($id . "." . $partes_ruta["extension"]); $uploadOk = false; if (is_uploaded_file($tempfile)) { if (move_uploaded_file($tempfile, $folder . $filename)) { $uploadOk = true; $archPath = $partes_ruta["basename"]; } } if (!$uploadOk) { echo "<script>alert('Ocurrió un error al guardar el archivo.');</script>"; } return $uploadOk; }
function uploadFile($id, $alta) { // Subo el archivo y borro el anterior para que no quede basura.. $filePath = ""; if ($_FILES["Archivo"]["name"] != "") { $tempfile = $_FILES["Archivo"]["tmp_name"]; $filename = StringToLower($id."_".$_FILES["Archivo"]["name"]); $uploadOk = false; if (is_uploaded_file($tempfile)) { $oldFilename = getActualFilename($id); rename(DATA_INFORMES_GESTION.$oldFilename, DATA_INFORMES_GESTION."OLD_".$oldFilename); if (move_uploaded_file($tempfile, DATA_INFORMES_GESTION.$filename)) { unlink(DATA_INFORMES_GESTION."OLD_".$oldFilename); $uploadOk = true; $filePath = $filename; } else // Si no se subió el archivo, pongo el nombre del archivo anterior de esa publicación como estaba antes.. rename(DATA_INFORMES_GESTION."OLD_".$oldFilename, DATA_INFORMES_GESTION.$oldFilename); } if ($uploadOk) return $filePath; else { ?> <SCRIPT> alert('Ocurrió un error al subir el archivo. Inténtelo nuevamente.'); history.go(-1); </SCRIPT> <? exit; } } elseif ($alta) { ?> <script> alert('Debe seleccionar un archivo a publicar.'); </script> <? exit; } }
} catch (Exception $e) { ?> <script> alert(unescape('<?= rawurlencode($e->getMessage())?>')); </script> <? exit; } // Subo la foto.. $imgFotoPath = ""; if ($_FILES["Foto"]["name"] != "") { $tempfile = $_FILES["Foto"]["tmp_name"]; $filename = StringToLower($_REQUEST["UserName"].strrchr($_FILES["Foto"]["name"], ".")); $uploadOk = false; if (is_uploaded_file($tempfile)) if (move_uploaded_file($tempfile, IMAGES_FOTOS_PATH.$filename)) { $uploadOk = true; $imgFotoPath = $filename; } if (!$uploadOk) { ?> <script> alert('Ocurrió un error al cargar la Foto. Inténtelo nuevamente.'); history.go(-1); <script> <?
function validar() { $errores = false; echo "<script type='text/javascript'>"; echo "with (window.parent.document) {"; echo "var errores = '';"; if ($_POST["puesto"] == "") { echo "errores+= '- El campo Puesto es obligatorio.<br />';"; $errores = true; } if ($_POST["empresa"] == -1) { echo "errores+= '- El campo Empresa es obligatorio.<br />';"; $errores = true; } if ($_POST["estado"] == -1) { echo "errores+= '- El campo Estado es obligatorio.<br />';"; $errores = true; } if ($_FILES["archivo"]["name"] != "") { $partes_ruta = pathinfo($_FILES["archivo"]["name"]); $ext = StringToLower($partes_ruta["extension"]); if (($ext != "doc") and ($ext != "docx") and ($ext != "pdf")) { echo "errores+= '- El Archivo debe ser de Word o Acrobat Reader.<br />';"; $errores = true; } } if ($_POST["vigenciaDesde"] == "") { echo "errores+= '- El campo Vigencia Desde es obligatorio.<br />';"; $errores = true; } elseif (!isFechaValida($_POST["vigenciaDesde"])) { echo "errores+= '- El campo Vigencia Desde debe ser una fecha válida.<br />';"; $errores = true; } if ($_POST["vigenciaHasta"] == "") { echo "errores+= '- El campo Vigencia Hasta es obligatorio.<br />';"; $errores = true; } elseif (!isFechaValida($_POST["vigenciaHasta"])) { echo "errores+= '- El campo Vigencia Hasta debe ser una fecha válida.<br />';"; $errores = true; } if (dateDiff($_POST["vigenciaHasta"], $_POST["vigenciaDesde"]) > 0) { echo "errores+= '- La Vigencia Hasta debe ser mayor a la Vigencia Desde.<br />';"; $errores = true; } if ($errores) { echo "body.style.cursor = 'default';"; echo "getElementById('btnGuardar').style.display = 'inline';"; echo "getElementById('imgProcesando').style.display = 'none';"; echo "getElementById('errores').innerHTML = errores;"; echo "getElementById('divErroresForm').style.display = 'block';"; echo "getElementById('foco').style.display = 'block';"; echo "getElementById('foco').focus();"; echo "getElementById('foco').style.display = 'none';"; } else { echo "getElementById('divErroresForm').style.display = 'none';"; } echo "}"; echo "</script>"; return !$errores; }
window.parent.document.getElementById('<?php echo $_REQUEST["obj"]; ?> ').style.display = 'none'; </script> <? } else { // Muestro el archivo.. $params = array(":id" => $_REQUEST["id"]); $sql = "SELECT tb_especial1 || '\' || ab_nombre FROM ctb_tablas, web.wab_archivobapro WHERE tb_clave = 'PATHS' AND tb_codigo = '008' AND ab_id = :id"; $file = StringToLower(ValorSql($sql, "", $params)); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=".basename($file)); if ((readfile($file)) and ($_REQUEST["u"] == "t")) { $params = array(":usuario" => $_SESSION["usuario"], ":id" => $_REQUEST["id"]); $sql = "UPDATE web.wab_archivobapro SET ab_usudescargado = :usuario, ab_fechadescargado = SYSDATE WHERE ab_id = :id"; DBExecSql($conn, $sql, $params); } } ?>
function setUrlAmigable($titulo) { return StringToLower(RemoveAccents(str_replace(" ", "-", $titulo))).".html"; }
<? require_once($_SERVER["DOCUMENT_ROOT"]."/../Common/miscellaneous/string_utils.php"); $file = StringToLower(base64_decode($_REQUEST["fl"])); $ext = substr($file, strrpos($file, ".")); $mode = "i"; if (isset($_REQUEST["md"])) $mode = $_REQUEST["md"]; if (isset($_REQUEST["ft"])) $fileTitle = $_REQUEST["ft"]; else $fileTitle = $file; if ($ext == ".pdf") header("Content-type: application/pdf"); elseif ($ext == ".doc") header("Content-type: application/msword"); elseif (($ext == ".htm") or ($ext == ".html")) header("Content-type: text/html"); elseif ($ext == ".jpg") header("Content-type: image/jpeg"); elseif ($ext == ".ppt") header("Content-type: application/vnd.ms-powerpoint"); elseif ($ext == ".xls") header("Content-type: application/vnd.ms-excel"); else header("Content-Type: application/octet-stream"); //if ($ext == ".bmp")