php-windows Digest 13 Sep 2006 06:24:49 -0000 Issue 3036

Topics (messages 27140 through 27145):

Re: [Linux dev] Undefined variables
        27140 by: Alex Turner
        27142 by: Stut

Re: Problem with execution external script
        27141 by: Alex Turner
        27143 by: Stut
        27144 by: DevPhp

Problems accessing the net units through PHP
        27145 by: German Piqué

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Alf Stockton wrote:
Hendrik Visage wrote:
On 9/8/06, Alf Stockton <[EMAIL PROTECTED]> wrote:
In this little script:-

<?php
session_start();
//read folder
$folder=opendir(".");
while ($file = readdir($folder))
$names[count($names)] = $file;  // <----- Line 8
Obviously $names won't be defined in the initial state the first time
this line
is hit, thus count($names) would/should be undefined...

Interesting that this works on versions of Windows PHP previous to 5.1.6

Maybe undefined has a meaningful count value in previous versions?

Anyhow - using variable before they are defined is kind of bad. We try to avoid it. In the above case TPN coding practice would have been to put a line:

$names=array();

before the loop.  This makes everything very explicit and stable.

Cheers

AJ

--
www.deployview.com
www.nerds-central.com
www.project-network.com

--- End Message ---
--- Begin Message ---
Please reply to the list not just directly to me.

Alf Stockton wrote:
> Stut wrote:
>> ......snip......
> 
>>    // Really not sure why this is here
>>    --$Count;
>>    //        echo 'Count = '.$Count.'  $tempvar = '.$tempvar;
>>
> .....snip.....
> Part of the backwards iteration. In other words I was using the array
> from the back to the front rather than from 0 through end.
> Thank you for your input and code.
> I do find it interesting that the program I had worked fine on versions
> of Windows PHP previous to 5.1.6.

The script you had was working, but it was throwing out notices. Notices
are a level of message below warnings that indicate that you're doing
something that can lead to bugs but that PHP can cope with. They can be
disabled and are on a shocking number of PHP installations I come across.

When you say it "worked fine" it's probably because the PHP
configuration had notices disabled. This is bad m'kay. With notices
enabled you may end up writing a bit more code, but you also get told
when you do things like mis-type variable names and the like.

Look in the PHP manual for the error_reporting php.ini setting. The
knowledge you seek will be found there.

-Stut

--- End Message ---
--- Begin Message ---
DevPhp wrote:
Hallo,
thanks for reply.

Also - why double launch?  Why not launch csript directly?

I've tried to launch Cscript directly...but it didn't work,
So I try to launch it in an alternative way, to bypass the permission problem.
It's not necessary double launch....

I guess that your server is running as a user with reduced permissions and thus cannot access the exec.

How can I see which user is? I've full permission for IUSR, IWAM and SYSTEM users on php directory, on root directory and also on system32 directory...in IIS I've read permission and allow execution for script and executables...but it doesn't still work....
Am I doing something wrong?

I'm still trying to find a solutions...

Please can you help me?
Thanks
Dood,

Don't try and do anything with web devel on  windows without:

http://www.sysinternals.com/Utilities/ProcessExplorer.html

It is a 100% must!

Double click on any process and it will tell you everything you want to know about it :-)

AJ

--
www.deployview.com
www.nerds-central.com
www.project-network.com

--- End Message ---
--- Begin Message ---
DevPhp wrote:
> How can I see which user is? I've full permission for IUSR, IWAM and SYSTEM 
> users on php directory,
> on root directory and also on system32 directory...in IIS I've read 
> permission and allow execution for script and executables...but it doesn't 
> still work....
> Am I doing something wrong?
> 
> I'm still trying to find a solutions...

PHP scripts usually run as the IUSR user.

Just to clarify... you're trying to run the IIS administration script
from an unprivileged user and you think that changing the file
permissions on the script are all that's required "to bypass the
permission problem". Thank $DEITY that it's not quite that easy.

The script you are attempting to run requires the user to have
Administrator privileges. While you can give the IUSR user the required
level of access you really need to think carefully about this. Giving
Administrator privileges to the user that any externally accessible
service runs as is generally a very very bad idea.

What exactly are you trying to achieve? Can you have the PHP queue up
descriptions of the operations needed and then have an AT script
actually execute them with the required privileges. Note that I said
"descriptions of operations" - queuing command lines does nothing to
make it more secure.

-Stut

--- End Message ---
--- Begin Message ---
> Don't try and do anything with web devel on  windows without:
>
> http://www.sysinternals.com/Utilities/ProcessExplorer.html
>
> It is a 100% must!

Thanks :)) it's a very interesting tool...now I'm downloading it and I'll 
try to use it :)

> While you can give the IUSR user the required
>level of access you really need to think carefully about this. Giving
>Administrator privileges to the user that any externally accessible
>service runs as is generally a very very bad idea.
> Can you have the PHP queue up
> descriptions of the operations needed and then have an AT script
> actually execute them with the required privileges.

Well, I've added IUSR to the administrators Group...and the web application 
now works :)  lol
But...
I've also understand the possible problems of giving administrator 
privileges to IUSR user, thanks...so I ask you: is there the possibility
to launch it with admin privileges, without adding IUSR to the 
administrators Group? Or also is it possible to launch it with another user 
?
(in any case I need to launch it from a php web page..)

Thanks again to all of you :))

--- End Message ---
--- Begin Message ---
Well, first of all i want to apologise for my poor english.

My problem is that I have problems accessing net mounts on windows. For
example, if R: is a unit attatched from the internal net and I try to access
it, I get error. The following code is what I'm trying to do to test the
access:


--------------------------------------------------------------------------------------------------
echo "<a href='" . $filename2 . "'> arxiu </a><br>";

 if($error=basename($filename2)) echo $error . ": basename<br>";
 else echo $error . ": basename<br>";

 if($error=disk_free_space('G:')) echo $error . "  G: free space<br>";
 else echo $error . " G: There isn't free space<br>";

 if($error=copy($filename2,'.')) echo "Copy successfull<br>";
 else echo $error . " Copy successless<br>";

 if($error=is_readable($filename2)) echo "Read successfull<br>";
 else echo $error . ": The file cannot be readed<br>";

 if($error=file_exists($filename2)) echo "File Exists<br>";
 else echo $error . ": The file doesn't exists<br>";
------------------------------------------------------------------------------------
--------------
$filename2 is the path to a file in a net mount.

and the output is:

------------------------------------------------------------
loss_of_supervision: basename
G: There isn't free space
Copy successless
: The file cannot be readed
: The file doesn't exists
------------------------------------------------------------

I try the same code with C: unit and a file inside it and works fine...

There's some kind of bug or it's my server's configuration that is wrong?

--- End Message ---

Reply via email to