Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3f22e8e0b | ||
|
|
40e36e0423 | ||
|
|
65a62ca0e4 | ||
|
|
accec47d08 | ||
|
|
6c74e09203 | ||
|
|
8f4ea50452 | ||
|
|
1e288af617 | ||
|
|
bda4cb18a6 | ||
|
|
9b2533695e | ||
|
|
07b53b8002 | ||
|
|
bd8b519753 | ||
|
|
7deee2be61 |
No files matched your search
+44
-6
@@ -88,8 +88,8 @@ if ! apt-get install -y asterisk; then
|
|||||||
apt-get install -y -t sid asterisk
|
apt-get install -y -t sid asterisk
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sons Asterisk en français (exacts de la machine de dev)
|
# Sons Asterisk en français et anglais
|
||||||
apt-get install -y asterisk-core-sounds-fr asterisk-core-sounds-fr-wav asterisk-core-sounds-fr-gsm 2>/dev/null || true
|
apt-get install -y asterisk-core-sounds-fr asterisk-core-sounds-fr-wav asterisk-core-sounds-fr-gsm asterisk-core-sounds-en asterisk-core-sounds-en-gsm 2>/dev/null || true
|
||||||
|
|
||||||
# Nginx, PHP-FPM et extensions requises
|
# Nginx, PHP-FPM et extensions requises
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
@@ -287,23 +287,61 @@ touch /etc/asterisk/pjsip.conf \
|
|||||||
/etc/asterisk/pjsip.custom.conf \
|
/etc/asterisk/pjsip.custom.conf \
|
||||||
/etc/asterisk/extensions.conf \
|
/etc/asterisk/extensions.conf \
|
||||||
/etc/asterisk/extensions.custom.conf \
|
/etc/asterisk/extensions.custom.conf \
|
||||||
|
/etc/asterisk/musiconhold.conf \
|
||||||
/etc/asterisk/musiconhold.custom.conf \
|
/etc/asterisk/musiconhold.custom.conf \
|
||||||
|
/etc/asterisk/voicemail.conf \
|
||||||
/etc/asterisk/voicemail.custom.conf \
|
/etc/asterisk/voicemail.custom.conf \
|
||||||
|
/etc/asterisk/modules.conf \
|
||||||
/etc/asterisk/rtp.conf \
|
/etc/asterisk/rtp.conf \
|
||||||
/etc/asterisk/features.conf
|
/etc/asterisk/features.conf
|
||||||
|
|
||||||
|
# 1. Modules Asterisk : Désactivation des modules ODBC/IMAP incompatibles sur Debian (évite conflit bloquant app_voicemail)
|
||||||
|
if ! grep -q 'noload => app_voicemail_odbc.so' /etc/asterisk/modules.conf 2>/dev/null; then
|
||||||
|
if grep -q '\[modules\]' /etc/asterisk/modules.conf 2>/dev/null; then
|
||||||
|
sed -i '/\[modules\]/a noload => app_voicemail_odbc.so\nnoload => app_voicemail_imap.so' /etc/asterisk/modules.conf 2>/dev/null || true
|
||||||
|
else
|
||||||
|
printf '[modules]\nautoload=yes\nnoload => app_voicemail_odbc.so\nnoload => app_voicemail_imap.so\n' >> /etc/asterisk/modules.conf
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Inclusions des fichiers custom dans les configurations principales
|
||||||
if ! grep -q 'pjsip.custom.conf' /etc/asterisk/pjsip.conf 2>/dev/null; then
|
if ! grep -q 'pjsip.custom.conf' /etc/asterisk/pjsip.conf 2>/dev/null; then
|
||||||
printf '\n#tryinclude "pjsip.custom.conf"\n' >> /etc/asterisk/pjsip.conf
|
printf '\n#tryinclude "pjsip.custom.conf"\n' >> /etc/asterisk/pjsip.conf
|
||||||
fi
|
fi
|
||||||
if ! grep -q 'extensions.custom.conf' /etc/asterisk/extensions.conf 2>/dev/null; then
|
if ! grep -q 'extensions.custom.conf' /etc/asterisk/extensions.conf 2>/dev/null; then
|
||||||
printf '\n#tryinclude "extensions.custom.conf"\n' >> /etc/asterisk/extensions.conf
|
printf '\n#tryinclude "extensions.custom.conf"\n' >> /etc/asterisk/extensions.conf
|
||||||
fi
|
fi
|
||||||
chown -R asterisk:asterisk /etc/asterisk
|
if ! grep -q 'musiconhold.custom.conf' /etc/asterisk/musiconhold.conf 2>/dev/null; then
|
||||||
|
sed -i 's/^\[default\]/;[default]/' /etc/asterisk/musiconhold.conf 2>/dev/null || true
|
||||||
|
sed -i 's/^mode=files/;mode=files/' /etc/asterisk/musiconhold.conf 2>/dev/null || true
|
||||||
|
sed -i 's/^directory=moh/;directory=moh/' /etc/asterisk/musiconhold.conf 2>/dev/null || true
|
||||||
|
printf '\n#tryinclude "/etc/asterisk/musiconhold.custom.conf"\n' >> /etc/asterisk/musiconhold.conf
|
||||||
|
fi
|
||||||
|
if ! grep -q 'voicemail.custom.conf' /etc/asterisk/voicemail.conf 2>/dev/null; then
|
||||||
|
sed -i 's/^1234 => 4242/;1234 => 4242/' /etc/asterisk/voicemail.conf 2>/dev/null || true
|
||||||
|
sed -i 's/^;\s*passwordlocation\s*=\s*spooldir/passwordlocation=spooldir/' /etc/asterisk/voicemail.conf 2>/dev/null || true
|
||||||
|
sed -i 's|^;\s*externpassnotify\s*=.*|externpassnotify=/usr/bin/php /var/www/nexus-pbx/scripts/voicemail_pass_sync.php|' /etc/asterisk/voicemail.conf 2>/dev/null || true
|
||||||
|
printf '\n#tryinclude "voicemail.custom.conf"\n' >> /etc/asterisk/voicemail.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p /var/spool/asterisk/voicemail/default /var/lib/asterisk/sounds/custom /var/lib/asterisk/moh
|
||||||
|
for lang in fr en es; do
|
||||||
|
if [ -d "/usr/share/asterisk/sounds/$lang" ] && [ ! -e "/var/lib/asterisk/sounds/$lang" ]; then
|
||||||
|
ln -sf "/usr/share/asterisk/sounds/$lang" "/var/lib/asterisk/sounds/$lang"
|
||||||
|
fi
|
||||||
|
if [ -d "/var/lib/asterisk/sounds/$lang" ] && [ ! -e "/var/lib/asterisk/sounds/$lang/custom" ]; then
|
||||||
|
ln -sf /var/lib/asterisk/sounds/custom "/var/lib/asterisk/sounds/$lang/custom" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ! -e "/usr/share/asterisk/sounds/custom" ]; then
|
||||||
|
ln -sf /var/lib/asterisk/sounds/custom /usr/share/asterisk/sounds/custom 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
chown -R asterisk:asterisk /etc/asterisk /var/spool/asterisk /var/lib/asterisk
|
||||||
chmod 0664 /etc/asterisk/*.conf /etc/asterisk/*.custom.conf 2>/dev/null || true
|
chmod 0664 /etc/asterisk/*.conf /etc/asterisk/*.custom.conf 2>/dev/null || true
|
||||||
chmod 2750 /etc/asterisk/keys
|
chmod 2750 /etc/asterisk/keys
|
||||||
chmod 2775 /etc/asterisk
|
chmod 2775 /etc/asterisk /var/spool/asterisk /var/spool/asterisk/voicemail /var/lib/asterisk/sounds /var/lib/asterisk/moh
|
||||||
setfacl -R -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk 2>/dev/null || true
|
setfacl -R -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk /var/spool/asterisk /var/lib/asterisk 2>/dev/null || true
|
||||||
setfacl -R -d -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk 2>/dev/null || true
|
setfacl -R -d -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk /var/spool/asterisk /var/lib/asterisk 2>/dev/null || true
|
||||||
|
|
||||||
# Rechargement Asterisk immédiat pour appliquer AMI et Logger
|
# Rechargement Asterisk immédiat pour appliquer AMI et Logger
|
||||||
asterisk -rx "core reload" 2>/dev/null || true
|
asterisk -rx "core reload" 2>/dev/null || true
|
||||||
|
|||||||
+53
-4
@@ -140,7 +140,7 @@ try {
|
|||||||
$installedVerData = file_exists("{$appDir}/version.json")
|
$installedVerData = file_exists("{$appDir}/version.json")
|
||||||
? json_decode((string)file_get_contents("{$appDir}/version.json"), true)
|
? json_decode((string)file_get_contents("{$appDir}/version.json"), true)
|
||||||
: [];
|
: [];
|
||||||
$installedVer = $installedVerData['version'] ?? '1.4.1';
|
$installedVer = $installedVerData['version'] ?? '1.5.0';
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
@@ -227,7 +227,7 @@ try {
|
|||||||
@chmod($webLog, 0664);
|
@chmod($webLog, 0664);
|
||||||
}
|
}
|
||||||
@unlink('/tmp/nexus_fw_status_cache.json');
|
@unlink('/tmp/nexus_fw_status_cache.json');
|
||||||
exec('sudo /usr/bin/fail2ban-client reload 2>&1');
|
exec('sudo /usr/bin/systemctl restart fail2ban 2>&1 || sudo /usr/bin/fail2ban-client reload 2>&1');
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
@@ -369,6 +369,13 @@ try {
|
|||||||
// Synchronisation automatique de l'annuaire d'entreprise
|
// Synchronisation automatique de l'annuaire d'entreprise
|
||||||
PhonebookManager::syncExtensions($db);
|
PhonebookManager::syncExtensions($db);
|
||||||
|
|
||||||
|
// Régénération automatique des fichiers Asterisk et rechargement PJSIP/Dialplan en direct
|
||||||
|
$generator->writeAllConfigs();
|
||||||
|
try {
|
||||||
|
$ami = AmiClient::fromDatabase($db);
|
||||||
|
$ami->reloadPjsipAndDialplan();
|
||||||
|
} catch (\Throwable $e) {}
|
||||||
|
|
||||||
$modeBadge = $transport === 'tls' ? 'Distant (TLS + SRTP)' : ($encryption ? 'Interne (UDP + SRTP)' : 'Interne (UDP)');
|
$modeBadge = $transport === 'tls' ? 'Distant (TLS + SRTP)' : ($encryption ? 'Interne (UDP + SRTP)' : 'Interne (UDP)');
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
@@ -381,6 +388,13 @@ try {
|
|||||||
$stmt = $db->prepare('DELETE FROM extensions WHERE id = :id');
|
$stmt = $db->prepare('DELETE FROM extensions WHERE id = :id');
|
||||||
$stmt->execute([':id' => $id]);
|
$stmt->execute([':id' => $id]);
|
||||||
PhonebookManager::syncExtensions($db);
|
PhonebookManager::syncExtensions($db);
|
||||||
|
|
||||||
|
$generator->writeAllConfigs();
|
||||||
|
try {
|
||||||
|
$ami = AmiClient::fromDatabase($db);
|
||||||
|
$ami->reloadPjsipAndDialplan();
|
||||||
|
} catch (\Throwable $e) {}
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => 'Poste téléphonique supprimé de la base SQLite.',
|
'message' => 'Poste téléphonique supprimé de la base SQLite.',
|
||||||
@@ -440,6 +454,12 @@ try {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$generator->writeAllConfigs();
|
||||||
|
try {
|
||||||
|
$ami = AmiClient::fromDatabase($db);
|
||||||
|
$ami->reloadPjsipAndDialplan();
|
||||||
|
} catch (\Throwable $e) {}
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => "Groupe d'appel {$extension} ({$name}) sauvegardé.",
|
'message' => "Groupe d'appel {$extension} ({$name}) sauvegardé.",
|
||||||
@@ -449,6 +469,12 @@ try {
|
|||||||
case 'delete_group':
|
case 'delete_group':
|
||||||
$id = (int)($payload['id'] ?? 0);
|
$id = (int)($payload['id'] ?? 0);
|
||||||
$db->prepare('DELETE FROM groups WHERE id = :id')->execute([':id' => $id]);
|
$db->prepare('DELETE FROM groups WHERE id = :id')->execute([':id' => $id]);
|
||||||
|
$generator->writeAllConfigs();
|
||||||
|
try {
|
||||||
|
$ami = AmiClient::fromDatabase($db);
|
||||||
|
$ami->reloadPjsipAndDialplan();
|
||||||
|
} catch (\Throwable $e) {}
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => "Groupe de sonnerie supprimé.",
|
'message' => "Groupe de sonnerie supprimé.",
|
||||||
@@ -540,6 +566,12 @@ try {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$generator->writeAllConfigs();
|
||||||
|
try {
|
||||||
|
$ami = AmiClient::fromDatabase($db);
|
||||||
|
$ami->reloadPjsipAndDialplan();
|
||||||
|
} catch (\Throwable $e) {}
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => "Groupe de téléavertissement {$extension} ({$name}) sauvegardé.",
|
'message' => "Groupe de téléavertissement {$extension} ({$name}) sauvegardé.",
|
||||||
@@ -549,6 +581,12 @@ try {
|
|||||||
case 'delete_paging_group':
|
case 'delete_paging_group':
|
||||||
$id = (int)($payload['id'] ?? 0);
|
$id = (int)($payload['id'] ?? 0);
|
||||||
$db->prepare('DELETE FROM paging_groups WHERE id = :id')->execute([':id' => $id]);
|
$db->prepare('DELETE FROM paging_groups WHERE id = :id')->execute([':id' => $id]);
|
||||||
|
$generator->writeAllConfigs();
|
||||||
|
try {
|
||||||
|
$ami = AmiClient::fromDatabase($db);
|
||||||
|
$ami->reloadPjsipAndDialplan();
|
||||||
|
} catch (\Throwable $e) {}
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => "Groupe de téléavertissement supprimé.",
|
'message' => "Groupe de téléavertissement supprimé.",
|
||||||
@@ -2311,14 +2349,25 @@ try {
|
|||||||
|
|
||||||
$newVerJson = file_exists("{$appDir}/version.json")
|
$newVerJson = file_exists("{$appDir}/version.json")
|
||||||
? json_decode((string)file_get_contents("{$appDir}/version.json"), true)
|
? json_decode((string)file_get_contents("{$appDir}/version.json"), true)
|
||||||
: ['version' => '1.3.8'];
|
: ['version' => '1.4.3'];
|
||||||
|
|
||||||
|
while (ob_get_level() > 0) {
|
||||||
|
@ob_end_clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
header('Cache-Control: no-cache, no-store, must-revalidate');
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => ($code === 0),
|
'success' => ($code === 0),
|
||||||
'new_version' => $newVerJson['version'] ?? '1.3.8',
|
'new_version' => $newVerJson['version'] ?? '1.4.3',
|
||||||
'output' => $outputStr,
|
'output' => $outputStr,
|
||||||
'message' => ($code === 0) ? "Mise à jour réussie !" : "Erreur lors de la mise à jour",
|
'message' => ($code === 0) ? "Mise à jour réussie !" : "Erreur lors de la mise à jour",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (function_exists('fastcgi_finish_request')) {
|
||||||
|
fastcgi_finish_request();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
+126
-23
@@ -266,20 +266,28 @@ function renderCompanyBranding() {
|
|||||||
|
|
||||||
if (loginBox) {
|
if (loginBox) {
|
||||||
loginBox.classList.remove('hidden');
|
loginBox.classList.remove('hidden');
|
||||||
|
loginBox.classList.add('flex');
|
||||||
if (logo && loginLogo) {
|
if (logo && loginLogo) {
|
||||||
loginLogo.src = logo;
|
loginLogo.src = logo;
|
||||||
loginLogo.classList.remove('hidden');
|
loginLogo.classList.remove('hidden');
|
||||||
} else if (loginLogo) {
|
} else if (loginLogo) {
|
||||||
|
loginLogo.src = '';
|
||||||
loginLogo.classList.add('hidden');
|
loginLogo.classList.add('hidden');
|
||||||
}
|
}
|
||||||
if (loginName) loginName.textContent = name;
|
if (loginName) {
|
||||||
|
loginName.textContent = name;
|
||||||
|
loginName.classList.toggle('hidden', !name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emptyBox?.classList.remove('hidden');
|
emptyBox?.classList.remove('hidden');
|
||||||
filledBox?.classList.add('hidden');
|
filledBox?.classList.add('hidden');
|
||||||
if (logoImg) { logoImg.src = ''; logoImg.classList.add('hidden'); }
|
if (logoImg) { logoImg.src = ''; logoImg.classList.add('hidden'); }
|
||||||
if (nameEl) { nameEl.textContent = ''; nameEl.classList.add('hidden'); }
|
if (nameEl) { nameEl.textContent = ''; nameEl.classList.add('hidden'); }
|
||||||
loginBox?.classList.add('hidden');
|
if (loginBox) {
|
||||||
|
loginBox.classList.add('hidden');
|
||||||
|
loginBox.classList.remove('flex');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5888,14 +5896,57 @@ async function checkSystemUpdate(notify = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runSystemUpdate() {
|
function openUpdateConfirmModal() {
|
||||||
if (!confirm("Voulez-vous lancer la mise à jour de NexusPBX ?\n\nUne sauvegarde préventive automatique de vos configurations et de votre base de données sera créée.")) {
|
const modal = document.getElementById('modal-confirm-update');
|
||||||
return;
|
if (!modal) return;
|
||||||
|
|
||||||
|
let targetVer = '';
|
||||||
|
let currVer = (appState && appState.version) ? appState.version : (document.querySelector('meta[name="nexus-app-version"]')?.content || '');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cachedRaw = localStorage.getItem('nexus_update_cached_data');
|
||||||
|
if (cachedRaw) {
|
||||||
|
const cached = JSON.parse(cachedRaw);
|
||||||
|
if (cached.latest_version) targetVer = cached.latest_version;
|
||||||
|
if (cached.current_version) currVer = cached.current_version;
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
|
const elTarget = document.getElementById('update-modal-target-version');
|
||||||
|
const elCurrent = document.getElementById('update-modal-current-version');
|
||||||
|
const elBadge = document.getElementById('update-modal-target-badge');
|
||||||
|
|
||||||
|
if (elTarget) elTarget.textContent = targetVer ? `v${targetVer}` : 'Dernière version';
|
||||||
|
if (elCurrent) elCurrent.textContent = currVer ? `v${currVer}` : 'vActuelle';
|
||||||
|
if (elBadge && targetVer) elBadge.textContent = `v${targetVer} disponible`;
|
||||||
|
|
||||||
|
modal.classList.remove('hidden');
|
||||||
|
modal.classList.add('flex');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeUpdateConfirmModal() {
|
||||||
|
const modal = document.getElementById('modal-confirm-update');
|
||||||
|
if (modal) {
|
||||||
|
modal.classList.add('hidden');
|
||||||
|
modal.classList.remove('flex');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runSystemUpdate() {
|
||||||
|
openUpdateConfirmModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function executeSystemUpdate() {
|
||||||
|
const btnModalConfirm = document.getElementById('btn-confirm-update-action');
|
||||||
const btnRun = document.getElementById('btn-run-update');
|
const btnRun = document.getElementById('btn-run-update');
|
||||||
const statusText = document.getElementById('update-status-text');
|
const statusText = document.getElementById('update-status-text');
|
||||||
|
|
||||||
|
if (btnModalConfirm) {
|
||||||
|
btnModalConfirm.disabled = true;
|
||||||
|
btnModalConfirm.classList.add('opacity-75', 'cursor-not-allowed');
|
||||||
|
btnModalConfirm.innerHTML = '<span class="animate-spin mr-2">↻</span> Déploiement en cours...';
|
||||||
|
}
|
||||||
|
|
||||||
if (btnRun) {
|
if (btnRun) {
|
||||||
btnRun.disabled = true;
|
btnRun.disabled = true;
|
||||||
btnRun.innerHTML = '<span class="animate-spin mr-1.5">↻</span> Mise à jour en cours...';
|
btnRun.innerHTML = '<span class="animate-spin mr-1.5">↻</span> Mise à jour en cours...';
|
||||||
@@ -5911,18 +5962,8 @@ async function runSystemUpdate() {
|
|||||||
localStorage.removeItem('nexus_update_last_check_ts');
|
localStorage.removeItem('nexus_update_last_check_ts');
|
||||||
localStorage.removeItem('nexus_update_cached_data');
|
localStorage.removeItem('nexus_update_cached_data');
|
||||||
|
|
||||||
try {
|
function finalizeUpdateSuccess(newVer) {
|
||||||
const res = await fetch('/api.php?action=run_update&_t=' + Date.now(), {
|
newVer = String(newVer || '').replace(/^v/, '');
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({})
|
|
||||||
});
|
|
||||||
const data = await res.json();
|
|
||||||
|
|
||||||
if (data.success) {
|
|
||||||
const newVer = data.new_version || '';
|
|
||||||
|
|
||||||
// 1. Mettre à jour immédiatement le cache avec l'état à jour
|
|
||||||
localStorage.setItem('nexus_update_last_check_ts', Date.now().toString());
|
localStorage.setItem('nexus_update_last_check_ts', Date.now().toString());
|
||||||
localStorage.setItem('nexus_update_cached_data', JSON.stringify({
|
localStorage.setItem('nexus_update_cached_data', JSON.stringify({
|
||||||
success: true,
|
success: true,
|
||||||
@@ -5933,7 +5974,6 @@ async function runSystemUpdate() {
|
|||||||
release_date: ''
|
release_date: ''
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// 2. Mettre à jour visuellement les badges immédiatement
|
|
||||||
const verTag = document.getElementById('system-version-tag');
|
const verTag = document.getElementById('system-version-tag');
|
||||||
const appBadge = document.getElementById('app-version-badge');
|
const appBadge = document.getElementById('app-version-badge');
|
||||||
const headerUpdateBadge = document.getElementById('header-update-badge');
|
const headerUpdateBadge = document.getElementById('header-update-badge');
|
||||||
@@ -5950,23 +5990,86 @@ async function runSystemUpdate() {
|
|||||||
statusText.className = 'text-emerald-400 font-bold';
|
statusText.className = 'text-emerald-400 font-bold';
|
||||||
statusText.textContent = `Mise à jour terminée avec succès (v${newVer}) ! Rechargement...`;
|
statusText.textContent = `Mise à jour terminée avec succès (v${newVer}) ! Rechargement...`;
|
||||||
}
|
}
|
||||||
|
if (btnModalConfirm) {
|
||||||
|
btnModalConfirm.className = 'px-5 py-2.5 rounded-xl text-xs font-bold bg-emerald-600 text-white flex items-center gap-2';
|
||||||
|
btnModalConfirm.innerHTML = '✓ Mise à jour terminée ! Rechargement...';
|
||||||
|
}
|
||||||
|
|
||||||
// 3. Rechargement avec paramètre anti-cache pour forcer le navigateur à récupérer le nouveau DOM
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
closeUpdateConfirmModal();
|
||||||
window.location.href = window.location.origin + window.location.pathname + '?_t=' + Date.now();
|
window.location.href = window.location.origin + window.location.pathname + '?_t=' + Date.now();
|
||||||
}, 2000);
|
}, 1800);
|
||||||
} else {
|
}
|
||||||
alert("Erreur lors de la mise à jour :\n\n" + (data.output || data.message));
|
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api.php?action=run_update&_t=' + Date.now(), {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({})
|
||||||
|
});
|
||||||
|
|
||||||
|
const rawText = await res.text();
|
||||||
|
let data = null;
|
||||||
|
try {
|
||||||
|
data = JSON.parse(rawText);
|
||||||
|
} catch (_) {
|
||||||
|
data = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data && data.success) {
|
||||||
|
finalizeUpdateSuccess(data.new_version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si la réponse n'était pas un JSON valide ou a été interrompue par le rechargement de php-fpm/nginx,
|
||||||
|
// on sonde le serveur pour vérifier si la mise à jour a en réalité bien été appliquée sur le disque
|
||||||
|
await new Promise(r => setTimeout(r, 2000));
|
||||||
|
try {
|
||||||
|
const probeRes = await fetch('/api.php?action=check_update&_t=' + Date.now());
|
||||||
|
const probeData = await probeRes.json();
|
||||||
|
if (probeData && probeData.success && probeData.current_version) {
|
||||||
|
finalizeUpdateSuccess(probeData.current_version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
|
// En cas d'échec réel avéré
|
||||||
|
closeUpdateConfirmModal();
|
||||||
|
const errMsg = (data && (data.output || data.message)) ? (data.output || data.message) : (rawText.slice(0, 150) || "Erreur inconnue");
|
||||||
|
alert("Erreur lors de la mise à jour :\n\n" + errMsg);
|
||||||
if (btnRun) {
|
if (btnRun) {
|
||||||
btnRun.disabled = false;
|
btnRun.disabled = false;
|
||||||
btnRun.innerHTML = 'Réessayer la mise à jour';
|
btnRun.innerHTML = 'Réessayer la mise à jour';
|
||||||
}
|
}
|
||||||
|
if (btnModalConfirm) {
|
||||||
|
btnModalConfirm.disabled = false;
|
||||||
|
btnModalConfirm.classList.remove('opacity-75', 'cursor-not-allowed');
|
||||||
|
btnModalConfirm.innerHTML = '<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg><span>Lancer la mise à jour (1-Clic)</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert("Erreur réseau lors de la mise à jour : " + e.message);
|
// En cas d'interruption réseau du socket (Safari WebKit DOMException ou timeout),
|
||||||
|
// on vérifie avant d'alerter si le serveur a quand même réussi à déployer les fichiers
|
||||||
|
await new Promise(r => setTimeout(r, 2000));
|
||||||
|
try {
|
||||||
|
const probeRes = await fetch('/api.php?action=check_update&_t=' + Date.now());
|
||||||
|
const probeData = await probeRes.json();
|
||||||
|
if (probeData && probeData.success && probeData.current_version) {
|
||||||
|
finalizeUpdateSuccess(probeData.current_version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
|
closeUpdateConfirmModal();
|
||||||
|
alert("Erreur réseau lors de la mise à jour : " + (e.message || "Connexion interrompue"));
|
||||||
if (btnRun) {
|
if (btnRun) {
|
||||||
btnRun.disabled = false;
|
btnRun.disabled = false;
|
||||||
btnRun.innerHTML = 'Réessayer la mise à jour';
|
btnRun.innerHTML = 'Réessayer la mise à jour';
|
||||||
}
|
}
|
||||||
|
if (btnModalConfirm) {
|
||||||
|
btnModalConfirm.disabled = false;
|
||||||
|
btnModalConfirm.classList.remove('opacity-75', 'cursor-not-allowed');
|
||||||
|
btnModalConfirm.innerHTML = '<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg><span>Lancer la mise à jour (1-Clic)</span>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+102
-10
@@ -11,8 +11,14 @@ Database::getConnection();
|
|||||||
$isAuth = Auth::isAuthenticated();
|
$isAuth = Auth::isAuthenticated();
|
||||||
$currentUser = Auth::getUsername();
|
$currentUser = Auth::getUsername();
|
||||||
|
|
||||||
|
$stmtSettings = Database::getConnection()->query('SELECT company_name, company_logo FROM settings WHERE id = 1 LIMIT 1');
|
||||||
|
$branding = $stmtSettings ? $stmtSettings->fetch(\PDO::FETCH_ASSOC) : null;
|
||||||
|
$companyName = trim($branding['company_name'] ?? '');
|
||||||
|
$companyLogo = trim($branding['company_logo'] ?? '');
|
||||||
|
$hasBranding = !empty($companyName) || !empty($companyLogo);
|
||||||
|
|
||||||
$appVerData = file_exists(__DIR__ . '/../version.json') ? json_decode((string)file_get_contents(__DIR__ . '/../version.json'), true) : [];
|
$appVerData = file_exists(__DIR__ . '/../version.json') ? json_decode((string)file_get_contents(__DIR__ . '/../version.json'), true) : [];
|
||||||
$appVersion = $appVerData['version'] ?? '1.4.1';
|
$appVersion = $appVerData['version'] ?? '1.5.0';
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr" class="h-full">
|
<html lang="fr" class="h-full">
|
||||||
@@ -149,8 +155,8 @@ $appVersion = $appVerData['version'] ?? '1.4.1';
|
|||||||
<div id="login-bg-layer" class="absolute inset-0 bg-cover bg-center bg-no-repeat" style="background-image: url('/assets/login-bg.jpg?v=<?= file_exists(__DIR__ . '/assets/login-bg.jpg') ? filemtime(__DIR__ . '/assets/login-bg.jpg') : 1 ?>');"></div>
|
<div id="login-bg-layer" class="absolute inset-0 bg-cover bg-center bg-no-repeat" style="background-image: url('/assets/login-bg.jpg?v=<?= file_exists(__DIR__ . '/assets/login-bg.jpg') ? filemtime(__DIR__ . '/assets/login-bg.jpg') : 1 ?>');"></div>
|
||||||
<div class="absolute inset-0 bg-gradient-to-tr from-anthracite-950/70 via-anthracite-950/50 to-indigo-950/30 backdrop-blur-[1px]"></div>
|
<div class="absolute inset-0 bg-gradient-to-tr from-anthracite-950/70 via-anthracite-950/50 to-indigo-950/30 backdrop-blur-[1px]"></div>
|
||||||
|
|
||||||
<!-- Carte de connexion flottante avec effet Glassmorphism -->
|
<!-- Carte de connexion flottante avec effet Glassmorphism transparent et aéré -->
|
||||||
<div class="relative z-10 w-full max-w-md bg-anthracite-900/85 backdrop-blur-xl border border-white/10 rounded-2xl shadow-2xl p-8">
|
<div class="relative z-10 w-full max-w-md bg-anthracite-900/60 backdrop-blur-2xl border border-white/15 rounded-3xl shadow-2xl shadow-black/50 p-8 sm:p-9 transition-all">
|
||||||
<div class="flex items-center gap-3.5 mb-6">
|
<div class="flex items-center gap-3.5 mb-6">
|
||||||
<div class="w-12 h-12 rounded-xl bg-indigo-500/20 border border-indigo-400/40 flex items-center justify-center text-indigo-300 shadow-inner">
|
<div class="w-12 h-12 rounded-xl bg-indigo-500/20 border border-indigo-400/40 flex items-center justify-center text-indigo-300 shadow-inner">
|
||||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
@@ -163,25 +169,25 @@ $appVersion = $appVerData['version'] ?? '1.4.1';
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Aperçu Logo Entreprise sur l'écran de connexion (si configuré) -->
|
<!-- Aperçu Logo Entreprise sur l'écran de connexion (rendu serveur natif) -->
|
||||||
<div id="login-company-box" class="hidden mb-5 p-3 rounded-xl bg-anthracite-950/90 border border-anthracite-700 flex items-center justify-center gap-3">
|
<div id="login-company-box" class="<?= $hasBranding ? 'flex' : 'hidden' ?> mb-5 p-3 rounded-xl bg-anthracite-950/45 border border-white/10 backdrop-blur-md items-center justify-center gap-3">
|
||||||
<img id="login-company-logo" src="" alt="Logo Entreprise" class="max-h-10 max-w-[160px] object-contain hidden">
|
<img id="login-company-logo" src="<?= htmlspecialchars($companyLogo) ?>" alt="Logo Entreprise" class="max-h-10 max-w-[160px] object-contain <?= !empty($companyLogo) ? '' : 'hidden' ?>">
|
||||||
<span id="login-company-name" class="text-xs font-semibold text-slate-200"></span>
|
<span id="login-company-name" class="text-xs font-semibold text-slate-200 <?= !empty($companyName) ? '' : 'hidden' ?>"><?= htmlspecialchars($companyName) ?></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="login-form" class="space-y-4">
|
<form id="login-form" class="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">Identifiant</label>
|
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">Identifiant</label>
|
||||||
<input type="text" name="username" value="admin" required
|
<input type="text" name="username" value="admin" required
|
||||||
class="w-full px-3.5 py-2.5 rounded-lg bg-anthracite-950 border border-anthracite-700 text-white focus:outline-none focus:border-indigo-400 text-sm">
|
class="w-full px-3.5 py-2.5 rounded-xl bg-anthracite-950/50 backdrop-blur-md border border-white/10 text-white placeholder-slate-400 focus:outline-none focus:border-indigo-400 focus:ring-2 focus:ring-indigo-500/20 text-sm transition">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">Mot de passe</label>
|
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">Mot de passe</label>
|
||||||
<input type="password" name="password" placeholder="••••••••" required
|
<input type="password" name="password" placeholder="••••••••" required
|
||||||
class="w-full px-3.5 py-2.5 rounded-lg bg-anthracite-950 border border-anthracite-700 text-white focus:outline-none focus:border-indigo-400 text-sm">
|
class="w-full px-3.5 py-2.5 rounded-xl bg-anthracite-950/50 backdrop-blur-md border border-white/10 text-white placeholder-slate-400 focus:outline-none focus:border-indigo-400 focus:ring-2 focus:ring-indigo-500/20 text-sm transition">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
class="w-full py-2.5 px-4 bg-indigo-600 hover:bg-indigo-500 active:bg-indigo-700 text-white font-semibold rounded-lg shadow-lg shadow-indigo-600/25 transition text-sm">
|
class="w-full py-2.5 px-4 bg-gradient-to-r from-indigo-600 to-indigo-500 hover:from-indigo-500 hover:to-indigo-400 active:from-indigo-700 active:to-indigo-600 text-white font-semibold rounded-xl shadow-lg shadow-indigo-500/25 transition text-sm">
|
||||||
Se connecter au PBX
|
Se connecter au PBX
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -4720,6 +4726,92 @@ $appVersion = $appVerData['version'] ?? '1.4.1';
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- ===================================================================== -->
|
||||||
|
<!-- MODAL : CONFIRMATION MISE À JOUR SYSTEME (OTA 1-CLIC) -->
|
||||||
|
<!-- ===================================================================== -->
|
||||||
|
<div id="modal-confirm-update" class="fixed inset-0 z-50 hidden items-center justify-center bg-black/80 backdrop-blur-sm p-3 sm:p-4 overflow-y-auto">
|
||||||
|
<div class="bg-anthracite-900 border border-indigo-500/40 rounded-2xl w-full max-w-lg shadow-2xl overflow-hidden my-6 animate-fadeIn">
|
||||||
|
<!-- Entête stylisée -->
|
||||||
|
<div class="px-6 py-5 border-b border-anthracite-800 bg-gradient-to-r from-indigo-950/50 via-anthracite-900 to-anthracite-900 flex items-start justify-between">
|
||||||
|
<div class="flex items-center gap-3.5">
|
||||||
|
<div class="w-11 h-11 rounded-xl bg-indigo-500/15 border border-indigo-500/30 text-indigo-400 flex items-center justify-center shrink-0 shadow-lg shadow-indigo-950/50">
|
||||||
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<h3 class="text-base font-bold text-white">Mise à Jour du Système NexusPBX</h3>
|
||||||
|
<span id="update-modal-target-badge" class="px-2 py-0.5 rounded text-[10px] font-bold tracking-wide uppercase bg-indigo-500/20 text-indigo-300 border border-indigo-500/30">OTA 1-Clic</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-xs text-slate-400 mt-0.5">Déploiement officiel et rechargement sans coupure</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick="closeUpdateConfirmModal()" class="text-slate-400 hover:text-white p-1.5 rounded-lg hover:bg-anthracite-800 transition">
|
||||||
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Corps de la modale -->
|
||||||
|
<div class="p-6 space-y-4">
|
||||||
|
<!-- Info cible -->
|
||||||
|
<div class="p-3.5 rounded-xl bg-anthracite-950/90 border border-anthracite-800 flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<div class="text-[11px] font-semibold text-slate-400 uppercase tracking-wider">Version Cible</div>
|
||||||
|
<div id="update-modal-target-version" class="text-base font-bold text-emerald-400 font-mono mt-0.5">v...</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-right">
|
||||||
|
<div class="text-[11px] font-semibold text-slate-400 uppercase tracking-wider">Version Actuelle</div>
|
||||||
|
<div id="update-modal-current-version" class="text-sm font-semibold text-slate-300 font-mono mt-0.5">v...</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Garanties & Sauvegarde automatique -->
|
||||||
|
<div class="p-3.5 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-xs text-emerald-300 flex items-start gap-3">
|
||||||
|
<svg class="w-5 h-5 text-emerald-400 shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/>
|
||||||
|
</svg>
|
||||||
|
<div>
|
||||||
|
<strong class="font-bold text-emerald-200">Sauvegarde préventive automatique incluse :</strong>
|
||||||
|
<p class="mt-0.5 text-emerald-300/90 leading-relaxed">Une sauvegarde complète de votre base SQLite et de vos configurations Asterisk sera créée avant toute modification.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Ce que fait la mise à jour -->
|
||||||
|
<div class="space-y-2">
|
||||||
|
<div class="text-xs font-semibold text-slate-300">Étapes automatiques du déploiement :</div>
|
||||||
|
<ul class="text-xs text-slate-400 space-y-1.5 pl-1">
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<span class="w-1.5 h-1.5 rounded-full bg-cyan-400 shrink-0"></span>
|
||||||
|
<span>Téléchargement des derniers fichiers et correctifs du dépôt officiel.</span>
|
||||||
|
</li>
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<span class="w-1.5 h-1.5 rounded-full bg-indigo-400 shrink-0"></span>
|
||||||
|
<span>Exécution des migrations SQLite et régénération des configurations Asterisk.</span>
|
||||||
|
</li>
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<span class="w-1.5 h-1.5 rounded-full bg-emerald-400 shrink-0"></span>
|
||||||
|
<span>Rechargement à chaud sans interruption des communications actives.</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Boutons d'action -->
|
||||||
|
<div class="px-6 py-4 border-t border-anthracite-800 bg-anthracite-950/80 flex items-center justify-end gap-3">
|
||||||
|
<button type="button" onclick="closeUpdateConfirmModal()"
|
||||||
|
class="px-4 py-2.5 rounded-xl text-xs font-semibold bg-anthracite-800 hover:bg-anthracite-750 text-slate-300 border border-anthracite-700 transition">
|
||||||
|
Annuler
|
||||||
|
</button>
|
||||||
|
<button type="button" id="btn-confirm-update-action" onclick="executeSystemUpdate()"
|
||||||
|
class="px-5 py-2.5 rounded-xl text-xs font-bold bg-gradient-to-r from-indigo-600 to-indigo-500 hover:from-indigo-500 hover:to-indigo-400 text-white shadow-lg shadow-indigo-600/30 transition flex items-center gap-2">
|
||||||
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
|
||||||
|
<span>Lancer la mise à jour (1-Clic)</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- ===================================================================== -->
|
<!-- ===================================================================== -->
|
||||||
<!-- MODAL : URL XML YEALINK REMOTE PHONEBOOK (cm_to_yl_ab.php) -->
|
<!-- MODAL : URL XML YEALINK REMOTE PHONEBOOK (cm_to_yl_ab.php) -->
|
||||||
<!-- ===================================================================== -->
|
<!-- ===================================================================== -->
|
||||||
|
|||||||
+45
-2
@@ -65,15 +65,58 @@ touch /etc/asterisk/pjsip.conf \
|
|||||||
/etc/asterisk/pjsip.custom.conf \
|
/etc/asterisk/pjsip.custom.conf \
|
||||||
/etc/asterisk/extensions.conf \
|
/etc/asterisk/extensions.conf \
|
||||||
/etc/asterisk/extensions.custom.conf \
|
/etc/asterisk/extensions.custom.conf \
|
||||||
|
/etc/asterisk/musiconhold.conf \
|
||||||
/etc/asterisk/musiconhold.custom.conf \
|
/etc/asterisk/musiconhold.custom.conf \
|
||||||
|
/etc/asterisk/voicemail.conf \
|
||||||
/etc/asterisk/voicemail.custom.conf \
|
/etc/asterisk/voicemail.custom.conf \
|
||||||
|
/etc/asterisk/modules.conf \
|
||||||
/etc/asterisk/rtp.conf \
|
/etc/asterisk/rtp.conf \
|
||||||
/etc/asterisk/features.conf 2>/dev/null || true
|
/etc/asterisk/features.conf 2>/dev/null || true
|
||||||
|
|
||||||
mkdir -p /var/lib/asterisk/sounds/custom /var/lib/asterisk/moh /var/spool/asterisk/voicemail 2>/dev/null || true
|
# Désactivation des modules ODBC/IMAP incompatibles sur Debian (évite conflit bloquant app_voicemail)
|
||||||
|
if ! grep -q 'noload => app_voicemail_odbc.so' /etc/asterisk/modules.conf 2>/dev/null; then
|
||||||
|
if grep -q '\[modules\]' /etc/asterisk/modules.conf 2>/dev/null; then
|
||||||
|
sed -i '/\[modules\]/a noload => app_voicemail_odbc.so\nnoload => app_voicemail_imap.so' /etc/asterisk/modules.conf 2>/dev/null || true
|
||||||
|
else
|
||||||
|
printf '[modules]\nautoload=yes\nnoload => app_voicemail_odbc.so\nnoload => app_voicemail_imap.so\n' >> /etc/asterisk/modules.conf
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Inclusions Asterisk et configuration messagerie vocale
|
||||||
|
if ! grep -q 'pjsip.custom.conf' /etc/asterisk/pjsip.conf 2>/dev/null; then
|
||||||
|
printf '\n#tryinclude "pjsip.custom.conf"\n' >> /etc/asterisk/pjsip.conf
|
||||||
|
fi
|
||||||
|
if ! grep -q 'extensions.custom.conf' /etc/asterisk/extensions.conf 2>/dev/null; then
|
||||||
|
printf '\n#tryinclude "extensions.custom.conf"\n' >> /etc/asterisk/extensions.conf
|
||||||
|
fi
|
||||||
|
if ! grep -q 'musiconhold.custom.conf' /etc/asterisk/musiconhold.conf 2>/dev/null; then
|
||||||
|
sed -i 's/^\[default\]/;[default]/' /etc/asterisk/musiconhold.conf 2>/dev/null || true
|
||||||
|
sed -i 's/^mode=files/;mode=files/' /etc/asterisk/musiconhold.conf 2>/dev/null || true
|
||||||
|
sed -i 's/^directory=moh/;directory=moh/' /etc/asterisk/musiconhold.conf 2>/dev/null || true
|
||||||
|
printf '\n#tryinclude "/etc/asterisk/musiconhold.custom.conf"\n' >> /etc/asterisk/musiconhold.conf
|
||||||
|
fi
|
||||||
|
if ! grep -q 'voicemail.custom.conf' /etc/asterisk/voicemail.conf 2>/dev/null; then
|
||||||
|
sed -i 's/^1234 => 4242/;1234 => 4242/' /etc/asterisk/voicemail.conf 2>/dev/null || true
|
||||||
|
sed -i 's/^;\s*passwordlocation\s*=\s*spooldir/passwordlocation=spooldir/' /etc/asterisk/voicemail.conf 2>/dev/null || true
|
||||||
|
sed -i 's|^;\s*externpassnotify\s*=.*|externpassnotify=/usr/bin/php /var/www/nexus-pbx/scripts/voicemail_pass_sync.php|' /etc/asterisk/voicemail.conf 2>/dev/null || true
|
||||||
|
printf '\n#tryinclude "voicemail.custom.conf"\n' >> /etc/asterisk/voicemail.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p /var/lib/asterisk/sounds/custom /var/lib/asterisk/moh /var/spool/asterisk/voicemail/default 2>/dev/null || true
|
||||||
|
for lang in fr en es; do
|
||||||
|
if [ -d "/usr/share/asterisk/sounds/$lang" ] && [ ! -e "/var/lib/asterisk/sounds/$lang" ]; then
|
||||||
|
ln -sf "/usr/share/asterisk/sounds/$lang" "/var/lib/asterisk/sounds/$lang" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
if [ -d "/var/lib/asterisk/sounds/$lang" ] && [ ! -e "/var/lib/asterisk/sounds/$lang/custom" ]; then
|
||||||
|
ln -sf /var/lib/asterisk/sounds/custom "/var/lib/asterisk/sounds/$lang/custom" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ! -e "/usr/share/asterisk/sounds/custom" ]; then
|
||||||
|
ln -sf /var/lib/asterisk/sounds/custom /usr/share/asterisk/sounds/custom 2>/dev/null || true
|
||||||
|
fi
|
||||||
chown -R asterisk:asterisk /etc/asterisk /var/lib/asterisk /var/spool/asterisk /var/log/asterisk 2>/dev/null || true
|
chown -R asterisk:asterisk /etc/asterisk /var/lib/asterisk /var/spool/asterisk /var/log/asterisk 2>/dev/null || true
|
||||||
chmod -R 775 /etc/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/moh /var/spool/asterisk 2>/dev/null || true
|
chmod -R 775 /etc/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/moh /var/spool/asterisk 2>/dev/null || true
|
||||||
chmod 2775 /etc/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/sounds/custom /var/lib/asterisk/moh /var/spool/asterisk 2>/dev/null || true
|
chmod 2775 /etc/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/sounds/custom /var/lib/asterisk/moh /var/spool/asterisk /var/spool/asterisk/voicemail 2>/dev/null || true
|
||||||
chmod 2750 /etc/asterisk/keys 2>/dev/null || true
|
chmod 2750 /etc/asterisk/keys 2>/dev/null || true
|
||||||
chmod 0664 /etc/asterisk/*.conf /etc/asterisk/*.custom.conf 2>/dev/null || true
|
chmod 0664 /etc/asterisk/*.conf /etc/asterisk/*.custom.conf 2>/dev/null || true
|
||||||
|
|
||||||
|
|||||||
+27
-2
@@ -130,8 +130,27 @@ $gen->writeAllConfigs();
|
|||||||
|
|
||||||
# 5. Fix permissions & ACLs
|
# 5. Fix permissions & ACLs
|
||||||
echo -e "${C_GRAY}[5/6] Application des permissions et ACLs système...${C_RESET}"
|
echo -e "${C_GRAY}[5/6] Application des permissions et ACLs système...${C_RESET}"
|
||||||
setfacl -R -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/moh 2>/dev/null || true
|
php -r '
|
||||||
setfacl -R -d -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/moh 2>/dev/null || true
|
require_once "/var/www/nexus-pbx/src/Database.php";
|
||||||
|
require_once "/var/www/nexus-pbx/src/SystemChecker.php";
|
||||||
|
App\SystemChecker::ensureAsteriskIncludes();
|
||||||
|
' 2>/dev/null || true
|
||||||
|
mkdir -p /var/spool/asterisk/voicemail/default /var/lib/asterisk/sounds/custom /var/lib/asterisk/moh 2>/dev/null || true
|
||||||
|
for lang in fr en es; do
|
||||||
|
if [ -d "/usr/share/asterisk/sounds/$lang" ] && [ ! -e "/var/lib/asterisk/sounds/$lang" ]; then
|
||||||
|
ln -sf "/usr/share/asterisk/sounds/$lang" "/var/lib/asterisk/sounds/$lang" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
if [ -d "/var/lib/asterisk/sounds/$lang" ] && [ ! -e "/var/lib/asterisk/sounds/$lang/custom" ]; then
|
||||||
|
ln -sf /var/lib/asterisk/sounds/custom "/var/lib/asterisk/sounds/$lang/custom" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ! -e "/usr/share/asterisk/sounds/custom" ]; then
|
||||||
|
ln -sf /var/lib/asterisk/sounds/custom /usr/share/asterisk/sounds/custom 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
chown -R asterisk:asterisk /var/spool/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/moh 2>/dev/null || true
|
||||||
|
chmod 2775 /var/spool/asterisk /var/spool/asterisk/voicemail /var/lib/asterisk/sounds /var/lib/asterisk/moh 2>/dev/null || true
|
||||||
|
setfacl -R -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/moh /var/spool/asterisk 2>/dev/null || true
|
||||||
|
setfacl -R -d -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk /var/lib/asterisk/sounds /var/lib/asterisk/moh /var/spool/asterisk 2>/dev/null || true
|
||||||
chmod 0664 /etc/asterisk/*.conf /etc/asterisk/*.custom.conf 2>/dev/null || true
|
chmod 0664 /etc/asterisk/*.conf /etc/asterisk/*.custom.conf 2>/dev/null || true
|
||||||
|
|
||||||
# 6. Rechargement des services
|
# 6. Rechargement des services
|
||||||
@@ -139,8 +158,14 @@ echo -e "${C_GRAY}[6/6] Rechargement à chaud d'Asterisk et des services web...$
|
|||||||
asterisk -rx "core reload" >/dev/null 2>&1 || true
|
asterisk -rx "core reload" >/dev/null 2>&1 || true
|
||||||
asterisk -rx "pjsip reload" >/dev/null 2>&1 || true
|
asterisk -rx "pjsip reload" >/dev/null 2>&1 || true
|
||||||
asterisk -rx "dialplan reload" >/dev/null 2>&1 || true
|
asterisk -rx "dialplan reload" >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
# Rechargement des services web : différé si exécuté depuis l'interface web pour éviter de couper la requête HTTP
|
||||||
|
if [ -t 1 ]; then
|
||||||
systemctl reload php8.4-fpm 2>/dev/null || systemctl reload php8.2-fpm 2>/dev/null || systemctl reload php*-fpm 2>/dev/null || true
|
systemctl reload php8.4-fpm 2>/dev/null || systemctl reload php8.2-fpm 2>/dev/null || systemctl reload php*-fpm 2>/dev/null || true
|
||||||
systemctl reload nginx 2>/dev/null || true
|
systemctl reload nginx 2>/dev/null || true
|
||||||
|
else
|
||||||
|
(nohup bash -c "sleep 2 && (systemctl reload php8.4-fpm 2>/dev/null || systemctl reload php8.2-fpm 2>/dev/null || systemctl reload php*-fpm 2>/dev/null || true); systemctl reload nginx 2>/dev/null || true" >/dev/null 2>&1 &)
|
||||||
|
fi
|
||||||
|
|
||||||
NEW_VER="Inconnue"
|
NEW_VER="Inconnue"
|
||||||
if [ -f "$APP_DIR/version.json" ]; then
|
if [ -f "$APP_DIR/version.json" ]; then
|
||||||
|
|||||||
+18
-13
@@ -256,6 +256,9 @@ class ConfigGenerator
|
|||||||
$lines[] = "type = aor";
|
$lines[] = "type = aor";
|
||||||
$lines[] = "max_contacts = {$maxContacts}";
|
$lines[] = "max_contacts = {$maxContacts}";
|
||||||
$lines[] = "remove_existing = yes";
|
$lines[] = "remove_existing = yes";
|
||||||
|
$lines[] = "default_expiration = 120";
|
||||||
|
$lines[] = "maximum_expiration = 300";
|
||||||
|
$lines[] = "minimum_expiration = 60";
|
||||||
$lines[] = "qualify_frequency = 30";
|
$lines[] = "qualify_frequency = 30";
|
||||||
if ($hasVm) {
|
if ($hasVm) {
|
||||||
$lines[] = "mailboxes = {$num}@default";
|
$lines[] = "mailboxes = {$num}@default";
|
||||||
@@ -571,10 +574,6 @@ class ConfigGenerator
|
|||||||
$lines[] = " same => n,Hangup()";
|
$lines[] = " same => n,Hangup()";
|
||||||
}
|
}
|
||||||
if ($groupCode !== '') {
|
if ($groupCode !== '') {
|
||||||
$lines[] = "exten => _{$groupCode}.,1,NoOp(Interception d'appel dirigee vers \${EXTEN:" . strlen($groupCode) . "})";
|
|
||||||
$lines[] = " same => n,Pickup(\${EXTEN:" . strlen($groupCode) . "}@from-internal)";
|
|
||||||
$lines[] = " same => n,Hangup()";
|
|
||||||
|
|
||||||
$lines[] = "exten => {$groupCode},1,NoOp(Interception d'appel de groupe)";
|
$lines[] = "exten => {$groupCode},1,NoOp(Interception d'appel de groupe)";
|
||||||
$lines[] = " same => n,Pickup()";
|
$lines[] = " same => n,Pickup()";
|
||||||
$lines[] = " same => n,Hangup()";
|
$lines[] = " same => n,Hangup()";
|
||||||
@@ -986,9 +985,10 @@ class ConfigGenerator
|
|||||||
$lines[] = "";
|
$lines[] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interphonie directe 1-à-1 (*80 + numéro de poste)
|
// Interphonie directe 1-à-1 (*80 + numéro de poste, ex: *80101 pour le poste 101)
|
||||||
|
// Pattern _*80XX. pour ne cibler que les numéros de postes (au moins 2 chiffres) et ne pas chevaucher *801
|
||||||
$lines[] = "; --- Interphonie directe 1-à-1 (*80 + numéro de poste) ---";
|
$lines[] = "; --- Interphonie directe 1-à-1 (*80 + numéro de poste) ---";
|
||||||
$lines[] = "exten => _*80.,1,NoOp(Interphonie directe vers poste \${EXTEN:3})";
|
$lines[] = "exten => _*80XX.,1,NoOp(Interphonie directe vers poste \${EXTEN:3})";
|
||||||
$lines[] = " same => n,Set(CHANNEL(language)={$sysLang})";
|
$lines[] = " same => n,Set(CHANNEL(language)={$sysLang})";
|
||||||
$lines[] = " same => n,Answer()";
|
$lines[] = " same => n,Answer()";
|
||||||
$lines[] = " same => n,Playback(beep)";
|
$lines[] = " same => n,Playback(beep)";
|
||||||
@@ -997,13 +997,14 @@ class ConfigGenerator
|
|||||||
$lines[] = "";
|
$lines[] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accès direct aux IVR depuis l'interne via *8 + id
|
// Accès direct aux IVR depuis l'interne via *8 + id (*801, *802...)
|
||||||
if (!empty($ivrs)) {
|
if (!empty($ivrs)) {
|
||||||
$lines[] = "; --- Test direct des SVI/IVR depuis l'interne ---";
|
$lines[] = "; --- Test direct des SVI/IVR depuis l'interne (*801, *802...) ---";
|
||||||
foreach ($ivrs as $ivr) {
|
foreach ($ivrs as $ivr) {
|
||||||
$ivrSlug = $this->slugify($ivr['name']);
|
$ivrSlug = $this->slugify($ivr['name']);
|
||||||
$testCode = '*8' . str_pad((string)$ivr['id'], 2, '0', STR_PAD_LEFT);
|
$testCode = '*8' . str_pad((string)$ivr['id'], 2, '0', STR_PAD_LEFT);
|
||||||
$lines[] = "exten => {$testCode},1,NoOp(Test SVI {$ivr['name']})";
|
$lines[] = "exten => {$testCode},1,NoOp(Test SVI {$ivr['name']})";
|
||||||
|
$lines[] = " same => n,Set(CHANNEL(language)={$sysLang})";
|
||||||
$lines[] = " same => n,Goto(ivr-{$ivrSlug},s,1)";
|
$lines[] = " same => n,Goto(ivr-{$ivrSlug},s,1)";
|
||||||
}
|
}
|
||||||
$lines[] = "";
|
$lines[] = "";
|
||||||
@@ -1500,6 +1501,7 @@ class ConfigGenerator
|
|||||||
$lines[] = "; --- Serveur Vocal Interactif : {$ivr['name']} ---";
|
$lines[] = "; --- Serveur Vocal Interactif : {$ivr['name']} ---";
|
||||||
$lines[] = "[ivr-{$ivrSlug}]";
|
$lines[] = "[ivr-{$ivrSlug}]";
|
||||||
$lines[] = "exten => s,1,NoOp(SVI {$ivr['name']})";
|
$lines[] = "exten => s,1,NoOp(SVI {$ivr['name']})";
|
||||||
|
$lines[] = " same => n,Set(CHANNEL(language)={$sysLang})";
|
||||||
$lines[] = " same => n,Answer()";
|
$lines[] = " same => n,Answer()";
|
||||||
$lines[] = " same => n,Wait(1)";
|
$lines[] = " same => n,Wait(1)";
|
||||||
$lines[] = " same => n,Set(IVR_INVALID_COUNT=0)";
|
$lines[] = " same => n,Set(IVR_INVALID_COUNT=0)";
|
||||||
@@ -1600,9 +1602,6 @@ class ConfigGenerator
|
|||||||
return implode("\n", $lines) . "\n";
|
return implode("\n", $lines) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sauvegarde les anciens fichiers et écrit atomiquement pjsip.custom.conf et extensions.custom.conf
|
|
||||||
* avec les droits Debian asterisk:asterisk (0660).
|
|
||||||
/**
|
/**
|
||||||
* Génère les classes Musique d'attente (MOH) personnalisées par site/catégorie
|
* Génère les classes Musique d'attente (MOH) personnalisées par site/catégorie
|
||||||
*/
|
*/
|
||||||
@@ -2223,18 +2222,24 @@ class ConfigGenerator
|
|||||||
$stmt = $this->db->prepare('SELECT slug FROM sounds WHERE id = :id');
|
$stmt = $this->db->prepare('SELECT slug FROM sounds WHERE id = :id');
|
||||||
$stmt->execute([':id' => (int)$soundRef]);
|
$stmt->execute([':id' => (int)$soundRef]);
|
||||||
$slug = $stmt->fetchColumn();
|
$slug = $stmt->fetchColumn();
|
||||||
return $slug ? "custom/{$slug}" : $fallback;
|
return $slug ? "/var/lib/asterisk/sounds/custom/{$slug}" : $fallback;
|
||||||
}
|
}
|
||||||
$ref = trim((string)$soundRef);
|
$ref = trim((string)$soundRef);
|
||||||
if (str_starts_with($ref, 'sound-')) {
|
if (str_starts_with($ref, 'sound-')) {
|
||||||
return $this->resolveSoundFile(substr($ref, 6), $fallback);
|
return $this->resolveSoundFile(substr($ref, 6), $fallback);
|
||||||
}
|
}
|
||||||
|
if (str_starts_with($ref, 'custom/')) {
|
||||||
|
return "/var/lib/asterisk/sounds/{$ref}";
|
||||||
|
}
|
||||||
|
if (str_starts_with($ref, '/var/lib/asterisk/sounds/custom/')) {
|
||||||
|
return $ref;
|
||||||
|
}
|
||||||
if (!str_contains($ref, '/') && !in_array($ref, ['demo-instruct', 'demo-echotest', 'pbx-invalid', 'hello-world', 'beep', 'silence/1', 'vm-goodbye'])) {
|
if (!str_contains($ref, '/') && !in_array($ref, ['demo-instruct', 'demo-echotest', 'pbx-invalid', 'hello-world', 'beep', 'silence/1', 'vm-goodbye'])) {
|
||||||
$stmt = $this->db->prepare('SELECT slug FROM sounds WHERE slug = :slug OR name = :name');
|
$stmt = $this->db->prepare('SELECT slug FROM sounds WHERE slug = :slug OR name = :name');
|
||||||
$stmt->execute([':slug' => $ref, ':name' => $ref]);
|
$stmt->execute([':slug' => $ref, ':name' => $ref]);
|
||||||
$slug = $stmt->fetchColumn();
|
$slug = $stmt->fetchColumn();
|
||||||
if ($slug) {
|
if ($slug) {
|
||||||
return "custom/{$slug}";
|
return "/var/lib/asterisk/sounds/custom/{$slug}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ref ?: $fallback;
|
return $ref ?: $fallback;
|
||||||
|
|||||||
+82
-5
@@ -70,17 +70,22 @@ class SystemChecker
|
|||||||
: 'Accès refusé en écriture dans /etc/asterisk pour PHP-FPM',
|
: 'Accès refusé en écriture dans /etc/asterisk pour PHP-FPM',
|
||||||
];
|
];
|
||||||
|
|
||||||
// 5. Directives #tryinclude dans pjsip.conf et extensions.conf
|
// 5. Directives #tryinclude dans pjsip.conf, extensions.conf, voicemail.conf et modules.conf
|
||||||
$pjsipMain = @file_get_contents('/etc/asterisk/pjsip.conf') ?: '';
|
$pjsipMain = @file_get_contents('/etc/asterisk/pjsip.conf') ?: '';
|
||||||
$extMain = @file_get_contents('/etc/asterisk/extensions.conf') ?: '';
|
$extMain = @file_get_contents('/etc/asterisk/extensions.conf') ?: '';
|
||||||
$incOk = str_contains($pjsipMain, 'pjsip.custom.conf') && str_contains($extMain, 'extensions.custom.conf');
|
$vmMain = @file_get_contents('/etc/asterisk/voicemail.conf') ?: '';
|
||||||
|
$modMain = @file_get_contents('/etc/asterisk/modules.conf') ?: '';
|
||||||
|
$incOk = str_contains($pjsipMain, 'pjsip.custom.conf')
|
||||||
|
&& str_contains($extMain, 'extensions.custom.conf')
|
||||||
|
&& str_contains($vmMain, 'voicemail.custom.conf')
|
||||||
|
&& str_contains($modMain, 'app_voicemail_odbc.so');
|
||||||
$checks[] = [
|
$checks[] = [
|
||||||
'id' => 'asterisk_includes',
|
'id' => 'asterisk_includes',
|
||||||
'label' => 'Inclusions natives (#tryinclude *.custom.conf)',
|
'label' => 'Inclusions Asterisk & Voicemail (#tryinclude & modules.conf)',
|
||||||
'ok' => $incOk,
|
'ok' => $incOk,
|
||||||
'detail' => $incOk
|
'detail' => $incOk
|
||||||
? 'pjsip.conf et extensions.conf incluent bien les fichiers .custom.conf'
|
? 'pjsip.conf, extensions.conf, voicemail.conf et modules.conf configurés'
|
||||||
: 'Directive #tryinclude manquante dans pjsip.conf ou extensions.conf',
|
: 'Directive #tryinclude manquante ou conflit modules.conf détecté',
|
||||||
];
|
];
|
||||||
|
|
||||||
// 6. Certificats TLS (Let's Encrypt ou Certificat local Debian)
|
// 6. Certificats TLS (Let's Encrypt ou Certificat local Debian)
|
||||||
@@ -142,6 +147,25 @@ class SystemChecker
|
|||||||
|
|
||||||
public static function ensureAsteriskIncludes(): void
|
public static function ensureAsteriskIncludes(): void
|
||||||
{
|
{
|
||||||
|
// 1. modules.conf: Désactiver les modules voicemail ODBC/IMAP incompatibles sur Debian (évite collision bloquante avec app_voicemail.so)
|
||||||
|
$modConf = '/etc/asterisk/modules.conf';
|
||||||
|
if (is_file($modConf) && is_writable($modConf)) {
|
||||||
|
$content = (string)file_get_contents($modConf);
|
||||||
|
$changed = false;
|
||||||
|
if (!str_contains($content, 'app_voicemail_odbc.so')) {
|
||||||
|
if (preg_match('/\[modules\]/i', $content)) {
|
||||||
|
$content = preg_replace('/\[modules\]/i', "[modules]\nnoload => app_voicemail_odbc.so\nnoload => app_voicemail_imap.so", $content, 1);
|
||||||
|
$changed = true;
|
||||||
|
} else {
|
||||||
|
$content = "[modules]\nautoload=yes\nnoload => app_voicemail_odbc.so\nnoload => app_voicemail_imap.so\n\n" . $content;
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($changed) {
|
||||||
|
file_put_contents($modConf, $content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$pjsipConf = '/etc/asterisk/pjsip.conf';
|
$pjsipConf = '/etc/asterisk/pjsip.conf';
|
||||||
if (is_file($pjsipConf) && is_writable($pjsipConf)) {
|
if (is_file($pjsipConf) && is_writable($pjsipConf)) {
|
||||||
$content = (string)file_get_contents($pjsipConf);
|
$content = (string)file_get_contents($pjsipConf);
|
||||||
@@ -177,8 +201,20 @@ class SystemChecker
|
|||||||
if (is_file($vmConf) && is_writable($vmConf)) {
|
if (is_file($vmConf) && is_writable($vmConf)) {
|
||||||
$content = (string)file_get_contents($vmConf);
|
$content = (string)file_get_contents($vmConf);
|
||||||
$cleaned = preg_replace('/^1234 => 4242.*/m', ';1234 => 4242,Example Mailbox,root@localhost', $content);
|
$cleaned = preg_replace('/^1234 => 4242.*/m', ';1234 => 4242,Example Mailbox,root@localhost', $content);
|
||||||
|
if (preg_match('/^;\s*passwordlocation\s*=\s*spooldir/m', $cleaned)) {
|
||||||
$cleaned = preg_replace('/^;\s*passwordlocation\s*=\s*spooldir/m', 'passwordlocation=spooldir', $cleaned);
|
$cleaned = preg_replace('/^;\s*passwordlocation\s*=\s*spooldir/m', 'passwordlocation=spooldir', $cleaned);
|
||||||
|
} elseif (!str_contains($cleaned, 'passwordlocation=spooldir') && !str_contains($cleaned, 'passwordlocation = spooldir')) {
|
||||||
|
if (preg_match('/\[general\]/i', $cleaned)) {
|
||||||
|
$cleaned = preg_replace('/\[general\]/i', "[general]\npasswordlocation=spooldir", $cleaned, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (preg_match('/^;\s*externpassnotify\s*=.*/m', $cleaned)) {
|
||||||
$cleaned = preg_replace('/^;\s*externpassnotify\s*=.*/m', 'externpassnotify=/usr/bin/php /var/www/nexus-pbx/scripts/voicemail_pass_sync.php', $cleaned);
|
$cleaned = preg_replace('/^;\s*externpassnotify\s*=.*/m', 'externpassnotify=/usr/bin/php /var/www/nexus-pbx/scripts/voicemail_pass_sync.php', $cleaned);
|
||||||
|
} elseif (!str_contains($cleaned, 'externpassnotify=')) {
|
||||||
|
if (preg_match('/\[general\]/i', $cleaned)) {
|
||||||
|
$cleaned = preg_replace('/\[general\]/i', "[general]\nexternpassnotify=/usr/bin/php /var/www/nexus-pbx/scripts/voicemail_pass_sync.php", $cleaned, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!str_contains($cleaned, 'voicemail.custom.conf')) {
|
if (!str_contains($cleaned, 'voicemail.custom.conf')) {
|
||||||
$cleaned = rtrim($cleaned) . "\n\n#tryinclude \"voicemail.custom.conf\"\n";
|
$cleaned = rtrim($cleaned) . "\n\n#tryinclude \"voicemail.custom.conf\"\n";
|
||||||
}
|
}
|
||||||
@@ -187,6 +223,47 @@ class SystemChecker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mkdir('/var/spool/asterisk/voicemail/default', 0775, true);
|
||||||
|
|
||||||
|
// Liens vers les répertoires de sons Debian (/usr/share/asterisk/sounds -> /var/lib/asterisk/sounds)
|
||||||
|
@mkdir('/var/lib/asterisk/sounds', 0775, true);
|
||||||
|
@mkdir('/var/lib/asterisk/sounds/custom', 0775, true);
|
||||||
|
@mkdir('/var/lib/asterisk/moh', 0775, true);
|
||||||
|
foreach (['fr', 'en', 'es'] as $lang) {
|
||||||
|
$src = "/usr/share/asterisk/sounds/{$lang}";
|
||||||
|
$dst = "/var/lib/asterisk/sounds/{$lang}";
|
||||||
|
if (is_dir($src) && !file_exists($dst)) {
|
||||||
|
@symlink($src, $dst);
|
||||||
|
}
|
||||||
|
if (is_dir($dst) && !file_exists("{$dst}/custom")) {
|
||||||
|
@symlink('/var/lib/asterisk/sounds/custom', "{$dst}/custom");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!file_exists('/usr/share/asterisk/sounds/custom')) {
|
||||||
|
@symlink('/var/lib/asterisk/sounds/custom', '/usr/share/asterisk/sounds/custom');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Synchroniser manager.conf avec le mot de passe AMI de la base SQLite si nécessaire (ex: après restauration de backup)
|
||||||
|
$mgrConf = '/etc/asterisk/manager.conf';
|
||||||
|
if (is_file($mgrConf) && is_writable($mgrConf)) {
|
||||||
|
try {
|
||||||
|
$db = Database::getConnection();
|
||||||
|
$st = $db->query('SELECT ami_user, ami_secret FROM settings WHERE id = 1')->fetch();
|
||||||
|
if (!empty($st['ami_secret'])) {
|
||||||
|
$sec = trim((string)$st['ami_secret']);
|
||||||
|
$usr = trim((string)($st['ami_user'] ?? 'pbxgui')) ?: 'pbxgui';
|
||||||
|
$content = (string)file_get_contents($mgrConf);
|
||||||
|
if (str_contains($content, "[{$usr}]")) {
|
||||||
|
$updated = preg_replace("/(\[{$usr}\][^\[]*secret\s*=\s*)([^\r\n]+)/i", "\${1}{$sec}", $content);
|
||||||
|
if ($updated !== null && $updated !== $content) {
|
||||||
|
file_put_contents($mgrConf, $updated);
|
||||||
|
@exec('asterisk -rx "manager reload" 2>/dev/null || true');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Throwable) {}
|
||||||
|
}
|
||||||
|
|
||||||
$astConf = '/etc/asterisk/asterisk.conf';
|
$astConf = '/etc/asterisk/asterisk.conf';
|
||||||
if (is_file($astConf) && is_writable($astConf)) {
|
if (is_file($astConf) && is_writable($astConf)) {
|
||||||
$content = (string)file_get_contents($astConf);
|
$content = (string)file_get_contents($astConf);
|
||||||
|
|||||||
+36
-4
@@ -298,17 +298,19 @@ class SystemMetrics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$seenExts = [];
|
||||||
foreach (preg_split('/\r?\n/', $rawContacts) ?: [] as $line) {
|
foreach (preg_split('/\r?\n/', $rawContacts) ?: [] as $line) {
|
||||||
// Contact: 101/sip:101@10.10.167.162:5060 5dd9a21be8 Avail 9.234
|
// Supporte sip:, sips:, sans préfixe, tous types de hash et RTT (numérique, nan, N/A ou absent)
|
||||||
// or with -nan: Contact: 102/sip:102@10.10.168.228:5060;x-ast-txp=trans bb0686ce80 Unavail -nan
|
if (preg_match('/Contact:\s+([^\s\/]+)\/(?:sips?:)?([^\s]+)\s+([a-zA-Z0-9]+)\s+(\S+)(?:\s+(\S+))?/i', $line, $m)) {
|
||||||
if (preg_match('/Contact:\s+([^\s\/]+)\/sip:([^\s]+)\s+([a-f0-9]+)\s+(\S+)\s+(-?[0-9.]+|nan|-nan)/i', $line, $m)) {
|
|
||||||
$extNum = $m[1];
|
$extNum = $m[1];
|
||||||
$uri = $m[2];
|
$uri = $m[2];
|
||||||
$status = $m[4];
|
$status = $m[4];
|
||||||
|
$rttRaw = $m[5] ?? null;
|
||||||
$isAvail = (stripos($status, 'Avail') !== false && stripos($status, 'Unavail') === false) || stripos($status, 'NonQual') !== false;
|
$isAvail = (stripos($status, 'Avail') !== false && stripos($status, 'Unavail') === false) || stripos($status, 'NonQual') !== false;
|
||||||
if ($isAvail) {
|
if ($isAvail) {
|
||||||
$onlineCount++;
|
$onlineCount++;
|
||||||
}
|
}
|
||||||
|
$seenExts[$extNum] = true;
|
||||||
|
|
||||||
$meta = $contactMeta[$extNum] ?? [];
|
$meta = $contactMeta[$extNum] ?? [];
|
||||||
$fullUri = $meta['uri'] ?? ("sip:" . $uri);
|
$fullUri = $meta['uri'] ?? ("sip:" . $uri);
|
||||||
@@ -330,7 +332,37 @@ class SystemMetrics
|
|||||||
'user_agent' => $userAgent,
|
'user_agent' => $userAgent,
|
||||||
'active_transport' => $activeTransport,
|
'active_transport' => $activeTransport,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'rtt_ms' => is_numeric($m[5]) ? round((float)$m[5], 1) : null,
|
'rtt_ms' => ($rttRaw !== null && is_numeric($rttRaw)) ? round((float)$rttRaw, 1) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filet de sécurité 100% infaillible : Tous les contacts enregistrés dans AstDB (/registrar/contact)
|
||||||
|
// non encore répertoriés (par exemple si qualify est désactivé ou RTT non disponible)
|
||||||
|
$nowTime = time();
|
||||||
|
foreach ($contactMeta as $extNum => $meta) {
|
||||||
|
if (isset($seenExts[$extNum])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$exp = (int)($meta['expiration_time'] ?? 0);
|
||||||
|
if ($exp === 0 || $exp > $nowTime) {
|
||||||
|
$onlineCount++;
|
||||||
|
$fullUri = $meta['uri'] ?? '';
|
||||||
|
$activeTransport = 'udp';
|
||||||
|
if (preg_match('/transport=(tls|wss|ws|tcp|udp)/i', $fullUri, $tm)) {
|
||||||
|
$activeTransport = strtolower($tm[1]);
|
||||||
|
} elseif (preg_match('/x-ast-txp=transport-(tls|wss|ws|tcp|udp)/i', $fullUri, $tm)) {
|
||||||
|
$activeTransport = strtolower($tm[1]);
|
||||||
|
} elseif (str_starts_with($fullUri, 'sips:')) {
|
||||||
|
$activeTransport = 'tls';
|
||||||
|
}
|
||||||
|
$contacts[] = [
|
||||||
|
'extension' => (string)$extNum,
|
||||||
|
'uri' => $fullUri,
|
||||||
|
'user_agent' => $meta['user_agent'] ?? '',
|
||||||
|
'active_transport' => $activeTransport,
|
||||||
|
'status' => 'Avail',
|
||||||
|
'rtt_ms' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-4
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"version": "1.4.1",
|
"version": "1.5.1",
|
||||||
"codename": "Helios",
|
"codename": "Helios",
|
||||||
"release_date": "2026-11-04",
|
"release_date": "2026-11-04",
|
||||||
"min_php_version": "8.2",
|
"min_php_version": "8.2",
|
||||||
"changelog": [
|
"changelog": [
|
||||||
"Nouveau fond d'écran immersif haute définition (réseau constellation) avec carte en glassmorphism sur la page de connexion",
|
"Plafond d'expiration d'enregistrement SIP standard (maximum_expiration = 300s, default = 120s) garantissant la reconnexion automatique rapide de tous les postes (1 à 3 min)",
|
||||||
"Lissage élégant des graphiques CPU/RAM et Réseau (splines Bézier cubiques sans angles vifs)",
|
"Support standard PJSIP check-sync et resync sans altération de l'état système",
|
||||||
"Mise à jour instantanée du numéro de version sur tous les badges sans aucun délai de cache navigateur"
|
"Nettoyage et isolation stricte des sauvegardes (base NexusPBX, sons, spools voicemail, certificats)",
|
||||||
|
"Résolution définitive et propre des conflits de préfixes Dialplan sur les SVI/IVR (*801-*899)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user