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

2006-11-04 Thread php-general-digest-help

php-general Digest 4 Nov 2006 17:36:02 - 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:
php-general@lists.php.net


--
---BeginMessage---

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---
---BeginMessage---
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---
---BeginMessage---
[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---
---BeginMessage---

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

H

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---
---BeginMessage---
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 

php-general Digest 5 Nov 2006 06:08:49 -0000 Issue 4441

2006-11-04 Thread php-general-digest-help

php-general Digest 5 Nov 2006 06:08:49 - Issue 4441

Topics (messages 244210 through 244222):

Re: setlocale madness... please help!
244210 by: Jochem Maas

Re: Finding user's timezone
244211 by: Dotan Cohen
244212 by: Jochem Maas

Re: str_replace on words with an array
244213 by: Dotan Cohen

Pear
244214 by: Alain Roger
244215 by: Rory Browne

phpPgAdmin
244216 by: Alain Roger
244219 by: Nirmalya Lahiri

Issue when inserting Slovak characters in database via PHP code
244217 by: Alain Roger

Re: postgreSQl and images
244218 by: Børge Holen

Trying to create an encryption method
244220 by: John Meyer
244221 by: Stut

Re: Protecting Streaming Audio
244222 by: Adam Gittins

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


--
---BeginMessage---
Roman Neuhauser wrote:
 # [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?

there is no simple way to determine if the locale was set because setlocale() 
is returning
false even when a locale has been successfully set, given that for each 
langauge I have a list
of locales (to be able to handle different server/OS setups) I can never be 
sure which locale
in the list was actually set - now I suppose you could check the output of a 
locale aware function
to see if the output is in the desired locale BUT this would mean having to 
have some know output
to check against for each locale - that sounds like a recipe for messy, 
horrible (and quite
likely brittle if not unreliable) code.


  
   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:

ok, wow - I'm definitely going to have a play with this when I have a
quite moment! nice one Roman! thank you.

 
 #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
 
---End Message---
---BeginMessage---

On 03/11/06, Richard Lynch [EMAIL PROTECTED] wrote:

On Fri, November 3, 2006 6:09 am, Dotan Cohen wrote:
 How does php decide what timezone a user is in? Although I am in
 Haifa, Israel (GMT+2), when I go to a page with date(e) I get
 America/New_York displayed.

I could be wrong, but I think date('e') tells us where your SERVER is.

Or, more accurately, what time zone your server was configured to tell
us it lived in, no matter where it really lives in the physical world.


Yes, this seems to be the case.


 To confirm, could some users tell me what output they get on:
 http://what-is-what.com/what_time_is_it.php

 Let me know where 

Re: [PHP] 301 redirect returning 302 instead

2006-11-04 Thread Chris Shiflett
[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/

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



Re: [PHP] Microsoft Partners With Zend

2006-11-04 Thread André Medeiros

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

H

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




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



Re: [PHP] in_array() related problem

2006-11-04 Thread Tom Atkinson

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=39356edit=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







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



Re: [PHP] setlocale madness... please help!

2006-11-04 Thread Roman Neuhauser
# [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

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



Re: [PHP] Why a script belong to user 'root' and the folder this script create is belonged to user 'nobody'?

2006-11-04 Thread Roman Neuhauser
# [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
root6652  0.0  2.3 19108 11340  ??  Ss   10:30AM   0:00.93 
/usr/local/sbin/httpd
www31670  0.0  2.6 20628 13028  ??  S 1:46PM   0:00.73 
/usr/local/sbin/httpd
www34625  0.0  5.0 32260 24736  ??  S 2:09PM   0:00.68 
/usr/local/sbin/httpd
www34734  0.0  2.9 21808 14200  ??  S 2:10PM   0:00.42 
/usr/local/sbin/httpd
www34735  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

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



[PHP] ChangeLog PHP 5.2.0 - Fileupload

2006-11-04 Thread Christian Heinrich

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

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



Re: [PHP] Protecting Streaming Audio

2006-11-04 Thread Ed Lazor
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


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



Re: [PHP] ChangeLog PHP 5.2.0 - Fileupload

2006-11-04 Thread Rasmus Lerdorf
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

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



[PHP] postgreSQl and images

2006-11-04 Thread Alain Roger

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.


Re: [PHP] ChangeLog PHP 5.2.0 - Fileupload

2006-11-04 Thread Ed Lazor

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



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



Re: [PHP] setlocale madness... please help!

2006-11-04 Thread Jochem Maas
Roman Neuhauser wrote:
 # [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?

there is no simple way to determine if the locale was set because setlocale() 
is returning
false even when a locale has been successfully set, given that for each 
langauge I have a list
of locales (to be able to handle different server/OS setups) I can never be 
sure which locale
in the list was actually set - now I suppose you could check the output of a 
locale aware function
to see if the output is in the desired locale BUT this would mean having to 
have some know output
to check against for each locale - that sounds like a recipe for messy, 
horrible (and quite
likely brittle if not unreliable) code.


  
   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:

ok, wow - I'm definitely going to have a play with this when I have a
quite moment! nice one Roman! thank you.

 
 #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
 

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



Re: [PHP] Finding user's timezone

2006-11-04 Thread Dotan Cohen

On 03/11/06, Richard Lynch [EMAIL PROTECTED] wrote:

On Fri, November 3, 2006 6:09 am, Dotan Cohen wrote:
 How does php decide what timezone a user is in? Although I am in
 Haifa, Israel (GMT+2), when I go to a page with date(e) I get
 America/New_York displayed.

I could be wrong, but I think date('e') tells us where your SERVER is.

Or, more accurately, what time zone your server was configured to tell
us it lived in, no matter where it really lives in the physical world.


Yes, this seems to be the case.


 To confirm, could some users tell me what output they get on:
 http://what-is-what.com/what_time_is_it.php

 Let me know where you are in the world, and what timezone you are in
 to confirm/ deny the correctness of the php date function. Any advise
 on how to get the correct user's timezone would be most appreciated.

The function is correct.  Your understanding of its purpose is incorrect.


Figures. Just like calculus :)


date('e') is there so that the server can know what time zone *IT*
lives in, not what time zone *I* live in.

There is a reason why all those web forums let you set your time zone
in your preferences... :-)


