changed git call from https to git readonly
[atutor.git] / mods / adobe_connect / lib / ACConnection.php
1 <?php
2
3 require_once('lib/lib.php');
4
5 class ACConnection {
6
7
8     var $adobe_connect_host;
9     var $adobe_connect_port;
10     var $adobe_connect_adminuser;
11     var $adobe_connect_adminpass;
12     var $adobe_connect_folderid;
13
14
15     public function __construct() {
16
17         $cfg = getAdobeConnectConfig();
18
19         foreach ($cfg as $attribute => $v) {
20             $this->$attribute = $cfg->$attribute;
21         }
22
23     }
24
25
26     public function getACHost() {
27         return $this->adobe_connect_host;
28     }
29
30
31     public function getACPort() {
32         return $this->adobe_connect_port;
33     }
34
35
36     public function getAdminSession() {
37
38         $fp = @fsockopen($this->adobe_connect_host, $this->adobe_connect_port);
39         if (!$fp) {
40             return false;
41         }
42   
43         $url = '/api/xml?action=login&external-auth=use';
44
45         fputs($fp, "GET ".$url." HTTP/1.0\r\n".$this->adobe_connect_adminpass.":".$this->adobe_connect_adminuser."\r\nHost: ".$this->adobe_connect_host."\r\n\r\n");
46
47         while ($line = fgets($fp)) {
48             if (strstr($line, "code=\"ok\"")) {
49                 $response = 1;
50                 break;
51             }
52
53             if (preg_match('/BREEZESESSION=(.*)\;/', $line, $result)) {
54                 $session = explode(';', $result[1]);
55                 $sessionid = $session[0];
56             }
57         }
58         fclose($fp);
59
60         if (empty($response)) {
61             return false;
62         }
63
64         return $sessionid;
65     }
66
67
68     public function checkResponse($socket, $source) {
69
70         while ($line = fgets($socket)) {
71             if (strstr($line, "code=\"ok\"")) {
72                 return true;
73             }
74         }
75
76         return false;
77     }
78
79
80 }
81
82 ?>