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