Actually, there are those who have it already filled it. Take for example:
http://extremetracking.com/?reg


 Note: I have considered matching the users' IP against a database, but
 I'd prefer a simpler method, without the overhead of such a database.
 Thanks in advance.

Put it this way:

If the info you want about me and my computer isn't in this output:
?php phpinfo();?
then you probably cannot get it.


I figured that, and that was the first place I went looking.


If you *do* use the IP-country db, please allow a manual override for
those users whose IP is wrong in the db, or who are using some kind of
proxy for whatever reason.


Of course. That was in the original plan.

Dotan Cohen

http://what-is-what.com/what_is/love.html

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



Re: [PHP] Finding user's timezone

2006-11-04 Thread Jochem Maas
Dotan Cohen wrote:
 On 03/11/06, Richard Lynch [EMAIL PROTECTED] wrote:
 On Fri, November 3, 2006 6:09 am, Dotan Cohen wrote:
  How does php decide what timezone a user is in? Although I am in
  Haifa, Israel (GMT+2), when I go to a page with date(e) I get
  America/New_York displayed.

 I could be wrong, but I think date('e') tells us where your SERVER is.

 Or, more accurately, what time zone your server was configured to tell
 us it lived in, no matter where it really lives in the physical world.
 
 Yes, this seems to be the case.
 
  To confirm, could some users tell me what output they get on:
  http://what-is-what.com/what_time_is_it.php
 
  Let me know where you are in the world, and what timezone you are in
  to confirm/ deny the correctness of the php date function. Any advise
  on how to get the correct user's timezone would be most appreciated.

 The function is correct.  Your understanding of its purpose is incorrect.
 
 Figures. Just like calculus :)
 
 date('e') is there so that the server can know what time zone *IT*
 lives in, not what time zone *I* live in.

 There is a reason why all those web forums let you set your time zone
 in your preferences... :-)
 
 Actually, there are those who have it already filled it. Take for example:
 http://extremetracking.com/?reg

