php-general Digest 3 Nov 2006 16:49:06 -0000 Issue 4438

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

php-general Digest 3 Nov 2006 16:49:06 - Issue 4438

Topics (messages 244121 through 244158):

Re: Mac PHP  MySQL
244121 by: Wee Keat Chin
244131 by: Ed Lazor
244136 by: Johan Martin

Re: WAP?
244122 by: Paul Scott
244125 by: tg-php.gryffyndevelopment.com
244138 by: Aarno Syvänen
244139 by: clive

Re: Viruses
244123 by: Rasmus Lerdorf
244126 by: tg-php.gryffyndevelopment.com
244127 by: tg-php.gryffyndevelopment.com
244128 by: tg-php.gryffyndevelopment.com
244129 by: tg-php.gryffyndevelopment.com

Re: why so slow?
244124 by: Mel
244137 by: clive

Use of substr()
244130 by: jekillen
244133 by: Chris
244135 by: Shuping Zhou

Why a script belong to user 'root' and the folder this script create is 
belonged to user 'nobody'?
244132 by: John.H
244134 by: Chris

Re: Frameworks
244140 by: Tony Marston

Re: str_replace on words with an array
244141 by: Dotan Cohen
244150 by: Roman Neuhauser

Finding user's timezone
244142 by: Dotan Cohen
244143 by: André Medeiros
244144 by: Stut
244145 by: Dotan Cohen
244146 by: Stut
244147 by: Dotan Cohen
244148 by: Stut
244151 by: Pawel Miroslawski
244155 by: Edward Kay

setlocale madness... please help!
244149 by: Jochem Maas
244153 by: Roman Neuhauser
244154 by: Jochem Maas
244157 by: Roman Neuhauser

open source zip code geographical drill down
244152 by: Ben Liu

File Repository / Managment Software
244156 by: Prathaban Mookiah

Re: How to Display a page while script runs?
244158 by: tedd

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

Ed,

Ed Lazor wrote:
I'm trying to configure and compile PHP 5.  The configure is failing to 
find the MySQL UNIX socket.  Any ideas?


I can't tell you why because I have not a clue, but why don't you try 
using MAMP (http://www.living-e.de/en/products/The-MAMP/download.php) 
and you can then switch between PHP4 AND 5?




--
Wee Keat Chin
---End Message---
---BeginMessage---
Very very nice.  I'm impressed with how easy everything was to  
setup.  I keep wondering why nobody at PHP/MySQL/Apache ever sets up  
stuff like this.



On Nov 2, 2006, at 8:40 PM, Wee Keat Chin wrote:


Ed,

Ed Lazor wrote:
I'm trying to configure and compile PHP 5.  The configure is  
failing to find the MySQL UNIX socket.  Any ideas?


I can't tell you why because I have not a clue, but why don't you  
try using MAMP (http://www.living-e.de/en/products/The-MAMP/ 
download.php) and you can then switch between PHP4 AND 5?




--
Wee Keat Chin

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

---End Message---
---BeginMessage---


On 02 Nov 2006, at 5:11 PM, Ed Lazor wrote:

I'm trying to configure and compile PHP 5.  The configure is  
failing to find the MySQL UNIX socket.  Any ideas?


./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-zlib \
--with-mysql=/usr/local/mysql \
--with-mysql-socket=/tmp




I had a similar problem and downloaded the tar version of the Mac OS  
X Mysql Server. Pointed --with-mysql= to the libraries and that  
folder and it worked. Decided to compile my own because the packages  
always seem to lag behind the released versions of the software. Also  
need both postgresql and mysql support.


Johan Martin
Catenare LLC
534 Pacific Ave
San Francisco, CA. 94133

Phone: (415) 834-9802
Fax: (415) 294-4495
http://www.catenare.com

AOL: catenarellc
Yahoo: martin_johan
GTalk: [EMAIL PROTECTED]

FreeWorldDialup  :716798  - http://www.freeworlddialup.com/
Gizmo Project: 747-627-9132 - http://www.gizmoproject.com/

http://www.linkedin.com/in/catenare
---End Message---
---BeginMessage---

On Thu, 2006-11-02 at 17:11 -0500, [EMAIL PROTECTED] wrote:

 http://www.w3schools.com/wap/

Also, don't forget hawhaw. I think it lives at http://www.hawhaw.de or
something.

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 
---End Message---
---BeginMessage---
Ah.. grat pull!  I did forget about that one.  Good stuff, thanks! And yes, 
that appears to be the address.

= = = Original message = = =

On Thu, 2006-11-02 at 17:11 -0500, [EMAIL PROTECTED] wrote:

 http://www.w3schools.com/wap/

Also, don't forget hawhaw. I think it lives at http://www.hawhaw.de or
something.

--Paul
All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm




Re: [PHP] WAP?

2006-11-03 Thread Aarno Syvänen

Perhaps you should start at http://www.kannel.org

Aarno

On 02 Nov 2006, at 22:02, Richard Lynch wrote:


So today I was tasked with converting a PHP SMS solution to a PHP WAP
solution...

My first attempt at running through a Zend tutorial from 2000 was of
limited success...

Apparently, the card tag has gone the way of the dodo or something...

Went looking for the php-wap list at php.net/mailing-lists.php and I
guess it's not there...

I'm about to make some more tries at all this after a meeting with the
boss, and will probably eventually stumble across a good
resource/site/list for PHP+WAP, but...

Anybody want to nudge me in the right general direction?...

Thanks!

--
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] WAP?

2006-11-03 Thread clive

Richard Lynch wrote:


Anybody want to nudge me in the right general direction?...


WAP 1.2.1 (not sure of the last version number ) is dead. Dont even 
bother with WAP 1.


WAP 2 is based on XHTML MP, thats xhtml mobile profile. Most newer 
phones are in some way compliant with WAP 2. What I mean is they will 
all display correctly, but things like file uploads aren't implemented 
on all phones.


Some people may say that WAP 1 was more compact and efficient than the 
latest version, but remember phones now use 3G, HSDPA etc instead of 
grps/edge, so I don't think thats a valid argument anymore, unless your 
accessing a wap page with brick.


clive



Thanks!



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



[PHP] Re: Frameworks

2006-11-03 Thread Tony Marston
It totally depends on what type of application you are writing, and what 
features you want out of the box so that you don't have to design and 
write them yourself.

