Re: [PHP] Re: How to re-order an array

2006-06-13 Thread Paul Novitski

At 07:53 PM 6/11/2006, jekillen wrote:

I force the user to have javascript enabled


Oops.

Unless you're working IT in a penal colony, I suspect that what you 
really mean is that you choose to serve broken pages or no content at 
all to users who don't have JavaScript enabled, whether by choice or 
network requirement or software availability.


It's an interesting decision, excluding browsers with JavaScript 
turned off.  I can see making it in cases of specialty audiences, 
such as the aforementioned penal colony, customized intranets, and 
others where all of the user agents are not only predictable but 
legislatable.  For public websites, I feel we need to set barriers to 
entrance only when necessary -- and when is that? -- consciously and 
deliberately, focusing not so much on Look at the cool things we can 
do with JavaScript! but Whom shall we exclude from this 
site?  Look a user in the eye, say, You can't come in, and reflect 
on how cool that is.


Although I still love to write client-side script, most of the energy 
I used to expend on JavaScript I now devote to PHP.  The server is 
the great leveler of the playing field, rendering our pages 
accessible to all user agents *if* our designs are sufficiently 
clever.  These days I mostly add JavaScript to perform functions that 
are already performed server-side by PHP, purely for the advantage of 
speed, but my best pages perform perfectly with JavaScript turned off.


Aside, the whole client-side/server-side debate depends on today's 
internet connection response time being as slow as it is.  In a few 
years a seemingly sexy technology like Ajax, which appears useful 
today in pages so heavy with content that whole-page reloads seem 
onerous, will be one of the unbelievable jokes of yesteryear, like 
RAM measured in kilobytes, 8 floppy discs, and punch cards.


Regards,
Paul 


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



[PHP] Dettach problem

2006-06-13 Thread grape

Hi all,

I would like run a php-script via CLI which outputs some information to 
stdout, and then go into background. I use code similar to this to fork 
and to dettach the child I/O from the TTY (some error handling removed 
to improve readability)


?
echo Hello from parent\n;

if(pcntl_fork()) {
  exit;
}

posix_setsid();

fclose( STDIN );
fclose( STDOUT );
fclose( STDERR );

if(pcntl_fork()) {
  exit;
}

echo This message should NOT go to stdout of parent process\n;
?

It works fine using PHP version 5.0.4, but when using PHP version 5.1.2 
the output of the child (This message) goes to stdout of the 
parent process. So if I do:


php test.php output

Using PHP 5.1.2, the file contains:

---
Hello from parent
This message should NOT go to stdout of parent process
---

Can anybody explain this?
I run FreeBSD 6.0-RELEASE...

Regards,

Grape

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



[PHP] Help with some clever bit operations

2006-06-13 Thread Niels
Hi,

I have a problem I can solve with some loops and if-thens, but I'm sure it
can be done with bit operations -- that would be prettier. I've tried to
work it out on paper, but I keep missing the final solution. Maybe I'm
missing something obvious...

The problem: A function tries to update an existing value, but is only
allowed to write certain bits.

There are 3 variables:
A: the existing value, eg. 10110101
B: what the function wants to write, eg. 01011100
C: which bits the function is allowed to write, eg. 

With these examples, 1000 should be written.

How do I combine A, B and C to get that result?


Thanks,
Niels

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



[PHP] Re: Help with some clever bit operations

2006-06-13 Thread Barry

Niels schrieb:

Hi,

I have a problem I can solve with some loops and if-thens, but I'm sure it
can be done with bit operations -- that would be prettier. I've tried to
work it out on paper, but I keep missing the final solution. Maybe I'm
missing something obvious...

The problem: A function tries to update an existing value, but is only
allowed to write certain bits.

There are 3 variables:
A: the existing value, eg. 10110101
B: what the function wants to write, eg. 01011100
C: which bits the function is allowed to write, eg. 

With these examples, 1000 should be written.

How do I combine A, B and C to get that result?


addition probably?

Btw. the result of the addition would be : 111010101

Barry

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

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread David Tulloh
The example starting values
$existing = 181; # = 10110101
$new = 92; # = 01011100
$mask = 15; # = 

Get the bits that will be changed
$changing = $new  $mask; # = 12 = 1100

Get the bits that won't be changed
$staying = $existing  ~$mask; # = 176 = 1011

Combine them together
$result = $changing ^ $staying; # = 188 = 1000


David

Niels wrote:
 Hi,
 
 I have a problem I can solve with some loops and if-thens, but I'm sure it
 can be done with bit operations -- that would be prettier. I've tried to
 work it out on paper, but I keep missing the final solution. Maybe I'm
 missing something obvious...
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.
 
 How do I combine A, B and C to get that result?
 
 
 Thanks,
 Niels
 

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Jochem Maas
Niels wrote:
 Hi,
 
 I have a problem I can solve with some loops and if-thens, but I'm sure it
 can be done with bit operations -- that would be prettier. I've tried to
 work it out on paper, but I keep missing the final solution. Maybe I'm
 missing something obvious...
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.

My brain needs a crutch when trying doing this kind of thing
(normally I only write hex number literally when dealing with bitwise stuff -
the conversion stuff still makes my head spin) - this is what this table is for:

128 64 32 16 8 4 2 1
1   0  1  1  0 1 0 1
0   1  0  1  1 1 0 0
0   0  0  0  1 1 1 1

and then I did this - hopefully it shows what you can/have to do:

?php

// set some values
$oldval = 128 + 32 + 16 + 4 + 1; // 10110101
$update = 64 + 16 + 8 + 4;   // 01011100
$mask   = 8 + 4 + 2 + 1; // 

// do a 'bit' of surgery ...
$add= $mask  $update;
$keep   = ~$mask  $oldval;
$newval = $keep | $add;

// show what happened
var_dump(
str_pad(base_convert($oldval, 10, 2), 8, 0),
str_pad(base_convert($update, 10, 2), 8, 0),
str_pad(base_convert($mask, 10, 2), 8, 0),
str_pad(base_convert($add, 10, 2), 8, 0),
str_pad(base_convert($keep, 10, 2), 8, 0),
str_pad(base_convert($newval, 10, 2), 8, 0)
);

?

 
 How do I combine A, B and C to get that result?
 
 
 Thanks,
 Niels
 

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



[PHP] Seeking recommendations for use of include()

2006-06-13 Thread Dave M G

PHP List,

Up until now, in order to get all the functions and classes I need in my 
scripts, I have always made a file called includes.php that contains a 
series of include() statements for all of the files that I want to 
include. Then I just include that one file at the top of all my PHP scripts.


This system works okay, but I thought it would be better to have a 
consistent naming standard, and use some kind wild card or loop to 
include all the files I want. That way I can change, add, and remove 
files a little easier.


All the files I want to include end with either .class, or with 
_fns.php. (fns stands for functions.)


It seems that wildcard characters are not supported in the include() 
function. Some experiments and a search on the web seem to confirm this.


So then I thought what I need to do is use the readdir() function 
somehow, and make an array of all files ending in .class or 
_fns.php, and then make a while or foreach loop to include every 
required file.


I couldn't quite figure out how to do that, but in any case I wondered 
if running this loop at the start of every single PHP script might be 
unnecessary overhead. After all, the list of included files will only 
change when I work on the system. It's not going to vary at all based on 
any kind of user input or in standard usage of my web site.


What would be the recommended way of including files that will change as 
I work on the system? Do most people create a function to detect the 
included files, or do most people make a static list that they edit by hand?


--
Dave M G

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Jochem Maas
David Tulloh wrote:
 The example starting values
 $existing = 181; # = 10110101
 $new = 92; # = 01011100
 $mask = 15; # = 
 
 Get the bits that will be changed
 $changing = $new  $mask; # = 12 = 1100
 
 Get the bits that won't be changed
 $staying = $existing  ~$mask; # = 176 = 1011
 
 Combine them together
 $result = $changing ^ $staying; # = 188 = 1000

heck, Davids 'result' line is more correct than mine I believe -
he uses an XOR operation where I used an OR operation - both have the same
result because the set of bits that are 'on' in the first operand are mutually
exclusive to the set of bits that are 'on' in the second operand.

 
 
 David
 
 Niels wrote:
 Hi,

 I have a problem I can solve with some loops and if-thens, but I'm sure it
 can be done with bit operations -- that would be prettier. I've tried to
 work it out on paper, but I keep missing the final solution. Maybe I'm
 missing something obvious...

 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.

 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 

 With these examples, 1000 should be written.

 How do I combine A, B and C to get that result?


 Thanks,
 Niels

 

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



RE: [PHP] Help with some clever bit operations

2006-06-13 Thread Ford, Mike
On 13 June 2006 10:31, Niels wrote:

 Hi,
 
 I have a problem I can solve with some loops and if-thens,
 but I'm sure it
 can be done with bit operations -- that would be prettier.
 I've tried to
 work it out on paper, but I keep missing the final solution. Maybe
 I'm missing something obvious... 
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.
 
 How do I combine A, B and C to get that result?

First use  (bitwise-and) to mask out bits the function is not allowed to write:

$b  $c // result is 1100 given above inputs

Then mask the bits that the function will write out of the original value - 
negate the mask and use  again:

$a  ~$c // result is 1011

Then combine the two using | (bitwise-or):

($a  ~$c) | ($b  $c) // result is 1001


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Help with some clever bit operations

2006-06-13 Thread Niels
On Tuesday 13 June 2006 12:32, Ford, Mike wrote:

 On 13 June 2006 10:31, Niels wrote:
 
 Hi,
 
 I have a problem I can solve with some loops and if-thens,
 but I'm sure it
 can be done with bit operations -- that would be prettier.
 I've tried to
 work it out on paper, but I keep missing the final solution. Maybe
 I'm missing something obvious...
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.
 
 How do I combine A, B and C to get that result?
 
 First use  (bitwise-and) to mask out bits the function is not allowed to
 write:
 
 $b  $c // result is 1100 given above inputs
 
 Then mask the bits that the function will write out of the original value
 - negate the mask and use  again:
 
 $a  ~$c // result is 1011
 
 Then combine the two using | (bitwise-or):
 
 ($a  ~$c) | ($b  $c) // result is 1001
 [snip]

Thanks! I appreciate your effort!

Regards,
Niels

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Niels
On Tuesday 13 June 2006 12:22, Jochem Maas wrote:

 Niels wrote:
 Hi,
 
 I have a problem I can solve with some loops and if-thens, but I'm sure
 it can be done with bit operations -- that would be prettier. I've tried
 to work it out on paper, but I keep missing the final solution. Maybe I'm
 missing something obvious...
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.
 
 My brain needs a crutch when trying doing this kind of thing
 (normally I only write hex number literally when dealing with bitwise
 stuff - the conversion stuff still makes my head spin) - this is what this
 table is for:
 
 128 64 32 16 8 4 2 1
 1   0  1  1  0 1 0 1
 0   1  0  1  1 1 0 0
 0   0  0  0  1 1 1 1
 
 and then I did this - hopefully it shows what you can/have to do:
 
 ?php
 
 // set some values
 $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
 $update = 64 + 16 + 8 + 4; // 01011100
 $mask   = 8 + 4 + 2 + 1;   // 
 
 // do a 'bit' of surgery ...
 $add= $mask  $update;
 $keep   = ~$mask  $oldval;
 $newval = $keep | $add;
 
 // show what happened
 var_dump(
 str_pad(base_convert($oldval, 10, 2), 8, 0),
 str_pad(base_convert($update, 10, 2), 8, 0),
 str_pad(base_convert($mask, 10, 2), 8, 0),
 str_pad(base_convert($add, 10, 2), 8, 0),
 str_pad(base_convert($keep, 10, 2), 8, 0),
 str_pad(base_convert($newval, 10, 2), 8, 0)
 );
 
 ?
 
 
 How do I combine A, B and C to get that result?
 
 
 Thanks,
 Niels



