Skip to content

Commit 6f617b7

Browse files
committed
Revert "Remove Windows syslog script and syslog.reg"
This reverts commit cc44bad, since its assumptions were not correct. Actually, the classic event logging is still used by PHP, because Windows 7 is still to be supported for a while. Without the respective registry entries, the event log entries show an error message regarding missing ID descriptions. Thanks to [email protected] for hinting at this! Obviously, the part depending on ext/win32std has still to be overhauled, and further improvements are conceivable; we will address this in due course.
1 parent 56a2ea7 commit 6f617b7

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

win32/build/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,6 @@ really-install:
261261
@type nul > $(BUILD_DIR)\extension_dlls.txt
262262
@if exist $(BUILD_DIR)\php_*.dll copy $(BUILD_DIR)\php_*.dll $(PHP_PREFIX)\ext /y >nul & dir /b $(BUILD_DIR)\php_*.dll > $(BUILD_DIR)\extension_dlls.txt
263263
@xcopy $(BUILD_DIR)\*.dll /exclude:$(BUILD_DIR)\extension_dlls.txt $(PHP_PREFIX) /y >nul
264+
@echo Registering event source with syslog (requires admin rights)
265+
@echo It's okay for this step to fail:
266+
-$(PHP_PREFIX)\php.exe -n -dextension_dir=$(PHP_PREFIX) win32/build/registersyslog.php $(PHP_PREFIX)\$(PHPDLL)

win32/build/registersyslog.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/* This script sets up an event source for use by the php syslog() function. */
4+
5+
if (!extension_loaded("win32std")) {
6+
@dl("php_win32std.dll");
7+
}
8+
9+
$PATH = "SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\PHP-" . phpversion();
10+
11+
$dll = $argv[1];
12+
13+
if (extension_loaded("win32std")) {
14+
$key = @reg_create_key(HKEY_LOCAL_MACHINE, $PATH, KEY_ALL_ACCESS);
15+
16+
if (!$key)
17+
$key = reg_open_key(HKEY_LOCAL_MACHINE, $PATH, KEY_ALL_ACCESS);
18+
19+
if ($key) {
20+
reg_set_value($key, "TypesSupported", REG_DWORD, 7) or die("Types");
21+
reg_set_value($key, "EventMessageFile", REG_SZ, $dll) or die("EventMessageFile");
22+
23+
syslog(LOG_NOTICE, "Registered PHP Event source");
24+
} else {
25+
echo "Could not register event source\n";
26+
}
27+
}
28+
29+
/* let's also generate/update the bundled .reg file */
30+
31+
$dll = addslashes($dll);
32+
33+
file_put_contents("win32/syslog.reg", <<<REG
34+
REGEDIT4
35+
36+
[HKEY_LOCAL_MACHINE\\$PATH]
37+
"TypesSupported"=dword:00000007
38+
"EventMessageFile"="$dll"
39+
40+
REG
41+
);
42+
43+
44+
?>

win32/syslog.reg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
REGEDIT4
2+
3+
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\PHP-7.3.0-dev]
4+
"TypesSupported"=dword:00000007
5+
"EventMessageFile"="g:\\test\\srctrunkinstall\\php7ts.dll"

0 commit comments

Comments
 (0)