Changes & added Club
This commit is contained in:
52
public_html/club/upload/css/main.css
Executable file
52
public_html/club/upload/css/main.css
Executable file
@@ -0,0 +1,52 @@
|
||||
div#alert {
|
||||
font-family: Arial, Helvetica, serif;
|
||||
font-weight: bold;
|
||||
margin: 20px 0px;
|
||||
}
|
||||
|
||||
div#alert.green {
|
||||
color: green;
|
||||
}
|
||||
|
||||
div#alert.red {
|
||||
color: red;
|
||||
}
|
||||
|
||||
div#progress-outer {
|
||||
width: 315px;
|
||||
height: 30px;
|
||||
border: 1px solid white;
|
||||
border-radius: 30px 30px 30px 30px;
|
||||
-moz-border-radius: 30px;
|
||||
-webkit-border-radius: 30px;
|
||||
padding: 5px;
|
||||
position: relative;
|
||||
margin-top: 30px;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
}
|
||||
|
||||
div#progress-inner {
|
||||
width: 0%;
|
||||
height: 100%;
|
||||
background-color: white;
|
||||
border-radius: 30px 30px 30px 30px;
|
||||
-moz-border-radius: 30px;
|
||||
-webkit-border-radius: 30px;
|
||||
transition: 0.25s all ease-in-out;
|
||||
-moz-transition: 0.25s all ease-in-out;
|
||||
-webkit-transition: 0.25s all ease-in-out;
|
||||
}
|
||||
|
||||
div#progress-text {
|
||||
width: 100%;
|
||||
font-family: Arial, Helvetica, serif;
|
||||
font-weight: bold;
|
||||
font-size: 18px;
|
||||
color: green;
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 0px;
|
||||
z-index: 2;
|
||||
}
|
||||
36
public_html/club/upload/form.php
Executable file
36
public_html/club/upload/form.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
ini_set("display_errors", 0);
|
||||
if (strtoupper($_GET["p"]) != "ELPEPE") {
|
||||
header("Location: unauth.php");
|
||||
die();
|
||||
}
|
||||
$APP_CODE = "club";
|
||||
$APP_NAME = "La web del Club<sup>3</sup>";
|
||||
$APP_TITLE = "La web del Club";
|
||||
require_once "/var/www/_incl/pre-body.php"; ?>
|
||||
<div class="card pad">
|
||||
<h1>Subir fotos</h1>
|
||||
<form id="upload" encType="multipart/form-data">
|
||||
<fieldset class="card"
|
||||
style="border: 2px solid black; border-radius: 6.5px; padding: 5px 25px; max-width: 500px;">
|
||||
|
||||
<label id="uploader0">
|
||||
<b>Elegir los archivos a subir (max 10)</b>
|
||||
<input type="file" name="file[]" multiple="true" id="uploaderfileinp" />
|
||||
</label>
|
||||
<hr>
|
||||
<span>
|
||||
<b>Progreso:</b> <span id="alert">Por subir...</span>
|
||||
</span>
|
||||
<progress id="fileuploaderprog" max="100" value="0" style="width: 100%;">0%</progress>
|
||||
<br>
|
||||
<button type="submit" class="button">Subir fotos</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
<script src="js/plugin/jquery-3.6.0.min.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
|
||||
</div>
|
||||
<?php require_once "/var/www/_incl/post-body.php"; ?>
|
||||
30
public_html/club/upload/index.php
Executable file
30
public_html/club/upload/index.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php ini_set("display_errors", "off");
|
||||
|
||||
$APP_CODE = "club";
|
||||
$APP_NAME = "La web del Club<sup>3</sup>";
|
||||
$APP_TITLE = "La web del Club";
|
||||
require_once "/var/www/_incl/pre-body.php"; ?>
|
||||
<div class="card pad">
|
||||
<h1>Subir fotos</h1>
|
||||
<form action="form.php" method="get">
|
||||
<fieldset class="card" style="border: 2px solid black; border-radius: 6.5px; padding: 5px 25px; max-width: 500px;">
|
||||
<label>
|
||||
<b>Tu nombre:</b>
|
||||
<input required type="text" name="n" value="<?php echo $_GET["n"] ?: "";?>" placeholder="Nombre...">
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<b>Fecha:</b>
|
||||
<input required type="date" name="f" value="<?php echo $_GET["f"] ?: "";?>" placeholder="Fecha...">
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<b>La contraseña:</b>
|
||||
<input required type="text" name="p" value="" placeholder="Contraseña...">
|
||||
</label>
|
||||
<br>
|
||||
<button type="submit">Continuar...</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<?php require_once "/var/www/_incl/post-body.php"; ?>
|
||||
61
public_html/club/upload/js/main.js
Executable file
61
public_html/club/upload/js/main.js
Executable file
@@ -0,0 +1,61 @@
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
$(document).ready(function() {
|
||||
|
||||
// on form submit, upload file:
|
||||
$("form#upload").submit(function(event) {
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "upload.php?pw=" + urlParams.get("p") + "&folder=/IMG/" + urlParams.get("f") + "/" + urlParams.get("n") + "/",
|
||||
data: new FormData($(this)[0]),
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
xhr: function() {
|
||||
var my_xhr = $.ajaxSettings.xhr();
|
||||
document.getElementById('alert').innerText = "Subiendo...";
|
||||
|
||||
if (my_xhr.upload) {
|
||||
my_xhr.upload.addEventListener("progress", function(event) {
|
||||
Progress(event.loaded, event.total);
|
||||
});
|
||||
}
|
||||
|
||||
return my_xhr;
|
||||
},
|
||||
success: function() {
|
||||
document.getElementById('alert').innerText = "Subido!";
|
||||
Finished();
|
||||
|
||||
},
|
||||
error: function(xhr, status, message) {
|
||||
document.getElementById('alert').innerText = "Error! " + xhr.status + " " + status + " - " + message;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// progress bar:
|
||||
function Progress(current, total) {
|
||||
var percent = ((current / total) * 100).toFixed(0) + "%";
|
||||
|
||||
document.getElementById('fileuploaderprog').value = ((current / total) * 100).toFixed(0);
|
||||
document.getElementById('fileuploaderprog').innerText = percent;
|
||||
}
|
||||
|
||||
// upload finished:
|
||||
function Finished() {
|
||||
setTimeout(function() {
|
||||
$("form#upload input[type='file']").val("");
|
||||
document.getElementById('uploaderfileinp').value = "";
|
||||
|
||||
document.getElementById('fileuploaderprog').innerText = "Subido!"
|
||||
|
||||
setTimeout(function() {
|
||||
document.getElementById('fileuploaderprog').innerText = "0%"
|
||||
location.href="../cal.php?f=" + urlParams.get("f")
|
||||
|
||||
}, 3000);
|
||||
}, 500);
|
||||
}
|
||||
2
public_html/club/upload/js/plugin/jquery-3.6.0.min.js
vendored
Executable file
2
public_html/club/upload/js/plugin/jquery-3.6.0.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
22
public_html/club/upload/unauth.php
Executable file
22
public_html/club/upload/unauth.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php ini_set("display_errors", "off");?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>La web del club</title>
|
||||
<link rel="stylesheet" href="/newcss-terminal.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<h1>La web del Club</h1>
|
||||
<a href="/club/">[ Inicio ]</a>
|
||||
<a href="/">[ Volver a tech.eus ]</a>
|
||||
</header>
|
||||
<h1>Subir fotos</h1>
|
||||
<h2>La contraseña es incorrecta.</h2>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
43
public_html/club/upload/upload.php
Executable file
43
public_html/club/upload/upload.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
ini_set("display_errors", 0);
|
||||
$config = json_decode(file_get_contents("/DATA/club/config.json"), true);
|
||||
if (strtoupper($_GET["pw"]) != $config["uploadpw"]) {
|
||||
header("HTTP/1.1 401 Unauthorized");
|
||||
die();
|
||||
}
|
||||
//remove files with error
|
||||
$error_files = array();
|
||||
foreach ($_FILES["file"]["error"] as $key => $error) {
|
||||
if ($error != UPLOAD_ERR_OK) {
|
||||
$error_files[] = $_FILES["file"]["name"][$key];
|
||||
}
|
||||
}
|
||||
foreach ($error_files as $file) {
|
||||
$key = array_search($file, $_FILES["file"]["name"]);
|
||||
unset($_FILES["file"]["name"][$key]);
|
||||
unset($_FILES["file"]["type"][$key]);
|
||||
unset($_FILES["file"]["tmp_name"][$key]);
|
||||
unset($_FILES["file"]["error"][$key]);
|
||||
unset($_FILES["file"]["size"][$key]);
|
||||
}
|
||||
$file_count = sizeof($_FILES["file"]["name"]);
|
||||
|
||||
for ($i = 0; $i < $file_count; $i++) {
|
||||
$file_name = $_FILES["file"]["name"][$i];
|
||||
$folder = $_GET["folder"];
|
||||
$location = "/DATA/club$folder" . $file_name;
|
||||
if (!is_dir("/DATA/club$folder")) {
|
||||
mkdir("/DATA/club$folder", recursive: true);
|
||||
}
|
||||
if (move_uploaded_file($_FILES["file"]["tmp_name"][$i], $location)) {
|
||||
// Generate thumbnail
|
||||
require_once "../_incl/tools.photos.php";
|
||||
$thumbnail_path = $location . ".thumbnail";
|
||||
if (!file_exists($thumbnail_path)) {
|
||||
generatethumbnail($location, $thumbnail_path, 240, 0);
|
||||
}
|
||||
header("HTTP/1.1 200 OK");
|
||||
} else {
|
||||
header("HTTP/1.1 500 Internal Server Error");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user