Thanks, I appreciate your effort! Working code with inlined pun -- very
nice!

Regards,
Niels

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Niels
On Tuesday 13 June 2006 12:18, David Tulloh wrote:

 The example starting values
 $existing = 181; # = 10110101
 $new = 92; # = 01011100
 $mask = 15; # = 
 
 Get the bits that will be changed
 $changing = $new  $mask; # = 12 = 1100
 
 Get the bits that won't be changed
 $staying = $existing  ~$mask; # = 176 = 1011
 
 Combine them together
 $result = $changing ^ $staying; # = 188 = 1000
 
 
 David
[snip]

Thank you very much, I appreciate it!

Niels

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



Re: [PHP] Re: How to re-order an array

2006-06-13 Thread tedd
At 11:26 PM -0700 6/12/06, Paul Novitski wrote:
Aside, the whole client-side/server-side debate depends on today's internet 
connection response time being as slow as it is.  In a few years a seemingly 
sexy technology like Ajax, which appears useful today in pages so heavy with 
content that whole-page reloads seem onerous, will be one of the unbelievable 
jokes of yesteryear, like RAM measured in kilobytes, 8 floppy discs, and 
punch cards.

Now, there's the way to think !

Don't confine yourself to the limitations of today, but rather open to the 
expectations of tomorrow.

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] GetText string not found

2006-06-13 Thread Ruben Rubio Rey

Hi,

I am using gettext to get a web page in several languages.

When gettext does not found an string, it shows the string.

Is it possible to detect when a string is not found, in order to advis me ?

Thanks in advance,
Ruben Rubio Rey

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Satyam


- Original Message - 
From: David Tulloh [EMAIL PROTECTED]

To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Tuesday, June 13, 2006 12:18 PM
Subject: Re: [PHP] Help with some clever bit operations



The example starting values
$existing = 181; # = 10110101
$new = 92; # = 01011100
$mask = 15; # = 

Get the bits that will be changed
$changing = $new  $mask; # = 12 = 1100

Get the bits that won't be changed
$staying = $existing  ~$mask; # = 176 = 1011

Combine them together
$result = $changing ^ $staying; # = 188 = 1000


David



Though the result is the same, logically a bitwise OR (|) would be more 
appropriate.  The bitwise  XOR flips bits which, since in this case one set 
of them is always 0 produces the same result.  The bitwise OR adds the bits.


An informal set of rules is:

, as a filter, extracts those bits where you put ones in the mask
 sets to zero those bits where you put zero in the mask
| sets bits
^ flips the bits where you put a one.

$evenodd   1 is true on odd numbers or otherwise tests for the rightmost 
bit.  Coupled with a right shift  allows you to loop through a set of 
bits.


for ($i=0;$i32;$i++) {
   if ($bitset  1) {
   echo bit $i is set;
   }
   $bitset = 1;
}

Anyway, avoid the most significant bit.  Since in PHP there are no unsigned 
integers, you might get some funny result if anything makes PHP do an 
automatic type conversion.


Satyam

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



[PHP] Setting headers for file download

2006-06-13 Thread Peter Lauri
Best group member,

This is how I try to push files to download using headers:

header(Content-type: $file_type);
header(Content-Disposition: attachment; filename=$filename); 
print $file;

It works fine in FireFox, but not that good in IE. I have been googled to
find the fix for IE, but I can not find it. Anyone with experience of this?

Best regards,
Peter Lauri

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



Re: [PHP] GetText string not found

2006-06-13 Thread Jochem Maas
Ruben Rubio Rey wrote:
 Hi,
 
 I am using gettext to get a web page in several languages.
 
 When gettext does not found an string, it shows the string.
 
 Is it possible to detect when a string is not found, in order to advis me ?

sure in a very simplistic manner;

function __($s)
{
$r = _($s);
if ($r === $s) logUntranslatedStr($s);

return $r;
}

but the php gettext extension does not seem to provide such a functionality
natively.

 
 Thanks in advance,
 Ruben Rubio Rey
 

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



Re: [PHP] Seeking recommendations for use of include()

2006-06-13 Thread tedd
At 7:22 PM +0900 6/13/06, Dave M G wrote:
PHP List,

Up until now, in order to get all the functions and classes I need in my 
scripts, I have always made a file called includes.php that contains a 
series of include() statements for all of the files that I want to include. 
Then I just include that one file at the top of all my PHP scripts.

This system works okay, but I thought it would be better to have a consistent 
naming standard, and use some kind wild card or loop to include all the files 
I want. That way I can change, add, and remove files a little easier.

All the files I want to include end with either .class, or with _fns.php. 
(fns stands for functions.)

It seems that wildcard characters are not supported in the include() function. 
Some experiments and a search on the web seem to confirm this.

So then I thought what I need to do is use the readdir() function somehow, and 
make an array of all files ending in .class or _fns.php, and then make a 
while or foreach loop to include every required file.

I couldn't quite figure out how to do that, but in any case I wondered if 
running this loop at the start of every single PHP script might be unnecessary 
overhead. After all, the list of included files will only change when I work 
on the system. It's not going to vary at all based on any kind of user input 
or in standard usage of my web site.

What would be the recommended way of including files that will change as I 
work on the system? Do most people create a function to detect the included 
files, or do most people make a static list that they edit by hand?

--
Dave M G


Dave:

I group my includes per functionality, such as all dB operations (config, open, 
close, etc.) go into a db include folder (db_inc) and so on. I don't make large 
files, but rather small files limited to a specific operations. That works for 
me -- but, only you can figure out what works for you.

As for your code, try this:

?php

$file_path = $_SERVER['DOCUMENT_ROOT']; // or whatever directory you 
want
$the_dir = opendir($file_path);

while ($file = readdir($the_dir))
{
if(eregi((\.pdf|\.html|\.htm|\.php|\.txt)$, $file))   // 
check the files extension:
{
$html[] = $file;
}
}

closedir($the_dir);

if($html == null)
{
die(No files in this directory!);
}

sort($html);
foreach($html as $html = $value)
{
echo (br/ $value);
}
?


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



Re: [PHP] php-html rendering

2006-06-13 Thread Ryan A


--- Larry Garfield [EMAIL PROTECTED] wrote:


clip 1
   that said it could take a week to figure out all
 the
   parameters. ;-)
 
/clip 1

...


/clip 2
 That's why I included the switches I did. :-)  I had
 to do something very 
 similar just last week. 

 ...
 
 -m means mirror.  That is, recurse to all links
 that don't leave the domain.  
 It's for exactly this sort of task.
 
 -k tells it to convert links.  That way if you have
 all absolute links in your 
 HTML output, it will mutate them for you to stay
 within the local mirror 
 you're creating.
 
 If you have GET queries in your pages (we did), then
 I recommend also using:
 
 --restrict-file-names=windows
 
 That will tell it to convert any blah?foo=bar links
 into [EMAIL PROTECTED], since 
 the first is not a valid filename in Windows.  I
 find that even on a Linux 
 box, the latter works better.

/clip 2

Hey,
Thanks for the explanation of the switches. 

One part that I dont really understand is:

 blah?foo=bar links
 into [EMAIL PROTECTED]

having a link such as [EMAIL PROTECTED] is not going to
work to link to the second document...right? (I have
not really tried it, but have never seen html like the
above)

And lastly, I read on another forum discussing wget
that there is a switch that converts the dynamic pages
to static WITH a .html/.htm extention; unfortunatly he
didnt give an example of how to do this, was he just
blowing smoke or is that true?

Thanks again,
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



Re: [PHP] Seeking recommendations for use of include()

2006-06-13 Thread Andrei


	Anyway when you include files by script (not scpecifying the order in 
which u include them) check out class inheritage and class usage in 
files you include. Classes that are inherited must be included first.


Andy


At 7:22 PM +0900 6/13/06, Dave M G wrote:

PHP List,

Up until now, in order to get all the functions and classes I need in my scripts, I have 
always made a file called includes.php that contains a series of include() 
statements for all of the files that I want to include. Then I just include that one file 
at the top of all my PHP scripts.

This system works okay, but I thought it would be better to have a consistent 
naming standard, and use some kind wild card or loop to include all the files I 
want. That way I can change, add, and remove files a little easier.

All the files I want to include end with either .class, or with _fns.php. (fns 
stands for functions.)

It seems that wildcard characters are not supported in the include() function. 
Some experiments and a search on the web seem to confirm this.

So then I thought what I need to do is use the readdir() function somehow, and make an array of all 
files ending in .class or _fns.php, and then make a while or foreach loop 
to include every required file.

I couldn't quite figure out how to do that, but in any case I wondered if 
running this loop at the start of every single PHP script might be unnecessary 
overhead. After all, the list of included files will only change when I work on 
the system. It's not going to vary at all based on any kind of user input or in 
standard usage of my web site.

What would be the recommended way of including files that will change as I work 
on the system? Do most people create a function to detect the included files, 
or do most people make a static list that they edit by hand?

--
Dave M G



Dave:

I group my includes per functionality, such as all dB operations 
(config, open, close, etc.) go into a db include folder (db_inc) and so 
on. I don't make large files, but rather small files limited to a 
specific operations. That works for me -- but, only you can figure out 
what works for you.


As for your code, try this:

?php

$file_path = $_SERVER['DOCUMENT_ROOT']; // or whatever directory you 
want
$the_dir = opendir($file_path);

while ($file = readdir($the_dir))
{
		if(eregi((\.pdf|\.html|\.htm|\.php|\.txt)$, $file))	// check the 
files extension:

{
$html[] = $file;
}
}

closedir($the_dir);

if($html == null)
{
die(No files in this directory!);
}

sort($html);
foreach($html as $html = $value)
{
echo (br/ $value);
}
?


hth's

tedd

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



[PHP] Please help me with a query

2006-06-13 Thread Jesús Alain Rodríguez Santos
First of all I'm sorry for my english I don't know speak very well, I will 
try to explain it, I hope you understain what I need.


I have two tables: centers and peoples, in table centers I have the centers 
values and in table peoples I have the peoples values and in table columns 
center the id corresponding the center.


db:
centers
id  nameccorreoc   telc
1 Cienfuegos  [EMAIL PROTECTED]  4534345
2   Havana [EMAIL PROTECTED] 4643765
3  Santiago[EMAIL PROTECTED]  3453453

peoples
idnamed   center  correod 
cargod
1 Albert  1   [EMAIL PROTECTED] 
sfgsdfgsdfgsdfg
2  Julio1  [EMAIL PROTECTED] 
sadfsgfdsfgfdsg
3 Sussan 2  [EMAIL PROTECTED] 
gjfhjfhjfhjfg
4 Peter2  [EMAIL PROTECTED] 
fgjhfgjgfjhjjghj


And the query and script to generate the tables for each centers list is:

$centers = mysql_query(SELECT namec FROM centers ORDER BY idc asc, 
$connect);


