Re: [PHP] Reading registry values

2007-08-07 Thread Richard Lynch
On Tue, July 31, 2007 4:54 pm, \"Crash\" Dummy wrote:
> To answer everyone's curiosity as to why I want to access the
> registry, I am
> working on my home computer with a dynamic IP, and I need to know what
> it is so
> I can modify my httpd.conf (or hosts) file, if necessary.

LOL

Take a look at whats in $_SERVER:



Your IP address is almost for sure in $_SERVER['HOST_ADDR']

That is filled in by the web-server, and should reflect your actual
current IP address.

If you have a NAT-ing router in between, then, no, it won't be your
"public" IP...  At that point, I'd almost suggest bypassing the
Registry and COM flakiness and see if something like this works:
http://l-i-e.com/ip.htm
http://l-i-e.com/ip.phps

ymmv, but I'd much rather trust an external server than some goofy
Windows registry setting... :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading registry values

2007-08-01 Thread \"Crash\" Dummy
> You might use http://www.php.net/reserved.variables "SERVER_ADDR"
> to get the address of the host you are running under if you wanted
to
> access it from PHP only.

Ah, but there is a catch. If you looked at my snapshot, you saw that
there are two addresses, and the server address will not necessarily
be the same as the internet address assigned by the DHCP server. In
fact, it most likely won't be.

In order to get the internet address from the server, I have to know
what it is already so I can set the server to use it. Catch 22. :-)
-- 
Crash
Please reply to the group. E-mail is blocked.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading registry values

2007-08-01 Thread Travis D
On 7/31/07, Crash Dummy <[EMAIL PROTECTED]> wrote:
>
> > Hope this isn't overkill but it is a module (read "COM", or "VBA
> module")
> > to manipulate the registry:
>
> "Overkill" is a massive understatement. :-)



No doubt.

To answer everyone's curiosity as to why I want to access the registry, I am
> working on my home computer with a dynamic IP, and I need to know what it
> is so
> I can modify my httpd.conf (or hosts) file, if necessary.


You might use http://www.php.net/reserved.variables "SERVER_ADDR" to get the
address of the host you are running under if you wanted to access it from
PHP only.

Travis Doherty


Re: [PHP] Reading registry values

2007-07-31 Thread \"Crash\" Dummy
> Hope this isn't overkill but it is a module (read "COM", or "VBA module")
> to manipulate the registry:

"Overkill" is a massive understatement. :-)

As noted elsewhere in this thread, I got what I wanted by using the PHP "exec"
command to execute a VB script, which has all the registry access I need. Much
simpler than compiling and installing a COM object module. :-)

