-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect_lib.php
More file actions
136 lines (106 loc) · 3.56 KB
/
Copy pathconnect_lib.php
File metadata and controls
136 lines (106 loc) · 3.56 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/******************************************************************************
* File: connect_lib.php
* Notes:
* This files provides the main code used to send requests to an Adobe Connect
* Service
*
* Distributed: Under GPL - See COPYING for info
* Copyright: 2009-2013 Simon Hanmer (simon.hanmer@gmail.com)
*
*****************************************************************************/
?>
<?php
class Connect {
function Connect($host, $user, $password) {
$this->host = $host;
$this->user = $user;
$this->password = $password;
}
// ----------------------------------------------------------------------------
// Function: request
// Arguments:
// $server - initialised instance of class Connect
// $debug - set to true to show debug info (optional)
// Return: true or false to reflect success of request.
//
// This function sends the request to the adobe connect service defined in the
// server instance.
// ----------------------------------------------------------------------------
function request($server, $debug = false) {
global $xml_response;
if (empty($server->action) || $server->action == '') {
return false;
}
$url = $this->host.'/api/xml?action='.$server->action;
if (!empty($this->cookie)) {
$server->session = $this->cookie;
}
if ($server->action == 'login') {
$server->login = $this->user;
$server->password = $this->password;
}
foreach ($server as $arg => $value) {
if ($arg == 'action') continue;
$url .= '&'.$arg.'='.$value;
}
if (!empty($this->domain) && $this->domain != $this->host && $server->action == "login") {
$url .= "&domain=".$this->domain;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$xml=simplexml_load_string($response); /* Convert XML tree */
$xml_response = $xml;
if ($debug) {
print "Debug - url: $url \n";
print_r($server);
print "----\n";
print_r($xml_response);
print "----\n";
print_r($xml);
print "====\n\n";
}
$status = $xml->status->attributes()->code;
if ($server->action == "common-info" && status) {
$this->cookie = (string)$xml_response->common->cookie;
}
if ($server->action == "login" && $status) {
$folder->action = "sco-shortcuts";
if ($this->request($folder) != "ok" ) {
return false;
}
$this->folders = array();
foreach ($xml_response->shortcuts->sco as $shortcut) {
$sco_id = (integer)$shortcut->attributes()->{'sco-id'};
$type = (string)$shortcut->attributes()->{'type'};
$this->folders[$type] = $sco_id;
}
}
$server->response = $xml_response;
return($status = "ok");
}
}
// ----------------------------------------------------------------------------
// Function: room_url
// Arguments:
// $link initialised instance of class Connect
// $sco_id sco_id of Adobe Connect meeting room
// Return: path to room or false if room cannot be found
//
// Find the path to a room with a specific sco_id
// ----------------------------------------------------------------------------
function room_url($link, $sco_id) {
$folder->action = "sco-nav";
$folder->{'sco-id'} = $sco_id;
if (!$link->request($folder)) return false;
$path = "";
foreach ($folder->response->{'sco-nav'}->sco as $subfolder) {
$path .= "/".$subfolder->name;
}
return $path;
}
?>