forked from blindsidenetworks-ps/moodle-mod_bigbluebuttonbn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping.php
More file actions
56 lines (46 loc) · 1.63 KB
/
Copy pathping.php
File metadata and controls
56 lines (46 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Ping the BigBlueButton server to see if the meeting is running
*
* Authors:
* Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*
* @package mod_bigbluebuttonbn
* @copyright 2012 Blindside Networks Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later
*/
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/locallib.php');
$callback = optional_param('callback', "", PARAM_TEXT);
$meetingID = optional_param('meetingid', 0, PARAM_TEXT);
if (!$meetingID) {
$error = 'You must specify a meetingID';
}
if (!$callback) {
$error = 'This call must include a javascript callback';
}
header('Content-Type: application/json; charset=utf-8');
if ( !isset($error) ) {
if (!isloggedin() && $PAGE->course->id == SITEID) {
$userid = guest_user()->id;
} else {
$userid = $USER->id;
}
$hascourseaccess = ($PAGE->course->id == SITEID) || can_access_course($PAGE->course, $userid);
if( !$hascourseaccess ){
header("HTTP/1.0 401 Unauthorized");
//http_response_code(401);
} else {
$salt = trim($CFG->BigBlueButtonBNSecuritySalt);
$url = trim(trim($CFG->BigBlueButtonBNServerURL),'/').'/';
try{
$ismeetingrunning = (bigbluebuttonbn_isMeetingRunning( $meetingID, $url, $salt )? 'true': 'false');
echo $callback.'({ "status": "'.$ismeetingrunning.'" });';
}catch(Exception $e){
header("HTTP/1.0 502 Bad Gateway. ".$e->getMessage());
}
}
} else {
header("HTTP/1.0 400 Bad Request. ".$error);
//http_response_code(400);
}