while ($centerss = mysql_fetch_array($centers, MYSQL_ASSOC)) {
  echo table border=1;
   echo tr;
   echo td width=265 height=20 align=center 
valign=middle.$centerss['namec']./td;
   echo td width=265 height=20 align=center valign=middlea 
href=mailto:.$centerss['correoc']..$centerss['correoc']./a/td;
   echo td width=265 height=20 align=center 
valign=middle.$centerss['telc']./td;

   echo /tr;
   echo /tablep/p;
}
mysql_free_result($centers);

That's generate one table with one row and three columns for each center, 
but, I would like to generate more rows and 3 columns in each table with the 
named, correod and cargod of peoples corresponding the center, I mean, print 
the centers values with the peoples corresponding this center, in one table 
each one.


I hope you understaind what I need, if not polease let me know.

regards Alain


--
Este mensaje ha sido analizado por MailScanner
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.

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



[PHP] SimpleXMLElement writing problem while in a reference

2006-06-13 Thread defragger
Hi all,
I found out (while playing with xpath()) that you cant edit the content of a 
node when you use a reference on a SimpleXMLElement object.
An example:
---
$xmlString = '?xml version=1.0 encoding=UTF-8? 
  container
   texte
text user=user1asdfasdfeorpqi/text
text user=user2oouzzrrzreorpqi/text
  /texte 
/container';

$xml = simplexml_load_string($xmlString);
$xml-texte-text[0] = 'newText'; // Works
$xml-texte-text[0]['user'] = 'newUser'; // Works
echo $xml-asXML() . \n;

$xml = simplexml_load_string($xmlString);
$xmlRef = $xml-texte-text[0]; // Creating a reference
$xmlRef['user'] = 'newUser'; // Works
$xmlRef = 'newUser'; // Doesnt Work!
echo $xml-asXML() . \n;
---
Am i doing something wrong. or is this a bug or what ?

Hope for some help

Bye
Georg Nagel

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



Re: [PHP] Please help me with a query

2006-06-13 Thread Jochem Maas
if you want to ask a question don't be so lazy as to
simply reply to a post in an existing thread - it's considered
rude.

send a new email.

Jesús Alain Rodríguez Santos wrote:

...

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



[PHP] Sending UTF-8 mail with mail()

2006-06-13 Thread Peter Lauri
How can I send UTF-8 mails with the mail() function. Right now I am doing:

mail('[EMAIL PROTECTED]', 'Subject', 'Message', 
From: The Sender [EMAIL PROTECTED] \n . 
Content-Type: text/plain; charset=utf-8 \n .
Content-Transfer-Encoding: 7bit\n\n)

The message is being sent, but the UTF-8 specific characters are not being
presented. Is there any fix on this?

The messages etc are coming from a form. Is it possible to set the charset
for the form?

/Peter

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



RE: [PHP] Please help me with a query

2006-06-13 Thread Jef Sullivan
Your query is wrong. You are selecting only one result yet you are 
referencing three. I suggest...

SELECT * FROM centers ORDER BY idc asc


Jef

-Original Message-
From: Jesús Alain Rodríguez Santos [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 13, 2006 8:49 AM
To: php-general@lists.php.net
Subject: [PHP] Please help me with a query

First of all I'm sorry for my english I don't know speak very well, I will 
try to explain it, I hope you understain what I need.

I have two tables: centers and peoples, in table centers I have the centers 
values and in table peoples I have the peoples values and in table columns 
center the id corresponding the center.

db:
centers
id  nameccorreoc   telc
1 Cienfuegos  [EMAIL PROTECTED]  4534345
2   Havana [EMAIL PROTECTED] 4643765
3  Santiago[EMAIL PROTECTED]  3453453

peoples
idnamed   center  correod 
cargod
1 Albert  1   [EMAIL PROTECTED] 
sfgsdfgsdfgsdfg
2  Julio1  [EMAIL PROTECTED] 
sadfsgfdsfgfdsg
3 Sussan 2  [EMAIL PROTECTED] 
gjfhjfhjfhjfg
4 Peter2  [EMAIL PROTECTED] 
fgjhfgjgfjhjjghj

And the query and script to generate the tables for each centers list is:

$centers = mysql_query(SELECT namec FROM centers ORDER BY idc asc, 
$connect);

while ($centerss = mysql_fetch_array($centers, MYSQL_ASSOC)) {
   echo table border=1;
echo tr;
echo td width=265 height=20 align=center 
valign=middle.$centerss['namec']./td;
echo td width=265 height=20 align=center valign=middlea 
href=mailto:.$centerss['correoc']..$centerss['correoc']./a/td;
echo td width=265 height=20 align=center 
valign=middle.$centerss['telc']./td;
echo /tr;
echo /tablep/p;
}
mysql_free_result($centers);

That's generate one table with one row and three columns for each center, 
but, I would like to generate more rows and 3 columns in each table with the 
named, correod and cargod of peoples corresponding the center, I mean, print 
the centers values with the peoples corresponding this center, in one table 
each one.

I hope you understaind what I need, if not polease let me know.

regards Alain


-- 
Este mensaje ha sido analizado por MailScanner
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.

-- 
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] php-html rendering

2006-06-13 Thread Larry Garfield
On Tuesday 13 June 2006 07:22, Ryan A wrote:

 Hey,
 Thanks for the explanation of the switches.

 One part that I dont really understand is:

  blah?foo=bar links
  into [EMAIL PROTECTED]

 having a link such as [EMAIL PROTECTED] is not going to
 work to link to the second document...right? (I have
 not really tried it, but have never seen html like the
 above)

Actually for me it didn't work until I did that conversion.  You're not 
sending an actual variable query, remember.  You're linking to a static file 
whose name on disk is [EMAIL PROTECTED], which is a valid filename, 
while blah?foo=bar is not (at least under Windows, although it didn't work 
for me under Unix either).  

 And lastly, I read on another forum discussing wget
 that there is a switch that converts the dynamic pages
 to static WITH a .html/.htm extention; unfortunatly he
 didnt give an example of how to do this, was he just
 blowing smoke or is that true?

man wget, and look for the -E option (aka --html-extension).

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



[PHP] Re: trapping fatal errors...?

2006-06-13 Thread Christopher J. Bottaro
Adam Zey wrote:

 Christopher J. Bottaro wrote:
 Hello,
 How can I trap a fatal error (like calling a non existant method,
 requiring
 a non existant file, etc) and go to a user defined error handler?  I
 tried set_error_handler(), but it seems to skip over the errors I care
 about.
 
 Thanks for the help.
 
 It is always safer to handle errors before they happen by checking that
 you're in a good state before you try to do something.
 
 For example, nonexistent files can be handled by file_exists().
 Undefined functions can be checked with function_exists().
 
 Regards, Adam Zey.

Well, I know that.

Sometimes unexpected errors happen.  We write hundreds of lines of code a
day.  Typos happen, I forget some includes, I type $d-appendCild() instead
of $d-appendChild().  It's all a part of the development process.

Our application makes extensive use of AJAX and JSON.  Sometimes we make an
AJAX request and expect a JSON object in return, but instead a fatal error
happens (DOMDocument::appendChid() does not exist), well now we get a JSON
error because the response headers were messed up by the fatal error.

That JSON error is useless.  We would rather see the real error as PHP would
have reported it on a simple webpage or command line.

Basically, we just want to trap all errors and reraise them as exceptions so
that our app's default exception handler can report them.

Thanks.

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



[PHP] Re: Sending UTF-8 mail with mail()

2006-06-13 Thread Barry

Peter Lauri schrieb:

How can I send UTF-8 mails with the mail() function. Right now I am doing:

mail('[EMAIL PROTECTED]', 'Subject', 'Message', 
From: The Sender [EMAIL PROTECTED] \n . 
Content-Type: text/plain; charset=utf-8 \n .

Content-Transfer-Encoding: 7bit\n\n)

The message is being sent, but the UTF-8 specific characters are not being
presented. Is there any fix on this?

The messages etc are coming from a form. Is it possible to set the charset
for the form?

/Peter

$bodytext = utf8_encode($bodytext);
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



[PHP] URL Rewrite???

2006-06-13 Thread Keith
Hi all

Not really a php issue per se - sorry.
But I'm sure someone here is bound to know the answer. :-)

I have a main site that is accessible at say 
http://www.somedomain.com/somedir/; but I want visitors to be able to 
access the site using simply http://www.somedomain.com; AND for the 
resulting URL displayed to STILL say http://www.somedomain.com;  and not 
http://www.somedomain.com/somedir/;.

Should this be possible using the .htaccess file and some mod_rewrite rule? 
Toyed around with that but couldn't get it to work.

ANY help would be greatly appreciated, thanks

P.S. Platform: Linux RedHat (running Apache)

scorpy 

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Robert Cummings
On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:

 My brain needs a crutch when trying doing this kind of thing
 (normally I only write hex number literally when dealing with bitwise stuff -
 the conversion stuff still makes my head spin) - this is what this table is 
 for:
 
 128 64 32 16 8 4 2 1
 1   0  1  1  0 1 0 1
 0   1  0  1  1 1 0 0
 0   0  0  0  1 1 1 1
 
 and then I did this - hopefully it shows what you can/have to do:
 
 ?php
 
 // set some values
 $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
 $update = 64 + 16 + 8 + 4; // 01011100
 $mask   = 8 + 4 + 2 + 1;   // 

You could just do the following:

$oldval = bindec( '10110101' );
$update = bindec( '01011100' );
$mask   = bindec( '' );

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



Re: [PHP] date_sunrise accuracy

2006-06-13 Thread Jochem Maas
KI wrote:
 I posted this Thursday as a PHP bug: http://bugs.php.net/bug.php?id=37743
 
 Basically this function is off by 2 minutes from the US  UK governments
 calculations. 

not today it isn't - U.S. Naval Observatory 
(http://aa.usno.navy.mil/data/docs/RS_OneDay.html)
gives me 5.23 for sunrise with the data you gave in your bug report.

I suggest you take dericks' words on it that this is a very difficult
algorithm and that this cannot easily, if at all, be 'fixed' (if it is
even actually a bug).

and besides since when were either of those govs considered trustworthy?
as far as authoritive sources are concerned they are right up there with
wikipedia and google.

and like like Einstein said - time is relative. so what is 5.22 anyway?

 While PHP is admitting there is a difference they are stating
 I should live with it and it's expected.  Does any one else not find this
 acceptable?  

about as acceptable as the number of vowels in your domain name.
(it remains a fact whether one 'accepts' it or not)

What can be done to push PHP to correct this?

nothing, unless you can provide a patch.

there is a reason why php is not used to track satellites or shuttle
reentries and the like... and 60 seconds off on the sunrise calculation on some
webpage is not exactly going to stop the world from rotating is it?

 
 Thanks
 

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Jochem Maas
Robert Cummings wrote:
 On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
 My brain needs a crutch when trying doing this kind of thing
 (normally I only write hex number literally when dealing with bitwise stuff -
 the conversion stuff still makes my head spin) - this is what this table is 
 for:

 128 64 32 16 8 4 2 1
 1   0  1  1  0 1 0 1
 0   1  0  1  1 1 0 0
 0   0  0  0  1 1 1 1

 and then I did this - hopefully it shows what you can/have to do:

 ?php

 // set some values
 $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
 $update = 64 + 16 + 8 + 4;// 01011100
 $mask   = 8 + 4 + 2 + 1;  // 
 
 You could just do the following:
 
 $oldval = bindec( '10110101' );
 $update = bindec( '01011100' );
 $mask   = bindec( '' );

when I was writing the reply I played with about 5 different
conversion funcs - pretty everything expect bindec() !!!

I guess i was being lazy - but then I alway think directly in hex numbers
when doing bitwise stuff (at least I use hex notation for the constant value
that I almost invariably end up creating)

anyway cheers for the lightbuld moment :-)

 
 Cheers,
 Rob.

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



