1 |
<?php |
2 |
|
3 |
// You need to do following: |
4 |
// (1) At PHP.ini you need to make following changes: |
5 |
// extension_dir = "ext" |
6 |
// extension=com_dotnet |
7 |
// (2) Run following commands as administrator: |
8 |
// regsvr32 ViaThinkSoftSimpleLogEvent32.dll (if you run 32 bit PHP) |
9 |
// regsvr32 ViaThinkSoftSimpleLogEvent64.dll (if you run 64 bit PHP) |
10 |
// (You can also run both) |
11 |
|
12 |
define('CLASS_ViaThinkSoftSimpleEventLog', '{E4270053-A217-498C-B395-9EF33187E8C2}'); |
13 |
|
14 |
define('LOGEVENT_MSG_SUCCESS', 0); |
15 |
define('LOGEVENT_MSG_INFORMATIONAL', 1); |
16 |
define('LOGEVENT_MSG_WARNING', 2); |
17 |
define('LOGEVENT_MSG_ERROR', 3); |
18 |
|
19 |
if (!class_exists('COM')) { |
20 |
die('To use ViaThinkSoftSimpleEventLog, please enable the lines "extension=com_dotnet" and "extension_dir=ext" in your PHP.ini file'); |
21 |
} |
22 |
|
23 |
try { |
24 |
$x = new COM(CLASS_ViaThinkSoftSimpleEventLog); |
25 |
} catch (Exception $e) { |
26 |
die('Error calling object ViaThinkSoftSimpleEventLog. Was the DLL file registered correctly? (Error: '.$e->getMessage().')'); |
27 |
} |
28 |
|
29 |
if (PHP_INT_SIZE == 8) { |
30 |
$x->LogEvent('MySourceName', LOGEVENT_MSG_WARNING, 'This is a test warning written by 64 bit PHP'); |
31 |
} else if (PHP_INT_SIZE == 4) { |
32 |
$x->LogEvent('MySourceName', LOGEVENT_MSG_WARNING, 'This is a test warning written by 32 bit PHP'); |
33 |
} else { |
34 |
// Should never happen! |
35 |
$x->LogEvent('MySourceName', LOGEVENT_MSG_WARNING, 'This is a test warning written by whatever-bit PHP'); |
36 |
} |