For example, if you are writing an administrative web application and you 
want user authentication, dynamic menus, role based access control, audit 
logging without database triggers, built-in workflow, and 
internationalisation facilities then you might want to take a look at 
Radicore (http://www.radicore.org/)

As well as having all the above features it has a custom built Data 
Dictionary which can generate all the basic code for you. This enables you 
to start with nothing more than a database schema which you then import into 
the Data Dictionary, and from there you can press buttons to generate the 
database table classes and also buttons to generate the scripts to view and 
maintain those tables. All this without having to write a single line of 
code. It uses a catalog of transaction patterns which deal with single 
tables, one-to-many relationships and even many-to-many relationships.

There is a massive amount of documentation and sample code, and a tutorial 
is available at http://www.tonymarston.net/php-mysql/radicore-tutorial.html


-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I know this subject has been covered in the past, but my question is why
 use them?  I'm hoping to not create a religious war...  I see that
 frameworks would probably help you develop some things faster, but most
 of the time they don't do the things the way I would want them to work.
 If I did use one, it almost seems like I would use it to get through
 something  until I had time to do things the way I wanted/needed to do
 them.  There's a lot of talk about frameworks lately, and especially
 the Zend Framework, so I'd like to look into what it's all about.  I
 think I might be missing out the framework issue, so I'd like to hear
 other people's opinions.

 I do like the mail, pdf, and a few other parts of the Zend Framework.  I
 also like that it's more like a set of tools than a monolithic beast
 that would take a lot of memory just to load up into your application.

 Your thoughts?

 Thanks,
 Ray 

-- 
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-03 Thread Dotan Cohen

On 31/10/06, Larry Garfield [EMAIL PROTECTED] wrote:

From your original message, it sounds like you want to strip selected complete
words, not substrings, from a string for indexing or searching or such.
Right?


I think that was my mistake- not differentiating between the two.
Symbols and such I wanted to replace as substrings, yet noise words I
wanted to replace as words. Now that I've created two arrays, one with
symbols and one with noise words, things are on track.


Try something like this:

$string = The quick sly fox jumped over a fence and ran away;
$words = array('the', 'a', 'and');

function make_regex($str) {
  return '/\b' . $str . '\b/i';
}

$search = array_map('make_regex', $words);
$string = preg_replace($search, '', $string);
print $string . \n;


I was completely unaware of the array_map function. Thank you- that is
exactly what I needed.


What you really need to do that is to match word boundaries, NOT string
boundaries.  So you take your list of words and mutate *each one* (that's
what the array_map() is about) into a regex pattern that finds that word,
case-insensitively.  Then you use preg_replace() to replace all matches of
any of those patterns with an empty string.


Yep.


You were close.  What you were missing was the array_map(), because you needed
to concatenate stuff to each element of the array rather than trying to
concatenate a string to an array, which as others have said will absolutely
not work.


Yep.


I can't guarantee that the above code is the best performant method, but it
works. :-)


It certainly does. Of course I'm not using it exactly how you pasted
it, but you got me on track. Thank you very much.

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.

Thank you.

Dotan Cohen

http://what-is-what.com

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



[PHP] Finding user's timezone

2006-11-03 Thread Dotan Cohen

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.

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.

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.

Dotan Cohen

http://what-is-what.com/
http://essentialinux.com/

--
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-03 Thread André Medeiros

The result of that function would depend on where the server is
installed, not where the client is accessing it from, right?

On 11/3/06, Dotan Cohen [EMAIL PROTECTED] 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.

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.

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.

Dotan Cohen

http://what-is-what.com/
http://essentialinux.com/

--
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] Finding user's timezone

2006-11-03 Thread Stut

André Medeiros wrote:

The result of that function would depend on where the server is
installed, not where the client is accessing it from, right?


Close but no cigar! It's how the server is configured, not where it is 
installed. But essentially correct, the PHP datetime functions use the 
server datetime not the client.


-Stut


On 11/3/06, Dotan Cohen [EMAIL PROTECTED] 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.

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.

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.

Dotan Cohen

http://what-is-what.com/
http://essentialinux.com/

--
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] Finding user's timezone

2006-11-03 Thread Dotan Cohen

On 03/11/06, André Medeiros [EMAIL PROTECTED] wrote:

The result of that function would depend on where the server is
installed, not where the client is accessing it from, right?



That's not what php.net/date implies:
e: Timezone identifier
T : Timezone setting of this machine

If T is the timezone of the machine, then why have e if it's the same thing?

Dotan Cohen

http://technology-sleuth.com/
http://gmail-com.com/


Re: [PHP] Finding user's timezone

2006-11-03 Thread Stut

Dotan Cohen wrote:

On 03/11/06, André Medeiros [EMAIL PROTECTED] wrote:

The result of that function would depend on where the server is
installed, not where the client is accessing it from, right?



That's not what php.net/date implies:
e: Timezone identifier
T : Timezone setting of this machine

If T is the timezone of the machine, then why have e if it's the 
same thing?


They're not the same thing. The date_default_timezone_set() function 
allows you to change the timezone that PHP will use. The 'T' option 
bypasses that setting and gets the timezone as set on the machine.


Example: http://dev.stut.net/php/date.php

-Stut

--
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-03 Thread Dotan Cohen

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

You can use javascript:

var Today = new Date();
alert(Today.toString());

just parse the output using regexp



Hmm, I suppose that I could use Javascript, but I'd rather do it all
serverside. Any other ideas on behalf of the think-tank that is this
list?

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-03 Thread Stut

Dotan Cohen wrote:

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

You can use javascript:

var Today = new Date();
alert(Today.toString());

just parse the output using regexp



Hmm, I suppose that I could use Javascript, but I'd rather do it all
serverside. Any other ideas on behalf of the think-tank that is this
list?


There is no way to get the client date/time/timezone on the server-side 
unless you have something on the client to give it to you, Javascript 
being the obvious example.


-Stut

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



[PHP] setlocale madness... please help!

2006-11-03 Thread Jochem Maas
I have a debian box, I have just added a bunch of locales using the following 
command:

dpkg-reconfigure locales

before I added more locales the only installed locale was '[EMAIL PROTECTED]'.
my php version is 5.1.2, now for the madness:

1. running the command 'locale -a' returns the following [shortened] list:

C
de_DE
dutch
en_GB
nl_NL
[EMAIL PROTECTED]
nl_NL.iso88591
[EMAIL PROTECTED]
nl_NL.utf8
[EMAIL PROTECTED]
POSIX

2. running the following from the commandline returns en_GB (meaning the 
locale was set correctly)

php -r 'var_dump(set_locale(LC_ALL, en_GB))';

3. running the same code via the webbrowser (it is Apache2 and yes I have 
restarted it!) always returns FALSE
(meaning the locale was not set correctly)

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?
TIA.

-- 
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-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-30 21:18:33 +:
 Dotan Cohen wrote:
  $searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);
 
 Ok, this is what the compiler will see...
 
 $searchQuery=str_replace(^Array$,  , $searchQuery);
 
 Yes, that's a literal Array in the string. You cannot, and you should
 remember this, you cannot concatenate strings and arrays. What would you
 expect it to do?

DTRT? This is what e. g. zsh does with the right configuration:

[EMAIL PROTECTED] ~ 1108:0  echo x-{aa,bb,cc}-y
x-aa-y x-bb-y x-cc-y

-- 
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] Finding user's timezone

2006-11-03 Thread Pawel Miroslawski

Hmm... in $_SERVER array you get a client IP so You know client coutry. if
exists a list of ip numbers and coutries should be exists list coutries and
timezones too, so it should be easy. Eventually you may create short list of
this countries what will be visitors from (or only biggest coutries).


[PHP] open source zip code geographical drill down

2006-11-03 Thread Ben Liu

I'm trying to build some functionality commonly seen on the web where
a user enters a zip code and they are provided with a listing of
business or entity locations sorted by geographical distance. I've got
a client with a distributor network and I need to create something
like this for them. They want an end user to be able to enter a zip
code and have a list of closest distributors be listed. Anyone know of
any open source, free code to get this done. I have a zip code
database and can perform a query on it and return the relevant
records. I can even associate distributors with certain zip codes, but
the whole geographical distance thing is beyond me. Anybody do this
before and have advice? Thanks for any guidance here.

Regards,

Ben

--
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-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-11-03 14:51:39 +0100:
 1. running the command 'locale -a' returns the following [shortened] list:
 
 C
 de_DE
 dutch
 en_GB
 nl_NL
 [EMAIL PROTECTED]
 nl_NL.iso88591
 [EMAIL PROTECTED]
 nl_NL.utf8
 [EMAIL PROTECTED]
 POSIX
 
 2. running the following from the commandline returns en_GB (meaning
 the locale was set correctly)
 
   php -r 'var_dump(set_locale(LC_ALL, en_GB))';
 
 3. running the same code via the webbrowser (it is Apache2 and yes I
 have restarted it!) always returns FALSE (meaning the locale was not
 set correctly)