Re: [PHP] URL Rewrite???

2006-06-13 Thread Jochem Maas
Keith wrote:
 Hi all
 
 Not really a php issue per se - sorry.
 But I'm sure someone here is bound to know the answer. :-)
 
 I have a main site that is accessible at say 
 http://www.somedomain.com/somedir/; but I want visitors to be able to 
 access the site using simply http://www.somedomain.com; AND for the 
 resulting URL displayed to STILL say http://www.somedomain.com;  and not 
 http://www.somedomain.com/somedir/;.
 
 Should this be possible using the .htaccess file and some mod_rewrite rule? 
 Toyed around with that but couldn't get it to work.

when you finished toying did you take time to read the Apache docs on 
mod_rewrite?

you need *something like*:

RewriteRule  ^/(.*)$  /somedir/$1 [L]

 
 ANY help would be greatly appreciated, thanks
 
 P.S. Platform: Linux RedHat (running Apache)
 
 scorpy 
 

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Robert Cummings
On Tue, 2006-06-13 at 11:03, Jochem Maas wrote:
 Robert Cummings wrote:
  On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
  My brain needs a crutch when trying doing this kind of thing
  (normally I only write hex number literally when dealing with bitwise 
  stuff -
  the conversion stuff still makes my head spin) - this is what this table 
  is for:
 
  128 64 32 16 8 4 2 1
  1   0  1  1  0 1 0 1
  0   1  0  1  1 1 0 0
  0   0  0  0  1 1 1 1
 
  and then I did this - hopefully it shows what you can/have to do:
 
  ?php
 
  // set some values
  $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
  $update = 64 + 16 + 8 + 4;  // 01011100
  $mask   = 8 + 4 + 2 + 1;// 
  
  You could just do the following:
  
  $oldval = bindec( '10110101' );
  $update = bindec( '01011100' );
  $mask   = bindec( '' );
 
 when I was writing the reply I played with about 5 different
 conversion funcs - pretty everything expect bindec() !!!
 
 I guess i was being lazy - but then I alway think directly in hex numbers
 when doing bitwise stuff (at least I use hex notation for the constant value
 that I almost invariably end up creating)
 
 anyway cheers for the lightbuld moment :-)

Well yours is at least faster since there's no function calls. Though
one can also do the following to avoid memorizing decimal bit values :)

$oldval = (1  7) + (1  5) + (1  4) + (1  2) + (1  0);
$update = (1  6) + (1  4) + (1  3) + (1  2);
$mask   = (1  3) + (1  2) + (1  1) + (1  0);

:)

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



Re: [PHP] Re: trapping fatal errors...?

2006-06-13 Thread Eric Butera

Sometimes unexpected errors happen.  We write hundreds of lines of code a
day.  Typos happen, I forget some includes, I type $d-appendCild() instead
of $d-appendChild().  It's all a part of the development process.

Our application makes extensive use of AJAX and JSON.  Sometimes we make an
AJAX request and expect a JSON object in return, but instead a fatal error
happens (DOMDocument::appendChid() does not exist), well now we get a JSON
error because the response headers were messed up by the fatal error.

That JSON error is useless.  We would rather see the real error as PHP would
have reported it on a simple webpage or command line.

Basically, we just want to trap all errors and reraise them as exceptions so
that our app's default exception handler can report them.


I read what you said and understand where you are coming from, but if
you call a function and it doesn't exist, your script is going to die.
The only thing you can do is just tail your error log and write unit
tests to make sure your stuff is working right.  If you are on a local
machine just keep an eye on your php error log on each request and you
will see the full error message if log errors is turned on.

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



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Jochem Maas
Robert Cummings wrote:
 On Tue, 2006-06-13 at 11:03, Jochem Maas wrote:
 Robert Cummings wrote:
 On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
 My brain needs a crutch when trying doing this kind of thing
 (normally I only write hex number literally when dealing with bitwise 
 stuff -
 the conversion stuff still makes my head spin) - this is what this table 
 is for:

 128 64 32 16 8 4 2 1
 1   0  1  1  0 1 0 1
 0   1  0  1  1 1 0 0
 0   0  0  0  1 1 1 1

 and then I did this - hopefully it shows what you can/have to do:

 ?php

 // set some values
 $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
 $update = 64 + 16 + 8 + 4;  // 01011100
 $mask   = 8 + 4 + 2 + 1;// 
 You could just do the following:

 $oldval = bindec( '10110101' );
 $update = bindec( '01011100' );
 $mask   = bindec( '' );
 when I was writing the reply I played with about 5 different
 conversion funcs - pretty everything expect bindec() !!!

 I guess i was being lazy - but then I alway think directly in hex numbers
 when doing bitwise stuff (at least I use hex notation for the constant value
 that I almost invariably end up creating)

 anyway cheers for the lightbuld moment :-)
 
 Well yours is at least faster since there's no function calls. Though
 one can also do the following to avoid memorizing decimal bit values :)
 
 $oldval = (1  7) + (1  5) + (1  4) + (1  2) + (1  0);
 $update = (1  6) + (1  4) + (1  3) + (1  2);
 $mask   = (1  3) + (1  2) + (1  1) + (1  0);

cool - more brainfood. thanks!

 
 :)
 
 Cheers,
 Rob.

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



RE: [PHP] Re: Sending UTF-8 mail with mail()

2006-06-13 Thread Peter Lauri
That worked better. Now I at least am getting something that looks like
the same it looks in MySQL database table. However, in the email client
(outlook, gmail, hotmail) it is being showed like this:

Document name: ´¡¿Ë
Document summary: ´¡Ë¿

/Peter



-Original Message-
From: Barry [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 13, 2006 9:34 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Sending UTF-8 mail with mail()

Peter Lauri schrieb:
 How can I send UTF-8 mails with the mail() function. Right now I am doing:
 
 mail('[EMAIL PROTECTED]', 'Subject', 'Message', 
 From: The Sender [EMAIL PROTECTED] \n . 
 Content-Type: text/plain; charset=utf-8 \n .
 Content-Transfer-Encoding: 7bit\n\n)
 
 The message is being sent, but the UTF-8 specific characters are not being
 presented. Is there any fix on this?
 
 The messages etc are coming from a form. Is it possible to set the charset
 for the form?
 
 /Peter
$bodytext = utf8_encode($bodytext);
-- 
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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

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



Re: [PHP] Re: trapping fatal errors...?

2006-06-13 Thread Jochem Maas
Christopher J. Bottaro wrote:
 Adam Zey wrote:
 
 Christopher J. Bottaro wrote:
 Hello,
 How can I trap a fatal error (like calling a non existant method,
 requiring
 a non existant file, etc) and go to a user defined error handler?  I
 tried set_error_handler(), but it seems to skip over the errors I care
 about.

 Thanks for the help.
 It is always safer to handle errors before they happen by checking that
 you're in a good state before you try to do something.

 For example, nonexistent files can be handled by file_exists().
 Undefined functions can be checked with function_exists().

 Regards, Adam Zey.
 
 Well, I know that.
 
 Sometimes unexpected errors happen.  We write hundreds of lines of code a
 day.  Typos happen, I forget some includes, I type $d-appendCild() instead
 of $d-appendChild().  It's all a part of the development process.
 
 Our application makes extensive use of AJAX and JSON.  Sometimes we make an
 AJAX request and expect a JSON object in return, but instead a fatal error
 happens (DOMDocument::appendChid() does not exist), well now we get a JSON
 error because the response headers were messed up by the fatal error.
 
 That JSON error is useless.  We would rather see the real error as PHP would
 have reported it on a simple webpage or command line.
 
 Basically, we just want to trap all errors and reraise them as exceptions so
 that our app's default exception handler can report them.

for fatal errors this not possible.

write test routines to check the output of requests that are usually made by
AJAX code... and made use a function like this to cover all your bases:

function PHPErrorReturned(response)
{
// this is a bit crude and could possibly break if we are recieving
// [content] HTML as part of the returned data.
if ((response.indexOf('bNotice/b:  ') ||
 response.indexOf('bWarning/b:  ') ||
 response.indexOf('bFatal Error/b:  '))  (response.indexOf('{') 
!= 0))
{
alert(Er was een fout opgetreden op de server\n+response.stripTags());
return true;
}

return false;
}

String.prototype.stripTags  = function (validTags)
{
var newstr  = this.toString();
var regExp1 = /\/?(\w+)(.*?)/ig;

if (validTags  validTags.prototype == Array) {
var regExp2 = new RegExp('/^('+validTags.join('|')+')$/i'); // 
em|strong|u|p
}

while(mt = regExp1.exec(newstr)) {
oldstr = mt[0]; tag = mt[1]; pars = mt[2];
repl   = '';

if(regExp2  tag.match(regExp2)) {
repl = oldstr.replace(pars,'');
}

newstr = newstr.replace(oldstr, repl);
}
return newstr;
}




 
 Thanks.
 

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



Re: [PHP] GD

2006-06-13 Thread Tom Ray [Lists]



Beauford wrote:

I'm using Slackware 10 and installed GD as an install package. I also
changed some lines in the php.ini file for GD.

Tom: I have no idea how this program works, all I know is that I need it for
the captcha program to display the image. I wouldn't even bother otherwise.

Thanks.

B

  
  
Well, do you know where it is installed? I have mine installed in 
/usr/local/gd so to test it I just ran gd2topng via 
/usr/local/gd/bin/gd2topng  it will ask for image information etc. If it 
does that then you're golden.


The downside is you will need to recompile PHP.

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



[PHP] Re: Re: trapping fatal errors...?

2006-06-13 Thread Christopher J. Bottaro
Jochem Maas wrote:

 Christopher J. Bottaro wrote:
 Adam Zey wrote:
 
 Christopher J. Bottaro wrote:
 Hello,
 How can I trap a fatal error (like calling a non existant method,
 requiring
 a non existant file, etc) and go to a user defined error handler?  I
 tried set_error_handler(), but it seems to skip over the errors I care
 about.

 Thanks for the help.
 It is always safer to handle errors before they happen by checking that
 you're in a good state before you try to do something.

 For example, nonexistent files can be handled by file_exists().
 Undefined functions can be checked with function_exists().

 Regards, Adam Zey.
 
 Well, I know that.
 
 Sometimes unexpected errors happen.  We write hundreds of lines of code a
 day.  Typos happen, I forget some includes, I type $d-appendCild()
 instead
 of $d-appendChild().  It's all a part of the development process.
 
 Our application makes extensive use of AJAX and JSON.  Sometimes we make
 an AJAX request and expect a JSON object in return, but instead a fatal
 error happens (DOMDocument::appendChid() does not exist), well now we get
 a JSON error because the response headers were messed up by the fatal
 error.
 
 That JSON error is useless.  We would rather see the real error as PHP
 would have reported it on a simple webpage or command line.
 
 Basically, we just want to trap all errors and reraise them as exceptions
 so that our app's default exception handler can report them.
 
 for fatal errors this not possible.
 
 write test routines to check the output of requests that are usually made
 by AJAX code... and made use a function like this to cover all your bases:
 
 function PHPErrorReturned(response)
 {
 // this is a bit crude and could possibly break if we are recieving
 // [content] HTML as part of the returned data.
 if ((response.indexOf('bNotice/b:  ') ||
  response.indexOf('bWarning/b:  ') ||
  response.indexOf('bFatal Error/b:  ')) 
  (response.indexOf('{') != 0))
 {
 alert(Er was een fout opgetreden op de
 server\n+response.stripTags()); return true;
 }
 
 return false;
 }
 
 String.prototype.stripTags  = function (validTags)
 {
 var newstr  = this.toString();
 var regExp1 = /\/?(\w+)(.*?)/ig;
 
 if (validTags  validTags.prototype == Array) {
 var regExp2 = new RegExp('/^('+validTags.join('|')+')$/i'); //
 em|strong|u|p
 }
 
 while(mt = regExp1.exec(newstr)) {
 oldstr = mt[0]; tag = mt[1]; pars = mt[2];
 repl   = '';
 
 if(regExp2  tag.match(regExp2)) {
 repl = oldstr.replace(pars,'');
 }
 
 newstr = newstr.replace(oldstr, repl);
 }
 return newstr;
 }
 
 
 
 
 
 Thanks.

Cool, that sounds promising, thanks for that idea (and everyone else who
replied).

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



RE: [PHP] Re: Sending UTF-8 mail with mail()

2006-06-13 Thread tedd
At 5:25 PM +0700 6/13/06, Peter Lauri wrote:
That worked better. Now I at least am getting something that looks like
the same it looks in MySQL database table. However, in the email client
(outlook, gmail, hotmail) it is being showed like this:

Document name: ´¡¿Ë
Document summary: ´¡Ë¿

/Peter


Does the output's font contains those characters?

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



RE: [PHP] Re: Sending UTF-8 mail with mail()

2006-06-13 Thread Peter Lauri
No they do not. It should be ฟหกด if it is correct. 

The process is like this:

1. The user enter the data in a form
2. The form data will be used to insert data into the database and send an 
alert via email about the name and summary of the document. The below is 
inserted into the database, and is displayed correct on the web site when 
retrieving the data from the database and using UTF-8 as the charset on the web 
site.

When sending it in text/plain via mail() and charset=utf-8 it is displayed like 
below.

/Peter


-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 13, 2006 11:00 PM
To: Peter Lauri; 'Barry'; php-general@lists.php.net
Subject: RE: [PHP] Re: Sending UTF-8 mail with mail()

At 5:25 PM +0700 6/13/06, Peter Lauri wrote:
That worked better. Now I at least am getting something that looks like
the same it looks in MySQL database table. However, in the email client
(outlook, gmail, hotmail) it is being showed like this:

Document name: ´¡¿Ë
Document summary: ´¡Ë¿

/Peter


Does the output's font contains those characters?

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



Re: [PHP] Dettach problem

2006-06-13 Thread Jochem Maas
pure guess work coming up...

grape wrote:
 Hi all,
 
 I would like run a php-script via CLI which outputs some information to
 stdout, and then go into background. I use code similar to this to fork
 and to dettach the child I/O from the TTY (some error handling removed
 to improve readability)
 
 ?
 echo Hello from parent\n;
 
 if(pcntl_fork()) {
   exit;
 }
 
 posix_setsid();
 
 fclose( STDIN );
 fclose( STDOUT );
 fclose( STDERR );
 
 if(pcntl_fork()) {
   exit;
 }

what happens if you move the fclose() statements after this
if() statement?

is STDIN et al actually defined? they should be - but we all
theory and practice often live on different planets :-)

