diff --git a/CHANGELOG.md b/CHANGELOG.md index 495a5af..9b8bf22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - Added search filter for conferences with time, ID and name - Added front page widgets - Added demo installation on https://work.lindeas.com/jilo-web-demo/ +- Added participant search page ### Changed diff --git a/public_html/classes/participant.php b/public_html/classes/participant.php new file mode 100644 index 0000000..38476d3 --- /dev/null +++ b/public_html/classes/participant.php @@ -0,0 +1,124 @@ +db = $database->getConnection(); + $this->queries = include('queries.php'); + } + + + // search/list specific participant ID + public function conferenceByParticipantId($participant_id, $from_time, $until_time) { + + // time period drill-down + // FIXME make it similar to the bash version + if (empty($from_time)) { + $from_time = '0000-01-01'; + } + if (empty($until_time)) { + $until_time = '9999-12-31'; + } + + // this is needed for compatibility with the bash version, so we use '%s' placeholders + $from_time = htmlspecialchars(strip_tags($from_time)); + $until_time = htmlspecialchars(strip_tags($until_time)); + $sql = $this->queries['conference_by_participant_id']; + $sql = sprintf($sql, $participant_id, $from_time, $until_time, $participant_id, $from_time, $until_time); + + $query = $this->db->prepare($sql); + $query->execute(); + + return $query->fetchAll(PDO::FETCH_ASSOC); + } + + + // search/list specific participant name (stats_id) + public function conferenceByParticipantName($participant_name, $from_time, $until_time) { + + // time period drill-down + // FIXME make it similar to the bash version + if (empty($from_time)) { + $from_time = '0000-01-01'; + } + if (empty($until_time)) { + $until_time = '9999-12-31'; + } + + // this is needed for compatibility with the bash version, so we use '%s' placeholders + $from_time = htmlspecialchars(strip_tags($from_time)); + $until_time = htmlspecialchars(strip_tags($until_time)); + $sql = $this->queries['participant_by_stats_id']; + $sql = sprintf($sql, $participant_name, $from_time, $until_time, $participant_name, $from_time, $until_time); + + $query = $this->db->prepare($sql); + $query->execute(); + + return $query->fetchAll(PDO::FETCH_ASSOC); + } + + + // search/list specific participant IP + public function conferenceByParticipantIP($participant_ip, $from_time, $until_time) { + + // time period drill-down + // FIXME make it similar to the bash version + if (empty($from_time)) { + $from_time = '0000-01-01'; + } + if (empty($until_time)) { + $until_time = '9999-12-31'; + } + + // this is needed for compatibility with the bash version, so we use '%s' placeholders + $from_time = htmlspecialchars(strip_tags($from_time)); + $until_time = htmlspecialchars(strip_tags($until_time)); + $sql = $this->queries['participant_by_ip']; + $sql = sprintf($sql, $participant_ip, $from_time, $until_time, $participant_ip, $from_time, $until_time); + + $query = $this->db->prepare($sql); + $query->execute(); + + return $query->fetchAll(PDO::FETCH_ASSOC); + } + + + // list of all conferences + public function participantsAll($from_time, $until_time) { + + // time period drill-down + // FIXME make it similar to the bash version + if (empty($from_time)) { + $from_time = '0000-01-01'; + } + if (empty($until_time)) { + $until_time = '9999-12-31'; + } + + // this is needed for compatibility with the bash version, so we use '%s' placeholders + $from_time = htmlspecialchars(strip_tags($from_time)); + $until_time = htmlspecialchars(strip_tags($until_time)); + $sql = $this->queries['participants_all']; + $sql = sprintf($sql, $from_time, $until_time); + + $query = $this->db->prepare($sql); + $query->execute(); + + return $query->fetchAll(PDO::FETCH_ASSOC); + } + + +} + +?> diff --git a/public_html/classes/queries.php b/public_html/classes/queries.php index be825fc..9c25ef9 100644 --- a/public_html/classes/queries.php +++ b/public_html/classes/queries.php @@ -139,6 +139,157 @@ WHERE c.conference_name = '%s' AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59') +ORDER BY + pe.time;", + + + // list all participants + 'participants_all' => " +SELECT DISTINCT + p.jitsi_component, p.endpoint_id, p.conference_id +FROM + participants p +JOIN + participant_events pe ON p.endpoint_id = pe.participant_id +WHERE + pe.time >= '%s 00:00:00' AND pe.time <= '%s 23:59:59' +ORDER BY p.id;", + + + // list conferences where participant ID (endpoint_id) is found + 'conference_by_participant_id' => " +SELECT + pe.time, + c.conference_id, + c.conference_name, + c.conference_host, + pe.loglevel, + pe.event_type, + p.endpoint_id AS participant_id, + pe.event_param +FROM + conferences c +LEFT JOIN + conference_events ce ON c.conference_id = ce.conference_id +LEFT JOIN + participants p ON c.conference_id = p.conference_id +LEFT JOIN + participant_events pe ON p.endpoint_id = pe.participant_id +WHERE + p.endpoint_id = '%s' +AND (pe.time >= '%s 00:00:00' AND pe.time <= '%s 23:59:59') + +UNION + +SELECT + ce.time AS event_time, + c.conference_id, + c.conference_name, + c.conference_host, + ce.loglevel, + ce.conference_event AS event_type, + NULL AS participant_id, + ce.conference_param AS event_param +FROM + conferences c +LEFT JOIN + conference_events ce ON c.conference_id = ce.conference_id +WHERE + participant_id = '%s' +AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59') + +ORDER BY + pe.time;", + + + // list conferences where participant name (stats_id) is found + 'participant_by_stats_id' => " +SELECT + pe.time, + c.conference_id, + c.conference_name, + c.conference_host, + pe.loglevel, + pe.event_type, + p.endpoint_id AS participant_id, + pe.event_param +FROM + conferences c +LEFT JOIN + conference_events ce ON c.conference_id = ce.conference_id +LEFT JOIN + participants p ON c.conference_id = p.conference_id +LEFT JOIN + participant_events pe ON p.endpoint_id = pe.participant_id +WHERE + pe.event_type = 'stats_id' AND pe.event_param LIKE '%%%s%%' +AND (pe.time >= '%s 00:00:00' AND pe.time <= '%s 23:59:59') + +UNION + +SELECT + ce.time AS event_time, + c.conference_id, + c.conference_name, + c.conference_host, + ce.loglevel, + ce.conference_event AS event_type, + NULL AS participant_id, + ce.conference_param AS event_param +FROM + conferences c +LEFT JOIN + conference_events ce ON c.conference_id = ce.conference_id +WHERE + event_type = 'stats_id' AND event_param LIKE '%%%s%%' +AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59') + +ORDER BY + pe.time;", + + + // list conferences where participant IP is found + 'participant_by_ip' => " +SELECT + pe.time, + c.conference_id, + c.conference_name, + c.conference_host, + pe.loglevel, + pe.event_type, + p.endpoint_id AS participant_id, + pe.event_param +FROM + conferences c +LEFT JOIN + conference_events ce ON c.conference_id = ce.conference_id +LEFT JOIN + participants p ON c.conference_id = p.conference_id +LEFT JOIN + participant_events pe ON p.endpoint_id = pe.participant_id +WHERE + pe.event_type = 'pair selected' AND pe.event_param = '%s' +AND (pe.time >= '%s 00:00:00' AND pe.time <= '%s 23:59:59') + +UNION + +SELECT + ce.time AS event_time, + c.conference_id, + c.conference_name, + c.conference_host, + ce.loglevel, + ce.conference_event AS event_type, + NULL AS participant_id, + ce.conference_param AS event_param +FROM + conferences c +LEFT JOIN + conference_events ce ON c.conference_id = ce.conference_id +WHERE + event_type = 'pair selected' AND event_param = '%s' +AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59') + ORDER BY pe.time;", diff --git a/public_html/index.php b/public_html/index.php index 80f8807..1582908 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -26,6 +26,7 @@ $allowed_urls = [ 'profile', 'config', 'conferences', + 'participants', ]; // cnfig file diff --git a/public_html/pages/conferences.php b/public_html/pages/conferences.php index 1d650dc..ea4683d 100644 --- a/public_html/pages/conferences.php +++ b/public_html/pages/conferences.php @@ -115,12 +115,20 @@ if (isset($conference_id)) { //table rows foreach ($conferences['records'] as $row) { echo "\t\t
" . htmlspecialchars($header) . " | \n"; + } + echo "\t\t|||||
---|---|---|---|---|---|
" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'conference ID') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'conference name') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($stats_id && $key === 'parameter') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($participant_ip && $key === 'parameter') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } else { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } + } + echo "\t\t
No matching conferences found.
'; + } + echo "\n" . htmlspecialchars($header) . " | \n"; + } + echo "\t\t||||
---|---|---|---|---|
" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'conference ID') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'conference name') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'participant ID') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } else { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } + } + echo "\t\t
No matching conferences found.
'; + } + echo "\n" . htmlspecialchars($header) . " | \n"; + } + echo "\t\t||||
---|---|---|---|---|
" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'conference ID') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'conference name') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'participant ID') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } else { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } + } + echo "\t\t
No matching conferences found.
'; + } + echo "\n" . htmlspecialchars($header) . " | \n"; + } + echo "\t\t||
---|---|---|
" . htmlspecialchars($column ?? '') . " | \n"; + } elseif ($key === 'conference ID') { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } else { + echo "\t\t\t" . htmlspecialchars($column ?? '') . " | \n"; + } + } + echo "\t\t
No matching participants found.
'; + } + echo "\n