that server seems to be in holland (so am I) and it's not even giving me the 
correct
selection. my guess is they either set the TZ to the servers TZ or take some 
kind of guess (ip database?).

I would use javascript to determine the user's local TZ by comparing a timestamp
written into the javascript output with the current time given by the 
javascript Date object ...
you can then offer a pre-selected TZ value in a selectbox.

just a thought
 

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



Re: [PHP] str_replace on words with an array

2006-11-04 Thread Dotan Cohen

On 03/11/06, Richard Lynch [EMAIL PROTECTED] wrote:

On Fri, November 3, 2006 5:30 am, Dotan Cohen wrote:
 To all others who took part in this thread: I was unclear on another
 point as well, the issue of sql-injection. As I'm removing the
 symbols, signs, and other non-alpha characters from the query, I
 expect it to be sql-injection proof. As I wrong? ie, could an attacker
 successful inject sql if he has nothing but alpha characters at his
 disposal? I think not, but I'd like to hear it from someone with more
 experience than i.

In Latin1, ISO-8891-1 or whatever, plain old not-quite-ASCII, yeah,
you should be safe, I think...

I'm making *no* promises if your DB is configured to accept some
*other* character set, or the Bad Guy manages to trick it into
thinking it should be using that charset.


Yep, configured to accept UTF-8. Us Hebrew-speakers and our funny letters :)


Why the big deal about just calling mysql_real_escape_string() on your
data?


No biggie- I'm doing that too.


Or using prepared statements and that ilk?

Then you'd be 100% sure, and not worrying about it, eh?


Well, abstinence is not an option! I can't use prepared statements on
a full-text search.

Thanks, Richard. When is that Uranus office opening I've been
waiting almost five years!!

Dotan Cohen

nirot.com
http://what-is-what.com/what_is/ubuntu.html

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



[PHP] Pear

2006-11-04 Thread Alain Roger

Hi,

I would like to know if a lot of people use the PEAR system (packages +
core) to their web sites ?

One of my colleague uses it for company internal usage, but i wonder if my
web hoster will allow me to use and install it...because i have only a
webftp access to my business web site...

thanks a lot for your feedback.

Al.


Re: [PHP] Pear

2006-11-04 Thread Rory Browne

I don't know about the command line pear app, but I don't see how they
either (a) could, or (b) would want to, stop you from using the individual
pear libraries. Unless they scan all the files you ftp to your site.

Just upload the ones that you require.

Some downloadables that use the Pear libraries include the ones that they
require.

You do however have to remember to set the include_path before you include
any pear libs - preferably in a config file, but if your host is not being
nice, you can http://www.php.net/manual/en/function.set-include-path.php

WebFtp sounds sucky. I can't imagine it integrating well with any apps.

On 11/4/06, Alain Roger [EMAIL PROTECTED] wrote:


Hi,

I would like to know if a lot of people use the PEAR system (packages +
core) to their web sites ?

One of my colleague uses it for company internal usage, but i wonder if my
web hoster will allow me to use and install it...because i have only a
webftp access to my business web site...

thanks a lot for your feedback.

Al.




[PHP] phpPgAdmin

2006-11-04 Thread Alain Roger

Hi,

Is there a way via PhpPgAdmin to export/import the whole database info
(structure, schema, tables, index, sequences, data...) ?

Because i developed my database on local server and now i want to import to
my web hoster server...