are you using the same sapi in both version (i.e. are you maybe using
CGI now iso CLI?)

 
 echo This message should NOT go to stdout of parent process\n;
 ?
 
 It works fine using PHP version 5.0.4, but when using PHP version 5.1.2
 the output of the child (This message) goes to stdout of the
 parent process. So if I do:
 
 php test.php output
 
 Using PHP 5.1.2, the file contains:
 
 ---
 Hello from parent
 This message should NOT go to stdout of parent process
 ---
 
 Can anybody explain this?
 I run FreeBSD 6.0-RELEASE...
 
 Regards,
 
 Grape
 

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



RE: [PHP] Re: Sending UTF-8 mail with mail()

2006-06-13 Thread tedd
At 6:14 PM +0700 6/13/06, Peter Lauri wrote:
No they do not. It should be øÀ°¥ if it is correct.

The process is like this:

1. The user enter the data in a form
2. The form data will be used to insert data into the database and send an 
alert via email about the name and summary of the document. The below is 
inserted into the database, and is displayed correct on the web site when 
retrieving the data from the database and using UTF-8 as the charset on the 
web site.

When sending it in text/plain via mail() and charset=utf-8 it is displayed 
like below.

/Peter


The point I'm trying to make, is that if the display font does not have the 
uft-8 glyphs, then you won't see anything but gibberish.

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



RE: [PHP] Re: Sending UTF-8 mail with mail()

2006-06-13 Thread Peter Lauri
What do you mean with the display fonts? Do you mean the text that is
inserted in the form?

-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 14, 2006 12:55 AM
To: Peter Lauri; 'tedd'; 'Barry'; php-general@lists.php.net
Subject: RE: [PHP] Re: Sending UTF-8 mail with mail()

At 6:14 PM +0700 6/13/06, Peter Lauri wrote:
No they do not. It should be øÀ°¥ if it is correct.

The process is like this:

1. The user enter the data in a form
2. The form data will be used to insert data into the database and send an
alert via email about the name and summary of the document. The below is
inserted into the database, and is displayed correct on the web site when
retrieving the data from the database and using UTF-8 as the charset on the
web site.

When sending it in text/plain via mail() and charset=utf-8 it is displayed
like below.

/Peter


The point I'm trying to make, is that if the display font does not have the
uft-8 glyphs, then you won't see anything but gibberish.

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] preg_replace \\1 yIKES!

2006-06-13 Thread sam


Wow this is hard I can't wait till I get the hang of it.

Capitalize the first letter of a word.

echo preg_replace('/(^)(.)(.*$)/', strtoupper('\\2') . '\\3', 'yikes!');
// outputs yikes!

Nope didn't work.

So I want to see if I'm in the right place:

echo preg_replace('/(^)(.)(.*$)/', '\\1' . '-' . strtoupper('\\2') .  
'-' . '\\3', 'yikes!');

//outputs -y-ikes!

So yea I've got it surrounded why now strtoupper: Yikes!

Thanks

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



Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread sam


for
Eyes burning; caffein shakes; project overdue

Thanks

Why not just use ucfirst http://us2.php.net/manual/en/ 
function.ucfirst.php?


-Original Message-
From: sam [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 13, 2006 2:34 PM
To: PHP
Subject: [PHP] preg_replace \\1 yIKES!


Wow this is hard I can't wait till I get the hang of it.

Capitalize the first letter of a word.

echo preg_replace('/(^)(.)(.*$)/', strtoupper('\\2') . '\\3',  
'yikes!');

// outputs yikes!

Nope didn't work.

So I want to see if I'm in the right place:

echo preg_replace('/(^)(.)(.*$)/', '\\1' . '-' . strtoupper('\\2') .
'-' . '\\3', 'yikes!');
//outputs -y-ikes!

So yea I've got it surrounded why now strtoupper: Yikes!

Thanks

--
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] preg_replace \\1 yIKES!

2006-06-13 Thread Jochem Maas
sam wrote:
 
 Wow this is hard I can't wait till I get the hang of it.
 
 Capitalize the first letter of a word.
 
 echo preg_replace('/(^)(.)(.*$)/', strtoupper('\\2') . '\\3', 'yikes!');
 // outputs yikes!
 
 Nope didn't work.
 
 So I want to see if I'm in the right place:
 
 echo preg_replace('/(^)(.)(.*$)/', '\\1' . '-' . strtoupper('\\2') . '-'
 . '\\3', 'yikes!');
 //outputs -y-ikes!
 
 So yea I've got it surrounded why now strtoupper: Yikes!

to running strtoupper() on the string literal '\\2' which after it has been
capitalized will be '\\2'.

if you *really* want to use preg_replace():

echo preg_replace(/(^)(.)(.*\$)/e, \\\1\ . strtoupper(\\\2\) . \\\3\, 
yikes!),
 \n;

notice the 'e' modifier on the regexp - it causes the replace string to be 
treated as a string of php
code that is autoamtically evaluated - checvk the manual for more info.
(I used double quotes only so that I could test the code on the cmdline using 
'php -r')

...BUT I suggest you try this function instead: ucfirst()

 
 Thanks
 
 --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] preg_replace \\1 yIKES!

2006-06-13 Thread Jochem Maas
sam wrote:
 
 for
 Eyes burning; caffein shakes; project overdue

nobody here cares whether your project is overdue -

waiting 7 minutes before sending a 'reminder' about the
question you asked suggests you need to take a PATIENCE
lesson.

