Issues (1796)

public/plugin/Bbb/start.php (2 issues)

1
<?php
2
3
/* For license terms, see /license.txt */
4
5
/**
6
 * This script initiates a video conference session, calling the BigBlueButton API.
7
 */
8
require_once __DIR__.'/../../../vendor/autoload.php';
9
10
$course_plugin = 'Bbb'; //needed in order to load the plugin lang variables
11
12
$isGlobal = isset($_GET['global']);
13
$isGlobalPerUser = isset($_GET['user_id']) ? (int) $_GET['user_id'] : false;
14
15
// If global setting is used then we delete the course sessions (cidReq/id_session)
16
if ($isGlobalPerUser || $isGlobal) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $isGlobalPerUser of type false|integer is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
17
    $cidReset = true;
18
}
19
20
require_once __DIR__.'/config.php';
21
22
$logInfo = [
23
    'tool' => 'Videoconference',
24
];
25
Event::registerLog($logInfo);
0 ignored issues
show
The method registerLog() does not exist on Event. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
Event::/** @scrutinizer ignore-call */ 
26
       registerLog($logInfo);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
27
$tool_name = get_lang('Videoconference');
28
$tpl = new Template($tool_name);
29
30
$vmIsEnabled = false;
31
$host = '';
32
$salt = '';
33
$bbb = new Bbb('', '', $isGlobal, $isGlobalPerUser);
34
35
$conferenceManager = $bbb->isConferenceManager();
36
if ($bbb->isGlobalConference()) {
37
    api_block_anonymous_users();
38
} else {
39
    api_protect_course_script(true);
40
}
41
42
$message = null;
43
if ($bbb->pluginEnabled) {
44
    if ($bbb->isServerConfigured()) {
45
        if ($bbb->isServerRunning()) {
46
            if (isset($_GET['launch']) && 1 == $_GET['launch']) {
47
                if (file_exists(__DIR__.'/config.vm.php')) {
48
                    $config = require __DIR__.'/config.vm.php';
49
                    $vmIsEnabled = true;
50
                    $host = '';
51
                    $salt = '';
52
53
                    require __DIR__.'/lib/vm/AbstractVM.php';
54
                    require __DIR__.'/lib/vm/VMInterface.php';
55
                    require __DIR__.'/lib/vm/DigitalOceanVM.php';
56
                    require __DIR__.'/lib/VM.php';
57
58
                    $vm = new VM($config);
59
60
                    if ($vm->isEnabled()) {
61
                        try {
62
                            $vm->resizeToMaxLimit();
63
                        } catch (\Exception $e) {
64
                            echo $e->getMessage();
65
                            exit;
66
                        }
67
                    }
68
                }
69
70
                $meetingParams = [];
71
                $meetingParams['meeting_name'] = $bbb->getCurrentVideoConferenceName();
72
                $url = null;
73
                if ($bbb->meetingExists($meetingParams['meeting_name'])) {
74
                    $joinUrl = $bbb->joinMeeting($meetingParams['meeting_name']);
75
                    if ($joinUrl) {
76
                        $url = $joinUrl;
77
                    }
78
                } else {
79
                    if ($bbb->isConferenceManager()) {
80
                        $url = $bbb->createMeeting($meetingParams);
81
                    }
82
                }
83
84
                $meetingInfo = $bbb->findMeetingByName($meetingParams['meeting_name']);
85
                if (!empty($meetingInfo) && $url) {
86
                    $bbb->saveParticipant($meetingInfo['id'], api_get_user_id());
87
                    $bbb->redirectToBBB($url);
88
                } else {
89
                    Display::addFlash(
90
                        Display::return_message($bbb->plugin->get_lang('ThereIsNoVideoConferenceActive'))
91
                    );
92
                    $url = $bbb->getListingUrl();
93
                    header('Location: '.$url);
94
                    exit;
95
                }
96
            } else {
97
                $url = $bbb->getListingUrl();
98
                header('Location: '.$url);
99
                exit;
100
            }
101
        } else {
102
            $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
103
        }
104
    } else {
105
        $message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning');
106
    }
107
} else {
108
    $message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning');
109
}
110
111
$tpl->assign('message', $message);
112
$tpl->display_one_col_template();
113