and i do not want to recreate everything manually :-(

thx,

Al.


[PHP] Issue when inserting Slovak characters in database via PHP code

2006-11-04 Thread Alain Roger

Hi,

Sorry to cross post this mail but i'm not able to know from where comes my
issue.
I have a postgreSQL database in UNICODE (UTF-8 in v8.1.4 and UNICODE in
v8.0.1).

Via my web application i type a sentence in Slovak language and it is stored
into DB without any slovak characters. Instead of that, all particular
characters are replace with \303\251 or \303\206 or \304\314 and so on...

I was thinking that issue was coming from DB encryption but on 2 different
versions of DB (see above) i get the same result.
after, i was thinking that it was coming from my web browser, but even if i
setup character mode in central europe and Slovak language as default
coding...nothing change...i tried on IE and Firefox.

Last step, i tried to type directly from my PhpPgAdmin (direct typing
sentence there to DB), and i realize that when i click on save...the changes
appear in DB aswritten above (e.g. : \303\251,...)

My latest test was to write via PhpPgAdmin (directly to DB) the UNICODE of
slovak character contained within my sentence...so i used #253, #237 and
so on...
if i do that, those code are correctly saved into DB and when my PHP code
show web pages, all sentences are correct.

I can not imagine to write a special interface to convert slovak characters
to unicode everytime that user would like to type something new.
Something else must be badly setup...

Please, could you tell me where to search because i'm confused now...

thx.

Alain


Re: [PHP] postgreSQl and images

2006-11-04 Thread Børge Holen
On Saturday 04 November 2006 18:26, Alain Roger wrote:
 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.

No you don't.


 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 ?

depends.

 what is the purpose in this case to store image a bytea / large object ?

Keeping track af thousands of small images... in my case anyway.
makes it very easy to keep track of what you got'n not.

 moreover, how my php code will load image from DB and stored there as OID ?

the usual way?

 isn't it too much complex in comparison with just storing path and name of
 image ?

depends again. You wouldn't be in my shoes storing all those small images on 
the fs and then keep track of them. 

either you end up with a had as method of grouping them together, 
moreover you can have thousands of small files inside one dir with an id name 
to it, and yes the last one, thousands of directories with one file inside...

no, no and nono


 thanks a lot

 Al.

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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



Re: [PHP] phpPgAdmin

2006-11-04 Thread Nirmalya Lahiri
--- Alain Roger [EMAIL PROTECTED] wrote:

 Hi,
 
 Is there a way via PhpPgAdmin to export/import the whole database
 info
 (structure, schema, tables, index, sequences, data...) ?
 
 Because i developed my database on local server and now i want to
 import to
 my web hoster server...
 
 and i do not want to recreate everything manually :-(
 
 thx,
 
 Al.
 

Alain,
 Why are you not using pg_dump command from the shell prompt of
postgresql administrative user account for doing backup? If you do
so, then you can restore backuped data in any postgresql server.

Nirmalya Lahiri
(+91-94331-13536)


 

Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates 
(http://voice.yahoo.com)

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



[PHP] Trying to create an encryption method

2006-11-04 Thread John Meyer
I'm trying to create this encryption method for puzzles (nothing super
secret, just those cryptograms), but this seems to time out, can anybody
point out what I'm doing wrong here:

for ($i=1;$i=26;$i++) {
$normalAlphabet[$i] = chr($i);
}
//now, to shuffle

for ($j=1;$j=26;$j++) {
do {
$k = rand(1,26);
} while ($k == $j || (strlen(trim($normalAlphabet[$k])) === 0));
$arEncryptedAlphabet[$j] = $normalAlphabet[$k];
$normalAlphabet[$k] = ;
}
$arNormalString = str_split($normalzedString);
$encryptedString = ;
for ($i=0;$icount($arNormalString);$i++) {
if (ord($arNormalString[$i])=65 
ord($arNormalString[$i])=90) {
$encryptedString = $encryptedString .
$arEncryptedAlphabet[ord($arNormalString[$i]) - 64];
} else {
$encryptedString = $encryptedString . $arNormalString[$i];
}
}
return $encryptedString;
}

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



Re: [PHP] Trying to create an encryption method

2006-11-04 Thread Stut

John Meyer wrote:

for ($i=1;$i=26;$i++) {
$normalAlphabet[$i] = chr($i);
}
//now, to shuffle

for ($j=1;$j=26;$j++) {
do {
$k = rand(1,26);
} while ($k == $j || (strlen(trim($normalAlphabet[$k])) === 0));
$arEncryptedAlphabet[$j] = $normalAlphabet[$k];
$normalAlphabet[$k] = ;
}
$arNormalString = str_split($normalzedString);
$encryptedString = ;
for ($i=0;$icount($arNormalString);$i++) {
if (ord($arNormalString[$i])=65 
ord($arNormalString[$i])=90) {
$encryptedString = $encryptedString .
$arEncryptedAlphabet[ord($arNormalString[$i]) - 64];
} else {
$encryptedString = $encryptedString . $arNormalString[$i];
}
}
return $encryptedString;
}