or did some fraudster sell you a php support contract?
... for 500 euros you can contact me anytime at [EMAIL PROTECTED]
for all you php woes :-P

 
 Thanks
 
 Why not just use ucfirst
 http://us2.php.net/manual/en/function.ucfirst.php?

 -Original Message-
 From: sam [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 13, 2006 2:34 PM
 To: PHP
 Subject: [PHP] preg_replace \\1 yIKES!


 Wow this is hard I can't wait till I get the hang of it.

 Capitalize the first letter of a word.

 echo preg_replace('/(^)(.)(.*$)/', strtoupper('\\2') . '\\3', 'yikes!');
 // outputs yikes!

 Nope didn't work.

 So I want to see if I'm in the right place:

 echo preg_replace('/(^)(.)(.*$)/', '\\1' . '-' . strtoupper('\\2') .
 '-' . '\\3', 'yikes!');
 //outputs -y-ikes!

 So yea I've got it surrounded why now strtoupper: Yikes!

 Thanks

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

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



Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread Robert Cummings
On Tue, 2006-06-13 at 15:07, Jochem Maas wrote:
 sam wrote:
  
  for
  Eyes burning; caffein shakes; project overdue
 
 nobody here cares whether your project is overdue -
 
 waiting 7 minutes before sending a 'reminder' about the
 question you asked suggests you need to take a PATIENCE
 lesson.
 
 or did some fraudster sell you a php support contract?
 ... for 500 euros you can contact me anytime at [EMAIL PROTECTED]
 for all you php woes :-P

Oooh, GREAT IDEA!! *scribbles down into his notebook*

:B

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



Re: [PHP] Sending UTF-8 mail with mail()

2006-06-13 Thread M

Peter Lauri wrote:

How can I send UTF-8 mails with the mail() function. Right now I am doing:

mail('[EMAIL PROTECTED]', 'Subject', 'Message', 
From: The Sender [EMAIL PROTECTED] \n . 
Content-Type: text/plain; charset=utf-8 \n .

Content-Transfer-Encoding: 7bit\n\n)

The message is being sent, but the UTF-8 specific characters are not being
presented. Is there any fix on this?

The messages etc are coming from a form. Is it possible to set the charset
for the form?

/Peter



Content-Transfer-Encoding is 7-bit, but utf-8 is 8-bit. So you need to 
encode it (see notes in http://sk.php.net/quoted_printable_decode), or 
leave the Content-Transfer-Encoding header.


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



Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread tedd
At 11:33 AM -0700 6/13/06, sam wrote:
Wow this is hard I can't wait till I get the hang of it.

Capitalize the first letter of a word.

Try:

?php
$word = yikes;
$word[0]=strtoupper($word[0]);
echo($word);
?

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



Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread Dave Goodchild

On 13/06/06, tedd [EMAIL PROTECTED] wrote:


At 11:33 AM -0700 6/13/06, sam wrote:
Wow this is hard I can't wait till I get the hang of it.

Capitalize the first letter of a word.

Why not use ucfirst(), that is what the function is for.
--


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





--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk


Re: [PHP] Seeking recommendations for use of include()

2006-06-13 Thread Richard Lynch


The problem with making it dynamic, is that you've just made it
AWFULLY easy for some Bad Guy to inject their own PHP file into your
system...

Think about that for awhile.

On Tue, June 13, 2006 5:22 am, Dave M G wrote:
 PHP List,

 Up until now, in order to get all the functions and classes I need in
 my
 scripts, I have always made a file called includes.php that contains
 a
 series of include() statements for all of the files that I want to
 include. Then I just include that one file at the top of all my PHP
 scripts.

 This system works okay, but I thought it would be better to have a
 consistent naming standard, and use some kind wild card or loop to
 include all the files I want. That way I can change, add, and remove
 files a little easier.

 All the files I want to include end with either .class, or with
 _fns.php. (fns stands for functions.)

 It seems that wildcard characters are not supported in the include()
 function. Some experiments and a search on the web seem to confirm
 this.

 So then I thought what I need to do is use the readdir() function
 somehow, and make an array of all files ending in .class or
 _fns.php, and then make a while or foreach loop to include every
 required file.

 I couldn't quite figure out how to do that, but in any case I wondered
 if running this loop at the start of every single PHP script might be
 unnecessary overhead. After all, the list of included files will only
 change when I work on the system. It's not going to vary at all based
 on
 any kind of user input or in standard usage of my web site.

 What would be the recommended way of including files that will change
 as
 I work on the system? Do most people create a function to detect the
 included files, or do most people make a static list that they edit by
 hand?

 --
 Dave M G

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Strange lockup - using curl

2006-06-13 Thread mbneto

Hi,

I am facing a strange problem.  I have a script that runs fine in one server
but simply locks up in another.

I´ve managed to find that when the curl_exec is called the problem appears,
so I decided to use a sample script with the same example found at
ww.php.net and got the same results.

The server-status shows me

SrvPIDAccMCPU SSReqConnChildSlotClientVHostRequest *0-0*201700/2/2*W* 0.00
27800.00.030.03 201.51.28.217myhost.comGET /temp/curl.php HTTP/1.1
I used strace with the pid shown

# strace  -p 20170
Process 20170 attached - interrupt to quit
select(1589, [], [], NULL, {0, 685000}) = 0 (Timeout)
gettimeofday({1150235209, 865596}, NULL) = 0
gettimeofday({1150235209, 866753}, NULL) = 0
select(1589, [], [], NULL, {1, 0})  = 0 (Timeout)
gettimeofday({1150235210, 868349}, NULL) = 0
gettimeofday({1150235210, 869048}, NULL) = 0
select(1589, [], [], NULL, {1, 0})  = 0 (Timeout)
gettimeofday({1150235211, 870045}, NULL) = 0
gettimeofday({1150235211, 870598}, NULL) = 0
select(1589, [], [], NULL, {1, 0})  = 0 (Timeout)
gettimeofday({1150235212, 870965}, NULL) = 0
gettimeofday({1150235212, 871669}, NULL) = 0
select(1589, [], [], NULL, {1, 0})  = 0 (Timeout)
gettimeofday({1150235213, 903386}, NULL) = 0
gettimeofday({1150235213, 930348}, NULL) = 0

But I do not have a clue about this.

The script.

?php

$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, http://www.myhost.com/;);
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);


// close curl resource, and free up system resources
curl_close($ch);

?


[PHP] Re: Sending UTF-8 mail with mail()

2006-06-13 Thread Manuel Lemos
Hello,

on 06/13/2006 06:09 AM Peter Lauri said the following:
 How can I send UTF-8 mails with the mail() function. Right now I am doing:
 
 mail('[EMAIL PROTECTED]', 'Subject', 'Message', 
 From: The Sender [EMAIL PROTECTED] \n . 
 Content-Type: text/plain; charset=utf-8 \n .
 Content-Transfer-Encoding: 7bit\n\n)
 
 The message is being sent, but the UTF-8 specific characters are not being
 presented. Is there any fix on this?
 
 The messages etc are coming from a form. Is it possible to set the charset
 for the form?

UTF-8 text is 8 bit. You must encode that message with quoted-printable,
not 7 bit.

If you don't know how to do it right, you may want to try this class.
Try the test_email_message.php example that demonstrates how to send
messages with non-ASCII characters.

The default encoding is ISO-8859-1 but if you have text already encoded
as UTF-8, you can just set the default_charset class variable to 'UTF-8'
to make the messages be sent correctly.

http://www.phpclasses.org/mimemessage


-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] RE: Sending UTF-8 mail with mail()

2006-06-13 Thread Peter Lauri
Yes, that class I am aware of. However, I only want to send text/plain
messages, not MIME messages.

-Original Message-
From: Manuel Lemos [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 14, 2006 4:36 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: Sending UTF-8 mail with mail()

Hello,

on 06/13/2006 06:09 AM Peter Lauri said the following:
 How can I send UTF-8 mails with the mail() function. Right now I am doing:
 
 mail('[EMAIL PROTECTED]', 'Subject', 'Message', 
 From: The Sender [EMAIL PROTECTED] \n . 
 Content-Type: text/plain; charset=utf-8 \n .
 Content-Transfer-Encoding: 7bit\n\n)
 
 The message is being sent, but the UTF-8 specific characters are not being
 presented. Is there any fix on this?
 
 The messages etc are coming from a form. Is it possible to set the charset
 for the form?

UTF-8 text is 8 bit. You must encode that message with quoted-printable,
not 7 bit.

If you don't know how to do it right, you may want to try this class.
Try the test_email_message.php example that demonstrates how to send
messages with non-ASCII characters.

The default encoding is ISO-8859-1 but if you have text already encoded
as UTF-8, you can just set the default_charset class variable to 'UTF-8'
to make the messages be sent correctly.

http://www.phpclasses.org/mimemessage


-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] Dettach problem

2006-06-13 Thread Richard Lynch
On Tue, June 13, 2006 4:22 am, grape wrote:
 I would like run a php-script via CLI which outputs some information
 to
 stdout, and then go into background. I use code similar to this to
 fork
 and to dettach the child I/O from the TTY (some error handling removed
 to improve readability)

 ?
 echo Hello from parent\n;

 if(pcntl_fork()) {
exit;
 }

 posix_setsid();

 fclose( STDIN );
 fclose( STDOUT );
 fclose( STDERR );

 if(pcntl_fork()) {
exit;
 }

 echo This message should NOT go to stdout of parent process\n;
 ?

 It works fine using PHP version 5.0.4, but when using PHP version
 5.1.2
 the output of the child (This message) goes to stdout of the
 parent process. So if I do:

 php test.php output

 Using PHP 5.1.2, the file contains:

 ---
 Hello from parent
 This message should NOT go to stdout of parent process
 ---

 Can anybody explain this?
 I run FreeBSD 6.0-RELEASE...

This seems to me like a cogent bug report...
http://bugs.php.net/

But what does the posix_setsid() bit do?  Seems like you could take
that out too, no?...  Or does that promote the process to be the
parent somehow?...  Thereby confusing fork into thinking that it's
not the child process in some twisted weird way?  I read the docs ;
But comprehension is not implied. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Sending UTF-8 mail with mail()

2006-06-13 Thread Richard Lynch
On Tue, June 13, 2006 4:09 am, Peter Lauri wrote:
 How can I send UTF-8 mails with the mail() function. Right now I am
 doing:

 mail('[EMAIL PROTECTED]', 'Subject', 'Message',
 From: The Sender [EMAIL PROTECTED] \n .
 Content-Type: text/plain; charset=utf-8 \n .
 Content-Transfer-Encoding: 7bit\n\n)

 The message is being sent, but the UTF-8 specific characters are not
 being
 presented. Is there any fix on this?

 The messages etc are coming from a form. Is it possible to set the
 charset
 for the form?

First, you should PROBABLY use \r\n to separate headers, unless you
know you are using a badly-broken (non-compliant) MTA.

Next, you should not tack on an extra \n (now \r\n) for the last
header -- PHP is gonna do it for you.  You don't even need the
trailing \r\n for that matter, as PHP works it out...  Though it's
good in case you add more headers.

Finally, if all else fails, I'm GUESSING that you may be stuck using
HTML-enhanced (cough, cough) email to get what you want...  Which I
don't recommend, but if you must, you must, and http://phpclasses.org
has a class you can use to build it.  Rolling your own is a real
PITA...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Re: Sending UTF-8 mail with mail()

2006-06-13 Thread Manuel Lemos
Hello,

on 06/13/2006 01:37 PM Peter Lauri said the following:
 Yes, that class I am aware of. However, I only want to send text/plain
 messages, not MIME messages.

MIME includes plain text messages. MIME is what is called the set of
standard rules defined in RFC documents for sending e-mail. 8 bit text
must be encoded as quoted-printable as defined in RFC 2045 or else you
will have the problems that you have described:

http://www.ietf.org/rfc/rfc2045.txt



 -Original Message-
 From: Manuel Lemos [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, June 14, 2006 4:36 AM
 To: Peter Lauri
 Cc: php-general@lists.php.net
 Subject: Re: Sending UTF-8 mail with mail()
 
 Hello,
 
 on 06/13/2006 06:09 AM Peter Lauri said the following:
 How can I send UTF-8 mails with the mail() function. Right now I am doing:

 mail('[EMAIL PROTECTED]', 'Subject', 'Message', 
 From: The Sender [EMAIL PROTECTED] \n . 
 Content-Type: text/plain; charset=utf-8 \n .
 Content-Transfer-Encoding: 7bit\n\n)

 The message is being sent, but the UTF-8 specific characters are not being
 presented. Is there any fix on this?

 The messages etc are coming from a form. Is it possible to set the charset
 for the form?
 
 UTF-8 text is 8 bit. You must encode that message with quoted-printable,
 not 7 bit.
 
 If you don't know how to do it right, you may want to try this class.
 Try the test_email_message.php example that demonstrates how to send
 messages with non-ASCII characters.
 
 The default encoding is ISO-8859-1 but if you have text already encoded
 as UTF-8, you can just set the default_charset class variable to 'UTF-8'
 to make the messages be sent correctly.
 
 http://www.phpclasses.org/mimemessage
 
 


-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] Setting headers for file download

2006-06-13 Thread Richard Lynch
On Tue, June 13, 2006 1:44 am, Peter Lauri wrote:
 This is how I try to push files to download using headers:

Content-type: application/octet-stream

Any browser failing to download THAT is seriously broken.

The Content-Disposition: crap will only work on select browsers -- If
you really want that filename to work, tack it onto the end of the
URL.

The link should be:

http://example.com/yourscript.php/?php echo $filename?

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] date_sunrise accuracy

2006-06-13 Thread Richard Lynch
On Mon, June 12, 2006 6:11 pm, KI wrote:
 I posted this Thursday as a PHP bug:
 http://bugs.php.net/bug.php?id=37743

 Basically this function is off by 2 minutes from the US  UK
 governments
 calculations. While PHP is admitting there is a difference they are
 stating
 I should live with it and it's expected.  Does any one else not find
 this
 acceptable?

2 minutes?  I'd be okay with a 2 hour difference, since, like, I'm
never awake at that time anyway :-)

 What can be done to push PHP to correct this?

