- Add db.php with PDO singleton, migration runner, and all helper functions - Add migrations/001_initial_schema.sql (full schema) - Add migrations/002_import_json.php (one-time JSON → DB importer) - Add _incl/switch_tenant.php POST endpoint for tenant/centro switching - Update tools.auth.php: DB-backed login, cookie auth, session reload, init_active_centro() - Update all sysadmin pages (users, centros, aularios, invitations, reset_password) to use DB - Update aulatek/index.php, aulario.php, supercafe.php, supercafe_edit.php to use DB - Update aulatek/comedor.php and api/comedor.php to use DB - Update aulatek/paneldiario.php: aulario config + comedor data from DB - Update aulatek/proyectos.php: aulario config + sharing metadata from DB - Update club/cal.php, index.php, edit_data.php, upload/upload.php to use DB - Update account/index.php: rich profile, tenant list, aula list, session info, permissions - Update pre-body.php account dropdown: shows active org + inline tenant switcher - Update DATA_STRUCTURE.md to document DB approach and migration system Co-authored-by: naielv <109038805+naielv@users.noreply.github.com>
59 lines
1.9 KiB
PHP
Executable File
59 lines
1.9 KiB
PHP
Executable File
<?php
|
|
ini_set("display_errors", 1);
|
|
require_once "../../_incl/db.php";
|
|
$uploadpw = db_get_config('club_uploadpw', '');
|
|
if ($uploadpw === '' || strtoupper($_GET["pw"] ?? '') !== strtoupper($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]);
|
|
}
|
|
// Reindex arrays to avoid gaps after unsetting
|
|
$_FILES["file"]["name"] = array_values($_FILES["file"]["name"]);
|
|
$_FILES["file"]["type"] = array_values($_FILES["file"]["type"]);
|
|
$_FILES["file"]["tmp_name"] = array_values($_FILES["file"]["tmp_name"]);
|
|
$_FILES["file"]["error"] = array_values($_FILES["file"]["error"]);
|
|
$_FILES["file"]["size"] = array_values($_FILES["file"]["size"]);
|
|
|
|
$file_count = sizeof($_FILES["file"]["name"]);
|
|
|
|
$all_ok = true;
|
|
|
|
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", 777, 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);
|
|
#}
|
|
} else {
|
|
$all_ok = false;
|
|
}
|
|
}
|
|
|
|
if ($all_ok) {
|
|
header("HTTP/1.1 200 OK");
|
|
} else {
|
|
header("HTTP/1.1 500 Internal Server Error");
|
|
}
|