Both the inner loop and the outer loop are using $i, meaning the outer 
loop will never end since it gets reset in the inner loop.


-Stut

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



Re: [PHP] Protecting Streaming Audio

2006-11-04 Thread Adam Gittins

Thanks. :)
That's an idea... Few questions. Grab the file and sendt it to someone, that
would work with a download but would it work with a streaming audio file,
because that has to be opened in realOne player or windows media player? I
was searching PHP.net documentation for a way of grabbing a file - what
function would be used?? Sorry about the silly questions..

Sincerely,
Adam




On 11/4/06, Ed Lazor [EMAIL PROTECTED] wrote:


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




[PHP] imagejpeg

2006-11-04 Thread Ron Piggott (PHP)
Is there a way to specify a font when using imagejpeg ?  Ron


Re: [PHP] 301 redirect returning 302 instead

2006-11-04 Thread ianevans
Chris,

I just posted this to php-internals in response to someone else, but this
tale of woe shows the problem:

header(HTTP/1.1 301 Moved Permanently);
header(Location: http://...;);
exit();

produces a 302.

header(Location: http://...;);
header(HTTP/1.1 301 Moved Permanently);
exit();

produces a 302.

header(Location: http://...,false,301);

produces a 302 and, for good luck,

header(Location: http://...,true,301);

produces a 302.

Everything's producing a 302. So you can see the dilemma.

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



Re: [PHP] Trying to create an encryption method

2006-11-04 Thread Paul Novitski

At 11/4/2006 08:15 PM, John Meyer wrote:

I'm trying to create this encryption method for puzzles (nothing super
secret, just those cryptograms), but this seems to time out, can anybody
point out what I'm doing wrong here:

for ($i=1;$i=26;$i++) {
$normalAlphabet[$i] = chr($i);
}
//now, to shuffle

for ($j=1;$j=26;$j++) {
do {
$k = rand(1,26);
} while ($k == $j || (strlen(trim($normalAlphabet[$k])) === 0));
$arEncryptedAlphabet[$j] = $normalAlphabet[$k];
$normalAlphabet[$k] = ;
}
$arNormalString = str_split($normalzedString);
$encryptedString = ;
for ($i=0;$icount($arNormalString);$i++) {
if (ord($arNormalString[$i])=65 
ord($arNormalString[$i])=90) {
$encryptedString = $encryptedString .
$arEncryptedAlphabet[ord($arNormalString[$i]) - 64];
} else {
$encryptedString = $encryptedString . $arNormalString[$i];
}
}
return $encryptedString;
}


At 11/4/2006 08:43 PM, Stut wrote:
Both the inner loop and the outer loop are using $i, meaning the 
outer loop will never end since it gets reset in the inner loop.



No, there is no loop nesting.  The OP's indenting is 
misleading.  Here's a reformatted version:



for ($i=1;$i=26;$i++)
{
$normalAlphabet[$i] = chr($i);
}

//now, to shuffle
for ($j=1;$j=26;$j++)
{
do
{
$k = rand(1,26);
}
while ($k == $j || (strlen(trim($normalAlphabet[$k])) === 0));

$arEncryptedAlphabet[$j] = $normalAlphabet[$k];
$normalAlphabet[$k] = ;
}

$arNormalString = str_split($normalzedString);
$encryptedString = ;

for ($i=0;$icount($arNormalString);$i++)
{
if (ord($arNormalString[$i])=65  
ord($arNormalString[$i])=90)

{
$encryptedString = $encryptedString . 
$arEncryptedAlphabet[ord($arNormalString[$i]) - 64];

}
else
{
$encryptedString = $encryptedString . 
$arNormalString[$i];

}
}
return $encryptedString;

}


The script spends eternity executing the do...while loop.  John, 
display your values at each loop while your code is running to see 
where your problem lies.


By the way, are you aware that chr(1) isn't 'A'?   It's hex(01).  'A' 
= hex(40) = dec(64).  Your array $normalAlphabet is not going to 
contain the alphabet the way it's written now.


Regards,
Paul

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