what happens if you run locale -a from apache?

 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.

-- 
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] setlocale madness... please help!

2006-11-03 Thread Jochem Maas
hi Roman,

Roman Neuhauser wrote:
 # [EMAIL PROTECTED] / 2006-11-03 14:51:39 +0100:
 1. running the command 'locale -a' returns the following [shortened] list:

 C
 de_DE
 dutch
 en_GB
 nl_NL
 [EMAIL PROTECTED]
 nl_NL.iso88591
 [EMAIL PROTECTED]
 nl_NL.utf8
 [EMAIL PROTECTED]
 POSIX

 2. running the following from the commandline returns en_GB (meaning
 the locale was set correctly)

  php -r 'var_dump(set_locale(LC_ALL, en_GB))';

 3. running the same code via the webbrowser (it is Apache2 and yes I
 have restarted it!) always returns FALSE (meaning the locale was not
 set correctly)
 
 what happens if you run locale -a from apache?

ah, I did check this. doing ?php system('locale -a'); ? in a webpage
produces the same list as running it on the commandline.

 
 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.



 

-- 
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-03 Thread Edward Kay
 Hmm... in $_SERVER array you get a client IP so You know client coutry. if
 exists a list of ip numbers and coutries should be exists list
 coutries and
 timezones too, so it should be easy. Eventually you may create
 short list of
 this countries what will be visitors from (or only biggest coutries).


The IP address isn't very reliable though. Many global corporations only
have a couple of external gateways through which all traffic goes. A user in
the UK could very well have their visable IP address located in the US.

Edward

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



[PHP] File Repository / Managment Software

2006-11-03 Thread Prathaban Mookiah
Hello,

Is there a open source file repository / managment software written in PHP ?

I need to setup a file repository where everyone working in my group can 
share their files in an organized manner. I am talking about something like 
phpBB, but with file handling capabilities.

Thanks in advance.

-- 
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-03 Thread Roman Neuhauser
# [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:
 
  C
  de_DE
  dutch
  en_GB
  nl_NL
  [EMAIL PROTECTED]
  nl_NL.iso88591
  [EMAIL PROTECTED]
  nl_NL.utf8
  [EMAIL PROTECTED]
  POSIX
 
  2. running the following from the commandline returns en_GB (meaning
  the locale was set correctly)
 
 php -r 'var_dump(set_locale(LC_ALL, en_GB))';
 
  3. running the same code via the webbrowser (it is Apache2 and yes I
  have restarted it!) always returns FALSE (meaning the locale was not
  set correctly)
  
  what happens if you run locale -a from apache?
 
 ah, I did check this. doing ?php system('locale -a'); ? in a webpage
 produces the same list as running it on the commandline.

ok then

  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.

So, before you go off recompiling mod_php with a few printf() and
perror() calls here and there, you should find out whether it's PHP
or Apache that makes the call fail. Try a simple CGI script, does
locale manipulation succeed there?

-- 
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] How to Display a page while script runs?

2006-11-03 Thread tedd

At 4:46 PM -0500 11/2/06, Chris wrote:

I have a php script which takes maybe 15-20 seconds to run, however until it
completes a blank web page is displayed to the user. Is there a way/method
which would enable me to give some feedback to the user while the script is
running so the blank page is not displayed?

Best,
Chris


Chris:

Use two scripts -- it will work.

The first to display a page, like so:

http://xn--ovg.com/a/wait.php

And then have that script run your second script like so:

ob_clean();
include('second.php');
exit(0);

hth's

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

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



[PHP] in_array() related problem

2006-11-03 Thread tamcy

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



Re: [PHP] Finding user's timezone

2006-11-03 Thread André Medeiros

I second that. My company has an IP address on the mainland which is
our internet gateway, but on the azorean islands the time zone is
different.



On 11/3/06, Edward Kay [EMAIL PROTECTED] wrote:

 Hmm... in $_SERVER array you get a client IP so You know client coutry. if
 exists a list of ip numbers and coutries should be exists list
 coutries and
 timezones too, so it should be easy. Eventually you may create
 short list of
 this countries what will be visitors from (or only biggest coutries).


The IP address isn't very reliable though. Many global corporations only
have a couple of external gateways through which all traffic goes. A user in
the UK could very well have their visable IP address located in the US.

Edward

--
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] Closing a connection to browser without exiting the script

2006-11-03 Thread Eric Butera

On 11/1/06, David Négrier [EMAIL PROTECTED] wrote:

Hello there,

I'm having a somewhat unusual question here, and I cannot find any way
to solve it.

I have a PHP page that displays a message, and then, performs a very
long operation. Note that it displays the message first.
I do not intend to give some feedback to the user when the operation is
done.

I've seen I can use ignore_user_abort() to prevent the user from
stopping the ongoing operation, but that solves only part of my problem.
Because as long as the page is not fully loaded, the mouse cursor in the
user's browser is showing a watch.

So ideally, what I would like is to be able to close the connection from
the server-side, but without using the exit() function, so my script
keeps running afterwards.

I know I could use a system() call to launch another process to do the
processing, but I would like to avoid doing that, because there are many
variables in the context that I cannot easily pass in parameter.

I also tried to use the register_shutdown_function() to perform my
operation after the page is displayed but since PHP 4.1.0, the
connection is closed after the function is called

Would any of you have an idea on how I could close that connection?

Thanks a lot,
David
www.thecodingmachine.com

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




If you haven't gone with any of the listed methods yet you could use
fsockopen with a timeout value to accomplish your goal.

frontend.php:
?php
$fp = fsockopen(localhost, 80);
fwrite($fp, GET /long_processing_script.php HTTP/1.0\r\n\r\n);
stream_set_timeout($fp, 1);
echo done!;
?

long_processing_script.php:
?php
ignore_user_abort();
set_time_limit(0);
// do stuff here
?

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



[PHP] Iterating over parallel arrays using each()

2006-11-03 Thread Brian Salomaki
I looked for a little while and didn't find any elegant solutions for 
doing this, so first if you have alternate suggestions for the right 
way to do this, I'd love to hear them.  I'm working with a big form to 
allow a user to make a change to many database rows at the same time. 
The results are getting passed to a PHP script to do the updates, as 
three different HTML arrays (i.e., input name='var1[]').  While I 
could do a normal for loop and just go through each array by its 
numerical index, the first thing I tried was using each() on all three 
arrays.  After seeing some weird results, I made a shorter test script 
that illustrates the same problem I've been having.


The problem seems to be that when each() is called multiple times on 
different arrays within the same expression, only the last call to 
each() assigns its variable correctly.  (The other two print_r 
statements within the loop show up as the '1's before the array is printed.)


Any thoughts on why this is happening?  Is it a bug, or am I just 
expecting PHP/while/each to do things that they're not actually supposed 
to do?


-brian



--- Code ---


?php
$letters = array('a','b','c');
$numbers = array(1,2,3);
$bigletters = array('A','B','C');

echo \n\nOutside of the loop\n\n;

$let = each($letters);
$num = each($numbers);
$cap = each($bigletters);

print_r($let);
print_r($num);
print_r($cap);

echo \n\nInside the loop\n\n;

reset($letters);
reset($numbers);
reset($bigletters);

