php-general Digest 4 Nov 2006 17:36:02 -0000 Issue 4440

Topics (messages 244198 through 244209):

Protecting Streaming Audio
        244198 by: Adam Gittins
        244206 by: Ed Lazor

Re: 301 redirect returning 302 instead
        244199 by: Chris Shiflett

Re: Microsoft Partners With Zend
        244200 by: André Medeiros

[newbie in session] Is is right behavior???
        244201 by: Mariusz Topczewski

Re: in_array() related problem
        244202 by: Tom Atkinson

Re: setlocale madness... please help!
        244203 by: Roman Neuhauser

Re: Why a script belong to user 'root' and the folder this script create is 
belonged to user 'nobody'?
        244204 by: Roman Neuhauser

ChangeLog PHP 5.2.0 - Fileupload
        244205 by: Christian Heinrich
        244207 by: Rasmus Lerdorf
        244209 by: Ed Lazor

postgreSQl and images
        244208 by: Alain Roger

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 ---
Dear List,

    I have had a question that has been bugging me for a while now. Say
that I need to have a members website. Which I want to protect streaming
audio (Real, or Windows Media), now all the pages I can protect with a MYSQL
DB and PHP. But when it comes to protecting a url of a file or audio feed it
becomes tricky. What is the procedure? Would I have to use the htaccess
file? But then when I open a realaudio file it will ask for a username and
passworld again..

How does one protect an url - or do I have to copy the file to a temp dir
and then after a set time delete it?

Help, there must be a way..

Thanks for any ideas..

Sincerely,
Adam

--- End Message ---
--- Begin Message --- You put the data in a directory outside of the webspace and use PHP to grab the file and send it to someone. That way you're able to control access to the file.

By webspace, I'm referring to the directories outside of the ones used to store and serve your webpages. This directory structure would serve as an example for where you store your webpages and where you store your data separately from the webpages:

/www/www.somesite.com/htdocs
/www/www.somesite.com/data




On Nov 3, 2006, at 9:29 PM, Adam Gittins wrote:

Dear List,

I have had a question that has been bugging me for a while now. Say that I need to have a members website. Which I want to protect streaming audio (Real, or Windows Media), now all the pages I can protect with a MYSQL DB and PHP. But when it comes to protecting a url of a file or audio feed it becomes tricky. What is the procedure? Would I have to use the htaccess file? But then when I open a realaudio file it will ask for a username and
passworld again..

How does one protect an url - or do I have to copy the file to a temp dir
and then after a set time delete it?

Help, there must be a way..

Thanks for any ideas..

Sincerely,
Adam

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> header('HTTP/1.1 301 Moved Permanently');
> header('Location: newurl');
> exit();

If you're using PHP 4.3 or later, header() lets you set the response
status code with the third argument. Otherwise, sending a Location
header sets the response status code to 302.

If you're using an old version of PHP, you should try reversing the
order of the header() calls in your example, if you haven't already.

Hope that helps.

Chris

-- 
Chris Shiflett
http://shiflett.org/

--- End Message ---
--- Begin Message ---
A bit out of topic perhaps, but is this the time to see Steve Balmer
and his developers dance all over again? ;)

Hmmmm....

On 11/3/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
On Fri, November 3, 2006 12:36 pm, Curt Zirzow wrote:
> Here is the actual demo given:
> http://blogs.iis.net/bills/archive/2006/10/31/PHP-on-IIS.aspx
>
> As seen my numbers were off a little bit from memory.
>
> I'm not sure exactly what the kernel cache is, it is some thing the
> file http.sys thing does and handles requests before IIS even sees
> them, I'm thinking it probably is like a thttpd type of server.

My reading of that URL makes it sound like a Squid cache, with
configurable GET args being seen as relevant.

But, heh, 100 to 6000 improvement is definitely good for Windows users.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving 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



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

I just start in using session, but unfortunatly I meet first problem right 
now :-(
On some PC when i load the page, the is no content, and on other PC the page 
is loaded properly. On computer where the page is blank i have to press F5 
(refresh), and the page appear ?.

The second thing I notice, is that i try display the source from browser, it 
doesn't work.

And i find, thet when I comment or remove session_start(); the page work on 
every PC, and i can view the source.

Could you help me?
 This is an example page: ( can't view the source)

<?php
session_start();
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
</head>
<body>
ble ble ble :-(
</body>
</html>

With best regards,
Mariusz

P.S. I hope you could understand me :-)))) 

