php-general Digest 18 May 2006 16:46:55 -0000 Issue 4135

Topics (messages 236376 through 236408):

Re: Add Multiple Items, Qty to Cart from html form
        236376 by: Wolf
        236387 by: Andras Kende
        236388 by: Jochem Maas
        236390 by: Wolf

Re: Need help calling PHP page from another server.
        236377 by: John Hicks
        236404 by: John Hicks

Re: Converting characters
        236378 by: Martin Alterisio

[Repost] Getting rid of "Web page has expired" (POSTDATA error)
        236379 by: Nicolas Verhaeghe
        236380 by: Chris
        236398 by: Nicolas Verhaeghe
        236399 by: Chris

Pictures and caches
        236381 by: Gustav Wiberg
        236407 by: Eric Butera

PEAR Algorithms/Containers
        236382 by: Andrew Brampton
        236389 by: Jochem Maas
        236391 by: tedd
        236392 by: Robert Cummings

Range mktime?
        236383 by: Gustav Wiberg
        236384 by: Barry
        236385 by: Barry
        236386 by: Gustav Wiberg

What's this in my dir list?
        236393 by: tedd
        236394 by: Barry
        236395 by: cajbecu
        236397 by: John Nichel
        236402 by: tedd
        236408 by: Jochem Maas

Re: Warning: chmod(): Operation not permitted ?
        236396 by: John Nichel
        236403 by: tedd
        236405 by: John Nichel
        236406 by: tedd

Re: Getting rid of "Web page has expired" (POSTDATA error)
        236400 by: Chris Shiflett

LDAP Query
        236401 by: php.swimwebs.com

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Andras,

<input type=hidden name=item[] value=apples>Apples <input type=text
name=qty[] value=0> <input type=text name=price[] value=0>

Will get you where you need to go on the HTML side of things, then on
the back end you need to process each array.  By setting a default value
of 0 for the qty, you force users to change the values, but you also
keep your arrays intact and easier (IMHO) to deal with.

Wolf