To answer everyone's curiosity as to why I want to access the registry, I am
working on my home computer with a dynamic IP, and I need to know what it is so
I can modify my httpd.conf (or hosts) file, if necessary. The ASP page I am
converting is my browser home page, which has lots of useful stuff I obtain with
server side scripts. Here is a snapshot (no, this isn't my home server).
http://crash.thedatalist.com/temp/home16m.png

I am currently running both servers (Apache and IIS), but I'd like to use a
universal scripting format.
-- 
Crash
Please reply to the group. E-mail is blocked.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading registry values

2007-07-31 Thread John A DAVIS


Hope this isn't overkill but it is a module (read "COM", or "VBA module") to manipulate the registry:
 
Option Compare DatabaseOption Explicit
 
'' Created by E.Spencer - This code is public domain.''Security Mask constantsPublic Const READ_CONTROL = &H2Public Const SYNCHRONIZE = &H10Public Const STANDARD_RIGHTS_ALL = &H1FPublic Const STANDARD_RIGHTS_READ = READ_CONTROLPublic Const STANDARD_RIGHTS_WRITE = READ_CONTROLPublic Const KEY_QUERY_VALUE = &H1Public Const KEY_SET_VALUE = &H2Public Const KEY_CREATE_SUB_KEY = &H4Public Const KEY_ENUMERATE_SUB_KEYS = &H8Public Const KEY_NOTIFY = &H10Public Const KEY_CREATE_LINK = &H20Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or _   KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or _   KEY_CREATE_LINK) And (Not SYNCHRONIZE))Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or _   KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))Public Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE _   Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))' Possible registry data typesPublic Enum InTypes   ValNull = 0   ValString = 1   ValXString = 2   ValBinary = 3   ValDWord = 4   ValLink = 6   ValMultiString = 7   ValResList = 8End Enum' Registry value type definitionsPublic Const REG_NONE As Long = 0Public Const REG_SZ As Long = 1Public Const REG_EXPAND_SZ As Long = 2Public Const REG_BINARY As Long = 3Public Const REG_DWORD As Long = 4Public Const REG_LINK As Long = 6Public Const REG_MULTI_SZ As Long = 7Public Const REG_RESOURCE_LIST As Long = 8' Registry section definitionsPublic Const HKEY_CLASSES_ROOT = &H8000Public Const HKEY_CURRENT_USER = &H8001Public Const HKEY_LOCAL_MACHINE = &H8002Public Const HKEY_USERS = &H8003Public Const HKEY_PERFORMANCE_DATA = &H8004Public Const HKEY_CURRENT_CONFIG = &H8005Public Const HKEY_DYN_DATA = &H8006' Codes returned by Reg API callsPrivate Const ERROR_NONE = 0Private Const ERROR_BADDB = 1Private Const ERROR_BADKEY = 2Private Const ERROR_CANTOPEN = 3Private Const ERROR_CANTREAD = 4Private Const ERROR_CANTWRITE = 5Private Const ERROR_OUTOFMEMORY = 6Private Const ERROR_INVALID_PARAMETER = 7Private Const ERROR_ACCESS_DENIED = 8Private Const ERROR_INVALID_PARAMETERS = 87Private Const ERROR_NO_MORE_ITEMS = 259' Registry API functions used in this module (there are more of them)Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As LongPrivate Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As LongPrivate Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As LongPrivate Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As LongPrivate Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As LongPrivate Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As LongPrivate Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As LongPrivate Declare Function RegFlushKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As LongPrivate Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As LongPrivate Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
 
Public Sub Main()On Error GoTo BYEWriteRegistry HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\", "DisableTaskMgr", ValDWord, "0"BYE:End Sub
 
' This routine allows you to get values from anywhere in the Registry, it currently' only handles string, double word and binary values. Binary values are returned as' hex strings. Example'' Text1.Text = ReadRegistry(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\Curr

Re: Re[2]: [PHP] Reading registry values

2007-07-31 Thread John A DAVIS


2 simple VBA/VB functions that write to specific place in the registry. Here is my library of code on this:
 
GetSetting(App.EXEName, "Properties", strPropertyName)
SaveSetting(App.EXEName, "Properties", strPropertyName, Trim(CStr(varValue)))
Specific place:
HKEY_CURRENT_USER\Software\VB and VBA Program Settings
 
If you issue a GetSetting when none exists, it simply returns an empty string. If you issue a SaveSetting where no entry exists, it simply creates the entry and places the value in the entry. Essentially , these have built in error handling.
 
 
>>> "Richard Davey" <[EMAIL PROTECTED]> 7/30/2007 11:49 AM >>>
Hi,Monday, July 30, 2007, 7:40:52 PM, you wrote:> I'm not sure that there's actually anything you'd need to access in> the server registry (and certainly no registry in Linux if you're> also transitioning from Windows to Linux). And depending on what the> ActiveX control your ASP pages accessed actually does, it may be> better to recreate it in PHP instead of trying to access ActiveX via> PHP.I've seen ASP components that required access to the registry in orderto validate they were legal. I.e. the installer of the component wrotesome serial number or something to the registry, which the ASP scriptschecked.Nasty, but true. Just saying that he may well have a genuine need forit.Cheers,Rich-- Zend Certified Engineerhttp://www.corephp.co.uk"Never trust a computer you can't throw out of a window"-- PHP General Mailing List (http://www.php.net/)To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Reading registry values

