cvs: pear-core /PEAR2 Config.php

From: Date: Fri, 29 Dec 2006 18:46:56 +0000
Subject: cvs: pear-core /PEAR2 Config.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-5318@lists.php.net to get a copy of this message
cellog Fri Dec 29 18:46:56 2006 UTC Modified files: /pear-core/PEAR2 Config.php Log: it took forever to find, but here is a MUCH better way to retrieve the user PEAR configuration path on windows, it will go in My Documents/pear/ for the current user http://cvs.php.net/viewvc.cgi/pear-core/PEAR2/Config.php?r1=1.2&r2=1.3&diff_format=u Index: pear-core/PEAR2/Config.php diff -u pear-core/PEAR2/Config.php:1.2 pear-core/PEAR2/Config.php:1.3 --- pear-core/PEAR2/Config.php:1.2 Fri Dec 29 05:48:22 2006 +++ pear-core/PEAR2/Config.php Fri Dec 29 18:46:56 2006 @@ -141,16 +141,17 @@ private function _locateLocalSettingsDirectory() { if (class_exists('COM')) { - // windows - $locator = new COM('WbemScripting.SWbemLocator'); - $services = $locator->ConnectServer('', '\\root\\default'); - $services->Security_->ImpersonationLevel = 0x3; - $registry = $services->Get("StdRegProv"); - $appdata = new VARIANT; - $registry->GetStringValue(0x80000001, - 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders', - 'Local AppData', $appdata); - return strval($appdata); + // windows, grab current user My Documents folder + $info = new COM('winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2'); + $users = $info->ExecQuery("Select * From Win32_ComputerSystem"); + foreach ($users as $user) { + $d = explode('\\', $user->UserName); + $curuser = $d[1]; + } + $registry = new COM('Wscript.Shell'); + return $registry->RegRead( + 'HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\' . + 'Explorer\\DocFolderPaths\\' . $curuser); } else { return getenv('HOME'); }

« previous php.pear.core (#5318) next »