Back to index

php5  5.3.10
registersyslog.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /* This script sets up an event source for use by the php syslog() function. */
00004 
00005 if (!extension_loaded("win32std")) {
00006        @dl("php_win32std.dll");
00007 }
00008 
00009 $PATH = "SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\PHP-" . phpversion();
00010 
00011 $dll = $argv[1];
00012 
00013 if (extension_loaded("win32std")) {
00014        $key = @reg_create_key(HKEY_LOCAL_MACHINE, $PATH, KEY_ALL_ACCESS);
00015 
00016        if (!$key)
00017               $key = reg_open_key(HKEY_LOCAL_MACHINE, $PATH, KEY_ALL_ACCESS);
00018 
00019        if ($key) {
00020               reg_set_value($key, "TypesSupported", REG_DWORD, 7) or die("Types");
00021               reg_set_value($key, "EventMessageFile", REG_SZ, $dll) or die("EventMessageFile");
00022 
00023               syslog(LOG_NOTICE, "Registered PHP Event source");
00024        } else {
00025               echo "Could not register event source\n";
00026        }
00027 }
00028 
00029 /* let's also generate/update the bundled .reg file */
00030 
00031 $dll = addslashes($dll);
00032 
00033 file_put_contents("win32/syslog.reg", <<<REG
00034 REGEDIT4
00035 
00036 [HKEY_LOCAL_MACHINE\\$PATH]
00037 "TypesSupported"=dword:00000007
00038 "EventMessageFile"="$dll"
00039 
00040 REG
00041 );
00042 
00043 
00044 ?>