Core->getAllUsers());\''; $jsonExt = shell_exec($cmd); if (!empty($jsonExt)) file_put_contents($cacheFileExt, $jsonExt); } $extData = json_decode($jsonExt, true); if (!is_array($extData)) die('Extensions load error'); /* ================= QUEUES ================= */ if (file_exists($cacheFileQueue) && time() - filemtime($cacheFileQueue) < $cacheTTL) { $jsonQ = file_get_contents($cacheFileQueue); } else { $cmdQ = 'php -r \'require_once "/etc/freepbx.conf"; global $db; $r = array(); if (isset($db)) { $tmp = $db->getAll("SELECT extension, descr FROM queues_config ORDER BY extension", array(), DB_FETCHMODE_ASSOC); if (is_array($tmp)) { $r = $tmp; } } echo json_encode($r);\''; $jsonQ = shell_exec($cmdQ); if (!empty($jsonQ)) file_put_contents($cacheFileQueue, $jsonQ); } $queueData = json_decode($jsonQ, true); if (!is_array($queueData)) $queueData = array(); /* ================= PJSIP STATUS ================= */ if (file_exists($statusFile) && time() - filemtime($statusFile) < $cacheTTL) { $pjsip = file_get_contents($statusFile); } else { $pjsip = shell_exec('asterisk -rx "pjsip show endpoints"'); if (!empty($pjsip)) file_put_contents($statusFile, $pjsip); } $online = array(); if (!empty($pjsip)) { preg_match_all('/Endpoint:\s+(\d+)/', $pjsip, $m); foreach ($m[1] as $e) { if (preg_match('/Endpoint:\s+' . $e . '.*?(Avail|Yes)/is', $pjsip)) { $online[$e] = true; } } } /* ================= SEARCH ================= */ $q = isset($_GET['q']) ? trim($_GET['q']) : ''; function h($s) { return htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } /* ================= BUILD EXT LIST ================= */ $extList = array(); foreach ($extData as $ext => $info) { $ext = (string)$ext; if (in_array($ext, $excludeExtensions, true)) continue; $name = isset($info['name']) ? (string)$info['name'] : ''; if ($q !== '' && stripos($name, $q) === false && stripos($ext, $q) === false) { continue; } $extList[] = array( 'name' => $name, 'ext' => $ext, 'status' => isset($online[$ext]) ? 'online' : 'offline' ); } /* ================= BUILD QUEUE LIST ================= */ $queueList = array(); foreach ($queueData as $row) { if (!is_array($row)) continue; $num = isset($row['extension']) ? (string)$row['extension'] : ''; if ($num === '') continue; if (in_array($num, $excludeQueues, true)) continue; $name = isset($row['descr']) ? (string)$row['descr'] : ''; if ($name === '') $name = 'Queue ' . $num; if ($q !== '' && stripos($name, $q) === false && stripos($num, $q) === false) { continue; } $queueList[] = array( 'name' => $name, 'num' => $num ); } ?> FreePBX Directory

Телефонный справочник

Сброс

Групповые номера отделов

Название Номер
Группы не найдены

Внутренние номера

Имя Номер Статус
🟢 Онлайн 🔴 Оффлайн
Ничего не найдено