--- End Message ---
--- Begin Message ---
Try like this:

var_dump(in_array($a, $test, true));


Richard Lynch wrote:
Try providing a custom comparison function.

Almost for sure, PHP is attempting to "test" the == by a deeper scan
than you think.

On Fri, November 3, 2006 10:56 am, tamcy wrote:
Hello all,

I'm new to this list. To not flooding the bug tracking system I hope
to clarify some of my understanding here.

I am referring to the (now bogus) bug report
http://bugs.php.net/bug.php?id=39356&edit=2. This happens after my
upgrade to PHP 5.2, where the code shown produces a "Fatal error:
Nesting level too deep - recursive dependency?". Same testing code
reproduced below:

----------------------------
<?php
class A
{
        public $b;
}

class B
{
        public $a;
}

$a = new A;
$b = new B;
$b->a = $a;
$a->b = $b;

$test = array($a, $b);

var_dump(in_array($a, $test));
----------------------------

I think this is not rare for a child item to have knowledge about its
parent, forming a cross-reference.

This code runs with no problem in PHP5.1.6, but not in 5.2. Ilia
kindly points out that "In php 5 objects are passed by reference, so
your code does in
fact create a circular dependency.". I know the passed by reference
rule. What I'm now puzzled is, why this should lead to an error.

To my knowledge, despite the type-casting issue and actual algorithm,
in_array() should actually do nothing more than:

function mimic_in_array($search, $list)
{
  foreach ($list as $item)
    if ($search == $item)
      return true;
  return false;
}

Which means:
1. in_array() isn't multi-dimensional.
2. in_array() doesn't care about the properties of any object.

That is, I don't expect in_array() to nest through all available inner
arrays for a match, not to mention those are object properties, not
arrays.

So here is the question: Why should in_array() throws such a "Fatal
error: Nesting level too deep" error? Why should it care? Is there any
behaviour I don't know?

Thanks all in advance.

Tamcy

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





--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-11-03 22:18:03 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2006-11-03 16:16:11 +0100:
> >> Roman Neuhauser wrote:
> >>> # [EMAIL PROTECTED] / 2006-11-03 14:51:39 +0100:
> >>>> 1. running the command 'locale -a' returns the following [shortened] 
> >>>> list:
> >>>>
> 
> ...
> 
> > 
> >>>> in fact I can set any installed locale I want on the commandline BUT
> >>>> trying to set any other than the originally installed "[EMAIL 
> >>>> PROTECTED]" in
> >>>> code running via Apache results in FALSE being returned and the locale
> >>>> not being set.
> >>>>
> >>>> has anybody got a clue for me?
> >>>     You don't mention what warning(s) the failing setlocale() call 
> >>> produces.
> >> it just returns false, telling me that the chosen locale(s) was/were not 
> >> set - there
> >> is no PHP error at all.
> > 
> >     I just checked the setlocale() code (in HEAD), and surely it can
> >     return false without a warning, it can even be an almost empty (and
> >     just as quiet) stub that just returns false, depending on the value
> >     of HAVE_SETLOCALE during compilation.
> 
> thank you for doing this ... turns out that indeed the locale is being set
> but the return value is false, I've settled for not checking the return value 
> and
> just assuming (blindly hoping) the setlocale worked - I don't really know what
> else there is to do, besides ik works :-)

    How did you confirmed that the locale got set?
 
> >   Try a simple CGI script, does
> >     locale manipulation succeed there?
> 
> I'd have to look up how to setup a php-cgi ...

    It doesn't have to be written in PHP.

    Compile the following program and try it from the command line:

    #include <errno.h>
    #include <string.h>
    #include <stdio.h>
    #include <locale.h>

    int
    main(int argc, char **argv)
    {
        if (2 > argc) {
            return printf("usage: %s <locale>\n", *argv);
        }
        char *old = setlocale(LC_ALL, NULL);
        printf("old: %p \"%s\"\n", old, old);
        char *loc = setlocale(LC_ALL, argv[1]);
        char *check = setlocale(LC_ALL, NULL);
        printf("check: %p \"%s\"\n", check, check);
        if (0 == loc) {
            printf("setlocale: \"%s\"\n", strerror(errno));
            return 1;
        }
        return printf("new: %p \"%s\"\n", loc, loc);
    }

    Put "AddHandler cgi-script .cgi" in your apache config
    and call the above from the script below, does the output differ?

    foo.cgi:

    #!/bin/sh
    printf "Content-Type: text/plain\r\n\r\n"
    /path/to/the-above-program en_GB

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-11-03 15:15:55 -0600:
> On Fri, November 3, 2006 12:45 am, John.H wrote:
> > My php program whose owner is root:

That has absolutely no influence on what user the process *runs* as.

> > <?
> >     mkdir('test',0777);
> > ?>
> >
> > and the folder 'test'  's owner is 'nobody'?

You're probably running this from a web server, and that often runs as
nobody. Apache is typically started as root to allow it to listen(2) on
port 80. This process running as root doesn't handle http requests
itself, it fork(2)s, the child process switches its effective user id to
nobody and then handles the request(s).

> > why?should the folder belong to 'root' too?

Filesystem nodes are owned by the effective user id of the process that
created them. See chown(2), open(2), setuid(2) for details.

> > By the way,the safe mode is turned on.

That does not affect this.

> I believe that the umask and other OS settings may also affect who
> ends up owning a file created by 'root'...
> http://php.net/umask

Not at all. umask influences the mode ("permissions") of the created
file, but is completely unrelated to ownership.
 
> You're running this as CLI, right?...
> 
> Cuz if you are running your web server as root, shut it down NOW. :-)

See above. This is from a completely ordinary Apache 2.0 install:

[EMAIL PROTECTED] ~ 1005:0 > ps auxww|grep httpd|head -5
root        6652  0.0  2.3 19108 11340  ??  Ss   10:30AM   0:00.93 
/usr/local/sbin/httpd
www        31670  0.0  2.6 20628 13028  ??  S     1:46PM   0:00.73 
/usr/local/sbin/httpd
www        34625  0.0  5.0 32260 24736  ??  S     2:09PM   0:00.68 
/usr/local/sbin/httpd
www        34734  0.0  2.9 21808 14200  ??  S     2:10PM   0:00.42 
/usr/local/sbin/httpd
www        34735  0.0  2.4 19672 12080  ??  S     2:10PM   0:00.24 
/usr/local/sbin/httpd
 
The root-owned process can be easily eliminated by running the server
on a port > 1024 and natting it to 80.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
Hey all,

I've just examined the latest Change-Log for Version 5.2.0 (see http://www.php.net/ChangeLog-5.php for details).

Seems to be fine, but I couldn't figure out one point.

The changelog talks about

Added RFC1867 fileupload processing hook. (Stefan E.)

and I actually don't know what is meant by that. I've looked up that RFC but it appears to me to be about multipart/form-data only. I confess that I haven't read it completly, but it didn't really seem to be talking about what I wanted to know.

So, could anyone be so kind to explain me what is meant by that and what its used for?

Thanks in advance.

Greetings from Germany

Yours sincerely
Christian Heinrich

--- End Message ---
--- Begin Message ---
Christian Heinrich wrote:
> Hey all,
> 
> I've just examined the latest Change-Log for Version 5.2.0 (see
> http://www.php.net/ChangeLog-5.php for details).
> 
> Seems to be fine, but I couldn't figure out one point.
> 
> The changelog talks about
> 
>> Added RFC1867 fileupload processing hook. (Stefan E.)
> 
> and I actually don't know what is meant by that. I've looked up that RFC
> but it appears to me to be about multipart/form-data only. I confess
> that I haven't read it completly, but it didn't really seem to be
> talking about what I wanted to know.
> 
> So, could anyone be so kind to explain me what is meant by that and what
> its used for?

Probably best explained with an example:

  http://progphp.com/upload.php

Try uploading a 200-300k file.

The source code is at:

  http://progphp.com/upload.phps

-Rasmus

--- End Message ---
--- Begin Message ---
Very cool example.

Probably best explained with an example:

  http://progphp.com/upload.php

Try uploading a 200-300k file.

The source code is at:

  http://progphp.com/upload.phps

-Rasmus

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


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

I create a table with some large object (ref: OID) to store some images.
When my PHP will display some data, it will also display the images stored
as OID.

However, i've read that before i must restore the image by exporting them to
local (on server) file.

isn't it easier in this case, to simply store the path and file name of file
to DB and just read the data to display image on PHP pages ?
what is the purpose in this case to store image a bytea / large object ?

moreover, how my php code will load image from DB and stored there as OID ?
isn't it too much complex in comparison with just storing path and name of
image ?

thanks a lot,

Al.

--- End Message ---

Reply via email to