Rev 1000 | Rev 1086 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1000 | Rev 1050 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | * See the License for the specific language governing permissions and |
16 | * See the License for the specific language governing permissions and |
17 | * limitations under the License. |
17 | * limitations under the License. |
18 | */ |
18 | */ |
19 | 19 | ||
20 | if (!defined('INSIDE_OIDPLUS')) die(); |
20 | namespace ViaThinkSoft\OIDplus; |
21 | 21 | ||
22 | class OIDplusLoggerPluginWindowsEventLog extends OIDplusLoggerPlugin { |
22 | class OIDplusLoggerPluginWindowsEventLog extends OIDplusLoggerPlugin { |
23 | 23 | ||
24 | const CLASS_ViaThinkSoftSimpleEventLog = '{E4270053-A217-498C-B395-9EF33187E8C2}'; |
24 | const CLASS_ViaThinkSoftSimpleEventLog = '{E4270053-A217-498C-B395-9EF33187E8C2}'; |
25 | 25 | ||
Line 40... | Line 40... | ||
40 | $reason = _L('To use %1, please enable the lines "extension=%2" and "extension_dir=ext" in your PHP.ini file.','ViaThinkSoftSimpleEventLog','com_dotnet'); |
40 | $reason = _L('To use %1, please enable the lines "extension=%2" and "extension_dir=ext" in your PHP.ini file.','ViaThinkSoftSimpleEventLog','com_dotnet'); |
41 | return false; |
41 | return false; |
42 | } |
42 | } |
43 | 43 | ||
44 | try { |
44 | try { |
45 | $x = new COM(self::CLASS_ViaThinkSoftSimpleEventLog); |
45 | $x = new \COM(self::CLASS_ViaThinkSoftSimpleEventLog); |
46 | $reason = '?'; // LogSimulate() must actively clear it if everything is OK |
46 | $reason = '?'; // LogSimulate() must actively clear it if everything is OK |
47 | $x->LogSimulate(self::LOGPROVIDER, self::LOGEVENT_MSG_SUCCESS, 'TEST', $reason);/** @phpstan-ignore-line */ |
47 | $x->LogSimulate(self::LOGPROVIDER, self::LOGEVENT_MSG_SUCCESS, 'TEST', $reason);/** @phpstan-ignore-line */ |
48 | return $reason != ''; |
48 | return $reason != ''; |
49 | } catch (Exception $e) { |
49 | } catch (\Exception $e) { |
50 | $reason = $e->getMessage(); |
50 | $reason = $e->getMessage(); |
51 | return false; |
51 | return false; |
52 | } |
52 | } |
53 | } |
53 | } |
54 | 54 | ||
Line 79... | Line 79... | ||
79 | if (!class_exists('COM')) { |
79 | if (!class_exists('COM')) { |
80 | return false; |
80 | return false; |
81 | } |
81 | } |
82 | 82 | ||
83 | try { |
83 | try { |
84 | $x = new COM(self::CLASS_ViaThinkSoftSimpleEventLog); |
84 | $x = new \COM(self::CLASS_ViaThinkSoftSimpleEventLog); |
85 | 85 | ||
86 | $admin_severity = 0; |
86 | $admin_severity = 0; |
87 | foreach ($users as list($severity, $username)) { |
87 | foreach ($users as list($severity, $username)) { |
88 | // Since the Windows Event Log is mostly for admins, we use the severity an admin would expect |
88 | // Since the Windows Event Log is mostly for admins, we use the severity an admin would expect |
89 | if ($username == 'admin') $admin_severity = $severity; |
89 | if ($username == 'admin') $admin_severity = $severity; |
90 | } |
90 | } |
91 | 91 | ||
92 | $x->LogEvent(self::LOGPROVIDER, self::convertOIDplusToWindowsSeverity($admin_severity), $event);/** @phpstan-ignore-line */ |
92 | $x->LogEvent(self::LOGPROVIDER, self::convertOIDplusToWindowsSeverity($admin_severity), $event);/** @phpstan-ignore-line */ |
93 | 93 | ||
94 | return true; |
94 | return true; |
95 | } catch (Exception $e) { |
95 | } catch (\Exception $e) { |
96 | return false; |
96 | return false; |
97 | } |
97 | } |
98 | 98 | ||
99 | } |
99 | } |
100 | 100 |