Submit a patch?

Seriously.  If you think it's that important, then by all means submit
a patch to fix it.

Another option, for you, is to just snarf down the Government's number
in a cron job every day, if you like their answer that much better.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] GetText string not found

2006-06-13 Thread Richard Lynch
On Tue, June 13, 2006 6:30 am, Ruben Rubio Rey wrote:
 I am using gettext to get a web page in several languages.

 When gettext does not found an string, it shows the string.

 Is it possible to detect when a string is not found, in order to advis
 me ?

My experience, if you call it that, with gettext consists of reading
the manual and saying Neat!, so take this with a HUGE grain of
salt...

One option that MIGHT work would be:

function ___ ($string) {
  //check for existince of the language file/string by hand :-(
}

Another option, perhaps, would be to have your default language be
something really... weird, and then the output itself would be icky...

I suppose you could do something hacky like:

?php
ob_start();
__'GETTEXT_START_MARKER This is the actual message GETTEXT_END_MARKER';
?
All code/html here.
?php
$output = ob_get_contents();
preg_match_all('/GETTEXT_START_MARKER (.*) GETEXT_END_MARKER/U',
$output, $gettexts);
foreach($gettexts[1] as $unknown){
  error_log($unknown);
}
$output = str_replace(array('GETTEXT_START_MARKER ', '
GETTEXT_END_MARKER'), '', $output);
echo $output;
?

Ugh.



Maybe a Feature Request at GetText and/or bugs.php.net would be in
order...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] GD

2006-06-13 Thread Richard Lynch
On windows, you just take out the ; in the line with php_gd2.dll in
your php.ini file

php.net has to be in the directory noted in ?php phpinfo();?

And your extension_dir in php.ini has to be the directory where
php_gd2.dll lives.

On Mon, June 12, 2006 6:11 pm, Beauford wrote:
 Hi,

 I am trying to get GD working so I can use a captcha script and not
 having
 much luck. I can get it to work in Windows, but not Linux.

 I have seen a few comments suggesting that PHP needs to be compiled
 with the
 GD switch. Is there another way to do this? I have PHP, MySQL and
 Apache
 installed and working great, I don't want to have to recompile PHP and
 have
 it screw up everything just for one program.

 Any help is appreciated.

 B

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] date_sunrise accuracy

2006-06-13 Thread KI

Jochem Maas [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 KI wrote:
 I posted this Thursday as a PHP bug: http://bugs.php.net/bug.php?id=37743

 Basically this function is off by 2 minutes from the US  UK governments
 calculations.

 not today it isn't - U.S. Naval Observatory 
 (http://aa.usno.navy.mil/data/docs/RS_OneDay.html)
 gives me 5.23 for sunrise with the data you gave in your bug report.

Today it's actually off by 3 minutes 5:23 vs 5:26.


 I suggest you take dericks' words on it that this is a very difficult
 algorithm and that this cannot easily, if at all, be 'fixed' (if it is
 even actually a bug).

 and besides since when were either of those govs considered trustworthy?
 as far as authoritive sources are concerned they are right up there with
 wikipedia and google.

Well you can add Canada to that list Did you check with Netherlands?


 and like like Einstein said - time is relative. so what is 5.22 anyway?

 While PHP is admitting there is a difference they are stating
 I should live with it and it's expected.  Does any one else not find 
 this
 acceptable?

 about as acceptable as the number of vowels in your domain name.
 (it remains a fact whether one 'accepts' it or not)

I don't quite comprehend why an algorithm - presumably (but apparently not) 
the same - should come up with 2 different responses.


 What can be done to push PHP to correct this?

 nothing, unless you can provide a patch.

If I could do that I wouldn't need the function in the first place.


 there is a reason why php is not used to track satellites or shuttle
 reentries and the like...

LOL

 and 60 seconds off on the sunrise calculation on some
 webpage is not exactly going to stop the world from rotating is it?

60 seconds wouldn't but 120 would. ;-)




 Thanks


Thanks for the feedback.

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



Re: [PHP] trapping fatal errors...?

2006-06-13 Thread Richard Lynch
On Mon, June 12, 2006 5:00 pm, Christopher J. Bottaro wrote:
 Hello,
 How can I trap a fatal error (like calling a non existant method,
 requiring
 a non existant file, etc) and go to a user defined error handler?  I
 tried
 set_error_handler(), but it seems to skip over the errors I care
 about.

I don't think you CAN...

The closest you could come, after all the set_error_handler and
php.ini settings to log and not display etc, would, maybe, be to wrap
everything in an ob_start() and search output for ERROR: -- which
really sucks, but my boss does it that way...

I think, though, that a syntax error would still get triggered before
the ob_start() every had a chance, unless you ALSO wrap it all up in
an include() somewhere outside the whole app...

This gets pretty ugly, pretty fast, but I suppose as a last-ditch
effort on top of all the file_exists() etc would be... okay.

There is a certain point where the real problem is insufficient
testing, though, and I suspect that is where you'd have to be for the
ob_start() hack to be a win...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] php-html rendering

2006-06-13 Thread Richard Lynch
On Mon, June 12, 2006 4:49 pm, Jochem Maas wrote:
 Ryan A wrote:
 Thanks for the suggestion, I am not too familier with
 wget but (correct me if i am wrong) wont wget just get
 the output from the pages ignoreing the links?

 that's the default behaviour - but wget has about a zillion
 parameters for controlling its behaviour, it's quite easy to scrap
 a complete site in one call and change the file extension of
 all files as you go (including the relevant links in the files
 that are downloaded).

 that said it could take a week to figure out all the
 parameters. ;-)

True -- even more than a week, for some of us. :-)

However I'm pretty sure ONE of the examples right in the man page for
wget covers exactly what he wants. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] PHP6 build help

2006-06-13 Thread Ligaya Turmelle

Ubuntu Breezy Badger, AMD 64

I am trying to build PHP6 from source.  I must admit to being a novice 
at *nix systems, but I am learning - so please be gentle.  :)


I have already gotten a copy of the PHP6 source from CVS, downloaded the 
autoconf version 2.13 as well as the ICU and ran the ./buildconf.  But 
when I tried to do the ./configure, I received back an error message 
that I do not understand.  Can someone please explain what has happened 
and point me in a general direction on what I need to do to get the 
./configure to work.


(Sorry for such a general question)

last set of output:
[EMAIL PROTECTED]:/usr/local/php6$ sudo ./configure
creating cache ./config.cache
checking for Cygwin environment... no
checking for mingw32 environment... no
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for AIX... no
checking whether ln -s works... yes
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking for re2c... no
configure: warning: You will need re2c 0.9.11 or later if you want to 
regenerate PHP parsers.

checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for bison... no
checking for byacc... no
checking for bison version... invalid
configure: warning: bison versions supported for regeneration of the 
Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 (found: none).

checking for flex... lex
checking for yywrap in -ll... no
checking lex output file root... ./configure: line 3210: lex: command 
not found

configure: error: cannot find output from lex; giving up


--

life is a game... so have fun.

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

Re: [PHP] PHP6 build help

2006-06-13 Thread Richard Lynch

You realize that compiling PHP6 from CVS is, errr, not really for
newbies... :-)

You may want to start over with a stable download from:
http://php.net/downloads.php

You do not seem to have the 'lex' command, which means you probably
didn't install 'lex'

you can Google for the error message (the last line or two) and find
links to how to get it and install 'lex'

On Tue, June 13, 2006 5:44 pm, Ligaya Turmelle wrote:
 Ubuntu Breezy Badger, AMD 64

 I am trying to build PHP6 from source.  I must admit to being a novice
 at *nix systems, but I am learning - so please be gentle.  :)

 I have already gotten a copy of the PHP6 source from CVS, downloaded
 the
 autoconf version 2.13 as well as the ICU and ran the ./buildconf.  But
 when I tried to do the ./configure, I received back an error message
 that I do not understand.  Can someone please explain what has
 happened
 and point me in a general direction on what I need to do to get the
 ./configure to work.

 (Sorry for such a general question)

 last set of output:
 [EMAIL PROTECTED]:/usr/local/php6$ sudo ./configure
 creating cache ./config.cache
 checking for Cygwin environment... no
 checking for mingw32 environment... no
 checking for egrep... grep -E
 checking for a sed that does not truncate output... /bin/sed
 checking host system type... x86_64-unknown-linux-gnu
 checking target system type... x86_64-unknown-linux-gnu
 checking for gcc... gcc
 checking whether the C compiler (gcc  ) works... yes
 checking whether the C compiler (gcc  ) is a cross-compiler... no
 checking whether we are using GNU C... yes
 checking whether gcc accepts -g... yes
 checking whether gcc and cc understand -c and -o together... yes
 checking how to run the C preprocessor... gcc -E
 checking for AIX... no
 checking whether ln -s works... yes
 checking if compiler supports -R... no
 checking if compiler supports -Wl,-rpath,... yes
 checking for re2c... no
 configure: warning: You will need re2c 0.9.11 or later if you want to
 regenerate PHP parsers.
 checking for gawk... no
 checking for nawk... nawk
 checking if nawk is broken... no
 checking for bison... no
 checking for byacc... no
 checking for bison version... invalid
 configure: warning: bison versions supported for regeneration of the
 Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 (found: none).
 checking for flex... lex
 checking for yywrap in -ll... no
 checking lex output file root... ./configure: line 3210: lex: command
 not found
 configure: error: cannot find output from lex; giving up


 --

 life is a game... so have fun.

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


-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] php-html rendering

2006-06-13 Thread Ryan A
Hey Larry,

Thanks again, now i have around 3 different ways of
doing this... can assure the client that all will be
well, all depends now if the project is confirmed and
given to us.

But the info you gave me will serve me even if this
project does not go through or i dont use wget for
this project.

Thanks for taking the time to explain the various
switches, my doubts, different tips and being so
helpful, i really appreciate it.

Have a great day!
Ryan

--- Larry Garfield [EMAIL PROTECTED] wrote:

 On Tuesday 13 June 2006 07:22, Ryan A wrote:
 
  Hey,
  Thanks for the explanation of the switches.
 
  One part that I dont really understand is:
 
   blah?foo=bar links
   into [EMAIL PROTECTED]
 
  having a link such as [EMAIL PROTECTED] is not going to
  work to link to the second document...right? (I
 have
  not really tried it, but have never seen html like
 the
  above)
 
 Actually for me it didn't work until I did that
 conversion.  You're not 
 sending an actual variable query, remember.  You're
 linking to a static file 
 whose name on disk is [EMAIL PROTECTED], which is a
 valid filename, 
 while blah?foo=bar is not (at least under Windows,
 although it didn't work 
 for me under Unix either).  
 
  And lastly, I read on another forum discussing
 wget
  that there is a switch that converts the dynamic
 pages
  to static WITH a .html/.htm extention;
 unfortunatly he
  didnt give an example of how to do this, was he
 just
  blowing smoke or is that true?
 
 man wget, and look for the -E option (aka
 --html-extension).
 
 -- 
 Larry GarfieldAIM: LOLG42
 [EMAIL PROTECTED] ICQ: 6817012
 
 If nature has made any one thing less susceptible
 than all others of 
 exclusive property, it is the action of the thinking
 power called an idea, 
 which an individual may exclusively possess as long
 as he keeps it to 
 himself; but the moment it is divulged, it forces
 itself into the possession 
 of every one, and the receiver cannot dispossess
 himself of it.  -- Thomas 
 Jefferson
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] Re: preg_replace \\1 yIKES!