while($let = each($letters)  $num = each($numbers) 
$cap = each($bigletters)) {
print_r($let);
print_r($num);
print_r($cap);
echo brbr\n;
}

?

--
--- Output ---
--

Outside of the loop

Array
(
[1] = a
[value] = a
[0] = 0
[key] = 0
)
Array
(
[1] = 1
[value] = 1
[0] = 0
[key] = 0
)
Array
(
[1] = A
[value] = A
[0] = 0
[key] = 0
)


Inside the loop

11Array
(
[1] = A
[value] = A
[0] = 0
[key] = 0
)
brbr
11Array
(
[1] = B
[value] = B
[0] = 1
[key] = 1
)
brbr
11Array
(
[1] = C
[value] = C
[0] = 2
[key] = 2
)
brbr

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



[PHP] Re: Encoding PC-850

2006-11-03 Thread Nisse Engström
On Mon, 30 Oct 2006 16:21:58 +0100, [EMAIL PROTECTED] wrote:

 I need to be able to encode text to PC-850 but I have big trouble
 finding out info about this encoding. Does it even exist? I get a few
 google hits, but nothing useful. Any idea of how I can convert for
 example an UTF-8 string or an ISO-8859-1 to this PC-850 format? 

Microsoft's cp850:

  http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP850.TXT

IBM's cp850 differs from the above in 3 places:

  http://www.unicode.org/Public/MAPPINGS/VENDORS/IBM/readme.txt


  --nfe

-- 
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-03 Thread Curt Zirzow

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.

Curt.

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

On Wed, November 1, 2006 5:53 pm, Curt Zirzow wrote:
 On 11/1/06, steve [EMAIL PROTECTED] wrote:
 On 11/1/06, Daevid Vincent [EMAIL PROTECTED] wrote:
  Personally I'm unsure. I would like to think that Zend is smart
 enough to
  realize M$ tactics of embrace/extend and will not allow that to
 happen.

 MS added a FastCGI module to IIS. Thats the big thing.

 They demo'd it at the zend conference with IIS7 on vista (installed on
 a macbook pro), there is also a bunch of work zend has done to improve
 speed.. the non improved php5 version benched like 30 requests/sec,
 the zend patched  version did over 100 requests/sec.

 Then they demo'd the kernel cache; 6500 requests/sec. (and no i didn't
 typo and add an extra zero).

Could you expand the term kernel cache to a formal name so I know if
that's an MS technology I don't care about, or a general Zend
technology that might apply to LAMP, which I'd be interested in
reading more about?

Thanks.

Cuz, frankly, 6500 per sec is nice, but not at the expense of Windows
and its inherent out-of-the-box instability versus the years of
l'arnin' I'd have to do to get a stable Win box.

I don't even host my own sites -- I'd much rather pay some other guy
$20/mo per site to let them have the 4am pager and reading every
security bulletin to figure out what matters.  And that's on LAMP!



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



Re: [PHP] why so slow?

2006-11-03 Thread Richard Lynch
On Thu, November 2, 2006 3:01 pm, Alan Milnes wrote:
 Robin Vickery wrote:
 include(http://www.squareinch.net/include/misc.inc;);
 Don't call files .inc - call them .inc.php if you really must have the
 inc somewhere, that way the Web Server will actually treat it as a php
 file and not display your details to the world if accessed directly.

So...

A Bad Guy can surf to them, and your PHP code gets executed completely
out of context, which you have never ever ever done any QA work on to
see what effect that would have...

Or, you could put your .inc files outside the web tree, and set
http://php.net/include_path correctly, and then the Bad Guy cannot
surf to them at all.

And you can name them .inc or .class or .dingdongthewickedwitchisdead
for all the difference it will make from a technical stand-point.

IMHO, the second option is much better.

YMMV

-- 
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] preg_split

2006-11-03 Thread Google Kreme

OK, I have this file:

web stuff
?php
  $CID_FILE= 'vonage.callers';
  $lines=file($CID_FILE);
  foreach ($lines as $line) {
 $cid=preg_split('^([^,]+),\s?(.*)', $line, -1,  
PREG_SPLIT_DELIM_CAPTURE);


  }
 ?
web stuff

the trouble is, $cid is empty.  The actual file has lots of print  
lines, so I know that $lines is an array with each line for $CID_FILE  
as one element of the array and that $line gets the data from a  
single array element correctly.


What I want is for each line to be an array, split at the first  
comma.  The regex works in BBEdit, where I can search for


^([^,]+),\s?(.*)

and replace with

\2 \1

and it does the right thing, over and over, so the regex is not the  
issue.  It's something that I am not doing right/understanding in  
preg_split.  I've also tried:


 $cid=preg_split('^([^,]+),', $line);
 $cid=preg_split('^([^,]+),\s?(.*)', $line, PREG_SPLIT_DELIM_CAPTURE);
 $cid=preg_split('^[^,]+,', $line, -1);
 $cid=preg_split('^[^,]+,', $line);

The actual code with the extra printing is here:

http://akane.covisp.net/~kreme/vonage.phps
http://akane.covisp.net/~kreme/vonage.php

and the sample data is

http://akane.covisp.net/~kreme/vonage.callers


--
No one ever thinks of themselves as one of Them. We're always one of  
Us. It's Them that do the bad things.


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



Re: [PHP] open source zip code geographical drill down

2006-11-03 Thread Leonard Burton

Hi Ben,


I'm trying to build some functionality commonly seen on the web where
a user enters a zip code and they are provided with a listing of
business or entity locations sorted by geographical distance.


I came up with a script to where it will do this, however, the big
question is how many distributors are there?

I can send my code to you but I have a premonition that it will
seriously choke up once the database becomes large.

Here are the steps

1) enter distributor addresses
2) find table with zip code and coordinates
3) find the formula that calculates straight line distances between
two sets of coordinates.
4) have LAMP perform its magic over the first 3.
5) then lather, rinse, and repeat.

The problem with my methodology is that it does not calculate road
distances.  Who knows how complex that would end up being.

Let me know what you find out and if you don't find out much else I
will be glad to dig out my code.  (but that might take a couple days).

--
Leonard Burton, N9URK
[EMAIL PROTECTED]

The prolonged evacuation would have dramatically affected the
survivability of the occupants.

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



Re: [PHP] WAP?

2006-11-03 Thread Richard Lynch
On Fri, November 3, 2006 3:14 am, clive wrote:
 Anybody want to nudge me in the right general direction?...

I appreciate everybody's help, I really do, but...

At this point, I've gone through about 10 Hello World tutorials,
altered my DOCTYPE and DTD several times, used 2 different handsets
and 2 different SDK thingies, and I've got nothing useful so far, in
terms of a working card deck with actual interaction...

The closest I can come is with a deck whose entire contents spew out
at once to a handset:

http://www.acousticdemo.com/nationalsystems/pizzahut.com/wap/index.wml

I must be doing something really stupid wrong here...

But what?

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



Re: [PHP] why so slow?

2006-11-03 Thread Jon Anderson

Richard Lynch wrote:

On Thu, November 2, 2006 3:01 pm, Alan Milnes wrote:
  

Don't call files .inc - call them .inc.php if you really must have the
inc somewhere, that way the Web Server will actually treat it as a php
file and not display your details to the world if accessed directly.




A Bad Guy can surf to them, and your PHP code gets executed completely
out of context, which you have never ever ever done any QA work on to
see what effect that would have...

Or, you could put your .inc files outside the web tree, and set
http://php.net/include_path correctly, and then the Bad Guy cannot
surf to them at all.

