Compare commits
22 Commits
b82a71b9e7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49ee669d8b | ||
|
|
abecd1843d | ||
|
|
7754459ae3 | ||
|
|
41edbfc11e | ||
|
|
e518229940 | ||
|
|
39121427db | ||
|
|
4949790bd0 | ||
|
|
bde024adf3 | ||
|
|
4078149eec | ||
|
|
e69f505873 | ||
|
|
cc720a3799 | ||
|
|
28d2bff3ef | ||
|
|
b085828350 | ||
|
|
8d55c06c2b | ||
|
|
a9e7024830 | ||
|
|
20361ed80d | ||
|
|
cc2ad0a6a7 | ||
|
|
3de9e74331 | ||
|
|
2847ed5514 | ||
|
|
61ef28108d | ||
|
|
8abff0fb6c | ||
|
|
0936b690ec |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.specstory
|
||||||
@@ -27,5 +27,9 @@ MYSQL_USER=""
|
|||||||
MYSQL_PASS=""
|
MYSQL_PASS=""
|
||||||
MYSQL_DB=""
|
MYSQL_DB=""
|
||||||
|
|
||||||
|
#CMD_parpar
|
||||||
|
|
||||||
|
CMD_PARPAR="-s10M -S -m4096M -t16 -r20%"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,5 +36,9 @@ module.exports = {
|
|||||||
auth: {
|
auth: {
|
||||||
username: 'user',
|
username: 'user',
|
||||||
password: 'pass'
|
password: 'pass'
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// Configuration pour le renvoi vers le site principal
|
||||||
|
apiUrl: 'A NOUS DEMANDER SUR DISCORD',
|
||||||
|
apiKey: 'A RETROUVER DANS VOTRE PROFIL'
|
||||||
};
|
};
|
||||||
@@ -20,13 +20,11 @@ attente() {
|
|||||||
|
|
||||||
checkusenet(){
|
checkusenet(){
|
||||||
SERVICE="nyuu"
|
SERVICE="nyuu"
|
||||||
if pgrep -x "$SERVICE" >/dev/null
|
while pgrep -x "$SERVICE" >/dev/null; do
|
||||||
then
|
|
||||||
echo "$SERVICE EN COURS"
|
echo "$SERVICE EN COURS"
|
||||||
sleep 16
|
sleep 16
|
||||||
else
|
done
|
||||||
echo "$SERVICE OK"
|
echo "$SERVICE OK"
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cd "${DOSSIER_GLOBAL}"
|
cd "${DOSSIER_GLOBAL}"
|
||||||
@@ -49,7 +47,9 @@ while true; do
|
|||||||
db_query "UPDATE \`$MYSQL_TABLE\` SET status = 4 WHERE id = ${id};"
|
db_query "UPDATE \`$MYSQL_TABLE\` SET status = 4 WHERE id = ${id};"
|
||||||
fi
|
fi
|
||||||
echo -e "${CYAN}CREATION DES PAR2${NORMAL}" | tee -a "$LOG"
|
echo -e "${CYAN}CREATION DES PAR2${NORMAL}" | tee -a "$LOG"
|
||||||
parpar -s10M -S -m4096M -t16 -r20% -O -o "${FILESANSEXT}.par2" "${name}" \
|
# Utilise CMD_PARPAR si défini, sinon valeurs par défaut
|
||||||
|
PARPAR_OPTS="${CMD_PARPAR:--s10M -S -m4096M -t16 -r20%}"
|
||||||
|
parpar $PARPAR_OPTS -O -o "${FILESANSEXT}.par2" "${name}" \
|
||||||
> >(tee -a "$LOG") 2> >(tee -a "$LOG" >&2)
|
> >(tee -a "$LOG") 2> >(tee -a "$LOG" >&2)
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ $ret -ne 0 ]; then
|
if [ $ret -ne 0 ]; then
|
||||||
@@ -69,7 +69,8 @@ while true; do
|
|||||||
--nzb-title '${FILESANSEXT}' \
|
--nzb-title '${FILESANSEXT}' \
|
||||||
-f '{rand(14)} {rand(14)}@{rand(5)}.{rand(3)}' \
|
-f '{rand(14)} {rand(14)}@{rand(5)}.{rand(3)}' \
|
||||||
--message-id '{rand(32)}@{rand(8)}.{rand(3)}' \
|
--message-id '{rand(32)}@{rand(8)}.{rand(3)}' \
|
||||||
--subject '{rand(32)}' --nzb-subject '{filename}' \
|
--subject '{rand(32)}' \
|
||||||
|
--nzb-subject '[{0filenum}/{files}] - \"{filename}\" yEnc ({part}/{parts})' \
|
||||||
--obfuscate-articles ${files[*]} \
|
--obfuscate-articles ${files[*]} \
|
||||||
--progress=stderr" \
|
--progress=stderr" \
|
||||||
/dev/null
|
/dev/null
|
||||||
@@ -78,11 +79,25 @@ while true; do
|
|||||||
echo -e "${JAUNE}VERIF DU NZB${NORMAL}"
|
echo -e "${JAUNE}VERIF DU NZB${NORMAL}"
|
||||||
nzbsizebit=$(bash ${ANALYZER} "${DOSSIER_NZB_ATTENTE}${FILESANSEXT}.nzb" | jq '.Taillebit')
|
nzbsizebit=$(bash ${ANALYZER} "${DOSSIER_NZB_ATTENTE}${FILESANSEXT}.nzb" | jq '.Taillebit')
|
||||||
echo -e "NZB_SIZE : ${nzbsizebit}"
|
echo -e "NZB_SIZE : ${nzbsizebit}"
|
||||||
|
# Détermine si on est en mode "symlink" selon la conf
|
||||||
|
symlink_mode=0
|
||||||
|
case "${MOVE_CMD:-}" in
|
||||||
|
"cp -rs"|"ln -s") symlink_mode=1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [[ "${name}" =~ \.(iso)$ ]]; then
|
if [[ "${name}" =~ \.(iso)$ ]]; then
|
||||||
jsonsizebit=$(du -b -c "${name}" | grep total | awk '{ print $1 }')
|
if (( symlink_mode )); then
|
||||||
|
# Suivre le lien symbolique pour obtenir la taille réelle
|
||||||
|
jsonsizebit=$(du -Lb -c -- "${name}" | awk '/total/ {print $1}')
|
||||||
else
|
else
|
||||||
|
# Comportement inchangé
|
||||||
|
jsonsizebit=$(du -b -c -- "${name}" | awk '/total/ {print $1}')
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Comportement inchangé
|
||||||
jsonsizebit=$(jq -r '.media.track[] | select(."@type" == "General") | .FileSize' "${DOSSIER_NFO}${FILESANSEXT}.json")
|
jsonsizebit=$(jq -r '.media.track[] | select(."@type" == "General") | .FileSize' "${DOSSIER_NFO}${FILESANSEXT}.json")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "MEDIAINFO_SIZE : ${jsonsizebit}"
|
echo -e "MEDIAINFO_SIZE : ${jsonsizebit}"
|
||||||
|
|
||||||
if [[ ${nzbsizebit} -le ${jsonsizebit} ]] || [[ ${nzbsizebit} = "NAN" ]]; then
|
if [[ ${nzbsizebit} -le ${jsonsizebit} ]] || [[ ${nzbsizebit} = "NAN" ]]; then
|
||||||
|
|||||||
718
autopost/public/autopost.js
Normal file
718
autopost/public/autopost.js
Normal file
@@ -0,0 +1,718 @@
|
|||||||
|
// === Autopost client script ===
|
||||||
|
|
||||||
|
// --- CSRF global ---
|
||||||
|
(function () {
|
||||||
|
const meta = document.querySelector('meta[name="csrf-token"]');
|
||||||
|
const CSRF_TOKEN = meta ? meta.content : (window.__BOOTSTRAP__ && window.__BOOTSTRAP__.csrf) || '';
|
||||||
|
if (window.jQuery) {
|
||||||
|
$.ajaxSetup({ headers: { 'x-csrf-token': CSRF_TOKEN } });
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
// --- XSS escape côté client ---
|
||||||
|
function esc(s) {
|
||||||
|
// ATTENTION: backtick échappé dans la classe de caractères: \`
|
||||||
|
return String(s).replace(/[&<>"'\`=]/g, c => ({
|
||||||
|
'&': '&', '<': '<', '>': '>',
|
||||||
|
'"': '"', "'": ''', '\`': '`', '=': '='
|
||||||
|
}[c]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Bootstrap values ---
|
||||||
|
const INITIAL_PAGE = (window.__BOOTSTRAP__ && window.__BOOTSTRAP__.page) || 1;
|
||||||
|
const INITIAL_TOTAL_PAGES= (window.__BOOTSTRAP__ && window.__BOOTSTRAP__.totalPages) || 1;
|
||||||
|
const PAGE_LIMIT = (window.__BOOTSTRAP__ && window.__BOOTSTRAP__.limit) || 100;
|
||||||
|
|
||||||
|
let currentPage = INITIAL_PAGE;
|
||||||
|
let currentTotalPages = INITIAL_TOTAL_PAGES;
|
||||||
|
let activeFilter = null; // number | null
|
||||||
|
let activeQuery = ''; // string
|
||||||
|
|
||||||
|
// --- Rendering: table ---
|
||||||
|
function updateTable(rows) {
|
||||||
|
var tbody = $('table tbody');
|
||||||
|
tbody.empty();
|
||||||
|
|
||||||
|
rows.forEach(function(row) {
|
||||||
|
var statusText = '';
|
||||||
|
var statusClass = '';
|
||||||
|
|
||||||
|
switch (parseInt(row.status)) {
|
||||||
|
case 0: statusText = 'EN ATTENTE'; statusClass = 'bg-cyan-500 text-black font-bold'; break;
|
||||||
|
case 1: statusText = 'ENVOI TERMINÉ'; statusClass = 'bg-green-300 text-black font-bold'; break;
|
||||||
|
case 2: statusText = 'ERREUR'; statusClass = 'bg-red-300 text-black font-bold'; break;
|
||||||
|
case 3: statusText = 'DEJA DISPONIBLE';statusClass = 'bg-pink-300 text-black font-bold'; break;
|
||||||
|
case 4: statusText = 'EN COURS'; statusClass = 'bg-yellow-300 text-black font-bold'; break;
|
||||||
|
default: statusText = 'INCONNU';
|
||||||
|
}
|
||||||
|
|
||||||
|
var logLink = (parseInt(row.status) === 1 || parseInt(row.status) === 2 || parseInt(row.status) === 4)
|
||||||
|
? ' | <a href="#" class="log-link text-blue-400 hover:underline" data-filename="' + esc(row.nom) + '">Log</a>'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
var mediainfoLink = (parseInt(row.status) === 0 || parseInt(row.status) === 1 || parseInt(row.status) === 2)
|
||||||
|
? ' | <a href="#" class="mediainfo-link text-blue-400 hover:underline" data-filename="' + esc(row.nom) + '">Mediainfo</a>'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
var dlLink = (parseInt(row.status) === 1)
|
||||||
|
? ' | <a href="/autopost/dl?name=' + encodeURIComponent(row.nom) + '" class="dl-link text-blue-400 hover:underline">DL</a>'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
var resendLink = (parseInt(row.status) === 1)
|
||||||
|
? ' | <a href="#" class="resend-link text-green-400 hover:underline" data-id="' + row.id + '" data-filename="' + esc(row.nom) + '">Renvoyer</a>'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
var tr =
|
||||||
|
'<tr id="row-' + row.id + '" data-status="' + row.status + '" class="odd:bg-gray-800 even:bg-gray-700">' +
|
||||||
|
'<td class="px-4 py-2 border border-gray-700 text-center">' +
|
||||||
|
'<input type="checkbox" class="row-checkbox checkbox-custom" data-id="' + row.id + '" data-name="' + esc(row.nom) + '">' +
|
||||||
|
'</td>' +
|
||||||
|
'<td class="px-4 py-2 border border-gray-700 whitespace-nowrap">' + esc(row.nom) + '</td>' +
|
||||||
|
'<td class="px-4 py-2 border border-gray-700 status-text whitespace-nowrap ' + statusClass + '">' + statusText + '</td>' +
|
||||||
|
'<td class="px-4 py-2 border border-gray-700">' + row.id + '</td>' +
|
||||||
|
'<td class="px-4 py-2 border border-gray-700">' +
|
||||||
|
'<a href="#" class="edit-link text-blue-400 hover:underline" data-id="' + row.id + '" data-status="' + row.status + '">Editer</a> | ' +
|
||||||
|
'<a href="#" class="delete-link text-blue-400 hover:underline" data-id="' + row.id + '">Supprimer</a>' +
|
||||||
|
logLink + mediainfoLink + dlLink + resendLink +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>';
|
||||||
|
|
||||||
|
tbody.append(tr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Rendering: pagination ---
|
||||||
|
function renderPaginationHTML(page, totalPages) {
|
||||||
|
var prevDisabled = page <= 1;
|
||||||
|
var nextDisabled = page >= totalPages;
|
||||||
|
|
||||||
|
var h = '';
|
||||||
|
h += '<ul class="inline-flex items-center -space-x-px">';
|
||||||
|
h += '<li>';
|
||||||
|
if (prevDisabled) {
|
||||||
|
h += '<span class="px-3 py-2 ml-0 leading-tight text-gray-500 bg-gray-200 border border-gray-300 rounded-l-lg">Précédent</span>';
|
||||||
|
} else {
|
||||||
|
h += '<a href="/autopost/?page=' + (page - 1) + '" data-page="' + (page - 1) + '" class="px-3 py-2 ml-0 leading-tight text-gray-500 bg-white border border-gray-300 rounded-l-lg hover:bg-gray-100 hover:text-gray-700">Précédent</a>';
|
||||||
|
}
|
||||||
|
h += '</li>';
|
||||||
|
h += '<li><span class="px-4 py-2 leading-tight text-gray-700 bg-white border border-gray-300">Page ' + page + ' sur ' + totalPages + '</span></li>';
|
||||||
|
h += '<li>';
|
||||||
|
if (nextDisabled) {
|
||||||
|
h += '<span class="px-3 py-2 leading-tight text-gray-500 bg-gray-200 border border-gray-300 rounded-r-lg">Suivant</span>';
|
||||||
|
} else {
|
||||||
|
h += '<a href="/autopost/?page=' + (page + 1) + '" data-page="' + (page + 1) + '" class="px-3 py-2 leading-tight text-gray-500 bg-white border border-gray-300 rounded-r-lg hover:bg-gray-100 hover:text-gray-700">Suivant</a>';
|
||||||
|
}
|
||||||
|
h += '</li>';
|
||||||
|
h += '</ul>';
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
function updatePagination(page, totalPages) {
|
||||||
|
$('#pagination').html(renderPaginationHTML(page, totalPages));
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Data loading ---
|
||||||
|
function loadPage(p) {
|
||||||
|
const targetPage = Math.max(1, parseInt(p, 10) || 1);
|
||||||
|
|
||||||
|
const isFilter = activeFilter !== null;
|
||||||
|
const url = isFilter ? '/autopost/filter' : '/autopost/search';
|
||||||
|
const data = isFilter
|
||||||
|
? { status: activeFilter, page: targetPage, limit: PAGE_LIMIT }
|
||||||
|
: { q: activeQuery || '', page: targetPage, limit: PAGE_LIMIT };
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: 'GET',
|
||||||
|
data: data,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(resp) {
|
||||||
|
updateTable(resp.rows);
|
||||||
|
currentPage = resp.page;
|
||||||
|
currentTotalPages = resp.totalPages;
|
||||||
|
updatePagination(currentPage, currentTotalPages);
|
||||||
|
// Mettre à jour les actions en lot après le chargement des nouvelles données
|
||||||
|
updateBulkActions();
|
||||||
|
},
|
||||||
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
|
if (textStatus !== 'abort') {
|
||||||
|
console.error('Erreur AJAX :', textStatus, errorThrown);
|
||||||
|
alert('Erreur lors du chargement de la page.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Long polling: refresh table when new mediainfo/log apparaît ---
|
||||||
|
(function () {
|
||||||
|
var lastVersion = null;
|
||||||
|
|
||||||
|
function poll() {
|
||||||
|
$.ajax({
|
||||||
|
url: '/autopost/updates',
|
||||||
|
type: 'GET',
|
||||||
|
data: { since: lastVersion || 0 },
|
||||||
|
timeout: 30000,
|
||||||
|
success: function (resp) {
|
||||||
|
if (resp && typeof resp.version === 'number') {
|
||||||
|
if (lastVersion === null) {
|
||||||
|
lastVersion = resp.version; // 1ère synchro: on se cale
|
||||||
|
} else if (resp.version > lastVersion) {
|
||||||
|
lastVersion = resp.version;
|
||||||
|
if (typeof loadPage === 'function') loadPage(currentPage || 1);
|
||||||
|
if (typeof updateStatsUI === 'function') {
|
||||||
|
$.getJSON('/autopost/stats', function (s) { if (s) updateStatsUI(s); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTimeout(poll, 100);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
setTimeout(poll, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(poll);
|
||||||
|
})();
|
||||||
|
|
||||||
|
function updateStatsUI(s) {
|
||||||
|
$('.filter-card[data-status="0"] .tabular-nums').text(s.attente || 0);
|
||||||
|
$('.filter-card[data-status="1"] .tabular-nums').text(s.termine || 0);
|
||||||
|
$('.filter-card[data-status="2"] .tabular-nums').text(s.erreur || 0);
|
||||||
|
$('.filter-card[data-status="3"] .tabular-nums').text(s.deja || 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshAfterChange() {
|
||||||
|
loadPage(currentPage || 1);
|
||||||
|
$.getJSON('/autopost/stats', function(s) { updateStatsUI(s); });
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- DOM bindings ---
|
||||||
|
$(document).ready(function() {
|
||||||
|
// Recherche
|
||||||
|
let searchTimer = null;
|
||||||
|
$('#searchInput').on('keyup', function() {
|
||||||
|
clearTimeout(searchTimer);
|
||||||
|
let q = $(this).val();
|
||||||
|
|
||||||
|
searchTimer = setTimeout(function() {
|
||||||
|
activeQuery = q || '';
|
||||||
|
activeFilter = null; // on sort du mode filtre
|
||||||
|
$('.filter-card').removeClass('ring-4 ring-white/40');
|
||||||
|
loadPage(1); // charge page 1 avec pagination AJAX
|
||||||
|
toggleShowAllButton();
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Pagination: intercepter et paginer en AJAX
|
||||||
|
$(document).on('click', '#pagination a[data-page]', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const p = parseInt($(this).data('page'), 10);
|
||||||
|
if (!isNaN(p)) loadPage(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Affichage/masquage du bouton "Tout afficher"
|
||||||
|
function toggleShowAllButton() {
|
||||||
|
if ($('.filter-card.ring-4').length === 0) {
|
||||||
|
$('#showAll').addClass('hidden');
|
||||||
|
} else {
|
||||||
|
$('#showAll').removeClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filtrage par clic sur une card
|
||||||
|
$(document).on('click', '.filter-card', function() {
|
||||||
|
const status = parseInt($(this).data('status'), 10);
|
||||||
|
|
||||||
|
$('.filter-card').removeClass('ring-4 ring-white/40');
|
||||||
|
$(this).addClass('ring-4 ring-white/40');
|
||||||
|
|
||||||
|
activeFilter = status;
|
||||||
|
activeQuery = ''; // on sort du mode recherche
|
||||||
|
loadPage(1); // page 1 du filtre
|
||||||
|
toggleShowAllButton();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Bouton tout afficher
|
||||||
|
$(document).on('click', '#showAll', function() {
|
||||||
|
$('.filter-card').removeClass('ring-4 ring-white/40');
|
||||||
|
activeFilter = null;
|
||||||
|
activeQuery = $('#searchInput').val() || '';
|
||||||
|
loadPage(1);
|
||||||
|
toggleShowAllButton();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Edition (ouvrir modale)
|
||||||
|
$(document).on('click', '.edit-link', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var releaseId = $(this).data('id');
|
||||||
|
var currentStatus = $(this).data('status');
|
||||||
|
$('#releaseId').val(releaseId);
|
||||||
|
$('#modalReleaseId').text(releaseId);
|
||||||
|
$('#statusSelect').val(currentStatus);
|
||||||
|
$('#editModal').removeClass('hidden').fadeIn();
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------- Confirmation de suppression (modale) ----------
|
||||||
|
var pendingDeleteId = null;
|
||||||
|
|
||||||
|
function openConfirmModal(id, name) {
|
||||||
|
pendingDeleteId = id;
|
||||||
|
$('#confirmItemName').text(name || ('ID ' + id));
|
||||||
|
$('#confirmDeleteModal').removeClass('hidden').fadeIn(120);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeConfirmModal() {
|
||||||
|
$('#confirmDeleteModal').fadeOut(120, function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
pendingDeleteId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fonctions pour la modal de renvoi
|
||||||
|
var pendingResendId = null;
|
||||||
|
var pendingResendFilename = null;
|
||||||
|
|
||||||
|
function openConfirmResendModal(id, filename) {
|
||||||
|
pendingResendId = id;
|
||||||
|
pendingResendFilename = filename;
|
||||||
|
$('#confirmResendItemName').text(filename || ('ID ' + id));
|
||||||
|
$('#confirmResendModal').removeClass('hidden').fadeIn(120);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeConfirmResendModal() {
|
||||||
|
$('#confirmResendModal').fadeOut(120, function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
pendingResendId = null;
|
||||||
|
pendingResendFilename = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function showToast(msg) {
|
||||||
|
$('#toastMsg').text(msg || 'Opération effectuée');
|
||||||
|
$('#toast').removeClass('hidden').fadeIn(120);
|
||||||
|
setTimeout(function() {
|
||||||
|
$('#toast').fadeOut(150, function() { $(this).addClass('hidden'); });
|
||||||
|
}, 1800);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ouvrir la modale au clic sur "Supprimer"
|
||||||
|
$(document).on('click', '.delete-link', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var releaseId = $(this).data('id');
|
||||||
|
var name = $(this).closest('tr').find('td:first').text().trim();
|
||||||
|
openConfirmModal(releaseId, name);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Boutons de la modale
|
||||||
|
$('#cancelDeleteBtn, #confirmDeleteClose').on('click', function() {
|
||||||
|
closeConfirmModal();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clic sur l'overlay pour fermer
|
||||||
|
$('#confirmDeleteModal').on('click', function(e) {
|
||||||
|
if (e.target === this) { closeConfirmModal(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gestionnaires pour la modal de renvoi
|
||||||
|
$('#cancelResendBtn, #confirmResendClose').on('click', function() {
|
||||||
|
closeConfirmResendModal();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clic sur l'overlay pour fermer la modal de renvoi
|
||||||
|
$('#confirmResendModal').on('click', function(e) {
|
||||||
|
if (e.target === this) { closeConfirmResendModal(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Accessibilité clavier: Esc = fermer, Enter = confirmer
|
||||||
|
$(document).on('keydown', function(e) {
|
||||||
|
var deleteModalVisible = !$('#confirmDeleteModal').hasClass('hidden');
|
||||||
|
var resendModalVisible = !$('#confirmResendModal').hasClass('hidden');
|
||||||
|
|
||||||
|
if (deleteModalVisible) {
|
||||||
|
if (e.key === 'Escape') { closeConfirmModal(); }
|
||||||
|
if (e.key === 'Enter') { $('#confirmDeleteBtn').click(); }
|
||||||
|
} else if (resendModalVisible) {
|
||||||
|
if (e.key === 'Escape') { closeConfirmResendModal(); }
|
||||||
|
if (e.key === 'Enter') { $('#confirmResendBtn').click(); }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Confirmer et supprimer via AJAX
|
||||||
|
$('#confirmDeleteBtn').on('click', function() {
|
||||||
|
if (!pendingDeleteId) return;
|
||||||
|
var releaseId = pendingDeleteId;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/autopost/delete/' + releaseId,
|
||||||
|
type: 'POST',
|
||||||
|
success: function() {
|
||||||
|
$('#row-' + releaseId)
|
||||||
|
.css('outline', '2px solid rgba(239,68,68,0.6)')
|
||||||
|
.fadeOut('300', function(){ $(this).remove(); });
|
||||||
|
showToast('Enregistrement supprimé');
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert('Erreur lors de la suppression.');
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
closeConfirmModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Confirmer et renvoyer via AJAX
|
||||||
|
$('#confirmResendBtn').on('click', function() {
|
||||||
|
if (!pendingResendId) return;
|
||||||
|
var releaseId = pendingResendId;
|
||||||
|
var filename = pendingResendFilename;
|
||||||
|
|
||||||
|
var $button = $(this);
|
||||||
|
var originalText = $button.text();
|
||||||
|
$button.text('Envoi...');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/autopost/resend/' + releaseId,
|
||||||
|
type: 'POST',
|
||||||
|
success: function(data) {
|
||||||
|
showToast(data.message || 'Renvoi effectué avec succès');
|
||||||
|
console.log('Renvoi réussi pour', filename);
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
var errorMsg = 'Erreur lors du renvoi';
|
||||||
|
if (xhr.responseJSON && xhr.responseJSON.error) {
|
||||||
|
errorMsg = xhr.responseJSON.error;
|
||||||
|
}
|
||||||
|
alert(errorMsg);
|
||||||
|
console.error('Erreur renvoi:', xhr.responseJSON);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$button.text(originalText);
|
||||||
|
closeConfirmResendModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Affichage log
|
||||||
|
$(document).on('click', '.log-link', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var filename = $(this).data('filename');
|
||||||
|
$.ajax({
|
||||||
|
url: '/autopost/log',
|
||||||
|
type: 'GET',
|
||||||
|
data: { name: filename },
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
$('#logContent').html(data.content);
|
||||||
|
$('#logModal').removeClass('hidden').fadeIn();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert('Erreur lors du chargement du fichier log.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Affichage mediainfo
|
||||||
|
$(document).on('click', '.mediainfo-link', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var filename = $(this).data('filename');
|
||||||
|
$.ajax({
|
||||||
|
url: '/autopost/mediainfo',
|
||||||
|
type: 'GET',
|
||||||
|
data: { name: filename },
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
$('#mediainfoContent').text(data.content);
|
||||||
|
$('#mediainfoModal').removeClass('hidden').fadeIn();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert('Erreur lors du chargement du fichier mediainfo.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fermeture modales (croix + clic overlay)
|
||||||
|
$('.close').click(function() {
|
||||||
|
$(this).closest('.fixed').fadeOut(function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.fixed').click(function(e) {
|
||||||
|
if (e.target === this) {
|
||||||
|
$(this).fadeOut(function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Edition: submit
|
||||||
|
$('#editForm').submit(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var releaseId = $('#releaseId').val();
|
||||||
|
var newStatus = $('#statusSelect').val();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/autopost/edit/' + releaseId,
|
||||||
|
type: 'POST',
|
||||||
|
data: { status: newStatus },
|
||||||
|
success: function() {
|
||||||
|
var statusText = '';
|
||||||
|
var statusClass = '';
|
||||||
|
switch (parseInt(newStatus)) {
|
||||||
|
case 0: statusText = 'EN ATTENTE'; statusClass = 'bg-cyan-500 text-black font-bold'; break;
|
||||||
|
case 1: statusText = 'ENVOI TERMINÉ'; statusClass = 'bg-green-300 text-black font-bold'; break;
|
||||||
|
case 2: statusText = 'ERREUR'; statusClass = 'bg-red-300 text-black font-bold'; break;
|
||||||
|
case 3: statusText = 'DEJA DISPONIBLE';statusClass = 'bg-pink-300 text-black font-bold'; break;
|
||||||
|
case 4: statusText = 'EN COURS'; statusClass = 'bg-yellow-300 text-black font-bold'; break;
|
||||||
|
default: statusText = 'INCONNU';
|
||||||
|
}
|
||||||
|
|
||||||
|
var row = $('#row-' + releaseId);
|
||||||
|
row.find('.status-text')
|
||||||
|
.removeClass('bg-cyan-500 bg-green-300 bg-red-300 bg-pink-300 bg-yellow-300')
|
||||||
|
.addClass(statusClass)
|
||||||
|
.text(statusText);
|
||||||
|
|
||||||
|
$('#editModal').fadeOut(function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert('Erreur lors de la mise à jour.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Bouton copier Mediainfo
|
||||||
|
$('#copyMediainfoBtn').on('click', function() {
|
||||||
|
const content = document.getElementById('mediainfoContent').textContent;
|
||||||
|
navigator.clipboard.writeText(content).then(() => {
|
||||||
|
this.textContent = '✅ Copié !';
|
||||||
|
setTimeout(() => this.textContent = '📋 Copier JSON', 2000);
|
||||||
|
}).catch(function(err) {
|
||||||
|
alert('Erreur lors de la copie : ' + err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Renvoi vers le site principal
|
||||||
|
$(document).on('click', '.resend-link', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var releaseId = $(this).data('id');
|
||||||
|
var filename = $(this).data('filename');
|
||||||
|
openConfirmResendModal(releaseId, filename);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ==================== GESTION SÉLECTION MULTIPLE ====================
|
||||||
|
|
||||||
|
function updateBulkActions() {
|
||||||
|
const selectedCheckboxes = $('.row-checkbox:checked');
|
||||||
|
const count = selectedCheckboxes.length;
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
$('#bulkActions').removeClass('hidden');
|
||||||
|
$('#selectedCount').text(count + ' élément' + (count > 1 ? 's' : '') + ' sélectionné' + (count > 1 ? 's' : ''));
|
||||||
|
} else {
|
||||||
|
$('#bulkActions').addClass('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mettre à jour la checkbox "Tout sélectionner"
|
||||||
|
const totalCheckboxes = $('.row-checkbox').length;
|
||||||
|
const allChecked = count === totalCheckboxes && totalCheckboxes > 0;
|
||||||
|
const someChecked = count > 0 && count < totalCheckboxes;
|
||||||
|
|
||||||
|
$('#selectAll').prop('checked', allChecked);
|
||||||
|
$('#selectAll').prop('indeterminate', someChecked);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checkbox "Tout sélectionner"
|
||||||
|
$(document).on('click', '#selectAll', function() {
|
||||||
|
const isChecked = $(this).is(':checked');
|
||||||
|
$('.row-checkbox').prop('checked', isChecked);
|
||||||
|
updateBulkActions();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Checkboxes individuelles
|
||||||
|
$(document).on('click', '.row-checkbox', function() {
|
||||||
|
updateBulkActions();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Bouton "Éditer la sélection"
|
||||||
|
$(document).on('click', '#bulkEditBtn', function() {
|
||||||
|
const selectedCheckboxes = $('.row-checkbox:checked');
|
||||||
|
const count = selectedCheckboxes.length;
|
||||||
|
|
||||||
|
if (count === 0) return;
|
||||||
|
|
||||||
|
$('#bulkEditCount').text(count);
|
||||||
|
$('#bulkEditModal').removeClass('hidden').fadeIn(120);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Bouton "Supprimer la sélection"
|
||||||
|
$(document).on('click', '#bulkDeleteBtn', function() {
|
||||||
|
const selectedCheckboxes = $('.row-checkbox:checked');
|
||||||
|
const count = selectedCheckboxes.length;
|
||||||
|
|
||||||
|
if (count === 0) return;
|
||||||
|
|
||||||
|
// Construire la liste des éléments à supprimer
|
||||||
|
let listHTML = '';
|
||||||
|
selectedCheckboxes.each(function() {
|
||||||
|
const name = $(this).data('name');
|
||||||
|
const id = $(this).data('id');
|
||||||
|
listHTML += `<div class="text-sm text-gray-300 mb-1">• ${name} (ID: ${id})</div>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#bulkDeleteCount').text(count);
|
||||||
|
$('#bulkDeleteList').html(listHTML);
|
||||||
|
$('#bulkDeleteModal').removeClass('hidden').fadeIn(120);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fermeture des modals en lot
|
||||||
|
$('#bulkEditClose, #bulkDeleteClose, #cancelBulkDeleteBtn').on('click', function() {
|
||||||
|
$('#bulkEditModal, #bulkDeleteModal').fadeOut(120, function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clic sur l'overlay pour fermer les modals en lot
|
||||||
|
$('#bulkEditModal, #bulkDeleteModal').on('click', function(e) {
|
||||||
|
if (e.target === this) {
|
||||||
|
$(this).fadeOut(120, function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Soumission du formulaire d'édition en lot
|
||||||
|
$('#bulkEditForm').on('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const selectedCheckboxes = $('.row-checkbox:checked');
|
||||||
|
const newStatus = $('#bulkStatusSelect').val();
|
||||||
|
const ids = [];
|
||||||
|
|
||||||
|
selectedCheckboxes.each(function() {
|
||||||
|
ids.push($(this).data('id'));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ids.length === 0) return;
|
||||||
|
|
||||||
|
const $submitBtn = $('#bulkEditForm button[type="submit"]');
|
||||||
|
const originalText = $submitBtn.text();
|
||||||
|
$submitBtn.text('Mise à jour...').prop('disabled', true);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/autopost/bulk-edit',
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
ids: ids,
|
||||||
|
status: newStatus,
|
||||||
|
_csrf: window.__BOOTSTRAP__.csrf
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
// Mettre à jour l'interface pour chaque ligne modifiée
|
||||||
|
ids.forEach(function(id) {
|
||||||
|
updateRowStatus(id, newStatus);
|
||||||
|
});
|
||||||
|
|
||||||
|
showToast(`${ids.length} élément(s) mis à jour`);
|
||||||
|
|
||||||
|
// Fermer la modal et désélectionner
|
||||||
|
$('#bulkEditModal').fadeOut(120, function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
$('.row-checkbox').prop('checked', false);
|
||||||
|
updateBulkActions();
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
let errorMsg = 'Erreur lors de la mise à jour en lot';
|
||||||
|
if (xhr.responseJSON && xhr.responseJSON.error) {
|
||||||
|
errorMsg = xhr.responseJSON.error;
|
||||||
|
}
|
||||||
|
alert(errorMsg);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$submitBtn.text(originalText).prop('disabled', false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Confirmation de suppression en lot
|
||||||
|
$('#confirmBulkDeleteBtn').on('click', function() {
|
||||||
|
const selectedCheckboxes = $('.row-checkbox:checked');
|
||||||
|
const ids = [];
|
||||||
|
|
||||||
|
selectedCheckboxes.each(function() {
|
||||||
|
ids.push($(this).data('id'));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ids.length === 0) return;
|
||||||
|
|
||||||
|
const $button = $(this);
|
||||||
|
const originalText = $button.text();
|
||||||
|
$button.text('Suppression...').prop('disabled', true);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/autopost/bulk-delete',
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
ids: ids,
|
||||||
|
_csrf: window.__BOOTSTRAP__.csrf
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
showToast(`${ids.length} élément(s) supprimé(s)`);
|
||||||
|
|
||||||
|
// Fermer la modal
|
||||||
|
$('#bulkDeleteModal').fadeOut(120, function() {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Décocher toutes les checkboxes AVANT de recharger
|
||||||
|
$('.row-checkbox').prop('checked', false);
|
||||||
|
$('#selectAll').prop('checked', false).prop('indeterminate', false);
|
||||||
|
$('#bulkActions').addClass('hidden');
|
||||||
|
|
||||||
|
// Recharger les données de la page courante
|
||||||
|
loadPage(currentPage || 1);
|
||||||
|
|
||||||
|
// Mettre à jour les statistiques
|
||||||
|
$.getJSON('/autopost/stats', function(s) {
|
||||||
|
if (s) updateStatsUI(s);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
let errorMsg = 'Erreur lors de la suppression en lot';
|
||||||
|
if (xhr.responseJSON && xhr.responseJSON.error) {
|
||||||
|
errorMsg = xhr.responseJSON.error;
|
||||||
|
}
|
||||||
|
alert(errorMsg);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$button.text(originalText).prop('disabled', false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fonction utilitaire pour mettre à jour le statut d'une ligne
|
||||||
|
function updateRowStatus(id, newStatus) {
|
||||||
|
const $row = $('#row-' + id);
|
||||||
|
const $statusCell = $row.find('.status-text');
|
||||||
|
|
||||||
|
let statusText = '';
|
||||||
|
let statusClass = '';
|
||||||
|
switch (parseInt(newStatus)) {
|
||||||
|
case 0: statusText = 'EN ATTENTE'; statusClass = 'bg-cyan-500 text-black font-bold'; break;
|
||||||
|
case 1: statusText = 'ENVOI TERMINÉ'; statusClass = 'bg-green-300 text-black font-bold'; break;
|
||||||
|
case 2: statusText = 'ERREUR'; statusClass = 'bg-red-300 text-black font-bold'; break;
|
||||||
|
case 3: statusText = 'DEJA DISPONIBLE'; statusClass = 'bg-pink-300 text-black font-bold'; break;
|
||||||
|
case 4: statusText = 'EN COURS'; statusClass = 'bg-yellow-300 text-black font-bold'; break;
|
||||||
|
default: statusText = 'INCONNU';
|
||||||
|
}
|
||||||
|
|
||||||
|
$statusCell.removeClass().addClass('px-4 py-2 border border-gray-700 status-text whitespace-nowrap ' + statusClass);
|
||||||
|
$statusCell.text(statusText);
|
||||||
|
$row.attr('data-status', newStatus);
|
||||||
|
}
|
||||||
|
});
|
||||||
141
autopost/public/checkboxes.css
Normal file
141
autopost/public/checkboxes.css
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
/* Checkboxes personnalisées modernes */
|
||||||
|
|
||||||
|
/* Style de base pour toutes les checkboxes */
|
||||||
|
.checkbox-custom {
|
||||||
|
appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border: 2px solid #4b5563;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #1f2937;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
outline: none;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* État hover */
|
||||||
|
.checkbox-custom:hover {
|
||||||
|
border-color: #6b7280;
|
||||||
|
background: #374151;
|
||||||
|
transform: scale(1.05);
|
||||||
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* État focus */
|
||||||
|
.checkbox-custom:focus {
|
||||||
|
border-color: #3b82f6;
|
||||||
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* État checked */
|
||||||
|
.checkbox-custom:checked {
|
||||||
|
background: linear-gradient(135deg, #3b82f6, #1d4ed8);
|
||||||
|
border-color: #3b82f6;
|
||||||
|
transform: scale(1.05);
|
||||||
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Icône de validation */
|
||||||
|
.checkbox-custom:checked::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
width: 10px;
|
||||||
|
height: 6px;
|
||||||
|
border: 2px solid white;
|
||||||
|
border-top: none;
|
||||||
|
border-right: none;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
top: 3px;
|
||||||
|
left: 3px;
|
||||||
|
animation: checkmark 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Animation de la coche */
|
||||||
|
@keyframes checkmark {
|
||||||
|
0% {
|
||||||
|
transform: rotate(-45deg) scale(0);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: rotate(-45deg) scale(1.2);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: rotate(-45deg) scale(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* État indéterminé pour "Tout sélectionner" */
|
||||||
|
.checkbox-custom:indeterminate {
|
||||||
|
background: linear-gradient(135deg, #f59e0b, #d97706);
|
||||||
|
border-color: #f59e0b;
|
||||||
|
transform: scale(1.05);
|
||||||
|
box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-custom:indeterminate::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
width: 8px;
|
||||||
|
height: 2px;
|
||||||
|
background: white;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
border-radius: 1px;
|
||||||
|
animation: indeterminate 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Animation de l'état indéterminé */
|
||||||
|
@keyframes indeterminate {
|
||||||
|
0% {
|
||||||
|
width: 0;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
width: 8px;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Effet de selection pour les lignes avec checkbox cochée */
|
||||||
|
tr:has(.checkbox-custom:checked) {
|
||||||
|
background-color: rgba(59, 130, 246, 0.05) !important;
|
||||||
|
border-left: 3px solid #3b82f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Animation d'apparition lors du chargement */
|
||||||
|
.checkbox-custom {
|
||||||
|
animation: fadeIn 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(0.8);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Amélioration pour les écrans tactiles */
|
||||||
|
@media (hover: none) {
|
||||||
|
.checkbox-custom:hover {
|
||||||
|
transform: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-custom:active {
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
}
|
||||||
1369
autopost/server.js
1369
autopost/server.js
File diff suppressed because it is too large
Load Diff
269
autopost/views/autopost.html
Normal file
269
autopost/views/autopost.html
Normal file
@@ -0,0 +1,269 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>{{TITLE}}</title>
|
||||||
|
<meta name="csrf-token" content="{{CSRF_TOKEN}}">
|
||||||
|
<link rel="icon" href="/autopost/favicon.ico" type="image/svg+xml">
|
||||||
|
<link rel="stylesheet" href="checkboxes.css" type="text/css">
|
||||||
|
<script src="js/index.global.js" type="application/javascript"></script>
|
||||||
|
<script src="jquery/jquery.min.js" type="application/javascript"></script>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body class="bg-{{BACKGROUND_CLASS}} text-white font-sans p-4">
|
||||||
|
<div class="w-full px-4">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="mb-6">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h1 class="text-2xl md:text-3xl font-extrabold tracking-tight bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-cyan-300">
|
||||||
|
Suivi Autopost {{APP_NAME}}
|
||||||
|
</h1>
|
||||||
|
<a href="/autopost/logout"
|
||||||
|
class="inline-flex items-center gap-2 px-3 py-2 rounded-xl bg-red-600/90 hover:bg-red-600 text-white shadow-lg shadow-red-900/20 transition">
|
||||||
|
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a2 2 0 01-2 2H6a2 2 0 01-2-2V7a2 2 0 012-2h5a2 2 0 012 2v1"/>
|
||||||
|
</svg>
|
||||||
|
Déconnexion
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<p class="mt-1 text-sm text-gray-400">Vue d’ensemble des traitements en cours et de l’état des envois.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Stat cards -->
|
||||||
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
|
||||||
|
<!-- En attente -->
|
||||||
|
<div class="group rounded-2xl p-3 md:p-5 bg-gradient-to-br from-cyan-500 to-cyan-400 text-black shadow-xl ring-1 ring-white/10 transition transform hover:-translate-y-0.5 hover:shadow-2xl cursor-pointer filter-card" data-status="0">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="rounded-xl bg-black/10 p-2">
|
||||||
|
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M12 6v6l4 2"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="text-sm/5 font-medium">En attente</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 text-3xl font-extrabold tabular-nums">{{STAT_ATTENTE}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Terminé -->
|
||||||
|
<div class="group rounded-2xl p-4 md:p-5 bg-gradient-to-br from-green-300 to-emerald-300 text-black shadow-xl ring-1 ring-white/10 transition transform hover:-translate-y-0.5 hover:shadow-2xl cursor-pointer filter-card" data-status="1">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="rounded-xl bg-black/10 p-2">
|
||||||
|
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M5 13l4 4L19 7"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="text-sm/5 font-medium">Terminé</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 text-3xl font-extrabold tabular-nums">{{STAT_TERMINE}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Erreur -->
|
||||||
|
<div class="group rounded-2xl p-4 md:p-5 bg-gradient-to-br from-rose-300 to-red-300 text-black shadow-xl ring-1 ring-white/10 transition transform hover:-translate-y-0.5 hover:shadow-2xl cursor-pointer filter-card" data-status="2">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="rounded-xl bg-black/10 p-2">
|
||||||
|
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M12 9v3m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="text-sm/5 font-medium">Erreur</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 text-3xl font-extrabold tabular-nums">{{STAT_ERREUR}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Déjà dispo -->
|
||||||
|
<div class="group rounded-2xl p-4 md:p-5 bg-gradient-to-br from-pink-300 to-fuchsia-300 text-black shadow-xl ring-1 ring-white/10 transition transform hover:-translate-y-0.5 hover:shadow-2xl cursor-pointer filter-card" data-status="3">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="rounded-xl bg-black/10 p-2">
|
||||||
|
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M8 7h8M8 11h8M8 15h6"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="text-sm/5 font-medium">Déjà dispo</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 text-3xl font-extrabold tabular-nums">{{STAT_DEJA}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Bouton réinitialiser -->
|
||||||
|
<div class="mb-4 text-center">
|
||||||
|
<button id="showAll"
|
||||||
|
class="hidden px-5 py-2 rounded-xl bg-gradient-to-br from-gray-600 to-gray-800 text-white font-semibold shadow-lg hover:from-gray-500 hover:to-gray-700 transition transform hover:-translate-y-0.5">
|
||||||
|
Tout afficher
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Search -->
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="searchInput" class="sr-only">Rechercher</label>
|
||||||
|
<div class="relative">
|
||||||
|
<span class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
|
||||||
|
<svg class="w-5 h-5 text-gray-400" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M21 21l-4.35-4.35M10 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16z"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<input id="searchInput" type="text" placeholder="Rechercher…"
|
||||||
|
class="w-full pl-10 pr-3 py-2 rounded-xl bg-gray-800/80 border border-gray-700 focus:border-blue-500 focus:ring-4 focus:ring-blue-500/20 outline-none transition placeholder:text-gray-400" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav id="pagination" aria-label="Page navigation" class="mb-4">
|
||||||
|
{{PAGINATION_HTML}}
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<!-- Boutons d'actions en lot -->
|
||||||
|
<div id="bulkActions" class="hidden mb-4 p-4 bg-gray-800 rounded-lg border border-gray-600">
|
||||||
|
<div class="flex items-center justify-between flex-wrap gap-3">
|
||||||
|
<span id="selectedCount" class="text-gray-300 font-medium">0 élément sélectionné</span>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<button id="bulkEditBtn" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-semibold transition">
|
||||||
|
✏️ Éditer la sélection
|
||||||
|
</button>
|
||||||
|
<button id="bulkDeleteBtn" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg font-semibold transition">
|
||||||
|
🗑️ Supprimer la sélection
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="min-w-full border border-gray-700 shadow-lg rounded-lg overflow-hidden">
|
||||||
|
<thead class="bg-gray-900 text-gray-300 uppercase text-sm">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-2">
|
||||||
|
<input type="checkbox" id="selectAll" class="checkbox-custom">
|
||||||
|
</th>
|
||||||
|
<th class="px-4 py-2">Name</th>
|
||||||
|
<th class="px-4 py-2">Status</th>
|
||||||
|
<th class="px-4 py-2">ID</th>
|
||||||
|
<th class="px-4 py-2">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-gray-700">
|
||||||
|
{{TABLE_ROWS}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modales + Toast (inchangés) -->
|
||||||
|
<!-- Modale d'édition -->
|
||||||
|
<div id="editModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||||
|
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-md transform transition-all scale-95">
|
||||||
|
<button type="button" class="absolute top-4 right-4 text-gray-400 hover:text-white text-2xl font-bold close">×</button>
|
||||||
|
<h2 class="text-2xl font-bold mb-6 text-center text-white">✏️ Éditer Release <span id="modalReleaseId" class="text-blue-400"></span></h2>
|
||||||
|
<form id="editForm">
|
||||||
|
<label for="statusSelect" class="block mb-2 text-gray-300 font-medium">Status :</label>
|
||||||
|
<select id="statusSelect" name="status"
|
||||||
|
class="w-full p-3 mb-6 rounded-lg border border-gray-700 bg-gray-800 text-white focus:ring-2 focus:ring-blue-500 focus:outline-none">
|
||||||
|
<option value="0" class="text-cyan-400">EN ATTENTE</option>
|
||||||
|
<option value="1" class="text-green-400">ENVOI TERMINÉ</option>
|
||||||
|
<option value="2" class="text-red-400">ERREUR</option>
|
||||||
|
<option value="3" class="text-pink-400">DEJA DISPONIBLE</option>
|
||||||
|
<option value="4" class="text-yellow-400">EN COURS</option>
|
||||||
|
</select>
|
||||||
|
<input type="hidden" id="releaseId" name="id" value=""/>
|
||||||
|
<button type="submit" class="w-full p-3 bg-gradient-to-r from-blue-600 to-blue-500 text-white font-semibold rounded-lg shadow hover:from-blue-500 hover:to-blue-400 transform hover:-translate-y-0.5 transition">💾 Mettre à jour</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale log -->
|
||||||
|
<div id="logModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||||
|
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-7xl relative">
|
||||||
|
<button type="button" class="absolute top-4 right-4 text-gray-400 hover:text-white text-2xl font-bold close log-close">×</button>
|
||||||
|
<h2 class="text-2xl font-bold mb-6 text-center text-white">📄 Contenu du log</h2>
|
||||||
|
<pre id="logContent" class="max-h-[90vh] overflow-y-auto p-6 rounded-lg bg-gray-800 text-green-400 font-mono text-sm leading-relaxed border border-gray-700 shadow-inner whitespace-pre-wrap"></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale mediainfo -->
|
||||||
|
<div id="mediainfoModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||||
|
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-6xl relative">
|
||||||
|
<button type="button" class="absolute top-4 right-4 text-gray-400 hover:text-white text-2xl font-bold close mediainfo-close" title="Fermer">×</button>
|
||||||
|
<h2 class="text-2xl font-bold text-white mb-4 pr-16">📄 Contenu du mediainfo</h2>
|
||||||
|
<div class="mb-6">
|
||||||
|
<button id="copyMediainfoBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm font-semibold shadow-md transition">📋 Copier JSON</button>
|
||||||
|
</div>
|
||||||
|
<pre id="mediainfoContent" class="max-h-[80vh] overflow-y-auto p-4 rounded-lg bg-gray-800 text-yellow-300 font-mono text-sm leading-relaxed border border-gray-700 shadow-inner whitespace-pre-wrap"></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale confirmation suppression -->
|
||||||
|
<div id="confirmDeleteModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||||
|
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-3xl md:max-w-4xl relative">
|
||||||
|
<button type="button" class="absolute top-3 right-3 text-gray-400 hover:text-white text-xl font-bold" id="confirmDeleteClose" aria-label="Fermer">×</button>
|
||||||
|
<h3 class="text-xl font-bold text-white mb-2">Supprimer cet enregistrement ?</h3>
|
||||||
|
<p class="text-gray-300 text-sm mb-6">Vous êtes sur le point de supprimer <span id="confirmItemName" class="text-white font-semibold"></span>. Cette action est irréversible.</p>
|
||||||
|
<div class="flex justify-end gap-3">
|
||||||
|
<button type="button" id="cancelDeleteBtn" class="px-4 py-2 rounded-lg bg-gray-700 hover:bg-gray-600 text-white">Annuler</button>
|
||||||
|
<button type="button" id="confirmDeleteBtn" class="px-4 py-2 rounded-lg bg-red-600 hover:bg-red-700 text-white font-semibold">Supprimer</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal de confirmation de renvoi -->
|
||||||
|
<div id="confirmResendModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||||
|
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-3xl md:max-w-4xl relative">
|
||||||
|
<button type="button" class="absolute top-3 right-3 text-gray-400 hover:text-white text-xl font-bold" id="confirmResendClose" aria-label="Fermer">×</button>
|
||||||
|
<h3 class="text-xl font-bold text-white mb-2">Renvoyer cet enregistrement ?</h3>
|
||||||
|
<p class="text-gray-300 text-sm mb-6">Vous êtes sur le point de renvoyer <span id="confirmResendItemName" class="text-white font-semibold"></span> vers le site principal.</p>
|
||||||
|
<div class="flex justify-end gap-3">
|
||||||
|
<button type="button" id="cancelResendBtn" class="px-4 py-2 rounded-lg bg-gray-700 hover:bg-gray-600 text-white">Annuler</button>
|
||||||
|
<button type="button" id="confirmResendBtn" class="px-4 py-2 rounded-lg bg-green-600 hover:bg-green-700 text-white font-semibold">Renvoyer</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal d'édition en lot -->
|
||||||
|
<div id="bulkEditModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||||
|
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-md relative">
|
||||||
|
<button type="button" class="absolute top-4 right-4 text-gray-400 hover:text-white text-2xl font-bold" id="bulkEditClose">×</button>
|
||||||
|
<h2 class="text-2xl font-bold mb-6 text-center text-white">✏️ Éditer la sélection</h2>
|
||||||
|
<p class="text-gray-300 text-sm mb-4">Modifier le statut de <span id="bulkEditCount" class="text-white font-semibold">0</span> élément(s) sélectionné(s).</p>
|
||||||
|
<form id="bulkEditForm">
|
||||||
|
<label for="bulkStatusSelect" class="block mb-2 text-gray-300 font-medium">Nouveau statut :</label>
|
||||||
|
<select id="bulkStatusSelect" name="status"
|
||||||
|
class="w-full p-3 mb-6 rounded-lg border border-gray-700 bg-gray-800 text-white focus:ring-2 focus:ring-blue-500 focus:outline-none">
|
||||||
|
<option value="0" class="text-cyan-400">EN ATTENTE</option>
|
||||||
|
<option value="1" class="text-green-400">ENVOI TERMINÉ</option>
|
||||||
|
<option value="2" class="text-red-400">ERREUR</option>
|
||||||
|
<option value="3" class="text-pink-400">DEJA DISPONIBLE</option>
|
||||||
|
<option value="4" class="text-yellow-400">EN COURS</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit" class="w-full p-3 bg-gradient-to-r from-blue-600 to-blue-500 text-white font-semibold rounded-lg shadow hover:from-blue-500 hover:to-blue-400 transform hover:-translate-y-0.5 transition">💾 Mettre à jour la sélection</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal de confirmation de suppression en lot -->
|
||||||
|
<div id="bulkDeleteModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||||
|
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-3xl md:max-w-4xl relative">
|
||||||
|
<button type="button" class="absolute top-3 right-3 text-gray-400 hover:text-white text-xl font-bold" id="bulkDeleteClose" aria-label="Fermer">×</button>
|
||||||
|
<h3 class="text-xl font-bold text-white mb-2">Supprimer ces enregistrements ?</h3>
|
||||||
|
<p class="text-gray-300 text-sm mb-4">Vous êtes sur le point de supprimer <span id="bulkDeleteCount" class="text-white font-semibold">0</span> élément(s) sélectionné(s).</p>
|
||||||
|
<div id="bulkDeleteList" class="max-h-40 overflow-y-auto mb-6 p-3 bg-gray-800 rounded-lg border border-gray-700">
|
||||||
|
<!-- Liste des éléments à supprimer -->
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end gap-3">
|
||||||
|
<button type="button" id="cancelBulkDeleteBtn" class="px-4 py-2 rounded-lg bg-gray-700 hover:bg-gray-600 text-white">Annuler</button>
|
||||||
|
<button type="button" id="confirmBulkDeleteBtn" class="px-4 py-2 rounded-lg bg-red-600 hover:bg-red-700 text-white font-semibold">Supprimer tout</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Toast -->
|
||||||
|
<div id="toast" class="hidden fixed bottom-6 left-1/2 -translate-x-1/2 px-4 py-2 rounded-lg bg-gray-900/95 text-white shadow-lg z-[60]">
|
||||||
|
<span id="toastMsg">Supprimé.</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Bootstrap côté client (données initiales) -->
|
||||||
|
<script>window.__BOOTSTRAP__ = {{BOOTSTRAP_JSON}};</script>
|
||||||
|
<script src="autopost.js" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
101
install.sh
101
install.sh
@@ -47,10 +47,35 @@ install_bin() { # install_bin <src> <dst>
|
|||||||
install -m 755 "$1" "$2"
|
install -m 755 "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ========= Downloader (curl→wget fallback) =========
|
||||||
|
download() {
|
||||||
|
local url="$1" out="$2"
|
||||||
|
[ -z "$url" ] || [ -z "$out" ] && { echo "download: usage: download <url> <outfile>" >&2; return 2; }
|
||||||
|
mkdir -p -- "$(dirname -- "$out")"
|
||||||
|
local tmp="${out}.dl.$$"
|
||||||
|
local curl_opts=(--fail --silent --show-error --location --retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 15)
|
||||||
|
local wget_opts=(--quiet --https-only --tries=5 --waitretry=2 --retry-connrefused)
|
||||||
|
|
||||||
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
if curl --http1.1 -4 "${curl_opts[@]}" -o "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
if env -u http_proxy -u https_proxy -u all_proxy \
|
||||||
|
curl --http1.1 -4 "${curl_opts[@]}" -o "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
if curl --http1.1 "${curl_opts[@]}" -o "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
fi
|
||||||
|
if command -v wget >/dev/null 2>&1; then
|
||||||
|
if wget --inet4-only "${wget_opts[@]}" -O "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
if wget "${wget_opts[@]}" -O "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
fi
|
||||||
|
rm -f -- "$tmp" 2>/dev/null || true
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# ========= Start =========
|
# ========= Start =========
|
||||||
log "Initialisation des dossiers"
|
log "Initialisation des dossiers"
|
||||||
ensure_dir "$BIN_DIR"
|
ensure_dir "$BIN_DIR"
|
||||||
ensure_dir "$AUTOPOST_DIR"
|
ensure_dir "$AUTOPOST_DIR"
|
||||||
|
ensure_dir "$AUTOPOST_DIR"/public
|
||||||
|
ensure_dir "$AUTOPOST_DIR"/views
|
||||||
ensure_dir "$BASH_COMPLETION_DIR"
|
ensure_dir "$BASH_COMPLETION_DIR"
|
||||||
|
|
||||||
# Ensure PATH contains $HOME/bin for this session & future shells
|
# Ensure PATH contains $HOME/bin for this session & future shells
|
||||||
@@ -68,7 +93,6 @@ MISSING=()
|
|||||||
for c in wget curl tar xz; do
|
for c in wget curl tar xz; do
|
||||||
has_cmd "$c" || MISSING+=("$c")
|
has_cmd "$c" || MISSING+=("$c")
|
||||||
done
|
done
|
||||||
# unzip est requis plus bas
|
|
||||||
has_cmd unzip || MISSING+=("unzip")
|
has_cmd unzip || MISSING+=("unzip")
|
||||||
if [ "${#MISSING[@]}" -gt 0 ]; then
|
if [ "${#MISSING[@]}" -gt 0 ]; then
|
||||||
warn "Installation des prérequis manquants: ${MISSING[*]}"
|
warn "Installation des prérequis manquants: ${MISSING[*]}"
|
||||||
@@ -99,14 +123,18 @@ else
|
|||||||
"https://mediaarea.net/download/binary/mediainfo/25.04/mediainfo_25.04-1_amd64.Debian_12.deb"
|
"https://mediaarea.net/download/binary/mediainfo/25.04/mediainfo_25.04-1_amd64.Debian_12.deb"
|
||||||
)
|
)
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
for u in "${DEBS[@]}"; do wget -q "$u"; done
|
for u in "${DEBS[@]}"; do
|
||||||
|
f="$(basename "$u")"
|
||||||
|
download "$u" "$f" || die "Téléchargement échoué: $u"
|
||||||
|
done
|
||||||
run_root dpkg -i ./*.deb || run_root apt-get -f -y install
|
run_root dpkg -i ./*.deb || run_root apt-get -f -y install
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# AppImage fallback
|
# AppImage fallback
|
||||||
APP="$BIN_DIR/mediainfo"
|
APP="$BIN_DIR/mediainfo"
|
||||||
curl -fsSL -o "$APP" "https://mediaarea.net/download/binary/mediainfo/20.09/mediainfo-20.09.glibc2.3-x86_64.AppImage"
|
download "https://mediaarea.net/download/binary/mediainfo/20.09/mediainfo-20.09.glibc2.3-x86_64.AppImage" "$APP" \
|
||||||
|
|| die "Téléchargement mediainfo AppImage"
|
||||||
install -m 755 "$APP" "$APP"
|
install -m 755 "$APP" "$APP"
|
||||||
ok "mediainfo AppImage installé dans $BIN_DIR"
|
ok "mediainfo AppImage installé dans $BIN_DIR"
|
||||||
fi
|
fi
|
||||||
@@ -127,9 +155,9 @@ select BDD in "SQLite" "MySQL"; do
|
|||||||
else
|
else
|
||||||
warn "apt absent → installation binaire sqlite3"
|
warn "apt absent → installation binaire sqlite3"
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
curl -fsSL -o sqlite-tools.zip "https://www.sqlite.org/2024/sqlite-tools-linux-x64-3470000.zip"
|
download "https://www.sqlite.org/2024/sqlite-tools-linux-x64-3470000.zip" "$TMP_DIR/sqlite-tools.zip" \
|
||||||
unzip -q sqlite-tools.zip
|
|| die "Téléchargement sqlite-tools"
|
||||||
# trouve sqlite3
|
unzip -q "$TMP_DIR/sqlite-tools.zip"
|
||||||
SQLITE_BIN="$(find . -type f -name sqlite3 -perm -u+x | head -n1)"
|
SQLITE_BIN="$(find . -type f -name sqlite3 -perm -u+x | head -n1)"
|
||||||
[ -n "$SQLITE_BIN" ] || die "sqlite3 introuvable dans l’archive"
|
[ -n "$SQLITE_BIN" ] || die "sqlite3 introuvable dans l’archive"
|
||||||
install_bin "$SQLITE_BIN" "$BIN_DIR/sqlite3"
|
install_bin "$SQLITE_BIN" "$BIN_DIR/sqlite3"
|
||||||
@@ -151,8 +179,9 @@ select BDD in "SQLite" "MySQL"; do
|
|||||||
run_root apt-get install -y sqlite3
|
run_root apt-get install -y sqlite3
|
||||||
else
|
else
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
curl -fsSL -o sqlite-tools.zip "https://www.sqlite.org/2024/sqlite-tools-linux-x64-3470000.zip"
|
download "https://www.sqlite.org/2024/sqlite-tools-linux-x64-3470000.zip" "$TMP_DIR/sqlite-tools.zip" \
|
||||||
unzip -q sqlite-tools.zip
|
|| die "Téléchargement sqlite-tools"
|
||||||
|
unzip -q "$TMP_DIR/sqlite-tools.zip"
|
||||||
SQLITE_BIN="$(find . -type f -name sqlite3 -perm -u+x | head -n1)"
|
SQLITE_BIN="$(find . -type f -name sqlite3 -perm -u+x | head -n1)"
|
||||||
[ -n "$SQLITE_BIN" ] || die "sqlite3 introuvable dans l’archive"
|
[ -n "$SQLITE_BIN" ] || die "sqlite3 introuvable dans l’archive"
|
||||||
install_bin "$SQLITE_BIN" "$BIN_DIR/sqlite3"
|
install_bin "$SQLITE_BIN" "$BIN_DIR/sqlite3"
|
||||||
@@ -174,7 +203,8 @@ else
|
|||||||
if has_cmd apt-get; then
|
if has_cmd apt-get; then
|
||||||
run_root apt-get install -y jq
|
run_root apt-get install -y jq
|
||||||
else
|
else
|
||||||
curl -fsSL -o "$TMP_DIR/jq" "https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64"
|
download "https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64" "$TMP_DIR/jq" \
|
||||||
|
|| die "Téléchargement jq"
|
||||||
install_bin "$TMP_DIR/jq" "$BIN_DIR/jq"
|
install_bin "$TMP_DIR/jq" "$BIN_DIR/jq"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -187,9 +217,8 @@ else
|
|||||||
log "Installation de 7z (binaire standalone)"
|
log "Installation de 7z (binaire standalone)"
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
Z_URL="https://7-zip.org/a/7z2409-linux-x64.tar.xz"
|
Z_URL="https://7-zip.org/a/7z2409-linux-x64.tar.xz"
|
||||||
wget -q -O 7z.tar.xz "$Z_URL"
|
download "$Z_URL" "$TMP_DIR/7z.tar.xz" || die "Téléchargement 7z"
|
||||||
tar -xJf 7z.tar.xz
|
tar -xJf "$TMP_DIR/7z.tar.xz"
|
||||||
# Cherche 7zz* exécutable
|
|
||||||
Z_BIN="$(find . -maxdepth 1 -type f -name '7zz*' -perm -u+x | head -n1)"
|
Z_BIN="$(find . -maxdepth 1 -type f -name '7zz*' -perm -u+x | head -n1)"
|
||||||
[ -n "$Z_BIN" ] || die "binaire 7z introuvable"
|
[ -n "$Z_BIN" ] || die "binaire 7z introuvable"
|
||||||
install_bin "$Z_BIN" "$BIN_DIR/7z"
|
install_bin "$Z_BIN" "$BIN_DIR/7z"
|
||||||
@@ -200,14 +229,16 @@ REQUIRED_CMDS+=(7z)
|
|||||||
# ========= BDInfo & Substractor =========
|
# ========= BDInfo & Substractor =========
|
||||||
log "Installation BDInfo"
|
log "Installation BDInfo"
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
curl -fsSL -o bdinfo.zip "https://github.com/dotnetcorecorner/BDInfo/releases/download/linux-2.0.6/bdinfo_linux_v2.0.6.zip"
|
download "https://github.com/dotnetcorecorner/BDInfo/releases/download/linux-2.0.6/bdinfo_linux_v2.0.6.zip" "$TMP_DIR/bdinfo.zip" \
|
||||||
unzip -q bdinfo.zip
|
|| die "Téléchargement BDInfo"
|
||||||
|
unzip -q "$TMP_DIR/bdinfo.zip"
|
||||||
BDINFO_BIN="$(find . -type f -name BDInfo -perm -u+x | head -n1)"
|
BDINFO_BIN="$(find . -type f -name BDInfo -perm -u+x | head -n1)"
|
||||||
[ -n "$BDINFO_BIN" ] || die "BDInfo introuvable"
|
[ -n "$BDINFO_BIN" ] || die "BDInfo introuvable"
|
||||||
install_bin "$BDINFO_BIN" "$BIN_DIR/BDInfo"
|
install_bin "$BDINFO_BIN" "$BIN_DIR/BDInfo"
|
||||||
|
|
||||||
curl -fsSL -o substractor.zip "https://github.com/dotnetcorecorner/BDInfo/releases/download/linux-2.0.6/bdinfodatasubstractor_linux_v2.0.6.zip"
|
download "https://github.com/dotnetcorecorner/BDInfo/releases/download/linux-2.0.6/bdinfodatasubstractor_linux_v2.0.6.zip" "$TMP_DIR/substractor.zip" \
|
||||||
unzip -q substractor.zip
|
|| die "Téléchargement BDInfoDataSubstractor"
|
||||||
|
unzip -q "$TMP_DIR/substractor.zip"
|
||||||
SUB_BIN="$(find . -type f -name BDInfoDataSubstractor -perm -u+x | head -n1)"
|
SUB_BIN="$(find . -type f -name BDInfoDataSubstractor -perm -u+x | head -n1)"
|
||||||
[ -n "$SUB_BIN" ] || die "BDInfoDataSubstractor introuvable"
|
[ -n "$SUB_BIN" ] || die "BDInfoDataSubstractor introuvable"
|
||||||
install_bin "$SUB_BIN" "$BIN_DIR/BDInfoDataSubstractor"
|
install_bin "$SUB_BIN" "$BIN_DIR/BDInfoDataSubstractor"
|
||||||
@@ -218,8 +249,8 @@ REQUIRED_CMDS+=(BDInfo BDInfoDataSubstractor)
|
|||||||
log "Installation Nyuu"
|
log "Installation Nyuu"
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
NYUU_URL="https://github.com/Antidote2151/Nyuu-Obfuscation/releases/download/v0.4.2-Obfuscate1.3/nyuu-v0.4.2-Obfuscate1.3-linux-amd64.tar.xz"
|
NYUU_URL="https://github.com/Antidote2151/Nyuu-Obfuscation/releases/download/v0.4.2-Obfuscate1.3/nyuu-v0.4.2-Obfuscate1.3-linux-amd64.tar.xz"
|
||||||
wget -q -O nyuu.tar.xz "$NYUU_URL"
|
download "$NYUU_URL" "$TMP_DIR/nyuu.tar.xz" || die "Téléchargement nyuu"
|
||||||
tar -xJf nyuu.tar.xz
|
tar -xJf "$TMP_DIR/nyuu.tar.xz"
|
||||||
NYUU_BIN="$(find . -type f -name nyuu -perm -u+x | head -n1)"
|
NYUU_BIN="$(find . -type f -name nyuu -perm -u+x | head -n1)"
|
||||||
[ -n "$NYUU_BIN" ] || die "nyuu introuvable dans l’archive"
|
[ -n "$NYUU_BIN" ] || die "nyuu introuvable dans l’archive"
|
||||||
install_bin "$NYUU_BIN" "$BIN_DIR/nyuu"
|
install_bin "$NYUU_BIN" "$BIN_DIR/nyuu"
|
||||||
@@ -230,9 +261,9 @@ REQUIRED_CMDS+=(nyuu)
|
|||||||
log "Installation ParPar"
|
log "Installation ParPar"
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
PARPAR_URL="https://github.com/animetosho/ParPar/releases/download/v0.4.5/parpar-v0.4.5-linux-static-amd64.xz"
|
PARPAR_URL="https://github.com/animetosho/ParPar/releases/download/v0.4.5/parpar-v0.4.5-linux-static-amd64.xz"
|
||||||
wget -q -O parpar.xz "$PARPAR_URL"
|
download "$PARPAR_URL" "$TMP_DIR/parpar-v0.4.5-linux-static-amd64.xz" || die "Téléchargement parpar"
|
||||||
xz -d parpar.xz
|
xz -d "$TMP_DIR/parpar-v0.4.5-linux-static-amd64.xz"
|
||||||
PARPAR_BIN="$(find . -maxdepth 1 -type f -name 'parpar-*' -perm -u+x | head -n1)"
|
PARPAR_BIN="$(find . -maxdepth 1 -type f -name 'parpar-*' | head -n1)"
|
||||||
[ -n "$PARPAR_BIN" ] || die "parpar introuvable"
|
[ -n "$PARPAR_BIN" ] || die "parpar introuvable"
|
||||||
install_bin "$PARPAR_BIN" "$BIN_DIR/parpar"
|
install_bin "$PARPAR_BIN" "$BIN_DIR/parpar"
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
@@ -240,11 +271,11 @@ REQUIRED_CMDS+=(parpar)
|
|||||||
|
|
||||||
# ========= Téléchargement scripts autopost =========
|
# ========= Téléchargement scripts autopost =========
|
||||||
log "Téléchargement des scripts autopost"
|
log "Téléchargement des scripts autopost"
|
||||||
wget -q -O "$AUTOPOST_DIR/analyzer.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/analyzer.sh"
|
download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/analyzer.sh" "$AUTOPOST_DIR/analyzer.sh" || die "analyzer.sh"
|
||||||
wget -q -O "$AUTOPOST_DIR/common.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/common.sh"
|
download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/common.sh" "$AUTOPOST_DIR/common.sh" || die "common.sh"
|
||||||
wget -q -O "$AUTOPOST_DIR/posteur.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/posteur.sh"
|
download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/posteur.sh" "$AUTOPOST_DIR/posteur.sh" || die "posteur.sh"
|
||||||
wget -q -O "$BIN_DIR/postauto" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/bin/postauto"
|
download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/bin/postauto" "$BIN_DIR/postauto" || die "postauto"
|
||||||
[ -f "$AUTOPOST_DIR/conf.sh" ] || wget -q -O "$AUTOPOST_DIR/conf.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/conf.sh"
|
[ -f "$AUTOPOST_DIR/conf.sh" ] || download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/conf.sh" "$AUTOPOST_DIR/conf.sh"
|
||||||
|
|
||||||
chmod 755 "$BIN_DIR/postauto"
|
chmod 755 "$BIN_DIR/postauto"
|
||||||
chmod -R 755 "$AUTOPOST_DIR"
|
chmod -R 755 "$AUTOPOST_DIR"
|
||||||
@@ -272,7 +303,6 @@ _autopost_completion() {
|
|||||||
complete -F _autopost_completion postauto
|
complete -F _autopost_completion postauto
|
||||||
EOF
|
EOF
|
||||||
ok "Completion bash installée dans $COMP_FILE"
|
ok "Completion bash installée dans $COMP_FILE"
|
||||||
# source automatique depuis .bashrc si pas déjà présent
|
|
||||||
if ! grep -q 'bash_completion.d' "$BASHRC_FILE" 2>/dev/null; then
|
if ! grep -q 'bash_completion.d' "$BASHRC_FILE" 2>/dev/null; then
|
||||||
echo '[ -f "$HOME/.bash_completion.d/postauto" ] && . "$HOME/.bash_completion.d/postauto"' >> "$BASHRC_FILE"
|
echo '[ -f "$HOME/.bash_completion.d/postauto" ] && . "$HOME/.bash_completion.d/postauto"' >> "$BASHRC_FILE"
|
||||||
fi
|
fi
|
||||||
@@ -287,7 +317,10 @@ if [ -s "$NVM_DIR/nvm.sh" ]; then
|
|||||||
. "$NVM_DIR/nvm.sh"
|
. "$NVM_DIR/nvm.sh"
|
||||||
else
|
else
|
||||||
log "Installation de nvm"
|
log "Installation de nvm"
|
||||||
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
|
tmp_nvm="$TMP_DIR/install_nvm.sh"
|
||||||
|
download "https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh" "$tmp_nvm" \
|
||||||
|
|| die "Téléchargement nvm install.sh"
|
||||||
|
bash "$tmp_nvm"
|
||||||
. "$NVM_DIR/nvm.sh"
|
. "$NVM_DIR/nvm.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -311,7 +344,7 @@ fi
|
|||||||
log "Vérification modules npm"
|
log "Vérification modules npm"
|
||||||
pushd "$AUTOPOST_DIR" >/dev/null
|
pushd "$AUTOPOST_DIR" >/dev/null
|
||||||
[ -f package.json ] || npm init -y >/dev/null 2>&1 || true
|
[ -f package.json ] || npm init -y >/dev/null 2>&1 || true
|
||||||
modules=(express express-session sqlite3 ansi-to-html @tailwindcss/browser autoprefixer jquery mysql2 session-file-store chokidar)
|
modules=(express express-session sqlite3 ansi-to-html @tailwindcss/browser autoprefixer jquery mysql2 session-file-store chokidar argon2)
|
||||||
missing=()
|
missing=()
|
||||||
for m in "${modules[@]}"; do
|
for m in "${modules[@]}"; do
|
||||||
npm list "$m" --depth=0 >/dev/null 2>&1 || missing+=("$m")
|
npm list "$m" --depth=0 >/dev/null 2>&1 || missing+=("$m")
|
||||||
@@ -326,10 +359,13 @@ popd >/dev/null
|
|||||||
|
|
||||||
# ========= Fichiers Node (server.js, db.js, config.js) =========
|
# ========= Fichiers Node (server.js, db.js, config.js) =========
|
||||||
log "Vérification fichiers Node"
|
log "Vérification fichiers Node"
|
||||||
[ -f "$AUTOPOST_DIR/server.js" ] || wget -q -O "$AUTOPOST_DIR/server.js" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/server.js"
|
[ -f "$AUTOPOST_DIR/server.js" ] || download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/server.js" "$AUTOPOST_DIR/server.js"
|
||||||
[ -f "$AUTOPOST_DIR/db.js" ] || wget -q -O "$AUTOPOST_DIR/db.js" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/db.js"
|
[ -f "$AUTOPOST_DIR/db.js" ] || download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/db.js" "$AUTOPOST_DIR/db.js"
|
||||||
|
[ -f "$AUTOPOST_DIR/public/autopost.js" ] || download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/public/autopost.js" "$AUTOPOST_DIR/public/autopost.js"
|
||||||
|
[ -f "$AUTOPOST_DIR/public/checkboxes.css" ] || download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/public/checkboxes.css" "$AUTOPOST_DIR/public/checkboxes.css"
|
||||||
|
[ -f "$AUTOPOST_DIR/views/autopost.html" ] || download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/views/autopost.html" "$AUTOPOST_DIR/views/autopost.html"
|
||||||
if [ ! -f "$AUTOPOST_DIR/config.js" ]; then
|
if [ ! -f "$AUTOPOST_DIR/config.js" ]; then
|
||||||
wget -q -O "$AUTOPOST_DIR/config.js" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/config.js"
|
download "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/config.js" "$AUTOPOST_DIR/config.js"
|
||||||
ok "Installation terminée. Configurez $AUTOPOST_DIR/config.js."
|
ok "Installation terminée. Configurez $AUTOPOST_DIR/config.js."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -338,7 +374,6 @@ log "Vérification finale des binaires requis"
|
|||||||
missing_final=()
|
missing_final=()
|
||||||
for cmd in "${REQUIRED_CMDS[@]}"; do
|
for cmd in "${REQUIRED_CMDS[@]}"; do
|
||||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||||
# autoriser chemin absolu
|
|
||||||
if [[ "$cmd" == */* ]]; then
|
if [[ "$cmd" == */* ]]; then
|
||||||
[ -x "$cmd" ] || missing_final+=("$cmd")
|
[ -x "$cmd" ] || missing_final+=("$cmd")
|
||||||
else
|
else
|
||||||
|
|||||||
103
update.sh
103
update.sh
@@ -26,6 +26,29 @@ die() { err "$*"; exit 1; }
|
|||||||
|
|
||||||
install_bin(){ install -m 755 "$1" "$2"; }
|
install_bin(){ install -m 755 "$1" "$2"; }
|
||||||
|
|
||||||
|
# ========= Downloader (curl→wget fallback) =========
|
||||||
|
download() {
|
||||||
|
local url="$1" out="$2"
|
||||||
|
[ -z "$url" ] || [ -z "$out" ] && { echo "download: usage: download <url> <outfile>" >&2; return 2; }
|
||||||
|
mkdir -p -- "$(dirname -- "$out")"
|
||||||
|
local tmp="${out}.dl.$$"
|
||||||
|
local curl_opts=(--fail --silent --show-error --location --retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 15)
|
||||||
|
local wget_opts=(--quiet --https-only --tries=5 --waitretry=2 --retry-connrefused)
|
||||||
|
|
||||||
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
if curl --http1.1 -4 "${curl_opts[@]}" -o "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
if env -u http_proxy -u https_proxy -u all_proxy \
|
||||||
|
curl --http1.1 -4 "${curl_opts[@]}" -o "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
if curl --http1.1 "${curl_opts[@]}" -o "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
fi
|
||||||
|
if command -v wget >/dev/null 2>&1; then
|
||||||
|
if wget --inet4-only "${wget_opts[@]}" -O "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
if wget "${wget_opts[@]}" -O "$tmp" "$url"; then mv -f -- "$tmp" "$out"; return 0; fi
|
||||||
|
fi
|
||||||
|
rm -f -- "$tmp" 2>/dev/null || true
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# --- lire une clé JS (ligne "clé: valeur") sans exécuter ---
|
# --- lire une clé JS (ligne "clé: valeur") sans exécuter ---
|
||||||
parse_js_raw() {
|
parse_js_raw() {
|
||||||
local key="$1"
|
local key="$1"
|
||||||
@@ -33,34 +56,17 @@ parse_js_raw() {
|
|||||||
| head -n1 | sed -E "s/[[:space:]]*(,)?[[:space:]]*$//"
|
| head -n1 | sed -E "s/[[:space:]]*(,)?[[:space:]]*$//"
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- normaliser une valeur JS simple: enlève guillemets, garde nombres, laisse path.join tel quel ---
|
|
||||||
# --- normaliser une valeur JS simple ---
|
# --- normaliser une valeur JS simple ---
|
||||||
# - supprime les commentaires inline " // ... "
|
|
||||||
# - supprime la virgule terminale
|
|
||||||
# - trim espaces
|
|
||||||
# - retire guillemets si présents
|
|
||||||
normalize_js_value() {
|
normalize_js_value() {
|
||||||
local raw="$1"
|
local raw="$1"
|
||||||
|
raw="$(printf '%s' "$raw" | sed -E 's@[[:space:]]//.*$@@')" # retire commentaire inline
|
||||||
# retire commentaire inline: seulement si précédé d'un espace (évite "https://")
|
raw="$(printf '%s' "$raw" | sed -E 's/,[[:space:]]*$//')" # retire virgule
|
||||||
raw="$(printf '%s' "$raw" | sed -E 's@[[:space:]]//.*$@@')"
|
raw="$(printf '%s' "$raw" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')" # trim
|
||||||
|
if [[ "$raw" =~ ^\"(.*)\"$ ]]; then printf '%s\n' "${BASH_REMATCH[1]}"; return; fi
|
||||||
# retire virgule en fin de champ et espaces résiduels
|
if [[ "$raw" =~ ^\'(.*)\'$ ]]; then printf '%s\n' "${BASH_REMATCH[1]}"; return; fi
|
||||||
raw="$(printf '%s' "$raw" | sed -E 's/,[[:space:]]*$//')"
|
|
||||||
raw="$(printf '%s' "$raw" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')"
|
|
||||||
|
|
||||||
# retire guillemets simples/doubles
|
|
||||||
if [[ "$raw" =~ ^\"(.*)\"$ ]]; then
|
|
||||||
printf '%s\n' "${BASH_REMATCH[1]}"; return
|
|
||||||
fi
|
|
||||||
if [[ "$raw" =~ ^\'(.*)\'$ ]]; then
|
|
||||||
printf '%s\n' "${BASH_REMATCH[1]}"; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf '%s\n' "$raw"
|
printf '%s\n' "$raw"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# placeholders à refuser (vides, “Voir…”, “CHANGEME…”, etc.)
|
# placeholders à refuser (vides, “Voir…”, “CHANGEME…”, etc.)
|
||||||
is_placeholder() {
|
is_placeholder() {
|
||||||
local v="$1"
|
local v="$1"
|
||||||
@@ -72,14 +78,12 @@ is_placeholder() {
|
|||||||
# entier (>=0)
|
# entier (>=0)
|
||||||
is_int() { [[ "$1" =~ ^[0-9]+$ ]]; }
|
is_int() { [[ "$1" =~ ^[0-9]+$ ]]; }
|
||||||
|
|
||||||
# booléen JS (true/false), avec ou sans guillemets
|
# booléen JS (true/false)
|
||||||
is_bool_literal() {
|
is_bool_literal() {
|
||||||
local v="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
|
local v="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
|
||||||
[[ "$v" == "true" || "$v" == "false" ]]
|
[[ "$v" == "true" || "$v" == "false" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ────────── Paths ──────────
|
# ────────── Paths ──────────
|
||||||
BIN_DIR="$HOME/bin"
|
BIN_DIR="$HOME/bin"
|
||||||
AUTOPOST_DIR="$HOME/autopost"
|
AUTOPOST_DIR="$HOME/autopost"
|
||||||
@@ -88,7 +92,7 @@ BASH_COMPLETION_DIR="$HOME/.bash_completion.d"
|
|||||||
CONF_SH="$AUTOPOST_DIR/conf.sh"
|
CONF_SH="$AUTOPOST_DIR/conf.sh"
|
||||||
CFG_JS="$AUTOPOST_DIR/config.js"
|
CFG_JS="$AUTOPOST_DIR/config.js"
|
||||||
|
|
||||||
mkdir -p "$BIN_DIR" "$AUTOPOST_DIR" "$BASH_COMPLETION_DIR"
|
mkdir -p "$BIN_DIR" "$AUTOPOST_DIR" "$BASH_COMPLETION_DIR" "$AUTOPOST_DIR/views" "$AUTOPOST_DIR/public"
|
||||||
|
|
||||||
TMP_DIR="$(mktemp -d)"
|
TMP_DIR="$(mktemp -d)"
|
||||||
cleanup(){ rm -rf "$TMP_DIR"; }
|
cleanup(){ rm -rf "$TMP_DIR"; }
|
||||||
@@ -104,18 +108,21 @@ FILES["$AUTOPOST_DIR/posteur.sh"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/
|
|||||||
FILES["$AUTOPOST_DIR/common.sh"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/common.sh"
|
FILES["$AUTOPOST_DIR/common.sh"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/common.sh"
|
||||||
FILES["$BIN_DIR/postauto"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/bin/postauto"
|
FILES["$BIN_DIR/postauto"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/bin/postauto"
|
||||||
FILES["$AUTOPOST_DIR/server.js"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/server.js"
|
FILES["$AUTOPOST_DIR/server.js"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/server.js"
|
||||||
|
FILES["$AUTOPOST_DIR/public/autopost.js"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/public/autopost.js"
|
||||||
|
FILES["$AUTOPOST_DIR/public/checkboxes.css"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/public/checkboxes.css"
|
||||||
|
FILES["$AUTOPOST_DIR/views/autopost.html"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/views/autopost.html"
|
||||||
|
|
||||||
log "Vérification/MAJ des fichiers…"
|
log "Vérification/MAJ des fichiers…"
|
||||||
for LOCAL in "${!FILES[@]}"; do
|
for LOCAL in "${!FILES[@]}"; do
|
||||||
URL="${FILES[$LOCAL]}"
|
URL="${FILES[$LOCAL]}"
|
||||||
TMP="$TMP_DIR/$(basename "$LOCAL").dl"
|
TMPF="$TMP_DIR/$(basename "$LOCAL").dl"
|
||||||
curl -fsSL "$URL" -o "$TMP" || die "Téléchargement échoué: $URL"
|
download "$URL" "$TMPF" || die "Téléchargement échoué: $URL"
|
||||||
|
|
||||||
if [ ! -f "$LOCAL" ] || ! cmp -s "$LOCAL" "$TMP"; then
|
if [ ! -f "$LOCAL" ] || ! cmp -s "$LOCAL" "$TMPF"; then
|
||||||
cp -f "$LOCAL" "$LOCAL.bak" 2>/dev/null || true
|
cp -f "$LOCAL" "$LOCAL.bak" 2>/dev/null || true
|
||||||
case "$LOCAL" in
|
case "$LOCAL" in
|
||||||
*postauto|*.sh) install_bin "$TMP" "$LOCAL" ;;
|
*postauto|*.sh) install_bin "$TMPF" "$LOCAL" ;;
|
||||||
*) install -m 644 "$TMP" "$LOCAL" ;;
|
*) install -m 644 "$TMPF" "$LOCAL" ;;
|
||||||
esac
|
esac
|
||||||
ok "Mise à jour: $LOCAL"
|
ok "Mise à jour: $LOCAL"
|
||||||
updated=1
|
updated=1
|
||||||
@@ -157,7 +164,6 @@ EOF
|
|||||||
if [ ! -s "$COMP_FILE" ] || ! cmp -s <(printf "%s" "$COMPLETION_CODE") "$COMP_FILE"; then
|
if [ ! -s "$COMP_FILE" ] || ! cmp -s <(printf "%s" "$COMPLETION_CODE") "$COMP_FILE"; then
|
||||||
printf "%s" "$COMPLETION_CODE" > "$COMP_FILE"
|
printf "%s" "$COMPLETION_CODE" > "$COMP_FILE"
|
||||||
ok "Completion installée: $COMP_FILE"
|
ok "Completion installée: $COMP_FILE"
|
||||||
# hook .bashrc si pas déjà présent
|
|
||||||
grep -q '\.bash_completion.d/postauto' "$BASHRC_FILE" 2>/dev/null || \
|
grep -q '\.bash_completion.d/postauto' "$BASHRC_FILE" 2>/dev/null || \
|
||||||
echo '[ -f "$HOME/.bash_completion.d/postauto" ] && . "$HOME/.bash_completion.d/postauto"' >> "$BASHRC_FILE"
|
echo '[ -f "$HOME/.bash_completion.d/postauto" ] && . "$HOME/.bash_completion.d/postauto"' >> "$BASHRC_FILE"
|
||||||
updated=1
|
updated=1
|
||||||
@@ -169,8 +175,8 @@ ensure_cmd(){ command -v "$1" >/dev/null 2>&1; }
|
|||||||
if ! ensure_cmd 7z; then
|
if ! ensure_cmd 7z; then
|
||||||
log "Installation 7z…"
|
log "Installation 7z…"
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
wget -q -o /dev/null -O 7z.tar.xz "https://7-zip.org/a/7z2409-linux-x64.tar.xz"
|
download "https://7-zip.org/a/7z2409-linux-x64.tar.xz" "$TMP_DIR/7z.tar.xz" || die "Téléchargement 7z"
|
||||||
tar -xJf 7z.tar.xz
|
tar -xJf "$TMP_DIR/7z.tar.xz"
|
||||||
ZBIN="$(find . -maxdepth 1 -type f -name '7zz*' -perm -u+x | head -n1)"
|
ZBIN="$(find . -maxdepth 1 -type f -name '7zz*' -perm -u+x | head -n1)"
|
||||||
[ -n "$ZBIN" ] || die "Binaire 7z introuvable"
|
[ -n "$ZBIN" ] || die "Binaire 7z introuvable"
|
||||||
install_bin "$ZBIN" "$BIN_DIR/7z"
|
install_bin "$ZBIN" "$BIN_DIR/7z"
|
||||||
@@ -180,8 +186,9 @@ fi
|
|||||||
if ! ensure_cmd BDInfo; then
|
if ! ensure_cmd BDInfo; then
|
||||||
log "Installation BDInfo…"
|
log "Installation BDInfo…"
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
curl -fsSL -o bdinfo.zip "https://github.com/dotnetcorecorner/BDInfo/releases/download/linux-2.0.6/bdinfo_linux_v2.0.6.zip"
|
download "https://github.com/dotnetcorecorner/BDInfo/releases/download/linux-2.0.6/bdinfo_linux_v2.0.6.zip" "$TMP_DIR/bdinfo.zip" \
|
||||||
unzip -q bdinfo.zip
|
|| die "Téléchargement BDInfo"
|
||||||
|
unzip -q "$TMP_DIR/bdinfo.zip"
|
||||||
BDBIN="$(find . -type f -name BDInfo -perm -u+x | head -n1)"
|
BDBIN="$(find . -type f -name BDInfo -perm -u+x | head -n1)"
|
||||||
[ -n "$BDBIN" ] || die "BDInfo introuvable"
|
[ -n "$BDBIN" ] || die "BDInfo introuvable"
|
||||||
install_bin "$BDBIN" "$BIN_DIR/BDInfo"
|
install_bin "$BDBIN" "$BIN_DIR/BDInfo"
|
||||||
@@ -191,8 +198,9 @@ fi
|
|||||||
if ! ensure_cmd BDInfoDataSubstractor; then
|
if ! ensure_cmd BDInfoDataSubstractor; then
|
||||||
log "Installation BDInfoDataSubstractor…"
|
log "Installation BDInfoDataSubstractor…"
|
||||||
pushd "$TMP_DIR" >/dev/null
|
pushd "$TMP_DIR" >/dev/null
|
||||||
curl -fsSL -o substractor.zip "https://github.com/dotnetcorecorner/BDInfo/releases/download/linux-2.0.6/bdinfodatasubstractor_linux_v2.0.6.zip"
|
download "https://github.com/dotnetcorecorner/BDInfo/releases/download/linux-2.0.6/bdinfodatasubstractor_linux_v2.0.6.zip" "$TMP_DIR/substractor.zip" \
|
||||||
unzip -q substractor.zip
|
|| die "Téléchargement BDInfoDataSubstractor"
|
||||||
|
unzip -q "$TMP_DIR/substractor.zip"
|
||||||
SBBIN="$(find . -type f -name BDInfoDataSubstractor -perm -u+x | head -n1)"
|
SBBIN="$(find . -type f -name BDInfoDataSubstractor -perm -u+x | head -n1)"
|
||||||
[ -n "$SBBIN" ] || die "BDInfoDataSubstractor introuvable"
|
[ -n "$SBBIN" ] || die "BDInfoDataSubstractor introuvable"
|
||||||
install_bin "$SBBIN" "$BIN_DIR/BDInfoDataSubstractor"
|
install_bin "$SBBIN" "$BIN_DIR/BDInfoDataSubstractor"
|
||||||
@@ -217,14 +225,12 @@ fi
|
|||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
||||||
# ────────── VALIDATION conf.sh (sans exécuter) ──────────
|
# ────────── VALIDATION conf.sh (sans exécuter) ──────────
|
||||||
# --- conf.sh : validation déclarative ---
|
|
||||||
check_conf() {
|
check_conf() {
|
||||||
local file="$CONF_SH"
|
local file="$CONF_SH"
|
||||||
[[ -f "$file" ]] || { err "Manquant: $file"; errors=$((errors+1)); return; }
|
[[ -f "$file" ]] || { err "Manquant: $file"; errors=$((errors+1)); return; }
|
||||||
|
|
||||||
log "Validation déclarative de $file…"
|
log "Validation déclarative de $file…"
|
||||||
|
|
||||||
# Parse simple NAME=VALUE (ignore commentaires / 'export')
|
|
||||||
declare -A V=()
|
declare -A V=()
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
||||||
@@ -239,7 +245,6 @@ check_conf() {
|
|||||||
fi
|
fi
|
||||||
done < "$file"
|
done < "$file"
|
||||||
|
|
||||||
# Requis généraux (non-placeholder)
|
|
||||||
for k in URL_API APIKEY DOSSIER_GLOBAL DOSSIER_NFO DOSSIER_LOGS DOSSIER_NZB_ATTENTE DOSSIER_NZB_FINAL MOVE_CMD MYSQL_TABLE dbtype; do
|
for k in URL_API APIKEY DOSSIER_GLOBAL DOSSIER_NFO DOSSIER_LOGS DOSSIER_NZB_ATTENTE DOSSIER_NZB_FINAL MOVE_CMD MYSQL_TABLE dbtype; do
|
||||||
v="${V[$k]:-}"
|
v="${V[$k]:-}"
|
||||||
if is_placeholder "$v"; then
|
if is_placeholder "$v"; then
|
||||||
@@ -247,7 +252,6 @@ check_conf() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# MOVE_CMD valeurs autorisées
|
|
||||||
case "${V[MOVE_CMD]:-}" in
|
case "${V[MOVE_CMD]:-}" in
|
||||||
"cp -rl"|"cp -rs"|"ln -s"|"mv"|"cp") : ;;
|
"cp -rl"|"cp -rs"|"ln -s"|"mv"|"cp") : ;;
|
||||||
*)
|
*)
|
||||||
@@ -256,7 +260,6 @@ check_conf() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Fournisseur Usenet : non-vides + numériques où nécessaire
|
|
||||||
for k in NG_HOST NG_USER NG_PASS; do
|
for k in NG_HOST NG_USER NG_PASS; do
|
||||||
if is_placeholder "${V[$k]:-}"; then
|
if is_placeholder "${V[$k]:-}"; then
|
||||||
err "conf.sh: '$k' non renseigné"; errors=$((errors+1))
|
err "conf.sh: '$k' non renseigné"; errors=$((errors+1))
|
||||||
@@ -269,7 +272,6 @@ check_conf() {
|
|||||||
err "conf.sh: NG_NBR_CONN doit être numérique"; errors=$((errors+1))
|
err "conf.sh: NG_NBR_CONN doit être numérique"; errors=$((errors+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# DB : règles conditionnelles (déclarations seulement)
|
|
||||||
case "${V[dbtype]:-}" in
|
case "${V[dbtype]:-}" in
|
||||||
sqlite)
|
sqlite)
|
||||||
if is_placeholder "${V[DB_FILE]:-}"; then
|
if is_placeholder "${V[DB_FILE]:-}"; then
|
||||||
@@ -293,16 +295,11 @@ check_conf() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
check_conf "$CONF_SH"
|
|
||||||
|
|
||||||
# ────────── VALIDATION config.js (avec Node) ──────────
|
# ────────── VALIDATION config.js (avec Node) ──────────
|
||||||
# --- config.js : validation déclarative (sans exécuter du JS) ---
|
|
||||||
validate_config_js() {
|
validate_config_js() {
|
||||||
[[ -f "$CFG_JS" ]] || { err "Manquant: $CFG_JS"; errors=$((errors+1)); return; }
|
[[ -f "$CFG_JS" ]] || { err "Manquant: $CFG_JS"; errors=$((errors+1)); return; }
|
||||||
log "Validation déclarative de $CFG_JS…"
|
log "Validation déclarative de $CFG_JS…"
|
||||||
|
|
||||||
# valeurs principales
|
|
||||||
local dbtype port name secret table
|
local dbtype port name secret table
|
||||||
dbtype="$(normalize_js_value "$(parse_js_raw dbtype)")"
|
dbtype="$(normalize_js_value "$(parse_js_raw dbtype)")"
|
||||||
port="$(normalize_js_value "$(parse_js_raw port)")"
|
port="$(normalize_js_value "$(parse_js_raw port)")"
|
||||||
@@ -310,7 +307,6 @@ validate_config_js() {
|
|||||||
secret="$(normalize_js_value "$(parse_js_raw sessionSecret)")"
|
secret="$(normalize_js_value "$(parse_js_raw sessionSecret)")"
|
||||||
table="$(normalize_js_value "$(parse_js_raw DB_TABLE)")"
|
table="$(normalize_js_value "$(parse_js_raw DB_TABLE)")"
|
||||||
|
|
||||||
# checks minimaux
|
|
||||||
if ! is_int "$port" || (( port < 1 || port > 65535 )); then
|
if ! is_int "$port" || (( port < 1 || port > 65535 )); then
|
||||||
err "config.js: 'port' invalide ($port)"; errors=$((errors+1))
|
err "config.js: 'port' invalide ($port)"; errors=$((errors+1))
|
||||||
fi
|
fi
|
||||||
@@ -318,7 +314,6 @@ validate_config_js() {
|
|||||||
if is_placeholder "$secret"; then err "config.js: 'sessionSecret' non renseigné"; errors=$((errors+1)); fi
|
if is_placeholder "$secret"; then err "config.js: 'sessionSecret' non renseigné"; errors=$((errors+1)); fi
|
||||||
if is_placeholder "$table"; then err "config.js: 'DB_TABLE' non renseigné"; errors=$((errors+1)); fi
|
if is_placeholder "$table"; then err "config.js: 'DB_TABLE' non renseigné"; errors=$((errors+1)); fi
|
||||||
|
|
||||||
# dossiers : déclaration non vide (pas de test FS)
|
|
||||||
for key in finishdirectory logdirectory infodirectory; do
|
for key in finishdirectory logdirectory infodirectory; do
|
||||||
val="$(normalize_js_value "$(parse_js_raw "$key")")"
|
val="$(normalize_js_value "$(parse_js_raw "$key")")"
|
||||||
if is_placeholder "$val"; then
|
if is_placeholder "$val"; then
|
||||||
@@ -326,7 +321,6 @@ validate_config_js() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# trustProxy / cookieSecure / sessionStorePath
|
|
||||||
local tp cs ssp
|
local tp cs ssp
|
||||||
tp="$(normalize_js_value "$(parse_js_raw trustProxy)")"
|
tp="$(normalize_js_value "$(parse_js_raw trustProxy)")"
|
||||||
cs="$(normalize_js_value "$(parse_js_raw cookieSecure)")"
|
cs="$(normalize_js_value "$(parse_js_raw cookieSecure)")"
|
||||||
@@ -339,9 +333,6 @@ validate_config_js() {
|
|||||||
if (( tp < 0 )); then
|
if (( tp < 0 )); then
|
||||||
err "config.js: 'trustProxy' doit être >= 0 (valeur=$tp)"; errors=$((errors+1))
|
err "config.js: 'trustProxy' doit être >= 0 (valeur=$tp)"; errors=$((errors+1))
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# chaîne non vide acceptée (ex: "loopback,uniquelocal")
|
|
||||||
:
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -353,7 +344,6 @@ validate_config_js() {
|
|||||||
err "config.js: 'sessionStorePath' non renseigné"; errors=$((errors+1))
|
err "config.js: 'sessionStorePath' non renseigné"; errors=$((errors+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# règles DB (déclarations uniquement)
|
|
||||||
case "$dbtype" in
|
case "$dbtype" in
|
||||||
sqlite)
|
sqlite)
|
||||||
val="$(normalize_js_value "$(parse_js_raw dbFile)")"
|
val="$(normalize_js_value "$(parse_js_raw dbFile)")"
|
||||||
@@ -381,6 +371,7 @@ validate_config_js() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_conf "$CONF_SH"
|
||||||
validate_config_js
|
validate_config_js
|
||||||
|
|
||||||
# ────────── Résumé & exit codes ──────────
|
# ────────── Résumé & exit codes ──────────
|
||||||
|
|||||||
Reference in New Issue
Block a user