-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from vittodevit/master
- Loading branch information
Showing
38 changed files
with
25,517 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ project.xml | |
/tests/installer-*.php | ||
unikey.txt | ||
.devmode | ||
node_modules | ||
node_modules | ||
/annuario/storage/a_* |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/* | ||
Copyright (C) 2024 Vittorio Lo Mele | ||
Questo programma è un software libero; potete redistribuirlo e/o modificarlo secondo i termini della | ||
GNU Affero General Public License come pubblicata | ||
dalla Free Software Foundation; sia la versione 3, | ||
sia (a vostra scelta) ogni versione successiva. | ||
Questo programma è distribuito nella speranza che sia utile | ||
ma SENZA ALCUNA GARANZIA; senza anche l'implicita garanzia di | ||
POTER ESSERE VENDUTO o di IDONEITA' A UN PROPOSITO PARTICOLARE. | ||
Vedere la GNU Affero General Public License per ulteriori dettagli. | ||
Dovreste aver ricevuto una copia della GNU Affero General Public License | ||
in questo programma; se non l'avete ricevuta, vedete http://www.gnu.org/licenses/ | ||
*/ | ||
|
||
$NG_API_ABIL = "MASP"; | ||
$NG_API_JSON = true; | ||
|
||
require_once '../lib/ng_api_init.php'; | ||
|
||
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | ||
if (isset($_POST['id'])) { | ||
$idFoto = $con->real_escape_string($_POST['id']); | ||
$foto = mysqli_fetch_assoc(eseguiQuery($con, "SELECT * FROM tbl_fotoannuario WHERE id_foto = $idFoto")); | ||
|
||
if(!$foto) { | ||
error_response(404, "Foto non trovata"); | ||
} else { | ||
$defImgPath = './storage/a_' . $foto['hash']; | ||
unlink($defImgPath); | ||
eseguiQuery($con, "DELETE FROM tbl_fotoannuario WHERE id_foto = $idFoto"); | ||
json_response(200, "Foto eliminata"); | ||
} | ||
|
||
} else { | ||
error_response(400, "Richiesta non valida"); | ||
} | ||
} else { | ||
error_response(405, "Method Not Allowed"); | ||
} | ||
|
||
mysqli_close($con); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/* | ||
Copyright (C) 2024 Vittorio Lo Mele | ||
Questo programma è un software libero; potete redistribuirlo e/o modificarlo secondo i termini della | ||
GNU Affero General Public License come pubblicata | ||
dalla Free Software Foundation; sia la versione 3, | ||
sia (a vostra scelta) ogni versione successiva. | ||
Questo programma è distribuito nella speranza che sia utile | ||
ma SENZA ALCUNA GARANZIA; senza anche l'implicita garanzia di | ||
POTER ESSERE VENDUTO o di IDONEITA' A UN PROPOSITO PARTICOLARE. | ||
Vedere la GNU Affero General Public License per ulteriori dettagli. | ||
Dovreste aver ricevuto una copia della GNU Affero General Public License | ||
in questo programma; se non l'avete ricevuta, vedete http://www.gnu.org/licenses/ | ||
*/ | ||
|
||
$NG_API_ABIL = "SKIP"; | ||
$NG_API_JSON = true; | ||
|
||
require_once '../lib/ng_api_init.php'; | ||
|
||
$path = ""; | ||
|
||
if (isset($_GET['hash']) && $_GET['hash'] != "") { | ||
if (file_exists('./storage/a_' . $_GET['hash'])) { | ||
$path = './storage/a_' . $_GET['hash']; | ||
} else { | ||
$path = './storage/default.webp'; | ||
} | ||
} else { | ||
$path = './storage/default.webp'; | ||
} | ||
|
||
header('Content-Type: image/webp'); | ||
readfile($path); | ||
mysqli_close($con); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!DOCTYPE html><title></title> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/* | ||
Copyright (C) 2024 Vittorio Lo Mele | ||
Questo programma è un software libero; potete redistribuirlo e/o modificarlo secondo i termini della | ||
GNU Affero General Public License come pubblicata | ||
dalla Free Software Foundation; sia la versione 3, | ||
sia (a vostra scelta) ogni versione successiva. | ||
Questo programma è distribuito nella speranza che sia utile | ||
ma SENZA ALCUNA GARANZIA; senza anche l'implicita garanzia di | ||
POTER ESSERE VENDUTO o di IDONEITA' A UN PROPOSITO PARTICOLARE. | ||
Vedere la GNU Affero General Public License per ulteriori dettagli. | ||
Dovreste aver ricevuto una copia della GNU Affero General Public License | ||
in questo programma; se non l'avete ricevuta, vedete http://www.gnu.org/licenses/ | ||
*/ | ||
|
||
$NG_API_ABIL = "MASP"; | ||
$NG_API_JSON = true; | ||
|
||
require_once '../lib/ng_api_init.php'; | ||
|
||
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | ||
if ( | ||
($_POST['tipoFoto'] == "alunno" || | ||
$_POST['tipoFoto'] == "classe") && | ||
isset($_POST['id']) | ||
) { | ||
$idFoto = 0; | ||
if ($_POST['tipoFoto'] == "alunno") { | ||
$idFoto = mysqli_fetch_assoc(eseguiQuery($con, "SELECT idfotoannuario FROM tbl_alunni WHERE idalunno = " . $_POST['id']))['idfotoannuario']; | ||
} else { | ||
$idFoto = mysqli_fetch_assoc(eseguiQuery($con, "SELECT idfotoannuario FROM tbl_classi WHERE idclasse = " . $_POST['id']))['idfotoannuario']; | ||
} | ||
|
||
$foto = mysqli_fetch_assoc(eseguiQuery($con, "SELECT * FROM tbl_fotoannuario WHERE id_foto = $idFoto")); | ||
|
||
if(!$foto) { | ||
error_response(404, "Foto non trovata"); | ||
} else { | ||
$data = [ | ||
'id' => $foto['id_foto'], | ||
'didascalia' => $foto['didascalia'], | ||
'hash' => $foto['hash'] | ||
]; | ||
|
||
json_response(200, $data); | ||
} | ||
|
||
} else { | ||
error_response(400, "Richiesta non valida"); | ||
} | ||
} else { | ||
error_response(405, "Method Not Allowed"); | ||
} | ||
|
||
mysqli_close($con); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/* | ||
Copyright (C) 2024 Vittorio Lo Mele | ||
Questo programma è un software libero; potete redistribuirlo e/o modificarlo secondo i termini della | ||
GNU Affero General Public License come pubblicata | ||
dalla Free Software Foundation; sia la versione 3, | ||
sia (a vostra scelta) ogni versione successiva. | ||
Questo programma è distribuito nella speranza che sia utile | ||
ma SENZA ALCUNA GARANZIA; senza anche l'implicita garanzia di | ||
POTER ESSERE VENDUTO o di IDONEITA' A UN PROPOSITO PARTICOLARE. | ||
Vedere la GNU Affero General Public License per ulteriori dettagli. | ||
Dovreste aver ricevuto una copia della GNU Affero General Public License | ||
in questo programma; se non l'avete ricevuta, vedete http://www.gnu.org/licenses/ | ||
*/ | ||
|
||
$NG_API_ABIL = "MASP"; | ||
$NG_API_JSON = true; | ||
|
||
require_once '../lib/ng_api_init.php'; | ||
|
||
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | ||
if ( | ||
isset($_FILES['image']) && | ||
$_FILES['image']['error'] === UPLOAD_ERR_OK && | ||
isset($_POST['tipoFoto']) && | ||
isset($_POST['id']) && | ||
( | ||
$_POST['tipoFoto'] == "alunno" | ||
|| $_POST['tipoFoto'] == "classe" | ||
) | ||
){ | ||
|
||
$tmpFilePath = $_FILES['image']['tmp_name']; | ||
$caption = $con->real_escape_string($_POST['caption']); | ||
$hash = md5_file($tmpFilePath); | ||
$defImgPath = './storage/a_' . $hash; | ||
|
||
if (file_exists($defImgPath)) { | ||
unlink($defImgPath); | ||
} | ||
|
||
if (!move_uploaded_file($tmpFilePath, $defImgPath)) { | ||
error_response(500, "Errore durante il salvataggio dell'immagine"); | ||
} | ||
|
||
$image = imagecreatefromstring(file_get_contents($defImgPath)); | ||
|
||
if ($image === false) { | ||
unlink($defImgPath); | ||
error_response(500, "Errore durante il caricamento dell'immagine"); | ||
} | ||
|
||
unlink($defImgPath); | ||
|
||
if (!imagewebp($image, $defImgPath)) { | ||
error_response(500, "Errore durante la conversione dell'immagine"); | ||
} | ||
|
||
// salva immagine a db | ||
$res = eseguiQuery($con, "INSERT INTO tbl_fotoannuario (hash, didascalia) VALUES ('$hash', '$caption')"); | ||
$last_insert_id = mysqli_insert_id($con); | ||
$id = $con->real_escape_string($_POST['id']); | ||
if ($_POST['tipoFoto'] == "alunno") { | ||
$res = $res && eseguiQuery($con, "UPDATE tbl_alunni SET idfotoannuario = $last_insert_id WHERE idalunno = $id"); | ||
} else { | ||
$res = $res && eseguiQuery($con, "UPDATE tbl_classi SET idfotoannuario = $last_insert_id WHERE idclasse = $id"); | ||
} | ||
|
||
if ($res == true) { | ||
json_response(200, "Immagine caricata con successo"); | ||
} else { | ||
unlink($defImgPath); | ||
error_response(500, "Errore durante il salvataggio su database"); | ||
} | ||
} else { | ||
error_response(400, "Richiesta non valida"); | ||
} | ||
} else { | ||
error_response(405, "Method Not Allowed"); | ||
} | ||
|
||
mysqli_close($con); |
Oops, something went wrong.