And you can name them .inc or .class or .dingdongthewickedwitchisdead
for all the difference it will make from a technical stand-point.

IMHO, the second option is much better.
Or you can .htaccess Deny From All them out... That's my preferred 
solution. It keeps the include tree near the code that accompanies it 
without risking anything even if they're called *.php.


jon

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



Re: [PHP] WAP?

2006-11-03 Thread tg-php
Doesn't look like the content type is set properly.  Here's another link that 
may be useful (from Zend themselves!) maybe that can help you out a bit.  
Content type and setting the xml version and DOCTYPE in the header are all 
fairly important.

Also, if I recall.. Firefox and/or Opera (not IE) will view the pages similar 
(but not identical) to how a cell phone does. Works nice if you just want 
quick/dirty script checking.

http://www.zend.com/zend/tut/wap.php?article=wapkind=tid=5191open=1anc=0view=1

-TG

= = = Original message = = =

On Fri, November 3, 2006 3:14 am, clive wrote:
 Anybody want to nudge me in the right general direction?...

I appreciate everybody's help, I really do, but...

At this point, I've gone through about 10 Hello World tutorials,
altered my DOCTYPE and DTD several times, used 2 different handsets
and 2 different SDK thingies, and I've got nothing useful so far, in
terms of a working card deck with actual interaction...

The closest I can come is with a deck whose entire contents spew out
at once to a handset:

http://www.acousticdemo.com/nationalsystems/pizzahut.com/wap/index.wml

I must be doing something really stupid wrong here...

But what?

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



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.


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



[PHP] Re: preg_split

2006-11-03 Thread Myron Turner

1. A preg_ expression has to have the delimeters '/^([^,]+),\s?(.*)/'.

2. Why do you need this complex expression to split at a comma? This 
'/,/' would do the trick.  And even simpler

explode(',', $line);

Also your regex ^([^,]+) asks the perl regex parser to find the 
beginning of a line at which there is one or more instances of NO Comma. 
 That is, [^ ] is a negation, so that [^0-9] means do not match any 
numbers.


Again, the rest of your regex asks for a match for anything else that 
follows 0 or 1 spaces, presumably the rest of the line.
So that any possible split would gobble up everything after the first 
instance in which the beginning of a line did not start with a comma, 
which would mean that you would get null results.


3. Is there a reason why you are using the flag PREG_SPLIT_DELIM_CAPTURE?


Regular expressions are always tricky, so I hope the above comments are 
not totally out to lunch!


Google Kreme wrote:

OK, I have this file:

web stuff
?php
  $CID_FILE= 'vonage.callers';
  $lines=file($CID_FILE);
  foreach ($lines as $line) {
 $cid=preg_split('^([^,]+),\s?(.*)', $line, -1, 
PREG_SPLIT_DELIM_CAPTURE);


  }
 ?
web stuff

the trouble is, $cid is empty.  The actual file has lots of print lines, 
so I know that $lines is an array with each line for $CID_FILE as one 
element of the array and that $line gets the data from a single array 
element correctly.


What I want is for each line to be an array, split at the first comma.  
The regex works in BBEdit, where I can search for


^([^,]+),\s?(.*)

and replace with

\2 \1

and it does the right thing, over and over, so the regex is not the 
issue.  It's something that I am not doing right/understanding in 
preg_split.  I've also tried:


 $cid=preg_split('^([^,]+),', $line);
 $cid=preg_split('^([^,]+),\s?(.*)', $line, PREG_SPLIT_DELIM_CAPTURE);
 $cid=preg_split('^[^,]+,', $line, -1);
 $cid=preg_split('^[^,]+,', $line);

The actual code with the extra printing is here:

http://akane.covisp.net/~kreme/vonage.phps
http://akane.covisp.net/~kreme/vonage.php

and the sample data is

http://akane.covisp.net/~kreme/vonage.callers


--No one ever thinks of themselves as one of Them. We're always one of 
Us. It's Them that do the bad things.



--

_
Myron Turner
http://www.mturner.org/XML_PullParser/

--
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-03 Thread Robert Cummings
On Fri, 2006-11-03 at 10:36 -0800, 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.

