1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | namespace Aurora\Modules\Autodiscover; |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | class Module extends \Aurora\System\Module\AbstractModule |
18: | { |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | public function init() |
25: | { |
26: | $this->AddEntries( |
27: | array( |
28: | 'autodiscover' => 'EntryAutodiscover' |
29: | ) |
30: | ); |
31: | } |
32: | |
33: | public function GetAutodiscover($Email) |
34: | { |
35: | return ''; |
36: | } |
37: | |
38: | public function EntryAutodiscover() |
39: | { |
40: | $sInput = \file_get_contents('php://input'); |
41: | |
42: | \Aurora\System\Api::Log('#autodiscover:'); |
43: | \Aurora\System\Api::LogObject($sInput); |
44: | |
45: | $aMatches = array(); |
46: | $aEmailAddress = array(); |
47: | \preg_match("/\<AcceptableResponseSchema\>(.*?)\<\/AcceptableResponseSchema\>/i", $sInput, $aMatches); |
48: | \preg_match("/\<EMailAddress\>(.*?)\<\/EMailAddress\>/", $sInput, $aEmailAddress); |
49: | if (!empty($aMatches[1]) && !empty($aEmailAddress[1])) { |
50: | $sAutodiscover = $this->Decorator()->GetAutodiscover($aEmailAddress[1]); |
51: | |
52: | $sResult = \implode("\n", array( |
53: | '<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">', |
54: | ' <Response xmlns="'.$aMatches[1].'">', |
55: | $sAutodiscover, |
56: | ' </Response>', |
57: | '</Autodiscover>')); |
58: | } |
59: | |
60: | if (empty($sResult)) { |
61: | $usec = $sec = 0; |
62: | list($usec, $sec) = \explode(' ', \microtime()); |
63: | $sResult = \implode("\n", array('<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">', |
64: | ( |
65: | empty($aMatches[1]) ? |
66: | ' <Response>' : |
67: | ' <Response xmlns="'.$aMatches[1].'">' |
68: | ), |
69: | ' <Error Time="'.\gmdate('H:i:s', $sec).\substr($usec, 0, \strlen($usec) - 2).'" Id="2477272013">', |
70: | ' <ErrorCode>600</ErrorCode>', |
71: | ' <Message>Invalid Request</Message>', |
72: | ' <DebugData />', |
73: | ' </Error>', |
74: | ' </Response>', |
75: | '</Autodiscover>')); |
76: | } |
77: | |
78: | \header('Content-Type: text/xml'); |
79: | $sResult = '<'.'?xml version="1.0" encoding="utf-8"?'.'>'."\n".$sResult; |
80: | |
81: | echo $sResult; |
82: | |
83: | \Aurora\System\Api::Log(''); |
84: | \Aurora\System\Api::Log($sResult); |
85: | } |
86: | } |
87: | |