2007-07-30 Thread Richard Lynch
On Mon, July 30, 2007 1:32 pm, Jay Blanchard wrote:
> [snip]
> I want to convert some ASP pages to PHP to go along with a transition
> from IIS
> to Apache. One of the ASP script functions involves reading data from
> the
> Windows registry. How does one read from the registry with PHP?
> [/snip]
>
> PHP is server-side and cannot read client side info. You would need to
> use something client-side, like JavaScript. JavaScript cannot read the
> registry either. It's a security thing.

I'm pretty sure the original ASP script was reading the SERVER
registry...

Even ASP isn't *that* insecure!

:-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re[2]: [PHP] Reading registry values

2007-07-30 Thread \"Crash\" Dummy
> I can't think of anything that a PHP app is going to need access to
> the registry for, so I'm trying to verify that there actually is a need
> for him to access the registry and/or use ActiveX via PHP.  I'm
> guessing that he doesn't need to at all.

I don't _need_ it for anything in the scripts or the server. I _want_ to read
some stuff from the registry for my own purposes. The registry datum is not a
means to an end, it is the end in itself. As for why I need or want to use an
ActiveX control, I am simply going by my past experience with VBScript, which
has only rudimentary registry access methods.

Now I'll go read up on the COM object and see if it solves my problems.
-- 
Crash

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re[2]: [PHP] Reading registry values

2007-07-30 Thread tg-php
Yeah, that could be one thing that the ASP/ActiveX combo need to access the 
registry for..  but if he's replacing ASP with PHP and if the ActiveX control 
doesn't do anything he can't re-create in PHP, then there's no need to verify 
that anything relating to ASP or ActiveX is registered and genuine because it 
would have been replaced with a PHP alternative.

I can't think of anything that a PHP app is going to need access to the 
registry for, so I'm trying to verify that there actually is a need for him to 
access the registry and/or use ActiveX via PHP.  I'm guessing that he doesn't 
need to at all.

-TG

= = = Original message = = =

Hi,

Monday, July 30, 2007, 7:40:52 PM, you wrote:

> I'm not sure that there's actually anything you'd need to access in
> the server registry (and certainly no registry in Linux if you're
> also transitioning from Windows to Linux). And depending on what the
> ActiveX control your ASP pages accessed actually does, it may be
> better to recreate it in PHP instead of trying to access ActiveX via
> PHP.

I've seen ASP components that required access to the registry in order
to validate they were legal. I.e. the installer of the component wrote
some serial number or something to the registry, which the ASP scripts
checked.

Nasty, but true. Just saying that he may well have a genuine need for
it.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading registry values

2007-07-30 Thread Andrew Ballard
I'm assuming you are intending to read the web server registry for
configuration purposes, not the client's registry. Look at the section
on COM in the manual.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] Reading registry values

2007-07-30 Thread Richard Davey
Hi,

Monday, July 30, 2007, 7:40:52 PM, you wrote:

> I'm not sure that there's actually anything you'd need to access in
> the server registry (and certainly no registry in Linux if you're
> also transitioning from Windows to Linux). And depending on what the
> ActiveX control your ASP pages accessed actually does, it may be
> better to recreate it in PHP instead of trying to access ActiveX via
> PHP.

I've seen ASP components that required access to the registry in order
to validate they were legal. I.e. the installer of the component wrote
some serial number or something to the registry, which the ASP scripts
checked.

Nasty, but true. Just saying that he may well have a genuine need for
it.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading registry values

2007-07-30 Thread \"Crash\" Dummy
> "Crash": The COM extension (http://php.net/com) should let you do that
> in essentially the same way ASP does.

Thank you. More stuff to confuse me! :-)
-- 
Crash

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading registry values