Looks to me like a static cache. Once PHP produces the content based on
the URL parameters, subsequent requests just return the previously
created content. Nothing special to see here.

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.  |
`'

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



[PHP] PEAR - LOG

2006-11-03 Thread Sr. Paulo Ricardo
Ola pessoal.

Uso o PEAR em algumas coisas.

 

Mas realmente estou quebrando a cabeça nesse LOG.

 

Que troço complicado.

Alguém já tentou usá-lo e poderia me mandar exemplos, manual ou algo do
tipo?

Ate a documentação dele eu não encontrei muita coisa.

 

http://pear.php.net/package/Log/

 

Valeu ai galera;

 

 

Att,

'É um orgulho ter você como nosso cliente'

 
Paulo Ricardo 
Programador (Desenvolvedor)
 
ArgoHost.net
Hospedagem Web com Facilidade
 http://www.argohost.net/ http://www.argohost.net
Suporte Telefônico: (85) 3264-9944 / (11) 4063-4844
E-mail:  mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]

 



Re: [PHP] in_array() related problem

2006-11-03 Thread Richard Lynch
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




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



Re: [PHP] open source zip code geographical drill down

2006-11-03 Thread Richard Lynch
On Fri, November 3, 2006 9:00 am, Ben Liu wrote:
 I'm trying to build some functionality commonly seen on the web where
 a user enters a zip code and they are provided with a listing of
 business or entity locations sorted by geographical distance. I've got
 a client with a distributor network and I need to create something
 like this for them. They want an end user to be able to enter a zip
 code and have a list of closest distributors be listed. Anyone know of
 any open source, free code to get this done. I have a zip code
 database and can perform a query on it and return the relevant
 records. I can even associate distributors with certain zip codes, but
 the whole geographical distance thing is beyond me. Anybody do this
 before and have advice? Thanks for any guidance here.

You can get the Lat/Long for the zips through any of the following
resources:
TIGER data (old, but you can just import it and be done)
Google Maps
Yahoo! Maps

I'm sure there are more free resources, and I *know* there are $$$ ones.

Doing the distance search gets a bit hairy in the trigonometry, but
you can find formulas on-line.  *OR* if you only want the closest
distributor, you can just use the overly-simplistic (and much faster)
formula:
abs(lat1 - lat2) + abs(long1 - long2)
This is a Cartesian distance, and will go haywire at the North and
South poles -- Like you give a [bleep] at the North and South poles...

The zips table is HUMUNGOUS.  For performance reasons, I *strongly*
encourace you to:

alter table distributors add latitude default null;
alter table distributors add longitude default null;

Now set up a cron job that finds NULL latitudes in distributors
LIMIT 100, and then looks up the zip in the zips table, and copies the
lat/long over to the distributors table.

Also be sure that if a zip changes on a distributor, that you NULL out
the lat/long -- You can do it with a fancy trigger, or with your
business logic in your application.

Your basic search logic then becomes:
require 'connect.inc';
$_CLEAN['zip'] = preg_replace('/^[0-9]{5}$/', '', $_REQUEST['zip']);
$q = select latitude, longitude from zips where zip = '$_CLEAN[zip]';
$r = mysql_query($q, $connection);
list($lat, $long) = mysql_fetch_row($r);
$q = select id, abs(latitude - $lat) + abs(longitude - $long) as close;
$q .=  from distributors ;
$q .=  order by close ;
$q .=  limit 1 ; //or more, to give user some freedom of choice


Yes, I chose to do 2 queries for the lat/long lookup and distance
search instead of a JOIN between zips.

The zips table has ~O(100K) entries.

Your distributors table has, whatever, maybe ~O(1K) entries.

You do *not* want to JOIN 100K X 1K and slam the db.

You *might* have more luck than I did if your db is fancy enough and
you can use LatLong as a geo-spatial datatype and *if* your DB has the
ability to index a LatLong geo-spatial datatype...

But in *my* experience, you just end up killing the DB if you try
that, and 2 dirt-simple queries with mindless indexed fields was way
more better.

YMMV

There are *much* fancier ways to do this with a million-dollar budget.

They might even be better solutions.

If you have a fair amount of time on your hands, and want a REALLY
cool interface for your client, you can do a Yahoo! maps mash-up in
about an hour of work, just from reading Rasmus' tutorial on his toys
page.
http://toys.lerdorf.com/

If you've got several more hours to spare, providing a Google map as
an alternative is also quite do-able, though not as quick-n-easy as
you have to walk the XML output in Javascript by hand instead of
letting a built-in function do it for you.

Then you just need to spend a day or two figuring out how to get the
dang maps to zoom in and focus on the zip code point you want.  That
has a couple gotchas I've just stumbled through myself, but can't
really express yet in short form...

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



Re: [PHP] Finding user's timezone

2006-11-03 Thread Richard Lynch
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.

 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.

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... :-)

 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.

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.

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



Re: [PHP] Finding user's timezone

2006-11-03 Thread Richard Lynch




On Fri, November 3, 2006 6:55 am, Dotan Cohen wrote:
 On 03/11/06, André Medeiros [EMAIL PROTECTED] wrote:
 The result of that function would depend on where the server is
 installed, not where the client is accessing it from, right?


 That's not what php.net/date implies:
 e: Timezone identifier
 T : Timezone setting of this machine

 If T is the timezone of the machine, then why have e if it's the
 same thing?

One of them outputs, like -4 and one of them outputs, like, New
York/America.

They're both providing the same info, in different formats.

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



Re: [PHP] str_replace on words with an array

2006-11-03 Thread Richard Lynch
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.

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

Or using prepared statements and that ilk?

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

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



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

2006-11-03 Thread Richard Lynch
On Fri, November 3, 2006 12:45 am, John.H wrote:
 My php program whose owner is root:

 ?
 mkdir('test',0777);
 ?

 and the folder 'test'  's owner is 'nobody'?
 why?should the folder belong to 'root' too?
 By the way,the safe mode is turned on.

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

You're running this as CLI, right?...

Cuz if you are running your web server as root, shut it down NOW. :-)

(Anybody reading this who is running their server as root and actually
knows what they are doing: You ain't the one asking the above
question, now, are you?...)

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



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

2006-11-03 Thread Jochem Maas
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 :-)

 
 So, before you go off recompiling mod_php with a few printf() and
 perror() calls here and there, you should find out whether it's PHP
 or Apache that makes the call fail. 

compiling php is not a problem but I'm not really at the stage I feel
I cando anything useful by changing the C source - although your remark
does inspire somewhat.

   Try a simple CGI script, does
 locale manipulation succeed there?

I'd have to look up how to setup a php-cgi ...
not really in the mood on friday evening :-)

anyway thanks for your input, you just saved me from an evening of brain pain 
;-)


 

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



Re: [PHP] Use of substr()

2006-11-03 Thread Richard Lynch
On Fri, November 3, 2006 12:33 am, jekillen wrote:
 I am scratching my head over the following:
 I have written code that is supposed to format text
 sent from a form in a textarea form element.
 This text does not have new lines added if
 the text is allowed to automatically wrap to the
 next line. I want to automatically add new lines
 to this input at appropriate locations.

Why in the world would you want to screw up my text by adding newlines?!

Sigh.

Okay, if you insist, just use the PHP builtin function:
http://php.net/wordwrap

 What does the browser actually do when it automatically wraps textarea
 input?

In the bad old days, you had the WRAP attribute, which was largely
abused and misused by people who failed to understand it.

There was really no excuse for anything other than WRAP=virtual in
the first place.

 What could explain the scrambled result?

Sorry.

I'm not tracing through your code to find the bugs...

You're on the right track printing out the start/end numbers though.

Start with a line of text that is very short and should not wrap.

Then with one long enough to wrap just ONCE.

Build your test suite up from there.

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



Re: [PHP] Viruses

2006-11-03 Thread Richard Lynch
On Fri, November 3, 2006 12:13 am, [EMAIL PROTECTED] wrote:
 Unfortunate reality of today's online universe.

Email has become increasingly less useful over the last few years...

I don't even *do* email anymore -- I do email triage.

:-)

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



Re: [PHP] How to Display a page while script runs?

2006-11-03 Thread Richard Lynch
?php
echo pWaiting 20 seconds for a web page is rather inexcusable,
isn't it?/p\n;
echo str_repeat(' ', 2048);
flush();
//rest of script here
?


On Thu, November 2, 2006 3:46 pm, Chris wrote:

 I have a php script which takes maybe 15-20 seconds to run, however
 until it
 completes a blank web page is displayed to the user. Is there a
 way/method
 which would enable me to give some feedback to the user while the
 script is
 running so the blank page is not displayed?

 Best,
 Chris

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




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



Re: [PHP] why so slow?

2006-11-03 Thread Richard Lynch
On Fri, November 3, 2006 1:12 pm, Jon Anderson wrote:
 Or you can .htaccess Deny From All them out... That's my preferred
 solution. It keeps the include tree near the code that accompanies it
 without risking anything even if they're called *.php.

Until you upgrade Apache and forget to enable .htaccess.

Or somebody turns .htaccess off for performance.

Or Junior Programmer wipes out your .htaccess file.

Or you tar up the site to move it to Production, but your tar command
doesn't do .htaccess unless you work at it.

Or Junior Programmer over-rides your .htaccess in a lower-level .htaccess

All of the above are simply too easy to happen in the real world, imho.

You have to work a lot harder at it to intentionally expose a
non-web-tree file to the web, even on accident.

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



RE: [PHP] open source zip code geographical drill down

2006-11-03 Thread Daevid Vincent
 If you've got several more hours to spare, providing a Google map as
 an alternative is also quite do-able, though not as quick-n-easy as
 you have to walk the XML output in Javascript by hand instead of
 letting a built-in function do it for you.
 
 Then you just need to spend a day or two figuring out how to get the
 dang maps to zoom in and focus on the zip code point you want.  That
 has a couple gotchas I've just stumbled through myself, but can't
 really express yet in short form...

I do this on a site I'm developing, and the shortcut I took was simply to
plug in the address in the URL and launch it into a new JS window.open()
using the features attributes. Popup blockers don't prevent that and it
looks very clean. Plus it's trivial to do and gives you all the fancy Google
maps zooming, directions and such...

http://maps.google.com/maps?f=dhl=ensaddr=1234+Some+St,+SomeTown,+WA+98765
daddr=1000+Another+Pl+SomeTown+WAie=UTF8z=11om=1

http://www.webreference.com/js/tutorial1/features.html


DÆVID  

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



Re: [PHP] why so slow?

2006-11-03 Thread Jon Anderson

Richard Lynch wrote:

On Fri, November 3, 2006 1:12 pm, Jon Anderson wrote:
  

Or you can .htaccess Deny From All them out... That's my preferred
solution. It keeps the include tree near the code that accompanies it
without risking anything even if they're called *.php.



Until you upgrade Apache and forget to enable .htaccess.

Or somebody turns .htaccess off for performance.

Or Junior Programmer wipes out your .htaccess file.

Or you tar up the site to move it to Production, but your tar command
doesn't do .htaccess unless you work at it.

Or Junior Programmer over-rides your .htaccess in a lower-level .htaccess

All of the above are simply too easy to happen in the real world, imho.

You have to work a lot harder at it to intentionally expose a
non-web-tree file to the web, even on accident.
  
These problems are trivial to overcome, and not PHP related. You can 
argue it if you want, but there are upsides and downsides to both 
solutions...I can easily come up with parallel problems with the 
non-web-tree solution even though it is obviously a very good solution 
to a common problem. I really don't see the point in having two 
professionals butt heads over something so trivial. I'd much rather 
just have both solutions in my arsenal, and use whichever one fits the 
situation best.


jon

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



Re: [PHP] WAP?

2006-11-03 Thread Richard Lynch
On Fri, November 3, 2006 1:19 pm, [EMAIL PROTECTED] wrote:
 Doesn't look like the content type is set properly.

The tutorial referenced says:
Content-type: text/vnd.wap.wml

wget is telling me I have:
 1 HTTP/1.1 200 OK
 2 Date: Fri, 03 Nov 2006 22:10:56 GMT
 3 Server: Apache/2.0.59 (FreeBSD) PHP/5.1.4 mod_ssl/2.0.59
OpenSSL/0.9.7d
 4 X-Powered-By: PHP/5.1.4
 5 Content-Length: 266
 6 Keep-Alive: timeout=15, max=100
 7 Connection: Keep-Alive
 8 Content-Type: text/vnd.wap.wml

LiveHTTPHeaders in FF is pretty much the same.

Ooh!
Is that HTTP/1.1 header messing me up?
What should it be?
Can I even change that?
I mean... It's *still* going out over HTTP, right?...

Is WAP 2.0 supposed to use a different Content-type?  Sure haven't run
across that in my reading so far...

A quick Google seems to indicate the Content-type does not change from
1.x to 2.x
http://www.ericsson.com/mobilityworld/sub/open/technologies/wap/about/wap_on_application_server

The DTD URL is valid, afaict...
Though I confess, I wouldn't really know an invalid DTD from a valid
DTD if they both ran up and bit me...

I was, early on, using text/plain if your ACCEPT headers from the
browser didn't have vnd.wap in them *somewhere*, but I ripped that
out, and it's always just text/vnd.wap.xml now, no matter what your
User-Agent...

 Also, if I recall.. Firefox and/or Opera (not IE) will view the pages
 similar (but not identical) to how a cell phone does. Works nice if
 you just want quick/dirty script checking.

For me, at least, FireFox is just prompting to download.

I then try to load that seemingly-valid output file into Nokia's NMB
4.0 and/or their NMI 4.1, and get nada.

Surfing on a Motorola v3c actual handset with their OpenWave
built-in browser thingie, I get the whole cardstack as one page.

Surfing on a BlackBerry 7520 with Nextel's default NOL browser, I get
500 Internal Server error - 500 Web service problem. Please contact
the service provider.  AFAIK, I *am* the service provider, and I don't
have a clue what went wrong.

I did have DocumentIndex instead of DirectoryIndex in my .htaccess
for about 20 minutes from 10:35 to 10:58 (Portland OR time) so
apologies to anybody who tried it in the time-frame.  I always screw
that one up.

My source code is dirt simple, with nothing more than the Zend
Tutorial referenced in it, really...

http://www.zend.com/zend/tut/wap.php?article=wapkind=tid=5191open=1anc=0view=1

I suppose my webhost's Apache might be doing something quite different
based on the ACCEPT line?

Doesn't seem to...

-bash-2.05b$ wget
http://acousticdemo.com/nationalsystems/pizzahut.com/wap/index.wml
--server-response   --14:17:49-- 
http://acousticdemo.com/nationalsystems/pizzahut.com/wap/index.wml
   = `index.wml.3'
