$serverid = dc_authenticate($accountid, $accountpwd);
}
if ($provider == "self" || $serverid != "FAILURE") {
    $fullname = urlencode($USER->firstname . " " . $USER->lastname);
    $meetingname = urlencode(get_field('bigbluebutton', 'meetingname', 'id', $bigbluebutton->id));
    $meetingid = urlencode(get_field('bigbluebutton', 'meetingid', 'id', $bigbluebutton->id));
    $attendeePW = urlencode(get_field('bigbluebutton', 'attendeepw', 'id', $bigbluebutton->id));
    $moderatorPW = urlencode(get_field('bigbluebutton', 'moderatorpw', 'id', $bigbluebutton->id));
    $loginRule = urlencode(get_field('bigbluebutton', 'autologin', 'id', $bigbluebutton->id));
    $newwindow = urlencode(get_field('bigbluebutton', 'newwindow', 'id', $bigbluebutton->id));
    $welcomeMsg = urlencode(get_field('bigbluebutton', 'welcomemsg', 'id', $bigbluebutton->id));
    $logoutURL = urlencode(wc_currentPageURL());
    $myURL = wc_currentPageURL();
    /// Create string to see if the meeting is running
    if ($provider == "self") {
        $isRunningURL = wc_isMeetingRunningURL($ip, $securitySalt, $meetingid);
    } else {
        $isRunningURL = dc_isMeetingRunningURL($accountid, $accountpwd, $meetingid);
    }
    /// Create the meeting
    if ($provider == "self") {
        $createResponse = wc_createMeeting($ip, $securitySalt, $meetingname, $meetingid, $attendeePW, $moderatorPW, $welcomeMsg, $logoutURL);
    } else {
        $createResponse = dc_createMeeting($accountid, $accountpwd, $meetingname, $meetingid, $attendeePW, $moderatorPW, $welcomeMsg, $logoutURL);
    }
    if ($createResponse == "SUCCESS") {
        /// Determine whether to launch the session in the same window or a new window
        $newWindowStr = "";
        if ($newwindow == '1') {
            $newWindowStr = "target=\"_blank\"";
        }
function wc_isMeetingRunning($myIP, $mySecuritySalt, $myMeetingID)
{
    $secQueryURL = wc_isMeetingRunningURL($myIP, $mySecuritySalt, $myMeetingID);
    $myResponse = file_get_contents($secQueryURL);
    $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;
}