| 2926 |
rexy |
1 |
<!DOCTYPE HTML>
|
|
|
2 |
<html><!-- Written by Rexy -->
|
|
|
3 |
<head>
|
| 3324 |
rexy |
4 |
<meta charset="UTF-8">
|
| 2926 |
rexy |
5 |
<title>Logo Customizing</title>
|
|
|
6 |
<link rel="stylesheet" href="/css/acc.css" type="text/css">
|
|
|
7 |
</head>
|
| 318 |
richard |
8 |
<body>
|
| 3028 |
rexy |
9 |
<div id="ldoverlay" class="overlay">
|
|
|
10 |
<div class="lds-spinner" id="spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
|
|
|
11 |
</div>
|
| 318 |
richard |
12 |
<?php
|
| 3316 |
rexy |
13 |
# Configuration
|
|
|
14 |
$max_file_size = 100000; // 100 Ko
|
|
|
15 |
$allowed_types = ['image/png'];
|
|
|
16 |
$upload_dir = $_SERVER['DOCUMENT_ROOT']."/images/";
|
|
|
17 |
$target_file = $upload_dir . 'organisme.png';
|
|
|
18 |
|
| 323 |
richard |
19 |
# Choice of language
|
| 3316 |
rexy |
20 |
$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? 'en', 0, 2);
|
|
|
21 |
$messages = [
|
|
|
22 |
'fr' => [
|
|
|
23 |
'l_title' => "Personnalisation du logo",
|
|
|
24 |
'l_current_logo' => "Logo actuel",
|
|
|
25 |
'l_logo_select' => "Sélectionnez un nouveau logo (fichier au format 'PNG' de taille inférieure à 100Ko) :",
|
|
|
26 |
'l_error_type' => "Le fichier doit être une image PNG valide.",
|
|
|
27 |
'l_error_size' => "Le fichier dépasse la taille maximale autorisée (100 Ko).",
|
|
|
28 |
'l_error_upload' => "Une erreur est survenue lors du téléchargement.",
|
|
|
29 |
'l_success' => "Votre logo a été mis à jour.",
|
|
|
30 |
'l_logo_refresh' => "Rafraîchissez la page de votre navigateur pour voir le résultat (CTRL+F5).",
|
|
|
31 |
'l_send' => "Envoyer"
|
|
|
32 |
],
|
|
|
33 |
'es' => [
|
|
|
34 |
'l_title' => "Personalización del logo",
|
|
|
35 |
'l_current_logo' => "Logo actual",
|
|
|
36 |
'l_logo_select' => "Seleccione un nuevo logotipo (archivo en formato «PNG» con un tamaño inferior a 100 KB) :",
|
|
|
37 |
'l_error_type' => "El archivo debe ser una imagen PNG válida.",
|
|
|
38 |
'l_error_size' => "El archivo supera el tamaño máximo permitido (100 KB).",
|
|
|
39 |
'l_error_upload' => "Se ha producido un error durante la descarga.",
|
|
|
40 |
'l_success' => "Se ha actualizado su logotipo.",
|
|
|
41 |
'l_logo_refresh' => "Actualice la página de su navegador para ver el resultado (CTRL+F5).",
|
|
|
42 |
'l_send' => "Enviar"
|
|
|
43 |
],
|
|
|
44 |
'en' => [
|
|
|
45 |
'l_title' => "Customizing the logo",
|
|
|
46 |
'l_current_logo' => "Current logo",
|
|
|
47 |
'l_logo_select' => "Select a new logo (file in ‘PNG’ format, less than 100 KB in size) :",
|
|
|
48 |
'l_error_type' => "The file must be a valid PNG image.",
|
|
|
49 |
'l_error_size' => "The file exceeds the maximum allowed size (100 KB).",
|
|
|
50 |
'l_error_upload' => "An error occurred during the download.",
|
|
|
51 |
'l_success' => "Your logo has been updated.",
|
|
|
52 |
'l_logo_refresh' => "Refresh your browser page to see the result (CTRL+F5).",
|
|
|
53 |
'l_send' => "Send"
|
|
|
54 |
]
|
|
|
55 |
];
|
|
|
56 |
$lang = $messages[$language] ?? $messages['en'];
|
| 323 |
richard |
57 |
|
| 3316 |
rexy |
58 |
# Logo download management
|
|
|
59 |
if(isset($_FILES['logo'])) {
|
|
|
60 |
$result = null;
|
|
|
61 |
$file = $_FILES['logo'];
|
|
|
62 |
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
|
|
63 |
$mime = finfo_file($finfo, $file['tmp_name']);
|
|
|
64 |
finfo_close($finfo);
|
|
|
65 |
// Download error
|
|
|
66 |
if ($file['error'] !== UPLOAD_ERR_OK) {
|
|
|
67 |
$result = $lang['l_error_upload']; }
|
|
|
68 |
// MIME type check
|
|
|
69 |
elseif (!in_array($file['type'], $allowed_types)) {
|
|
|
70 |
$result = $lang['l_error_type']; }
|
|
|
71 |
elseif (!in_array($mime, $allowed_types)) {
|
|
|
72 |
$result = $lang['l_error_type']; }
|
|
|
73 |
// Size check
|
|
|
74 |
elseif ($file['size'] > $max_file_size) {
|
|
|
75 |
$result = $lang['l_error_size']; }
|
|
|
76 |
// PNG consistent check
|
|
|
77 |
elseif (!getimagesize($file['tmp_name'])) {
|
|
|
78 |
$result = $lang['l_error_type']; }
|
|
|
79 |
// ok : move it
|
|
|
80 |
elseif (!move_uploaded_file($file['tmp_name'], $target_file)) {
|
|
|
81 |
$result = $lang['l_error_upload']; }
|
|
|
82 |
else {
|
|
|
83 |
$result = $lang['l_success'];}
|
| 318 |
richard |
84 |
}
|
|
|
85 |
?>
|
| 2926 |
rexy |
86 |
<div class="panel">
|
| 3316 |
rexy |
87 |
<div class="panel-header"><?= $lang['l_title'] ?></div>
|
| 2926 |
rexy |
88 |
<div class="panel-row">
|
|
|
89 |
<table width="100%" border=0 cellspacing=0 cellpadding=1>
|
|
|
90 |
<tr><td>
|
|
|
91 |
<table width="100%" border=0 cellspacing=0 cellpadding=2>
|
|
|
92 |
<tr><td valign="middle" align="left">
|
| 3316 |
rexy |
93 |
<center><H3><?= $lang['l_current_logo'] ?><img src="/images/organisme.png" width="90"></H3></center><BR>
|
|
|
94 |
<?= $lang['l_logo_select'] ?>
|
|
|
95 |
<form action="logo.php" method="POST" ENCTYPE="multipart/form-data">
|
| 2926 |
rexy |
96 |
<input type="file" name="logo">
|
| 3316 |
rexy |
97 |
<input type="hidden" name="MAX_FILE_SIZE" value="<?= $max_file_size ?>">
|
|
|
98 |
<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $lang['l_send'] ?>">
|
| 2926 |
rexy |
99 |
</form>
|
| 318 |
richard |
100 |
<?php
|
| 2926 |
rexy |
101 |
if (isset($result)){
|
| 3316 |
rexy |
102 |
echo "<H3>".$result."</H3>";
|
|
|
103 |
echo "<H3>".$lang['l_logo_refresh']."</H3>";
|
|
|
104 |
}
|
|
|
105 |
?>
|
| 2926 |
rexy |
106 |
</td></tr>
|
|
|
107 |
</table>
|
|
|
108 |
</td></tr>
|
|
|
109 |
</table>
|
|
|
110 |
</div>
|
|
|
111 |
</div>
|
|
|
112 |
</body>
|
|
|
113 |
</html>
|