Resolving acousticdemo.com... done.
Connecting to acousticdemo.com[67.139.134.211]:80... connected.
HTTP request sent, awaiting response...
 1 HTTP/1.1 200 OK
 2 Date: Fri, 03 Nov 2006 22:17:49 GMT
 3 Server: Apache/2.0.59 (FreeBSD) PHP/5.1.4 mod_ssl/2.0.59
OpenSSL/0.9.7d
 4 X-Powered-By: PHP/5.1.4
 5 Content-Length: 266
 6 Keep-Alive: timeout=15, max=100
 7 Connection: Keep-Alive
 8 Content-Type: text/vnd.wap.wml

100%[=]
266  259.77K/sETA 00:00

14:17:49 (259.77 KB/s) - `index.wml.3' saved [266/266]

-bash-2.05b$ cat index.wml.3
?xml version=1.0?
!DOCTYPE wml PUBLIC -//WAPFORUM//DTD WML 2.0//EN
http://www.wapforum.org/dtd/wml20.dtd; 
vml
card id=no1 title=Card 1
pHello World!/p
/card

card id=no2 title=Card 2
pWelcome to our WAP Tutorial!/p
/card
/vml
-bash-2.05b$

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



Re: [PHP] Re: preg_split

2006-11-03 Thread Google Kreme

On 03 Nov 2006, at 12:32 , Myron Turner wrote:


1. A preg_ expression has to have the delimeters '/^([^,]+),\s?(.*)/'.


Ah, well, that would make a difference.

http://akane.covisp.net/~kreme/vonage.phps
http://akane.covisp.net/~kreme/vonage.php

 $cid[$i]=preg_split('/^([^,]+),\s?(.*)/', $line, -1,  
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);


Now it has an extra field in the array, but at least it is splitting  
the line.


[6] = Array
(
[0] = (555) 555-5556
[1] = Maggie, Fred, and George Cell
[2] =

)


2. Why do you need this complex expression to split at a comma?  
This '/,/' would do the trick.  And even simpler

explode(',', $line);


Because I need to split only at the FIRST comma.



Also your regex ^([^,]+) asks the perl regex parser to find the  
beginning of a line at which there is one or more instances of NO  
Comma.  That is, [^ ] is a negation, so that [^0-9] means do not  
match any numbers.


Yes, and ^([^,]+) means, From the start of the line, get 1 or more  
characters that are not a comma and put them in \01.


So that any possible split would gobble up everything after the  
first instance in which the beginning of a line did not start with  
a comma, which would mean that you would get null results.


No, that's not right at all.  As I said, the regex works (and has  
been tested in other ways).




3. Is there a reason why you are using the flag  
PREG_SPLIT_DELIM_CAPTURE?


I tried many different variations.


--
It's better to burn out than it is to rust
  -- Neil Young as quoted by Kurt Cobain

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



[PHP] Re: WAP?

2006-11-03 Thread Richard Lynch
I *knew* it was something stupid!

vml is not the same at all as wml

I need new glasses! :-(

SORRY!!!

I *do* want to thank everybody who helped me out!

And the W3C validator wins the prize for being the *most* helpful for
this paritcular idiot.

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



Re: [PHP] Re: preg_split

2006-11-03 Thread Stut
Google Kreme wrote:
 On 03 Nov 2006, at 12:32 , Myron Turner wrote:
 2. Why do you need this complex expression to split at a comma? This
 '/,/' would do the trick.  And even simpler
 explode(',', $line);
 
 Because I need to split only at the FIRST comma.

explode(',', $line, 2);

http://php.net/explode

-Stut

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



[PHP] Re: Iterating over parallel arrays using each()

2006-11-03 Thread Brian Salomaki
Thanks to a reply off-list, I figured out that this was an issue of 
operator precedence ( over =).


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



Re: [PHP] Re: preg_split

2006-11-03 Thread Myron Turner
I see, I miusunderstood, read too quickly, and thought you simply wanted 
to split at the comma.  The suggestion that you use exlode(',',2) makes 
sense to me.  You could do the same with

 preg_split ($pattern, $string, 2)
Or for a more complex regex, there's preg_match, which puts the results 
in an array of matches.  That would to me seem the more logical choice 
if you want to save parenthesized data. But I'm an old Perl programmer 
and there we don't have the extras that PHP gives to preg_split.  So, in 
Perl it's split() for splitting and m// for matching.  Perhaps in 
programming as in art, less is more.


Cheers,

Myron

Google Kreme wrote:




2. Why do you need this complex expression to split at a comma? This 
'/,/' would do the trick.  And even simpler

explode(',', $line);


Because I need to split only at the FIRST comma.



Also your regex ^([^,]+) asks the perl regex parser to find the 
beginning of a line at which there is one or more instances of NO 
Comma.  That is, [^ ] is a negation, so that [^0-9] means do not match 
any numbers.


Yes, and ^([^,]+) means, From the start of the line, get 1 or more 
characters that are not a comma and put them in \01.



--

_
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

--
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-03 Thread Richard Lynch
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



Re: [PHP] Re: preg_split

2006-11-03 Thread Google Kreme

On 03 Nov 2006, at 15:56 , Stut wrote:

Google Kreme wrote:

On 03 Nov 2006, at 12:32 , Myron Turner wrote:

2. Why do you need this complex expression to split at a comma? This
'/,/' would do the trick.  And even simpler
explode(',', $line);


Because I need to split only at the FIRST comma.


explode(',', $line, 2);

http://php.net/explode


Heh.  This is why I post here.  Last time I posted I was told to use  
preg_split.  Explode is simpler.


BTW, preg_split works it I change $line to trim($line), which is  
needed for explode too, else the 'name' part ends up with a return  
embedded.


Code as it stands now:
?php
  $CID_FILE= '/home/user/caller_id.txt';
  echo ' h1PHP Caller ID Info for procmail ('.$CID_FILE.') / 
h1';

  $lines=file($CID_FILE);
  $i=0;
  foreach ($lines as $line) {
 $cid[$i] = explode(',',trim($line),2);
 // This line works too
 // $cid[$i]=preg_split('/^([^,]+),\s?(.*)/', trim($line),  
-1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

 $i=$i+1;
  }
  echo 'form action='.  $_SERVER['PHP_SELF'] .' method=post';
  echo 'table';
  $i=1;
  foreach ($cid as $line) {
 $count = substr('00'.$i,-3);
 echo '
 tr
   td
 label for=phone'.$count.'Phone #'.$count.':/label
 input name=phone'.$count.' maxlength=14 value='.  
$line['0'].' /

   /td
   td
 label for=name'.$count.'Name #'.$count.':/label
 input name=name'.$count.' maxlength=34 value='.  
$line['1'].' /

 /tr';
 $i=$i+1;
  }
  echo '/table
  input name=submit type=submit tabindex=99 a /
  /form
   ';
?

Course, there's nothing there to process the submit as yet. And yes,  
I will combine these into one for-each  and a function call.



--
A marriage is always made up of two people who are prepared to swear  
that only the other one snores.


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



[PHP] Make install dumps core with PHP 5.2.0

2006-11-03 Thread Mendonce, Kiran (STSD)
On HP-UX Itanium, make install of PHP 5.2.0 dumps core while installing
pear. The php cli gets built fine, but when it is executed with the
install-pear-nozlib.phar as argumnt (part of the installation), it fails
with a SIGSEGV.

I noticed that someone has already filed a bug against this (#39252).
The trace is as follows :
HP gdb 5.2.03 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.2.03 (based on GDB) is covered by the
GNU General Public License. Type show copying to see the conditions to
change it and/or distribute copies. Type show warranty for
warranty/support.
..
Core was generated by `php'.
Program terminated with signal 11, Segmentation fault.
SEGV_MAPERR - Address not mapped to object
#0  0x403d7470:1 in zend_do_fcall_common_helper_SPEC ()
at /user/kiranm/php-5.2.0/Zend/zend_vm_execute.h:150
150 EX_T(opline-result.u.var).var.ptr_ptr =
EX_T(opline-result.u.var).var.ptr;
(gdb) bt
#0  0x403d7470:1 in zend_do_fcall_common_helper_SPEC ()
at /user/kiranm/php-5.2.0/Zend/zend_vm_execute.h:150
#1  0x403d70c0:0 in ZEND_DO_FCALL_SPEC_CONST_HANDLER ()
at /user/kiranm/php-5.2.0/Zend/zend_vm_execute.h:1681
#2  0x404974a0:0 in execute ()
at /user/kiranm/php-5.2.0/Zend/zend_vm_execute.h:92
#3  0x403d7ec0:0 in zend_do_fcall_common_helper_SPEC ()
at /user/kiranm/php-5.2.0/Zend/zend_vm_execute.h:234
#4  0x403db060:0 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
at /user/kiranm/php-5.2.0/Zend/zend_vm_execute.h:322
#5  0x404974a0:0 in execute ()
at /user/kiranm/php-5.2.0/Zend/zend_vm_execute.h:92
#6  0x409525b0:0 in zend_execute_scripts ()
at /user/kiranm/php-5.2.0/Zend/zend.c:1096
#7  0x40951b20:0 in php_execute_script ()
at /user/kiranm/php-5.2.0/main/main.c:1756
#8  0x4019d4c0:0 in main ()
at /user/kiranm/php-5.2.0/sapi/cli/php_cli.c:1027


