Subversion Repositories HomeAutomation

Rev

Rev 1160 | Rev 1162 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1160 Rev 1161
Line 17... Line 17...
17
        break;
17
        break;
18
       
18
       
19
        //case "":
19
        //case "":
20
        //
20
        //
21
        //break;
21
        //break;
-
 
22
    }
22
}
23
}
23
 
24
 
24
function getMeetingsRestOfDay($shortname)
25
function getMeetingsRestOfDay($shortname)
25
{
26
{
26
    global $Calender;
27
    global $Calender;
Line 36... Line 37...
36
        }
37
        }
37
    }
38
    }
38
   
39
   
39
    if ($founditem !== false)
40
    if ($founditem !== false)
40
    {
41
    {
41
        $user = $founditem->UserName;
-
 
42
        $pass = $founditem->Password;
-
 
43
       
-
 
44
        $FindItem->Traversal = "Shallow";
42
        $FindItem->Traversal = "Shallow";
45
        $FindItem->ItemShape->BaseShape = "AllProperties";
43
        $FindItem->ItemShape->BaseShape = "AllProperties";
46
        $FindItem->ParentFolderIds->DistinguishedFolderId->Id = "calendar";
44
        $FindItem->ParentFolderIds->DistinguishedFolderId->Id = "calendar";
47
        $FindItem->CalendarView->StartDate = "2009-04-07T00:00:00Z";
45
        $FindItem->CalendarView->StartDate = "2009-04-07T00:00:00Z";
48
        $FindItem->CalendarView->EndDate = "2009-04-08T00:00:00Z";
46
        $FindItem->CalendarView->EndDate = "2009-04-08T00:00:00Z";
49
       
47
       
50
        stream_wrapper_unregister('https');
48
        stream_wrapper_unregister('https');
51
        stream_wrapper_register('https', 'NTLMStream') or die("Failed to register protocol");
49
        stream_wrapper_register('https', 'NTLMStream') or die("Failed to register protocol");
52
         
50
         
-
 
51
          $returndata = "";
53
        try
52
        try
54
        {
53
        {
55
            $client = new NTLMSoapClient($wsdl);
54
            $client = new ExchangeNTLMSoapClient($wsdl);
-
 
55
            $client->user = $founditem->UserName;
-
 
56
            $client->pass = $founditem->Password;
56
            $result = $client->FindItem($FindItem);
57
            $result = $client->FindItem($FindItem);
57
            if ($result)
58
            if ($result)
58
            {
59
            {
59
              //print_array($result);
60
              //print_array($result);
60
              $calendaritems = $result->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem;
61
              $calendaritems = $result->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem;
61
              //print_array($calendaritems);
62
              //print_array($calendaritems);
-
 
63
              $returndata = "";
62
              foreach($calendaritems as $item)
64
              foreach($calendaritems as $item)
-
 
65
              {
63
              {
66
               
-
 
67
                $returndata .= "<meeting>\n";
64
                return "Organizer: ".$item->Organizer->Mailbox->Name." Start: ".$item->Start." End: ".$item->End."<br>";
68
                $returndata .= "\t<organizer>".$item->Organizer->Mailbox->Name."</organizer>\n";
-
 
69
                $returndata .= "\t<start>".date("G:s",strtotime($item->Start))." ".$item->Start."</start>\n";
-
 
70
                $returndata .= "\t<end>".date("G:s",strtotime($item->End))." ".$item->End."</end>\n";
-
 
71
                $returndata .= "</meeting>\n";
65
              }
72
              }
66
            }
73
            }
67
           
74
           
68
        }
75
        }
69
        catch (SoapFault $exception)
76
        catch (SoapFault $exception)
70
        {
77
        {
71
            return "<error>".$exception."</error>";
78
            return "<error>".$exception."</error>";
72
        }
79
        }
73
 
80
 
74
        stream_wrapper_restore('https');
81
        stream_wrapper_restore('https');
-
 
82
          return $returndata;
75
    }
83
    }
76
    else
84
    else
77
    {
85
    {
78
        return "<error>Unknown shortname</error>";
86
        return "<error>Unknown shortname</error>";
79
    }
87
    }
Line 91... Line 99...
91
}
99
}
92
 
100
 
93
class NTLMSoapClient extends SoapClient {
101
class NTLMSoapClient extends SoapClient {
94
  function __doRequest($request, $location, $action, $version)
102
  function __doRequest($request, $location, $action, $version)
95
  {
103
  {
96
    global $user;
-
 
97
    global $pass;
-
 
98
    global $exchangeurl;
104
    global $exchangeurl;
99
    $location=$exchangeurl; //override url to exchange server
105
    $location=$exchangeurl; //override url to exchange server
100
 
106
 
101
    $headers = array( 'Method: POST',
107
    $headers = array( 'Method: POST',
102
            'Connection: Keep-Alive',
108
            'Connection: Keep-Alive',
Line 112... Line 118...
112
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
118
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
113
    curl_setopt($ch, CURLOPT_POST, true );
119
    curl_setopt($ch, CURLOPT_POST, true );
114
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
120
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
115
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
121
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
116
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
122
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
117
    curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$pass);
123
    curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->pass);
118
    $response = curl_exec($ch);
124
    $response = curl_exec($ch);
119
 
125
 
120
//$myfile = "/tmp/debugex.txt";
126
/*$myfile = "/tmp/debugex.txt";
121
//$fh = fopen($myfile, 'a+') or die("can't open file");
127
$fh = fopen($myfile, 'w+') or die("can't open file");
-
 
128
fwrite($fh, "user: ". $this->user. " pass: ".$this->pass."\n");
122
//fwrite($fh, "req: ". $request ."loc: ". $location ." act: ". $action ." ver: ". $version."\n");
129
fwrite($fh, "req: ". $request ."loc: ". $location ." act: ". $action ." ver: ". $version."\n");
123
//fwrite($fh, "reponse: ". $response."\n\n");
130
fwrite($fh, "reponse: ". $response."\n\n");
124
//fclose($fh);
131
fclose($fh);
-
 
132
*/
125
   
133
   
126
    return $response;
134
    return $response;
127
  }
135
  }
128
 
136
 
129
  function __getLastRequestHeaders()
137
  function __getLastRequestHeaders()
130
  {
138
  {
131
    return implode("\n", $this->__last_request_headers)."\n";
139
    return implode("\n", $this->__last_request_headers)."\n";
132
  }
140
  }
133
}
141
}
134
 
142
 
-
 
143
class ExchangeNTLMSoapClient extends NTLMSoapClient
-
 
144
{
-
 
145
    public $user = '';
-
 
146
    public $password = '';
-
 
147
}
135
 
148
 
136
class NTLMStream
149
class NTLMStream
137
{
150
{
138
  private $path;
151
  private $path;
139
  private $mode;
152
  private $mode;