Newer
Older
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/**
* @package mod
* @subpackage adobeconnect
* @author Akinsaya Delamarre (adelamarre@remote-learner.net)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('connect_class.php');
class connect_class_dom extends connect_class {
public function __construct($serverurl = '', $serverport = '',
$username = '', $password = '',
$cookie = '', $https) {
parent::__construct($serverurl, $serverport, $username, $password, $cookie, $https);
}
public function create_request($params = array(), $sentrequest = true) {
if (empty($params)) {
return false;
}
$dom = new DOMDocument('1.0', 'UTF-8');
$root = $dom->createElement('params');
$dom->appendChild($root);
foreach($params as $key => $data) {
// DFNVC
// htmlentities() durch htmlspecialchars() ersetzt,
// damit auch Nutzer agelegt werden können, deren Namen
// Umlaute enthalten.
//
$datahtmlent = htmlspecialchars($data);
$child = $dom->createElement('param', $datahtmlent);
$root->appendChild($child);
$attribute = $dom->createAttribute('name');
$child->appendChild($attribute);
$text = $dom->createTextNode($key);
$attribute->appendChild($text);
}
$this->_xmlrequest = $dom->saveXML();
if ($sentrequest) {
$this->_xmlresponse = $this->send_request();
}
}
/**
* Parses through xml and looks for the 'cookie' parameter
* @param string $xml the xml to parse through
* @return string $sessoin returns the session id
*/
public function read_cookie_xml($xml = '') {
global $USER, $COURSE, $CFG;
if (empty($xml)) {
if (is_siteadmin($USER->id)) {
notice(get_string('adminemptyxml', 'adobeconnect'),
$CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
} else {
notice(get_string('emptyxml', 'adobeconnect'),
'', $COURSE);
}
}
$dom = new DomDocument();
$dom->loadXML($xml);
$domnodelist = $dom->getElementsByTagName('cookie');
if (isset($domnodelist->item(0)->nodeValue)) {
$this->_cookie = $domnodelist->item(0)->nodeValue;
} else {
$this->_cookie = null;
}
}
public function call_success() {
global $USER, $COURSE, $CFG;
if (empty($this->_xmlresponse)) {
if (is_siteadmin($USER->id)) {
notice(get_string('adminemptyxml', 'adobeconnect'),
$CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
} else {
notice(get_string('emptyxml', 'adobeconnect'),
'', $COURSE);
}
}
$dom = new DomDocument();
$dom->loadXML($this->_xmlresponse);
$domnodelist = $dom->getElementsByTagName('status');
if ($domnodelist->item(0)->hasAttributes()) {
$domnode = $domnodelist->item(0)->attributes->getNamedItem('code');
if (!is_null($domnode)) {
if (0 == strcmp('ok', $domnode->nodeValue)) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
private function create_http_head_login_xml() {
$params = array('action' => 'login',
'external-auth' => 'use',
);
$this->create_request($params, false);
}
public function user_session_cookie_old($username = '') {
global $CFG;
$header = array();
$params = array('action' => 'lms-user-login',
'login' => $username,
);
$this->create_request($params, true);
$data = $this->_xmlresponse;
$sessionval = false;
$sessionstart = strpos($data, 'BREEZESESSION=');
if (false !== $sessionstart) {
$sessionend = strpos($data, ';');
$sessionlength = strlen('BREEZESESSION=');
$sessionvallength = $sessionend - ($sessionstart + $sessionlength);
$sessionval = substr($data, $sessionstart+$sessionlength, $sessionvallength);
return $sessionval;
}
else {
return false;
}
}
public function user_session_cookie($username = '') {
global $CFG;
$header = array();
$params = array('action' => 'lms-user-login',
'login' => $username,
);
$this->create_request($params, true);
if ($this->call_success()) {
$xmldoc = new DomDocument();
$xmldoc->loadXML($this->_xmlresponse);
$xpath = new DomXpath($xmldoc);
$cookie = $xpath->query("//cookie")->item(0)->nodeValue;
return $cookie;
}
else {
return false;
}
}
}