2007-07-30 Thread \"Crash\" Dummy
> PHP is server-side and cannot read client side info. You would need to
> use something client-side, like JavaScript. JavaScript cannot read the
> registry either. It's a security thing.

ASP is also server side and the registry I want to read is on the server
platform. I am not trying to read the client's registry.
-- 
Crash

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading registry values

2007-07-30 Thread tg-php
I'm not sure that there's actually anything you'd need to access in the server 
registry (and certainly no registry in Linux if you're also transitioning from 
Windows to Linux).   And depending on what the ActiveX control your ASP pages 
accessed actually does, it may be better to recreate it in PHP instead of 
trying to access ActiveX via PHP.

What, exactly, is being pulled from the registry and if the ActiveX control 
does more than just facilitate registry access, what else does it do that you'd 
need to emulate?

I have a feeeling that you don't need to worry about these things after you 
transition to PHP and Apache.

More info please? :)

-TG


= = = Original message = = =

I want to convert some ASP pages to PHP to go along with a transition from IIS
to Apache. One of the ASP script functions involves reading data from the
Windows registry. How does one read from the registry with PHP?

Also, is it possible to use ActiveX objects with PHP? The above mentioned script
uses a third party control to facilitate the registry operations. The VBScript
code looks like this:

Set objRegistry = CreateObject("RegObj.Registry")

Is there a PHP equivalent?

This newbie thanks you.
-- 
Crash


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading registry values

2007-07-30 Thread Stut

Jay Blanchard wrote:

[snip]
I want to convert some ASP pages to PHP to go along with a transition
from IIS
to Apache. One of the ASP script functions involves reading data from
the
Windows registry. How does one read from the registry with PHP?
[/snip]

PHP is server-side and cannot read client side info. You would need to
use something client-side, like JavaScript. JavaScript cannot read the
registry either. It's a security thing.


I think you'll find the OP means on the server-side, which is kinda 
obvious when you consider the fact the OP already has an ASP app that 
does this.


"Crash": The COM extension (http://php.net/com) should let you do that 
in essentially the same way ASP does.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Reading registry values

2007-07-30 Thread Jay Blanchard
[snip]
I want to convert some ASP pages to PHP to go along with a transition
from IIS
to Apache. One of the ASP script functions involves reading data from
the
Windows registry. How does one read from the registry with PHP?
[/snip]

PHP is server-side and cannot read client side info. You would need to
use something client-side, like JavaScript. JavaScript cannot read the
registry either. It's a security thing.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Reading registry values

2007-07-30 Thread \"Crash\" Dummy
I want to convert some ASP pages to PHP to go along with a transition from IIS
to Apache. One of the ASP script functions involves reading data from the
Windows registry. How does one read from the registry with PHP?

Also, is it possible to use ActiveX objects with PHP? The above mentioned script
uses a third party control to facilitate the registry operations. The VBScript
code looks like this:

Set objRegistry = CreateObject("RegObj.Registry")

Is there a PHP equivalent?

This newbie thanks you.
-- 
Crash

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reading Registry

2003-01-09 Thread Kansu Dinçer
Hi,

CD> Hello all.  I don't think this is possible, but I wanted to ask to be
CD> sure.  Is it possible to read and write to a web user's registry with
CD> php?  I believe this can be done with CF and ASP, but I was not sure
CD> about PHP.  A search turned up nothing usefull.

I don't think so.. Clientside is client's business...

-- 
Regards,
 Kansumailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Reading Registry

2003-01-09 Thread Christopher Ditty
Hello all.  I don't think this is possible, but I wanted to ask to be
sure.  Is it possible to read and write to a web user's registry with
php?  I believe this can be done with CF and ASP, but I was not sure
about PHP.  A search turned up nothing usefull.

Thanks

CDitty


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php