2006-06-13 Thread Rafael

Capitalize the first letter of a word: ucwords()[1]

	Now, if it's just for practice, then you need a little change in you 
code, since  strtoupper('\\2')  will give '\\2' (i.e. does nothing) and 
the letter will remain the same.  One way to do it would be

  $text = 'hello world (any ...world)';
  echo  preg_replace('/\b(\w)/Xe', 'strtoupper(\\1)', $text);
check the manual[2] for more info...

[1] http://php.net/ucwords
[2] http://php.net/manual/en/reference.pcre.pattern.syntax.php
http://php.net/manual/en/reference.pcre.pattern.modifiers.php

sam wrote:

Wow this is hard I can't wait till I get the hang of it.

Capitalize the first letter of a word.

echo preg_replace('/(^)(.)(.*$)/', strtoupper('\\2') . '\\3', 'yikes!');
// outputs yikes!

Nope didn't work.

So I want to see if I'm in the right place:

echo preg_replace('/(^)(.)(.*$)/', '\\1' . '-' . strtoupper('\\2') .  
'-' . '\\3', 'yikes!');

//outputs -y-ikes!

So yea I've got it surrounded why now strtoupper: Yikes!

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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



[PHP] Re: Setting headers for file download

2006-06-13 Thread Rafael

I use something like this...
  $file_len = filesize($file_name);
  $file_ts  = filemtime($file_name);
  header('Content-Type: application/x-octet-stream'); // none known
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Last-Modified: '. gmdate('D, d M Y H:i:s', $file_ts) .' GMT');
  header('Content-Disposition: attachment; filename='. 
basename($file_name) .'');

  header(Content-Length: $file_len);
  readfile($file_name);


Peter Lauri wrote:

Best group member,

This is how I try to push files to download using headers:

header(Content-type: $file_type);
header(Content-Disposition: attachment; filename=$filename); 
print $file;


It works fine in FireFox, but not that good in IE. I have been googled to
find the fix for IE, but I can not find it. Anyone with experience of this?

Best regards,
Peter Lauri


--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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



Re: [PHP] PHP6 build help

2006-06-13 Thread Ligaya Turmelle

Richard Lynch wrote:

You realize that compiling PHP6 from CVS is, errr, not really for
newbies... :-)
Yeah - I know.  but I am helping out the php qa team by writing some 
phpt tests... and they prefer (though don't require) the tests also 
include the unicode support.  which means PHP6.  As I told them - guess 
that means it is time for me to learn something new.



You do not seem to have the 'lex' command, which means you probably
didn't install 'lex'

you can Google for the error message (the last line or two) and find
links to how to get it and install 'lex'
D'uh.  I have never heard of the lex command before...  Will search and 
hopefully install it.  Will let you know how it goes.




--

life is a game... so have fun.

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

Re: [PHP] php-html rendering

2006-06-13 Thread Larry Garfield
On Tuesday 13 June 2006 17:57, Ryan A wrote:
 Hey Larry,

 Thanks again, now i have around 3 different ways of
 doing this... can assure the client that all will be
 well, all depends now if the project is confirmed and
 given to us.

 But the info you gave me will serve me even if this
 project does not go through or i dont use wget for
 this project.

 Thanks for taking the time to explain the various
 switches, my doubts, different tips and being so
 helpful, i really appreciate it.

Not a problem.  Just remember to pay it forward. :-)

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



[PHP] errata

2006-06-13 Thread Rafael
Now, if it's just for practice, then you need a little change in you 
code, since  strtoupper('\\2')  will give '\\2' (i.e. does nothing) and 
the letter will remain the same.


	I meant, since *strtoupper('\\2')* is evaluated _before_ being included 
in the string (used as replacement), i.e...

  preg_replace('/(^)(.)(.*$)/', strtoupper('\\2') . '\\3', 'yikes!');
is evaluated as
  preg_replace('/(^)(.)(.*$)/', '\\2\\3', 'yikes!');
since *strtoupper('\\2')* = *'\\2'*, that's why I said it does nothing.

	In the code sent, *strtoupper()* is passed as a (literal) string which, 
combined with the e modifier (at the end of the expression), gives the 
effect you were looking for (i.e. the replacement string is evaluated 
--as code-- before it actually replaces the string found)

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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



Re: [PHP] Seeking recommendations for use of include()

2006-06-13 Thread Dave M G

Richard Lynch wrote:

The problem with making it dynamic, is that you've just made it
AWFULLY easy for some Bad Guy to inject their own PHP file into your
system...

Think about that for awhile.
I have thought about it, and I can only see it as possible if the person 
already has the ability to write PHP scripts into my directory. If they 
can do that, then the damage is already done and they don't need to 
bother with slipping the name of their file into my include() functions. 
They could just write a script and then execute it from the browser 
directly.


If there is some other way for them to exploit a dynamic include() 
function, then please let me know.


--
Dave M G

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



[PHP] transfer file

2006-06-13 Thread kristianto adi widiatmoko
i try to transfer file from one server to another server, lets call it server A 
to server B.

My Idea is like this 
I place my script in server A

?php
$local = fopen(file.txt,r);
$remote = fopen(http://B/file.txt,w+);

while(!feof($local)) {
$buff = fread($local,1024);
fwrite($remote, $buff);
}

fclose($local);
fclose($remote);

?

Is Any one has sugestion about it, or another method ??

 Send instant messages to your online friends http://uk.messenger.yahoo.com 

Re: [PHP] Seeking recommendations for use of include()

2006-06-13 Thread Larry Garfield
On Tuesday 13 June 2006 21:17, Dave M G wrote:

 If there is some other way for them to exploit a dynamic include()
 function, then please let me know.

$untrusted_var = '../../../../../../../etc/passwd';
include($untrusted_var);

Or in later versions of PHP, I *think* the following may even work:

$untrusted_var = 'http://evilsite.com/pub/evil.php';
include($untrusted_var);

Now, having a variable inside an include() is not automatically bad.  It can 
be a good way to make code cleaner and allow you to conditionally include 
certain libraries only when you need them.  Just be very very careful about 
where those variables come from.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] transfer file

2006-06-13 Thread Chris

kristianto adi widiatmoko wrote:

i try to transfer file from one server to another server, lets call it server A 
to server B.

My Idea is like this 
I place my script in server A


?php
$local = fopen(file.txt,r);
$remote = fopen(http://B/file.txt,w+);

while(!feof($local)) {
$buff = fread($local,1024);
fwrite($remote, $buff);
}

fclose($local);
fclose($remote);

?

Is Any one has sugestion about it, or another method ??


You can't write files to a remote server through a web server like this.

The php page (http://php.net/fopen) has an example of what you want:

$handle = fopen(ftp://user:[EMAIL PROTECTED]/somefile.txt, w);

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

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



Re: [PHP] Strange lockup - using curl

2006-06-13 Thread Chris

mbneto wrote:

Hi,

I am facing a strange problem.  I have a script that runs fine in one 
server

but simply locks up in another.

I´ve managed to find that when the curl_exec is called the problem appears,
so I decided to use a sample script with the same example found at
ww.php.net and got the same results.

The server-status shows me

SrvPIDAccMCPU SSReqConnChildSlotClientVHostRequest *0-0*201700/2/2*W* 0.00
27800.00.030.03 201.51.28.217myhost.comGET /temp/curl.php HTTP/1.1
I used strace with the pid shown

# strace  -p 20170
Process 20170 attached - interrupt to quit
select(1589, [], [], NULL, {0, 685000}) = 0 (Timeout)
gettimeofday({1150235209, 865596}, NULL) = 0
gettimeofday({1150235209, 866753}, NULL) = 0
select(1589, [], [], NULL, {1, 0})  = 0 (Timeout)
gettimeofday({1150235210, 868349}, NULL) = 0
gettimeofday({1150235210, 869048}, NULL) = 0
select(1589, [], [], NULL, {1, 0})  = 0 (Timeout)
gettimeofday({1150235211, 870045}, NULL) = 0
gettimeofday({1150235211, 870598}, NULL) = 0
select(1589, [], [], NULL, {1, 0})  = 0 (Timeout)
gettimeofday({1150235212, 870965}, NULL) = 0
gettimeofday({1150235212, 871669}, NULL) = 0
select(1589, [], [], NULL, {1, 0})  = 0 (Timeout)
gettimeofday({1150235213, 903386}, NULL) = 0
gettimeofday({1150235213, 930348}, NULL) = 0

But I do not have a clue about this.

The script.

?php

$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, http://www.myhost.com/;);
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);


// close curl resource, and free up system resources
curl_close($ch);

?



You might need to compile php with --with-debug and see what you get 
back from an strace then.. the php-internals list would need to see the 
debug symbols to work out where it's breaking (and you'll need to talk 
to the -internals list).


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

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



RE: [PHP] Setting headers for file download

2006-06-13 Thread Peter Lauri
Hi, when I do that I do not get any download frame showing up. Can that be
solved?

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 14, 2006 4:58 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Setting headers for file download

On Tue, June 13, 2006 1:44 am, Peter Lauri wrote:
 This is how I try to push files to download using headers:

Content-type: application/octet-stream

Any browser failing to download THAT is seriously broken.

The Content-Disposition: crap will only work on select browsers -- If
you really want that filename to work, tack it onto the end of the
URL.

The link should be:

http://example.com/yourscript.php/?php echo $filename?

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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] Re: Setting headers for file download

2006-06-13 Thread Peter Lauri
I will try that after golf...

-Original Message-
From: Rafael [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 14, 2006 6:28 AM
To: php-general@lists.php.net
Subject: [PHP] Re: Setting headers for file download

I use something like this...
   $file_len = filesize($file_name);
   $file_ts  = filemtime($file_name);
   header('Content-Type: application/x-octet-stream'); // none known
   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
   header('Last-Modified: '. gmdate('D, d M Y H:i:s', $file_ts) .' GMT');
   header('Content-Disposition: attachment; filename='. 
basename($file_name) .'');
   header(Content-Length: $file_len);
   readfile($file_name);


Peter Lauri wrote:
 Best group member,
 
 This is how I try to push files to download using headers:
 
 header(Content-type: $file_type);
 header(Content-Disposition: attachment; filename=$filename); 
 print $file;
 
 It works fine in FireFox, but not that good in IE. I have been googled to
 find the fix for IE, but I can not find it. Anyone with experience of
this?
 
 Best regards,
 Peter Lauri

-- 
Atentamente / Sincerely,
J. Rafael Salazar Magaña

-- 
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] PHP6 build help

2006-06-13 Thread Rabin Vincent

On 6/14/06, Ligaya Turmelle [EMAIL PROTECTED] wrote:

Richard Lynch wrote:
 You realize that compiling PHP6 from CVS is, errr, not really for
 newbies... :-)
Yeah - I know.  but I am helping out the php qa team by writing some
phpt tests... and they prefer (though don't require) the tests also
include the unicode support.  which means PHP6.  As I told them - guess
that means it is time for me to learn something new.

 You do not seem to have the 'lex' command, which means you probably
 didn't install 'lex'

 you can Google for the error message (the last line or two) and find
 links to how to get it and install 'lex'
D'uh.  I have never heard of the lex command before...  Will search and
hopefully install it.  Will let you know how it goes.


Run this command: sudo apt-get build-dep php5

This will get you all the packages needed to build php5, which
should be most of what is needed for php6.

Rabin

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