Removing bbb old code see BT#3123

skala
Julio Montoya 13 years ago
parent d0b0347a11
commit 728c292687
  1. 327
      plugin/bbb/bbb.lib.php

@ -5,6 +5,7 @@
*/
class bbb {
var $url;
var $salt;
var $api;
@ -200,330 +201,4 @@ class bbb {
}
return 0;
}
}
/**
* Create string where we check if the meeting is running
*/
function wc_isMeetingRunningURL($myIP,$mySecuritySalt,$myMeetingID) {
$checkAPI = "/bigbluebutton/api/isMeetingRunning?";
$queryStr = "meetingID=".$myMeetingID;
$checksum = sha1('isMeetingRunning'.$queryStr.$mySecuritySalt);
$secQueryURL = "http://".$myIP.$checkAPI.$queryStr."&checksum=".$checksum;
return $secQueryURL;
}
/**
* Determine if the meeting is already running (e.g. has attendees in it)
*/
function wc_isMeetingRunning($myIP,$mySecuritySalt,$myMeetingID) {
$secQueryURL = wc_isMeetingRunningURL($myIP,$mySecuritySalt,$myMeetingID);
$myResponse = @file_get_contents($secQueryURL);
if ($myResponse === false) { return false;}
$doc = new DOMDocument();
$doc->loadXML($myResponse);
$returnCodeNode = $doc->getElementsByTagName("returncode");
$returnCode = $returnCodeNode->item(0)->nodeValue;
$runningNode = $doc->getElementsByTagName("running");
$isRunning = $runningNode->item(0)->nodeValue;
return $isRunning;
}
/**
* Create meeting if it's not already running
*/
function wc_createMeeting($myIP, $mySecuritySalt, $myMeetingName, $myMeetingID, $myAttendeePW, $myModeratorPW, $myWelcomeMsg, $myLogoutURL, $record = false, $duration = null) {
$createAPI = "/bigbluebutton/api/create?";
$myVoiceBridge = rand(70000,79999);
if (isset($record)) {
$record = 'true';
} else {
$record = 'false';
}
$duration_param = '';
if (!empty($duration)) {
$duration_param = '&duration='.intval($duration);
}
$queryStr = "name=".urlencode($myMeetingName)."&meetingID=".urlencode($myMeetingID)."&attendeePW=".urlencode($myAttendeePW)."&moderatorPW=".urlencode($myModeratorPW).
"&voiceBridge=".$myVoiceBridge."&welcome=".urlencode($myWelcomeMsg)."&logoutURL=".urlencode($myLogoutURL)."&record=".$record.$duration_param;
$checksum = sha1('create'.$queryStr.$mySecuritySalt);
$secQueryURL = "http://".$myIP.$createAPI.$queryStr."&checksum=".$checksum;
$myResponse = @file_get_contents($secQueryURL);
if ($myResponse === false) {
return false;
}
$doc= new DOMDocument();
$doc->loadXML($myResponse);
$returnCodeNode = $doc->getElementsByTagName("returncode");
$returnCode = $returnCodeNode->item(0)->nodeValue;
if ($returnCode=="SUCCESS") {
return $returnCode;
} else {
$messageKeyNode = $doc->getElementsByTagName("messageKey");
$messageKey = $messageKeyNode->item(0)->nodeValue;
return $messageKey;
}
}
/**
* Create a URL to join the meeting
*/
function wc_joinMeetingURL($myIP,$mySecuritySalt,$myName,$myMeetingID,$myPassword,$userID) {
$joinAPI = "/bigbluebutton/api/join?";
$queryStr = "fullName=".urlencode($myName)."&meetingID=".urlencode($myMeetingID)."&password=".urlencode($myPassword)."&userID=".$userID;
$checksum = sha1('join'.$queryStr.$mySecuritySalt);
$createStr = "http://".$myIP.$joinAPI.$queryStr."&checksum=".$checksum;
return $createStr;
}
/**
* This API is not yet supported in bigbluebutton
*/
function wc_endMeeting($myIP,$mySecuritySalt,$myMeetingID,$myModeratorPW) {
$endAPI = "/bigbluebutton/api/end?";
$myVoiceBridge = rand(70000,79999);
$queryStr = "meetingID=".$myMeetingID."&moderatorPW=".$myModeratorPW."&voiceBridge=".$myVoiceBridge;
$checksum = sha1('create'.$queryStr.$mySecuritySalt);
$secQueryURL = "http://".$myIP.$endAPI.$queryStr."&checksum=".$checksum;
$myResponse = @file_get_contents($secQueryURL);
if ($myResponse === false) { return false; }
$doc= new DOMDocument();
$doc->loadXML($myResponse);
$returnCodeNode = $doc->getElementsByTagName("returncode");
$returnCode = $returnCodeNode->item(0)->nodeValue;
if ($returnCode=="SUCCESS") {
return $returnCode;
} else {
$messageKeyNode = $doc->getElementsByTagName("messageKey");
$messageKey = $messageKeyNode->item(0)->nodeValue;
return $messageKey;
}
}
/**
* This API is not yet supported in bigbluebutton
*/
function wc_listAttendees() {
return false;
}
/**
* This API is not yet supported in bigbluebutton
*/
function wc_getMeetingInfo($myIP,$mySecuritySalt,$meetingID,$modPW) {
$checkAPI = "/bigbluebutton/api/getMeetingInfo?";
$queryStr = 'meetingID='.$meetingID.'&password='.$modPW;
$checksum = sha1('getMeetingInfo'.$queryStr.$mySecuritySalt);
$secQueryURL = "http://".$myIP.$checkAPI.$queryStr."&checksum=".$checksum;
$myResponse = @file_get_contents($secQueryURL);
if ($myResponse === false) { return false;}
$doc = new DOMDocument();
$doc->loadXML($myResponse);
$returnCodeNode = $doc->getElementsByTagName("returncode");
$returnCode = $returnCodeNode->item(0)->nodeValue;
$createTimeNode = $doc->getElementsByTagName("createTime");
$createTime = $createTimeNode->item(0)->nodeValue;
$runningNode = $doc->getElementsByTagName("running");
$running = $runningNode->item(0)->nodeValue;
$attendeesNode = $doc->getElementsByTagName("attendee");
$attendees = array();
foreach ($attendeesNode as $attendeeNode) {
$attendee = array();
if ($attendeeNode->childNodes->length) {
foreach ($attendeeNode->childNodes as $i) {
//see http://code.google.com/p/bigbluebutton/wiki/API#Get_Meeting_Info for details
$attendee[$i->nodeName] = $i->nodeValue;
}
}
$attendees[] = $attendee;
}
$info = array('returnCode'=>$returnCode,'createTime'=>$createTime,'attendees'=>$attendees,'running'=>$running);
return $info;
}
/**
* Determine the URL of the current page (for logoutURL)
*/
function wc_currentPageURL() {
$isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on");
$port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443")));
$port = ($port) ? ':'.$_SERVER["SERVER_PORT"] : '';
$pageURL = ($isHTTPS ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$port.$_SERVER["REQUEST_URI"];
return $pageURL;
}
/**
* Determine the IP/Domain of the current Corporate University
*/
function wc_currentDomain() {
$currentDomain = $_SERVER["SERVER_NAME"];
return $currentDomain;
}
/**
* Determine if a new version of the plug-in is available
*/
function wc_needUpgrade() {
$returnValue = false;
$installedVersion = "20100805";
$availableVersion = dc_getVersion();
if ((int)$installedVersion < (int)$availableVersion) {
$returnValue = true;
}
return $returnValue;
}
/**
* Gets a list of all meetings currently running
*/
function wc_getRunningMeetings($myIP,$mySecuritySalt) {
$checkAPI = "/bigbluebutton/api/getMeetings?";
$queryStr = '';
$checksum = sha1('getMeetings'.$queryStr.$mySecuritySalt);
$secQueryURL = "http://".$myIP.$checkAPI.$queryStr."&checksum=".$checksum;
$myResponse = @file_get_contents($secQueryURL);
if ($myResponse === false) { return false;}
$doc = new DOMDocument();
$doc->loadXML($myResponse);
$returnCodeNode = $doc->getElementsByTagName("returncode");
$returnCode = $returnCodeNode->item(0)->nodeValue;
$meetingsNode = $doc->getElementsByTagName("meeting");
$meetings = array();
foreach ($meetingsNode as $meetingNode) {
$meeting = array();
if ($meetingNode->childNodes->length) {
foreach ($meetingNode->childNodes as $i) {
//see http://code.google.com/p/bigbluebutton/wiki/API#Get_Meetings for details
$meeting[$i->nodeName] = $i->nodeValue;
}
}
$meetings[] = $meeting;
}
return $meetings;
}
function wc_getRecordingsURL($meetingID, $URL, $SALT) {
$base_url_record = $URL."api/getRecordings?";
$params = "meetingID=".urlencode($meetingID);
return ($base_url_record.$params."&checksum=".sha1("getRecordings".$params.$SALT) );
}
/**
*This method calls getMeetings on the bigbluebuttonbn server, then calls getMeetingInfo for each meeting and concatenates the result.
*
*@param URL -- the url of the bigbluebuttonbn server
*@param SALT -- the security salt of the bigbluebuttonbn server
*
*@return
* - Null if the server is unreachable
* - If FAILED then returns an array containing a returncode, messageKey, message.
* - If SUCCESS then returns an array of all the meetings. Each element in the array is an array containing a meetingID,
moderatorPW, attendeePW, hasBeenForciblyEnded, running.
*/
function wc_getRecordingsArray($meetingID, $URL, $SALT ) {
$xml = _wrap_simplexml_load_file(wc_getRecordingsURL( $meetingID, $URL, $SALT));
if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey ) {
////The meetings were returned
return array('returncode' => (string) $xml->returncode, 'message' => (string) $xml->message, 'messageKey' => (string) $xml->messageKey);
} else if($xml && $xml->returncode == 'SUCCESS') { //If there were meetings already created
$recordings = array();
foreach ($xml->recordings->recording as $recording) {
$recordings[(string) $recording->recordID] = array( 'recordID' => (string) $recording->recordID, 'meetingID' => (string) $recording->meetingID, 'meetingName' => (string) $recording->name, 'published' => (string) $recording->published, 'startTime' => (string) $recording->startTime, 'endTime' => (string) $recording->endTime );
$recordings[(string) $recording->recordID]['playbacks'] = array();
foreach ( $recording->playback->format as $format ){
$recordings[(string) $recording->recordID]['playbacks'][(string) $format->type] = array( 'type' => (string) $format->type, 'url' => (string) $format->url );
}
// THIS IS FOR TESTING MULTIPLE FORMATS, DO REMOVE IT FOR FINAL RELEASE
//$recordings[(string) $recording->recordID]['playbacks']['desktop'] = array( 'type' => 'desktop', 'url' => (string) $recording->playback->format->url );
//Add the metadata to the recordings array
$metadata = get_object_vars($recording->metadata);
while ($data = current($metadata)) {
$recordings[(string) $recording->recordID]['meta_'.key($metadata)] = $data;
next($metadata);
}
}
ksort($recordings);
return $recordings;
} else if( $xml ) { //If the xml packet returned failure it displays the message to the user
return array('returncode' => (string) $xml->returncode, 'message' => (string) $xml->message, 'messageKey' => (string) $xml->messageKey);
} else { //If the server is unreachable, then prompts the user of the necessary action
return NULL;
}
}
function _wrap_simplexml_load_file($url){
if (extension_loaded('curl')) {
$ch = curl_init() or die ( curl_error() );
$timeout = 10;
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec( $ch );
curl_close( $ch );
if($data)
return (new SimpleXMLElement($data,LIBXML_NOCDATA));
else
return false;
}
return (simplexml_load_file($url,'SimpleXMLElement', LIBXML_NOCDATA));
}
function getMeetingsURL($URL, $SALT) {
$base_url = $URL."api/getMeetings?";
$params = '';
return ( $base_url.$params.'&checksum='.sha1("getMeetings".$params.$SALT));
}
/**
*This method calls getMeetings on the bigbluebuttonbn server, then calls getMeetingInfo for each meeting and concatenates the result.
*
*@param URL -- the url of the bigbluebuttonbn server
*@param SALT -- the security salt of the bigbluebuttonbn server
*
*@return
* - Null if the server is unreachable
* - If FAILED then returns an array containing a returncode, messageKey, message.
* - If SUCCESS then returns an array of all the meetings. Each element in the array is an array containing a meetingID,
moderatorPW, attendeePW, hasBeenForciblyEnded, running.
*/
function getMeetingsArray( $URL, $SALT ) {
if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey ) {//The meetings were returned
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
}
else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created
foreach ($xml->meetings->meeting as $meeting)
{
$meetings[] = array( 'meetingID' => $meeting->meetingID, 'moderatorPW' => $meeting->moderatorPW, 'attendeePW' => $meeting->attendeePW, 'hasBeenForciblyEnded' => $meeting->hasBeenForciblyEnded, 'running' => $meeting->running );
}
return $meetings;
}
else if( $xml ) { //If the xml packet returned failure it displays the message to the user
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
}
else { //If the server is unreachable, then prompts the user of the necessary action
return null;
}
}
Loading…
Cancel
Save