php-general Digest 26 Dec 2008 19:50:04 -0000 Issue 5866

Topics (messages 285071 through 285072):

Re: Round to a given value?
        285071 by: Anders Norrbring

PHP (under httpd) reading a file outside DocumentRoot?
        285072 by: Jeff Weinberger

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 ---
> Anders Norrbring wrote:
> >>>> On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote:
> >>>>> Rounding an integer to the closest divisor by ten is easy with
> >>>> round() and a
> >>>>> negative precision, but I turn out to be lost if I want to round
> >> to
> >>> a
> >>>> given
> >>>>> number..
> >>>>>
> >>>>> Example, round to the closest 5000, or closest 400? Any great
> >>> ideas?
> >>>>> Thanks, and merry x-mas!
> >>>>> Anders.
> >>>>>
> >>>>>
> >>>>>
> >>>> http://www.alixaxel.com/wordpress/wp-content/2008/05/Round.php
> >>>>
> >>>> Someone was way ahead of you and found the answer and posted on
> the
> >>> PHP
> >>>> manual pages back in May. The manual pages are always useful, even
> >> if
> >>>> only for the user-written functions!
> >>>>
> >>>>
> >>>> Ash
> >>>> www.ashleysheridan.co.uk
> >>>
> >>> Thanks Ash.
> >>> I browse the pages frequently for ideas, and also did it
> yesterday..
> >>> However, I must have missed that post, maybe because it was so
> small
> >> in
> >>> the
> >>> list.. ;-)
> >>>
> >>> Thanks for the tip!
> >>>
> >>> Anders.
> >>
> >> I cheered too fast.. That function rounds to the closest 500,
> >> literally..
> >> So, 1100 is rounded to 1500, not to 1000 which would be the correct
> >> value.
> >>
> >> Any more ideas from anyone? My mind isn't working right at the
> moment,
> >> so a
> >> "ready-to-plug-in" function would be really great!
> >
> >
> > Dear Lord.. It seems like it was so much simpler than I would even
> guess..
> > Maybe that's why I didn't see it?
> >
> > function roundto($number, $to) {
> >     return round($number / $to) * $to;
> > }
> >
> > Anders.
> >
> >
> 
> Isn't what you wrote the same as the following?
> 
> function Multiple($number, $multiple)
> {
>      return round($number / $multiple) * $multiple;
> }
> 
> The above was on the page that Ash linked to...
> 
> Named differently true, but it was right there in front of you...


Absolutely true. But when I saw it on the php.net site at first, I didn't
see it as the one I was looking for. I guess when looking to hard, you miss
the obvious. ;-)



--- End Message ---
--- Begin Message --- I don't know if this is an Apache (httpd) or a PHP issue (I suspect PHP, but I may be doing something wrong with mod_suexec), so I hope this is the right place to ask. I certainly appreciate any help anyone can offer!

I am trying to get a PHP script to read a file that's outside the DocumentRoot of a VirtualHost, in fact well outside the parent directory of all of my virtual hosts.

I have successfully managed to get Apache httpd to run the script as the correct user and group (matching the target file's ownership) using SuexecUserGroup. I tested this by having the script create/write a test file, which had owner and group set correctly.

However, when I run the script, at the file("/path/to/target/file") command, PHP tells me it can't open the file - permission is denied.

In php.ini safe_mode is off and open_basedir is not set.

I am not sure where else to look for a solution - any help is very much appreciated!

FYI: PHP 5.2.6, Apache httpd 2.2.11, mod_ssl/2.2.11, OpenSSL/0.9.7l on Mac OS/X 10.5.5. I'm reaching the script over an SSL (https) connection if that matters).

Thanks!

--- End Message ---

Reply via email to