Andras Kende wrote:
> Hello,
> 
> I trying to add multiple items to a shopping cart with selectable
> quantity and price form text field like..
> 
> apple   : qty: [__]  price: [__]
> orange : qty: [__]  price: [__]
> <Add Items to Cart>
> 
> 
> I could add multiple items with checkboxes but without selecting
> quantity and price..
> 
> if (isset($_POST['itemschecked'])) {
> foreach($_POST['itemschecked'] as $itemschecked => $checkeditems ){
> AddItem($checkeditems, 1);
> }
> 
> Any help is appreciated..
> 
> Thanks,
> 
> Andras

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Wolf [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 17, 2006 9:47 PM
To: Andras Kende
Cc: php-general@lists.php.net
Subject: Re: [PHP] Add Multiple Items, Qty to Cart from html form

Andras,

<input type=hidden name=item[] value=apples>Apples <input type=text
name=qty[] value=0> <input type=text name=price[] value=0>

Will get you where you need to go on the HTML side of things, then on
the back end you need to process each array.  By setting a default value
of 0 for the qty, you force users to change the values, but you also
keep your arrays intact and easier (IMHO) to deal with.

Wolf

Andras Kende wrote:
> Hello,
> 
> I trying to add multiple items to a shopping cart with selectable
> quantity and price form text field like..
> 
> apple   : qty: [__]  price: [__]
> orange : qty: [__]  price: [__]
> <Add Items to Cart>
> 
> 
> I could add multiple items with checkboxes but without selecting
> quantity and price..
> 
> if (isset($_POST['itemschecked'])) {
> foreach($_POST['itemschecked'] as $itemschecked => $checkeditems ){
> AddItem($checkeditems, 1);
> }
> 
> Any help is appreciated..
> 
> Thanks,
> 
> Andras


Wolf,

The tip worked great !! All working as expected now...

        $listvals=$_POST['item'];
        $n=count($listvals);
        $i=0;
        while ( $i < $n )  {
        if ($qty[$i] > 0) {
        AddItem($item[$i], $qty[$i]);
        UpdatePrice($item[$i], $price[$i]);
        }
        $i++;
        }

Thanks,

Andras Kende
http://www.kende.com

--- End Message ---
--- Begin Message ---
Wolf wrote:
Andras,

<input type=hidden name=item[] value=apples>Apples <input type=text
name=qty[] value=0> <input type=text name=price[] value=0>

a useful addition can be to use the item id in the 'key' of the input names
(and always quoting your element attributes is highly recommended):

<input type="hidden" name="item[18]" value="apples">Apples <input type="text"
name="qty[18]" value="0"> <input type="text" name="price[18]" value="0">

that way you can easily fish out the quantities when looping the
selected items (example mostly ignores input cleaning/validation for brevity 
etc -
but you shouldn't :-) e.g. get anal about make sure things are actually 
integers when
that is what you require, etc):

foreach ($_POST['item'] as $itemId => $itemName) {
        if (isset($_POST['item'][$itemId]) && ($qty = 
intval($_POST['item'][$itemId])) {
                addItem($itemId, $qty);
        }
}

another thing that popped into my head was the fact that it's
probably not intended behaviour to allow the customer to determine the
unit price of an item -
        but if it is then can I have 10 Plasma Screens at 1 dollar a pop? ;-)


Will get you where you need to go on the HTML side of things, then on
the back end you need to process each array.  By setting a default value
of 0 for the qty, you force users to change the values, but you also
keep your arrays intact and easier (IMHO) to deal with.

Wolf

Andras Kende wrote:

Hello,

I trying to add multiple items to a shopping cart with selectable
quantity and price form text field like..

apple   : qty: [__]  price: [__]
orange : qty: [__]  price: [__]
<Add Items to Cart>


I could add multiple items with checkboxes but without selecting
quantity and price..

if (isset($_POST['itemschecked'])) {
foreach($_POST['itemschecked'] as $itemschecked => $checkeditems ){
AddItem($checkeditems, 1);
}

Any help is appreciated..

Thanks,

Andras



--- End Message ---
--- Begin Message ---
<SNIP>
> a useful addition can be to use the item id in the 'key' of the input names
> (and always quoting your element attributes is highly recommended):
Yes, when I generate my cart I use the itemID as a key field (since the
ID stayed the same but the # in the database could change).

And ALWAYS quote your inputs in HTML.  It makes for a lot less
headaches.  But then I wasn't sending COMPLETE code, just enough to get
him on the right track. :)

We should all be using the guidelines within http://phpsec.org/ to keep
good coding practices.


<SNIP>
> another thing that popped into my head was the fact that it's
> probably not intended behaviour to allow the customer to determine the
> unit price of an item -
>     but if it is then can I have 10 Plasma Screens at 1 dollar a pop? ;-)
I too need the screens at 1 dollar (52" Wide-screen format please) as
well as the 6-person hot-tub and deck combo.

Wolf

--- End Message ---
--- Begin Message ---
Robert Filipovich wrote:
I am using a chat program and trying to call the status page from another
server and the graphic that the page returns does not show up.

It works if you are calling from the webserver that the chat program is
working so i feel it is some type of config problem or security issue.

http://www.hidho.com/chattest.htm is the page that uses the code

<a href="javascript:pophelp('
http://chat.siuprem.com/siupchat/client.php',500,500)"><img src="
http://chat.siuprem.com/siupchat/statusimage.php";></a> and it works on
http://chat.siuprem.com/siupchat/chattest.htm which is the windows IIS
sesrver where PHP is running.


Do you have access to the source of statusimage.php?

(I have a hunch it is checking the request's referer.)

--J

--- End Message ---
--- Begin Message ---
John Hicks wrote:
Robert Filipovich wrote:
I am using a chat program and trying to call the status page from another
server and the graphic that the page returns does not show up.

It works if you are calling from the webserver that the chat program is
working so i feel it is some type of config problem or security issue.

http://www.hidho.com/chattest.htm is the page that uses the code

<a href="javascript:pophelp('
http://chat.siuprem.com/siupchat/client.php',500,500)"><img src="
http://chat.siuprem.com/siupchat/statusimage.php";></a> and it works on
http://chat.siuprem.com/siupchat/chattest.htm which is the windows IIS
sesrver where PHP is running.


Do you have access to the source of statusimage.php?

(I have a hunch it is checking the request's referer.)

--J

Since this is open source code ('phpOnline') available at
http://www.dayanahost.com/phponline.cfm
I guess it's safe to post an excerpt here:

...
[a number of mysql statements without error checking or other exits]
...
[concluding with:]

header ("Content-type: image/jpeg");

if($LastAdmLoginTime==0 || $LastAdmLoginTime<($TTime-120))
{
        echo implode('', file('pathtooffline.jpg'));
        $OnlineStatus = 0;
}
else
{
        echo implode('', file('pathtoonline.jpg'));
}

Since both of these images are present (i.e. can be accessed directly) and since there isn't any exit prior to the execution of the above statement, I conclude that the program must be erring out before it gets here.

Check your php error log first. If you don't find anything there then edit the program to add error checking for all the sql commands.

You might also find help at the phpOnline forums: http://www.dayanahost.com/forum2/index.php?act=SF&f=11&;

If you can't find the problem, since the program is short, you could post it to the list.

--J

--- End Message ---
--- Begin Message ---
2006/5/17, Jonas Rosling <[EMAIL PROTECTED]>:

Hi,
the PHP newbie is here again asking questions.
Is there anyway in PHP to convert none international characters so the are
displayed correct?
In my case I have lots of data in the database with å,ä and ö.

Thanks // Jonas

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



If your db uses a character encode that doesn't support all the characters
in the character set of the string you want to store, this characters will
be lost when converting from one set to another, and there will be no way to
convert them back. The proper solution is to set the correct character set
in your db.

--- End Message ---
--- Begin Message ---
I am having an issue with certain pages preventing the user from going back
to the previous page.
 
The message given by Firefox is: "The page you are trying to view contains
PSTDATA that has expired from cache".
 
This happens in the case of an HTML form using the POST method but also a
query object in the URL.
 
In this case: index.php?id=shopping_cart in my URL, along with a bunch of
form data you carry from page to page in a shopping cart (quantities, what
to remove, addresses, payment info, etc...)
 
Is this due to the fact that I am mixing POST and query objects or is it
something else?
 
I already tried adding the following but it does not help:
 
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
 
Thanks for your help!
 
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
Nicolas Verhaeghe wrote:
I am having an issue with certain pages preventing the user from going back
to the previous page.
The message given by Firefox is: "The page you are trying to view contains
PSTDATA that has expired from cache".

This has been discussed a lot in the past. Check the archives:

http://marc.theaimsgroup.com/?l=php-general

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
I have searched and not found...


-----Original Message-----
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 18, 2006 1:21 AM
To: Nicolas Verhaeghe
Cc: php-general@lists.php.net
Subject: Re: [PHP] [Repost] Getting rid of "Web page has expired"
(POSTDATAerror)


Nicolas Verhaeghe wrote:
> I am having an issue with certain pages preventing the user from going 
> back to the previous page.
>  
> The message given by Firefox is: "The page you are trying to view 
> contains PSTDATA that has expired from cache".

This has been discussed a lot in the past. Check the archives:

http://marc.theaimsgroup.com/?l=php-general

-- 
Postgresql & php tutorials
http://www.designmagick.com/

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

--- End Message ---
--- Begin Message ---
On 5/19/06, Nicolas Verhaeghe <[EMAIL PROTECTED]> wrote:
I have searched and not found...

http://marc.theaimsgroup.com/?t=109805869300001&r=1&w=2
http://marc.theaimsgroup.com/?t=107515229700002&r=1&w=2
http://marc.theaimsgroup.com/?t=106201107100002&r=1&w=2


--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Hi!

The thing I want to do is to copy a picturefile to another picturefile.
The thing is that I want to copy this file, show it , and then delete it (when it has been shown) .Is this possible?

I want to do this, because of avoiding problems with cache when uploading file through an admin-online-system... (the customer uses IE)

When I delete the file in code down below, the picture is not shown (I guess because the browser hasn't rendered out all info?)

If you want more code, tell me :-)

Best regards
/Gustav Wiberg



$fileName = "pictures/products/$dbIDProduct1" . "_small";

$ran = strval(mktime()); //Current time

if (file_exists($fileName . ".gif")) {

   copy($fileName . ".gif", "pictures/products/1_$ran.gif");
showpicture("pictures/products/1_$ran.gif", $dbProductName1, 300, 150, "top");
   //deletefile("pictures/products/1_$ran.gif");

}

--- End Message ---
--- Begin Message ---
On 5/18/06, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
Hi!

The thing I want to do is to copy a picturefile to another picturefile.
The thing is that I want to copy this file, show it , and then delete it
(when it has been shown) .Is this possible?

I want to do this, because of avoiding problems with cache when uploading
file through an admin-online-system... (the customer uses IE)

When I delete the file in code down below, the picture is not shown (I guess
because the browser hasn't rendered out all info?)

If you want more code, tell me :-)

Best regards
/Gustav Wiberg



$fileName = "pictures/products/$dbIDProduct1" . "_small";

$ran = strval(mktime()); //Current time

if (file_exists($fileName . ".gif")) {

    copy($fileName . ".gif", "pictures/products/1_$ran.gif");
    showpicture("pictures/products/1_$ran.gif", $dbProductName1, 300, 150,
"top");
    //deletefile("pictures/products/1_$ran.gif");

}

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



I had to do something similar to keep a javascript file from being
cached by an aol proxy.  Heres a simple example that you could change
to suit your needs by changing the js to something like image.php and
making it send image headers and outputting the contents of your file.

1) Rewrite rule in httpd.conf or virtual.conf
=======================================================================
RewriteRule ^/lib/(.*)/test.js.php /lib/test.js.php [QSA,L]


2) Create test.js.php in /lib/test.js.php
=======================================================================
<?php
header('Content-Type: text/javascript');
?>


3) Access url: http://example.local/lib/4908574987/test.js.php.  You
can create your url like /lib/time()/test.js.php.

This way you don't have to worry about creating and deleting files.

--- End Message ---
--- Begin Message ---
Hi,

In the past few weeks I've found the need for a hash table and a container that gives me O(log) search efficiency. Now I'm aware I can use associative arrays for my hash table, but I wanted to ensure efficiency. For my O(log) container I ended up using a sorted array, and a binary search (which I had to write).

Now I thought common data structures, and algorithms, like these, and many others such as Binary Trees, Red/Black Trees and sorting algorithms and so on would be a useful addition to PHP, or more specifically PEAR, however I was unable to find any previous classes that provided these structures.

So I figured I would make a set of containers and algorithms that could be used in a generic way , and hopefully put this code into PEAR. But before I start making nice PEAR code, I wanted to ask why nothing like this already exists? Is it because everyone has been to lazy until now, or is there a real reason that I'm missing that has made such structures pointless.

thanks for any comments/replies
Andrew
--- End Message ---
--- Begin Message ---
Andrew Brampton wrote:
Hi,

In the past few weeks I've found the need for a hash table and a container that gives me O(log) search efficiency. Now I'm aware I can use associative arrays for my hash table, but I wanted to ensure efficiency. For my O(log) container I ended up using a sorted array, and a binary search (which I had to write).

Now I thought common data structures, and algorithms, like these, and many others such as Binary Trees, Red/Black Trees and sorting algorithms and so on would be a useful addition to PHP, or more specifically PEAR, however I was unable to find any previous classes that provided these structures.

So I figured I would make a set of containers and algorithms that could be used in a generic way , and hopefully put this code into PEAR. But before I start making nice PEAR code, I wanted to ask why nothing like this already exists? Is it because everyone has been to lazy until now, or is there a real reason that I'm missing that has made such structures pointless.

sounds like a good idea. probably the reason it doesn't exist is because
the entry level for making something worthwhile is high - and most people
with such needs end up building something specific because it's easier.

if you do go the PEAR route my suggestion would be to avoid all/any of the
PEAR base classes - to save bloat and make the components more usable for
people who don't want/need PEAR (or are not allowed to use it).


thanks for any comments/replies
Andrew

--- End Message ---
--- Begin Message ---
At 11:41 AM +0100 5/18/06, Andrew Brampton wrote:
Hi,

In the past few weeks I've found the need for a hash table and a container that gives me O(log) search efficiency. Now I'm aware I can use associative arrays for my hash table, but I wanted to ensure efficiency. For my O(log) container I ended up using a sorted array, and a binary search (which I had to write).

Now I thought common data structures, and algorithms, like these, and many others such as Binary Trees, Red/Black Trees and sorting algorithms and so on would be a useful addition to PHP, or more specifically PEAR, however I was unable to find any previous classes that provided these structures.

So I figured I would make a set of containers and algorithms that could be used in a generic way , and hopefully put this code into PEAR. But before I start making nice PEAR code, I wanted to ask why nothing like this already exists? Is it because everyone has been to lazy until now, or is there a real reason that I'm missing that has made such structures pointless.

thanks for any comments/replies
Andrew


Andrew:

I know what you are talking about, I wrote a splay binary-tree demo, see:

http://www.sperling.com/freeware.php

I've often wondered if there are algorithms like that in php buried somewhere.

However, binary-trees are for searching and I use MySQL for that. I don't know specifically how MySQL preforms searches. I had hoped that somewhere one could set a bit and change the algorithms, but I haven't been able to find any references that allow that.

In any event, the size of the things I work with (<50k items) are so small that it really doesn't matter for me -- and I don't know at what size where it starts to be a problem for others.

So, if I was to take my previous code and port it over to php, I would most certainly test it against MySQL for performance before spending too much time providing something that doesn't significantly improve the status-quo.

tedd
--
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Thu, 2006-05-18 at 06:41, Andrew Brampton wrote:
> Hi,
> 
> In the past few weeks I've found the need for a hash table and a container 
> that gives me O(log) search efficiency. Now I'm aware I can use associative 
> arrays for my hash table, but I wanted to ensure efficiency. For my O(log) 
> container I ended up using a sorted array, and a binary search (which I had 
> to write).
> 
> Now I thought common data structures, and algorithms, like these, and many 
> others such as Binary Trees, Red/Black Trees and sorting algorithms and so 
> on would be a useful addition to PHP, or more specifically PEAR, however I 
> was unable to find any previous classes that provided these structures.
> 
> So I figured I would make a set of containers and algorithms that could be 
> used in a generic way , and hopefully put this code into PEAR. But before I 
> start making nice PEAR code, I wanted to ask why nothing like this already 
> exists? Is it because everyone has been to lazy until now, or is there a 
> real reason that I'm missing that has made such structures pointless.

They more than likely don't exist because PHP's associative array is
O(lg n) and so everything else is pretty much just as good, except not
quite as good because it will be implemented in PHP whereas the internal
associative array is in C. Additionally PHP already provides all you
could probably need for sorting. If this is purely for academic fun then
I'd say go ahead, but if you are thinking real life applications, then
I'd suggest spending your time on algorithms that don't have a
just-as-good alternative already implemented internally.

BTW, I don't think you can make an O(1) hash table in PHP since even if
you succeeded in making a perfect hash then PHP will perform O(lg n)
lookup into whatever structure you've made.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Hi

I wondew which range the mktime has? (in digits)
In my case it always start with 1.
something like
1147951344

Is this ALWAYS TRUE (that it would start with 1)

Best regards
/Gustav Wiberg

--- End Message ---
--- Begin Message ---
Gustav Wiberg schrieb:
Hi

I wondew which range the mktime has? (in digits)
In my case it always start with 1.
something like
1147951344

Is this ALWAYS TRUE (that it would start with 1)

Best regards
/Gustav Wiberg
mktime is giving you the time in seconds since 1st april 1970

So no. It's not true.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
Gustav Wiberg schrieb:
Hi

I wondew which range the mktime has? (in digits)
In my case it always start with 1.
something like
1147951344

Is this ALWAYS TRUE (that it would start with 1)

Best regards
/Gustav Wiberg
mktime is giving you the time in seconds since 1st april 1970

So no. It's not true.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Barry" <[EMAIL PROTECTED]>
To: <php-general@lists.php.net>; "Gustav Wiberg" <[EMAIL PROTECTED]>
Cc: "PHP General" <php-general@lists.php.net>
Sent: Thursday, May 18, 2006 1:45 PM
Subject: [PHP] Re: Range mktime?


Gustav Wiberg schrieb:
Hi

I wondew which range the mktime has? (in digits)
In my case it always start with 1.
something like
1147951344

Is this ALWAYS TRUE (that it would start with 1)

Best regards
/Gustav Wiberg
mktime is giving you the time in seconds since 1st april 1970

So no. It's not true.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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

Ok, thanx!

Best regards
/Gustav Wiberg

--- End Message ---
--- Begin Message ---
Hi Gang:

When I list one of my directories, via:

echo("<pre>");
system("ls -l");
echo("</pre>");

I get:

-rw-r--r--  1 ancientstones psacln  6980 Apr 28 18:46 ancientstones.gif
-rw-r--r--  1 ancientstones psacln  2090 May 14 10:10 as.css
-rw-r--r--  1 ancientstones psacln   658 May  2 14:59 big_m.php
...

My question is, what is "psacln"?

In all the reference material I've looked at, that column is absent. Is that the "name" for the group?

Thanks.

tedd
--
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd schrieb:
Hi Gang:

When I list one of my directories, via:

echo("<pre>");
system("ls -l");
echo("</pre>");

I get:

-rw-r--r--  1 ancientstones psacln  6980 Apr 28 18:46 ancientstones.gif
-rw-r--r--  1 ancientstones psacln  2090 May 14 10:10 as.css
-rw-r--r--  1 ancientstones psacln   658 May  2 14:59 big_m.php
...

My question is, what is "psacln"?

In all the reference material I've looked at, that column is absent. Is that the "name" for the group?

Thanks.

tedd
groupowner of that file.
yes.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
yup, psacln is the group of the user ancientstones who`s owner of the files.

tedd wrote:
> Hi Gang:
> 
> When I list one of my directories, via:
> 
> echo("<pre>");
> system("ls -l");
> echo("</pre>");
> 
> I get:
> 
> -rw-r--r--  1 ancientstones psacln  6980 Apr 28 18:46 ancientstones.gif
> -rw-r--r--  1 ancientstones psacln  2090 May 14 10:10 as.css
> -rw-r--r--  1 ancientstones psacln   658 May  2 14:59 big_m.php
> ...
> 
> My question is, what is "psacln"?
> 
> In all the reference material I've looked at, that column is absent. Is
> that the "name" for the group?
> 
> Thanks.
> 
> tedd

--- End Message ---
--- Begin Message ---
tedd wrote:
Hi Gang:

When I list one of my directories, via:

echo("<pre>");
system("ls -l");
echo("</pre>");

I get:

-rw-r--r--  1 ancientstones psacln  6980 Apr 28 18:46 ancientstones.gif
-rw-r--r--  1 ancientstones psacln  2090 May 14 10:10 as.css
-rw-r--r--  1 ancientstones psacln   658 May  2 14:59 big_m.php
--^ -> Type of file
---^^^ -> User bits (user has read write)
------^^^ -> Group bits (group can read)
---------^^^ -> Other bits (world can read)
--------------^ -> Hard links
----------------^^^^^^^^^^^^^ -> User (owner)
------------------------------^^^^^^ -> Group
--------------------------------------^^^^ -> Filesize
-------------------------------------------^^^^^^^^^^^^ -> last mod
--------------------------------------------------------^^^^ -> filename

Really, I'm not trying to be a dick, but buy a book/research this online. It's pretty important for the security of your system.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
At 10:58 AM -0400 5/18/06, John Nichel wrote:
tedd wrote:
Hi Gang:

When I list one of my directories, via:

echo("<pre>");
system("ls -l");
echo("</pre>");

I get:

-rw-r--r--  1 ancientstones psacln  6980 Apr 28 18:46 ancientstones.gif
-rw-r--r--  1 ancientstones psacln  2090 May 14 10:10 as.css
-rw-r--r--  1 ancientstones psacln   658 May  2 14:59 big_m.php
--^ -> Type of file
---^^^ -> User bits (user has read write)
------^^^ -> Group bits (group can read)
---------^^^ -> Other bits (world can read)
--------------^ -> Hard links
----------------^^^^^^^^^^^^^ -> User (owner)
------------------------------^^^^^^ -> Group
--------------------------------------^^^^ -> Filesize
-------------------------------------------^^^^^^^^^^^^ -> last mod
--------------------------------------------------------^^^^ -> filename

Really, I'm not trying to be a dick, but buy a book/research this online. It's pretty important for the security of your system.

--
John C. Nichel IV

No problem being a dick -- my question was "is psacln the group"?

The answer was "Yes". I was looking for conformation.

Thanks.

tedd
--
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 10:58 AM -0400 5/18/06, John Nichel wrote:

tedd wrote:

Hi Gang:

When I list one of my directories, via:

echo("<pre>");
system("ls -l");
echo("</pre>");

I get:

-rw-r--r--  1 ancientstones psacln  6980 Apr 28 18:46 ancientstones.gif
-rw-r--r--  1 ancientstones psacln  2090 May 14 10:10 as.css
-rw-r--r--  1 ancientstones psacln   658 May  2 14:59 big_m.php

--^ -> Type of file
---^^^ -> User bits (user has read write)
------^^^ -> Group bits (group can read)
---------^^^ -> Other bits (world can read)
--------------^ -> Hard links
----------------^^^^^^^^^^^^^ -> User (owner)
------------------------------^^^^^^ -> Group
--------------------------------------^^^^ -> Filesize
-------------------------------------------^^^^^^^^^^^^ -> last mod
--------------------------------------------------------^^^^ -> filename

Really, I'm not trying to be a dick, but buy a book/research this online. It's pretty important for the security of your system.

--
John C. Nichel IV


No problem being a dick -- my question was "is psacln the group"?

which is a question about the *nix filesystem - bit off the scope for
this list.

btw 'psacln' is a group created by Plesk Hosting Software installations.
googling for 'psacln' on its own actually would have given you this info
and confirmed that it is indeed a user group.


The answer was "Yes". I was looking for conformation.

confirmation as in confirm not conform.

--- End Message ---
--- Begin Message ---
tedd wrote:
At 11:18 AM -0400 5/17/06, John Nichel wrote:
tedd wrote:
Hi (please insert your preference):

This should be simple, but I'm having problems.

I have a program that uploads an image file and then tries to set the permissions for the image (to be altered later). However, I get a "Warning: chmod(): Operation not permitted" error when trying to set the permission, what gives? If my program created the file, shouldn't it have permission to set the files permissions?

What am I not understanding?

Without seeing code, permissions of the directories, what sticky bits might or might not be set, etc., you could not be understanding many things....or just one....who knows.

I read all of your Google links, but no help. Just another example of how Google is not the answer.

Then you're asking the wrong question.

In any event, my code is pretty simple, just:

chmod($url, 0755);  //where $url is the file I want to change.

The error I receive is noted above in the subject line.

The permissions of the directories vary, but the folder that has the file I want to change permissions is currently set at 0777.

Nice security there. Regardless, even if the user your webserver is running as has write permission to the directory (don't know who owns/what group that directory belongs to, as you didn't tell us that), you won't be able to change permissions of a file in that directory if the file isn't owned by the same user apache is running as.

In doing a lstat() of both the parent program that created the file and the child file shows that they both have the identical uid and gid (i.e., the same user and group id's).

And what user does Apache run as?

Now, everything I've read, says:

chmod() changes the permission of the specified file with the following caveat.

"chmod() can only change the permissions of files that are owned by the user running the command. In most cases, this is the user that the web server runs on."

That confuses me, because who's the user here? Is it just the system administrator or the application?

And if it is just the system administrator, then can't the system admin change anything he/she wants anyway? What's the point of having uid and gid's if a program can't change the permissions of a sibling file?

This question should answer the previous question for you.

I have tons of references as to what php filesystem functions are available, but I need a good reference as to what permissions are and how they actually can be changed in php -- does anyone have one a good reference OR care to explain?

As it is now, I know how ride the horse, but I can't get the gate open.

File permissions is beyond the scope of this mailing list. You need to buy a book, research on the web, etc., on *nix system administration, and concentrate on the filesystem/security/permissions sections, and the section on how apps/daemons operate.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
File permissions is beyond the scope of this mailing list. You need to buy a book, research on the web, etc., on *nix system administration, and concentrate on the filesystem/security/permissions sections, and the section on how apps/daemons operate.

--
John C. Nichel IV


John:

My question basically was "why isn't chmod() working for me?" So, I thought it might be a question to pose to a php mailing list -- my mistake, sorry.

In any event, I'll figure it out.

Thanks.

tedd

PS: 0777 -- so you never go to extremes, or press limits, to try to solve a problem?

--
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
File permissions is beyond the scope of this mailing list. You need to buy a book, research on the web, etc., on *nix system administration, and concentrate on the filesystem/security/permissions sections, and the section on how apps/daemons operate.

--
John C. Nichel IV


John:

My question basically was "why isn't chmod() working for me?" So, I thought it might be a question to pose to a php mailing list -- my mistake, sorry.

chmod() is working the way it's supposed to. You're not getting the results you desire, and to understand why, you need to understand how file ownership and permissions work on a *nix system.

PS: 0777 -- so you never go to extremes, or press limits, to try to solve a problem?


Not when it will compromise the security of my system. There is always another way to solve the problem.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
At 5:11 PM -0600 5/17/06, Brady Mitchell wrote:
 > "chmod() can only change the permissions of files that are owned by
 the user running the command. In most cases, this is the user that
 the web server runs on."

 That confuses me, because who's the user here? Is it just the system
 administrator or the application?

This is the user that Apache (or whatever webserver) is running as.  If
you're using Apache, look at your httpd.conf file to find out who that
user is.  If you're creating files successfully, you can just look at
the owner of that file to find out who it is.

Is safe_mode enabled?

 >From the manual (http://us3.php.net/chmod):


In my code, I use:

ini_set( 'safe_mode', '0' );

Which I think disables "safe_mode" and from what I've read, the default is off and in my phpinfo, it says it's 'off" -- so I think it's off. :-)

Note:  When safe mode is enabled, PHP checks whether the files or
directories you are about to operate on have the same UID (owner) as the
script that is being executed. In addition, you cannot set the SUID,
SGID and sticky bits.

I understand that, except for the sticky bits -- I don't know what they are, but will look them up later.

But safe_mode is off, so any application should be able to chmod(), right?

However, when my application tries to change permissions via chmod(), it fails and generates a warning.

BUT -- considering that this is a permission issue and not a php one, as I've been told, I'll end this thread and look elsewhere for an answer.

Thanks.

tedd
--
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
I wrote an article on this subject that might help:

http://shiflett.org/articles/guru-speak-nov2004

Chris

--
Chris Shiflett
Principal, OmniTI
http://omniti.com/

--- End Message ---
--- Begin Message ---
Our organization is migrating away from Novell E-directory to MS Active 
Directory.  I have a php class that allows me to run various queries on our 
e-directory ldap server which I am working to convert to AD.  However, I'm 
running into an error that i cannot figure out.  I have updated the base_dn to 
point tothe correct location (verified by a third party ldap browser).  Also 
added a username and password since our AD environment doesn't allow anonymous 
queries.  The error I get is 

Warning: ldap_search() [function.ldap-search]: Search: Operations error in 
/var/www/html/intranet/_php/class.ldap_test.php on line 149

On that line I have this line of code
$result = ldap_search($this->conn,$this->base_dn,$filter);

Where $this->conn evaluates to Resource id #3, $this->base_dn is the correct dn 
(ou=something,dc=domain,dc=domain_part_2) and $filter is cn=myusername

Can anyone shed some light on this?  Below is the entire method from the class.

        function connectldap($filter,$override=false) {
                //connect to the server
                $this->conn = ldap_connect($this->server);
                
                //if the connection failed, set the error message
                //and return false
                if(!$this->conn) {
                        $this->errMsg[] = "Unable to connect to server\n";
                        return false;
                }
                //ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
                //bind the connection.  This function will perform an
                //anonymous query to get the full 
                $bind = @ldap_bind($this->conn,$this->ldap_user,$ldap_passwd);
                if(!$bind) {
                        $this->errMsg[] =  "Unable to bind to server\n";
                        return false;
                }
                echo "<p>$filter - " . $this->conn . " - " . $bind . " - " . 
$this->base_dn . "</p>\n";
                //run the ldap query
                $result = ldap_search($this->conn,$this->base_dn,$filter);
                //if the search failed, then return false and set the error 
message
                if(!$result) {
                        $this->errMsg[] =  "Search failed - " . 
ldap_error($this->conn) . "\n";
                        return false;
                }
                //get the entries and store them in a variable
                $info=ldap_get_entries($this->conn,$result);
                
                //if the number of entries reutnred is zero, then the user
                //could not be found in the ldap server
                if($info["count"] == 0) {
                        $this->errMsg[] =  "User Unknown\n";
                        return false;
                }
                //otherwise, if the number of entries found is greater than 1, 
then
                //more than one object was found.
                elseif($info["count"]>1 && !$override) {
                        $this->errMsg[] =  "There was more than one user 
found\n";
                        return false;
                }
                else {
                        return $info;
                }
        }

Thank you,
Robbert van Andel

--- End Message ---

Reply via email to