Any idea how this can be resolved ?

Thanks and Regards,
Kiran

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



Re: [PHP] Mac PHP MySQL

2006-11-03 Thread Ed Lazor
Thanks Johan, I appreciate the info.  I ended up going with MAMP as a  
quick solution.



On Nov 2, 2006, at 11:29 PM, Johan Martin wrote:



On 02 Nov 2006, at 5:11 PM, Ed Lazor wrote:

I'm trying to configure and compile PHP 5.  The configure is  
failing to find the MySQL UNIX socket.  Any ideas?


./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-zlib \
--with-mysql=/usr/local/mysql \
--with-mysql-socket=/tmp




I had a similar problem and downloaded the tar version of the Mac  
OS X Mysql Server. Pointed --with-mysql= to the libraries and that  
folder and it worked. Decided to compile my own because the  
packages always seem to lag behind the released versions of the  
software. Also need both postgresql and mysql support.


Johan Martin
Catenare LLC
534 Pacific Ave
San Francisco, CA. 94133

Phone: (415) 834-9802
Fax: (415) 294-4495
http://www.catenare.com

AOL: catenarellc
Yahoo: martin_johan
GTalk: [EMAIL PROTECTED]

FreeWorldDialup  :716798  - http://www.freeworlddialup.com/
Gizmo Project: 747-627-9132 - http://www.gizmoproject.com/

http://www.linkedin.com/in/catenare





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



[PHP] Protecting Streaming Audio

2006-11-03 Thread Adam Gittins

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] Protecting Streaming Audio

2006-11-03 Thread Adam Gittins

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