php-general Digest 23 Mar 2008 10:22:13 -0000 Issue 5363

2008-03-23 Thread php-general-digest-help

php-general Digest 23 Mar 2008 10:22:13 - Issue 5363

Topics (messages 271991 through 272005):

sprintf problem...
271991 by: Richard

Re: sprintf problem... (with simplified code )
271992 by: Richard

Re: strange list behavior when replying to message on list
271993 by: Shawn McKenzie
271994 by: Shawn McKenzie
271995 by: Shawn McKenzie
271997 by: Nilesh Govindrajan
272003 by: Mark Weaver
272005 by: Nilesh Govindrajan

Re: Comparing file creating dates...
271996 by: Al

Re: pulling text from a file
271998 by: Nilesh Govindrajan

Re: spider
271999 by: Nilesh Govindrajan

Re: question about customized error
272000 by: Nilesh Govindrajan

Re: selling gpl software?
272001 by: Nilesh Govindrajan
272004 by: Larry Garfield

Re: problem with sessions config.
272002 by: N.Boatswain

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
Hello, I'm trying to write a invoice script but I have encountered a 
slight problem.
Each product needs to be listed without tax, and at the end of the file 
I need to show the VAT. In France VAT is 19.6%

So €10.03 without vat = €12.00 with vat.
So I do this :

$totalwithoutvat = 0;
$totalwithoutvat = 0;
$totalvat =0;
while ( $itemwithoutvat) = each( $px ) )
{
$totalwithoutvat += $itemwithoutvat;
$totalwithoutvat += sprintf(%0.2f, $itemwithoutvat * ( 1 + 19.6/100 ));
$totalvat += sprintf(%0.2f,$itemwithoutvat * 19.6/100);
}
print (Total Vat =.sprintf(%0.2f,$totalvat). - Total without vat = 
.sprintf(%0.2f,$totalwithoutvat). - Total with vat = 
.sprintf(%0.2f,$totalwithvat));


But I'm not sure I am using sprintf correctly, maybe I should use a 
different function because :
When I have one item at 10.03, the result is : Total Vat = 1.97 - Total 
without vat = 10.03 Total with vat = 12.00
but if I have two items at 10.03 the result is : Total vat = 3.93 - 
Total without vat = 20.06 Total with vat = 23.99
but I need it to be : Total vat = 3.94 - Total without vat = 20.06 Total 
with vat = 24.00
So from what I can see, sprintf only seems to work for printing and the 
actual result is kept in memory, is this correct ? if so what function 
should I use instead?


Thanks in advance :)

Richard








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

Here is a simplifie version of my code :

?php
$total = 0;
$ht = 10.03;
$vat = 19.6;
$total += $ht*($vat/100+1);
print(Total = .sprintf(%0.2f, $total));
$total += $ht*($vat/100+1);
print( - Total 2 = .sprintf(%0.2f, $total));
?

I get 12.00 and 23.99 ... what should I do to get 12.00 and 24.00 ?


Richard a écrit :
Hello, I'm trying to write a invoice script but I have encountered a 
slight problem.
Each product needs to be listed without tax, and at the end of the 
file I need to show the VAT. In France VAT is 19.6%

So €10.03 without vat = €12.00 with vat.
So I do this :

$totalwithoutvat = 0;
$totalwithoutvat = 0;
$totalvat =0;
while ( $itemwithoutvat) = each( $px ) )
{
$totalwithoutvat += $itemwithoutvat;
$totalwithoutvat += sprintf(%0.2f, $itemwithoutvat * ( 1 + 19.6/100 ));
$totalvat += sprintf(%0.2f,$itemwithoutvat * 19.6/100);
}
print (Total Vat =.sprintf(%0.2f,$totalvat). - Total without vat 
= .sprintf(%0.2f,$totalwithoutvat). - Total with vat = 
.sprintf(%0.2f,$totalwithvat));


But I'm not sure I am using sprintf correctly, maybe I should use a 
different function because :
When I have one item at 10.03, the result is : Total Vat = 1.97 - 
Total without vat = 10.03 Total with vat = 12.00
but if I have two items at 10.03 the result is : Total vat = 3.93 - 
Total without vat = 20.06 Total with vat = 23.99
but I need it to be : Total vat = 3.94 - Total without vat = 20.06 
Total with vat = 24.00
So from what I can see, sprintf only seems to work for printing and 
the actual result is kept in memory, is this correct ? if so what 
function should I use instead?


Thanks in advance :)

Richard


---End Message---
---BeginMessage---
Mark Weaver wrote:
 Andrew Ballard wrote:
 On Sat, Mar 22, 2008 at 11:13 AM, Mark Weaver [EMAIL PROTECTED]
 wrote:
 Hi all,

  I'm wondering if anyone else happens to be using Mozilla Thunderbird
 and
  seeing this behavior, and also if this behavior is a feature or a bug.

  When I hit the reply button to respond to a message most of the time
 the
  actual sender's address is the one the message is being sent to rather
  than the list itself. This is the first mailing list I've been on that
  I've seen this behavior; all other lists I'm on when one hits the reply
  button, or CTRL+R the mailing list's address is inserted as it
 should be
  and is expected.

  I know with some email clients there is a menu item specifically there
  for responding to the list 

Re: [PHP] strange list behavior when replying to message on list

2008-03-23 Thread Mark Weaver

Nilesh Govindrajan wrote:

Shawn McKenzie wrote:

Mark Weaver wrote:

Andrew Ballard wrote:

On Sat, Mar 22, 2008 at 11:13 AM, Mark Weaver [EMAIL PROTECTED]
wrote:

Hi all,

 I'm wondering if anyone else happens to be using Mozilla Thunderbird
and
 seeing this behavior, and also if this behavior is a feature or a 
bug.


 When I hit the reply button to respond to a message most of the time
the
 actual sender's address is the one the message is being sent to 
rather
 than the list itself. This is the first mailing list I've been on 
that
 I've seen this behavior; all other lists I'm on when one hits the 
reply

 button, or CTRL+R the mailing list's address is inserted as it
should be
 and is expected.

 I know with some email clients there is a menu item specifically 
there

 for responding to the list based on whether or not there is a
 list-header in the header information but that isn't an available
option
 with Thunderbird. Is anyone else seeing this behavior or is there
 something I'm missing?

 Mark


It's not specific to Thunderbird or any other mail client. I'm pretty
sure it was configured that way on purpose. Have a look at this
thread:

http://marc.info/?l=php-generalm=105700032521606w=2

Andrew


well, obviously since the issue still exists it's clear that this never
got resolved. I just don't understand the obstenant behavior of some
folks in the presence of clear and plain logic. Especially from a
programmer. Makes no sense at all.

Guess I'm off to create the necessary recipe for Procmail to do the
adult thing and make sense of the non-sense.


I use Thunderbird 2.x on Kubuntu and I just hit reply to this mail.  I
have news.php.net setup as a news account.  I do receive and have
received frequent timeouts contacting the news server though.  Has been
a pain for quite awhile.

-Shawn


That's what I also do. :D I have thunderbird 2.x on Fedora 8. So, it 
works. :)




by the way... I thought everyone would be rather interested to know that 
because of the way the list is setup and running at the moment and not 
hiding the senders email address, it's extremely easy to harvest 
addresses from messages. That means that if someone got infected or a 
spammer, scammer, etc... ever subscribed to the list it wouldn't be any 
trouble at all to get list members' addresses.


It took all of 10 seconds to grep the imap folder where all the messages 
I get are stored for the From: header and out popped everyone's address. 
Just another reason to hide the sender's address and use the reply-to 
header.


--
Mark

If you have found a very wise man, then you've found a man that at one 
time was an idiot and lived long enough to learn from his own stupidity.

==
Powered by CentOS5 (RHEL5)

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



Re: [PHP] Re: selling gpl software?

2008-03-23 Thread Larry Garfield
On Saturday 22 March 2008, Nilesh Govindrajan wrote:

 Larry, read the GPL license. It has can be used, distributed, modified
 under GPL only.

And where have I said otherwise?  

-- 
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] strange list behavior when replying to message on list

2008-03-23 Thread Nilesh Govindrajan

Mark Weaver wrote:

Nilesh Govindrajan wrote:

Shawn McKenzie wrote:

Mark Weaver wrote:

Andrew Ballard wrote:

On Sat, Mar 22, 2008 at 11:13 AM, Mark Weaver [EMAIL PROTECTED]
wrote:

Hi all,

 I'm wondering if anyone else happens to be using Mozilla Thunderbird
and
 seeing this behavior, and also if this behavior is a feature or a 
bug.


 When I hit the reply button to respond to a message most of the time
the
 actual sender's address is the one the message is being sent to 
rather
 than the list itself. This is the first mailing list I've been on 
that
 I've seen this behavior; all other lists I'm on when one hits the 
reply

 button, or CTRL+R the mailing list's address is inserted as it
should be
 and is expected.

 I know with some email clients there is a menu item specifically 
there

 for responding to the list based on whether or not there is a
 list-header in the header information but that isn't an available
option
 with Thunderbird. Is anyone else seeing this behavior or is there
 something I'm missing?

 Mark


It's not specific to Thunderbird or any other mail client. I'm pretty
sure it was configured that way on purpose. Have a look at this
thread:

http://marc.info/?l=php-generalm=105700032521606w=2

Andrew


well, obviously since the issue still exists it's clear that this never
got resolved. I just don't understand the obstenant behavior of some
folks in the presence of clear and plain logic. Especially from a
programmer. Makes no sense at all.

Guess I'm off to create the necessary recipe for Procmail to do the
adult thing and make sense of the non-sense.


I use Thunderbird 2.x on Kubuntu and I just hit reply to this mail.  I
have news.php.net setup as a news account.  I do receive and have
received frequent timeouts contacting the news server though.  Has been
a pain for quite awhile.

-Shawn


That's what I also do. :D I have thunderbird 2.x on Fedora 8. So, it 
works. :)




by the way... I thought everyone would be rather interested to know that 
because of the way the list is setup and running at the moment and not 
hiding the senders email address, it's extremely easy to harvest 
addresses from messages. That means that if someone got infected or a 
spammer, scammer, etc... ever subscribed to the list it wouldn't be any 
trouble at all to get list members' addresses.


It took all of 10 seconds to grep the imap folder where all the messages 
I get are stored for the From: header and out popped everyone's address. 
Just another reason to hide the sender's address and use the reply-to 
header.



It is not possible. This is one of the major drawbacks of mailing lists 
/ news groups.


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



Re: [PHP] strange list behavior when replying to message on list

2008-03-23 Thread Jason Pruim


On Mar 23, 2008, at 2:48 AM, Mark Weaver wrote:


Nilesh Govindrajan wrote:

Shawn McKenzie wrote:

Mark Weaver wrote:

Andrew Ballard wrote:
On Sat, Mar 22, 2008 at 11:13 AM, Mark Weaver  
[EMAIL PROTECTED]

wrote:

Hi all,

I'm wondering if anyone else happens to be using Mozilla  
Thunderbird

and
seeing this behavior, and also if this behavior is a feature or  
a bug.


When I hit the reply button to respond to a message most of the  
time

the
actual sender's address is the one the message is being sent to  
rather
than the list itself. This is the first mailing list I've been  
on that
I've seen this behavior; all other lists I'm on when one hits  
the reply

button, or CTRL+R the mailing list's address is inserted as it
should be
and is expected.

I know with some email clients there is a menu item  
specifically there

for responding to the list based on whether or not there is a
list-header in the header information but that isn't an available
option
with Thunderbird. Is anyone else seeing this behavior or is there
something I'm missing?

Mark

It's not specific to Thunderbird or any other mail client. I'm  
pretty

sure it was configured that way on purpose. Have a look at this
thread:

http://marc.info/?l=php-generalm=105700032521606w=2

Andrew

well, obviously since the issue still exists it's clear that this  
never
got resolved. I just don't understand the obstenant behavior of  
some

folks in the presence of clear and plain logic. Especially from a
programmer. Makes no sense at all.

Guess I'm off to create the necessary recipe for Procmail to do the
adult thing and make sense of the non-sense.

I use Thunderbird 2.x on Kubuntu and I just hit reply to this  
mail.  I

have news.php.net setup as a news account.  I do receive and have
received frequent timeouts contacting the news server though.  Has  
been

a pain for quite awhile.

-Shawn
That's what I also do. :D I have thunderbird 2.x on Fedora 8. So,  
it works. :)


by the way... I thought everyone would be rather interested to know  
that because of the way the list is setup and running at the moment  
and not hiding the senders email address, it's extremely easy to  
harvest addresses from messages. That means that if someone got  
infected or a spammer, scammer, etc... ever subscribed to the list  
it wouldn't be any trouble at all to get list members' addresses.


It took all of 10 seconds to grep the imap folder where all the  
messages I get are stored for the From: header and out popped  
everyone's address. Just another reason to hide the sender's address  
and use the reply-to header.




I'm on about 10 different mailing lists NONE of which completely hide  
your address, and I have NO spam that comes in. I handle all my spam  
at the MTA rather then the MUA. So all I'm saying is for some spam is  
a way of life... it's a necessary evil But there are ways to avoid  
it.





--
Mark

If you have found a very wise man, then you've found a man that at  
one time was an idiot and lived long enough to learn from his own  
stupidity.

==
Powered by CentOS5 (RHEL5)

--
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] sprintf problem... (with simplified code )

2008-03-23 Thread Richard
Sorry, this morning I have gone through everything again, and the 
simplified example was wrong, but corrected it gives the right answer, 
however although I'm sure I've done the same with the main script I can 
not get the correct answer.


I need to round each article seperatly so that the Vat inc prince 
remains the same.


So a 10.03 without vat always makes 12.00 with vat.

My test files works as it should :

?php
$total = 0;
$ht = 10.03;
$vat = 19.6;
$total += sprintf(%0.2f,$ht*($vat/100+1));
print(Total = .sprintf(%0.2f,$total));
$total += sprintf(%0.2f,$ht*($vat/100+1));
print( - Total 2 = .sprintf(%0.2f,$total));
?

Result : Total : 12 - Total 2 : 24

However the file I'm working on does not :(

The script I'm working on makes use of the fpdf php project which 
automaticaly creates PDF files.


Here is the extract of code :

while ( list($code_tva, $articleHT) = each( $px ) )
{
$tva = $tab_tva[$code_tva]; // is 19.6 %
$this-SetXY(15, $y); //sets the coordinates of cell to be created in 
PDF file for each item )
$this-Cell( 21.5,4, sprintf(%0.2f, $articleHT),'', '','C' ); // 
inserts the item
//= $totalHT is TOTAL without VAT and 
$articleHT is a table which contains the price of each item without tax

$totalHT += $articleHT; //adds all items without vat
//= $totalTTC is TOTAL with VAT 
$totalTTC += sprintf(%0.2f, ($articleHT * ( 1 + $tva/100 ))); // adds 
the rounded (item * 1.196) (including vat)

//= $totalTVA is TOTAL of VAT 
$tmp_tva = sprintf(%0.2f,$articleHT * $tva/100); //amount of VAT of 
current item

$a_tva[ $code_tva ] = $tmp_tva;
$totalTVA += $tmp_tva; //adds current item's vat to total vat
$this-SetXY(10, $y);
$this-Cell( 5,4, $code_tva, 0,0,C); //prints vat option
$this-SetXY(58, $y);
$this-Cell( 21.5,4, sprintf(%0.2f,$tmp_tva),'', '' ,'C'); //prints 
the current item's vat amount

$this-SetXY(79.5, $y);
$this-Cell( 21.5,4, sprintf(%0.2f,$tva) ,'', '', 'C'); //prints the 
vat percentage for item

$y+=4;
}
$this-SetXY(114,266.4);
$this-Cell(15,4, sprintf(%0.2f, $totalHT), '', '', 'R' ); //prints 
the total amount excluding vat

$this-SetXY(114,271.4);
$this-Cell(15,4, sprintf(%0.2f, $totalTVA), '', '', 'R' ); //prints 
total amount including vat


This is how I see it :
If I have two different items ($articleHT) at 10.03 this line ($tva = 
19.6 and $articleHT = 10.03) :

$totalTTC += sprintf(%0.2f, ($articleHT * ( 1 + $tva/100 )));
Should add 12.00 to $totalTTC However it seems to add 11.99588 to 
$totalTTC instead ...


In my test files it does exactly this, any idea why it would not do this 
in the real file ?


Thanks again :)


lists-php a écrit :

your issue is with rounding, and whether vat is applied (rounded)
per-item or on the invoice total.

your sprintf output is simply truncating and rounding on display. you
aren't storing the rounded (up) value.

increase the decimal positions to 4 or 6 and you'll see things better.

  Total = 11.995880 - Total 2 = 23.991760

the vat on 10.03 is 1.96588, which when you only display 2 positions
on display rounds up to 1.97. 


if you stored the rounded value ,on a per-item basis, you'd get what
you're after.

now, the question is whether vat is applied per item or on the
invoice total.

the difference becomes more obvious with say 3 items, at 10.03. on a
(rounded) per-item basis the vat total would be 5.91. on an invoice
total it would be 5.90 (rounded up from 5.89784).


  - Rick


 Original Message 
  

Date: Saturday, March 22, 2008 10:35:12 PM +0100
From: Richard [EMAIL PROTECTED]
To: PHP lists php-general@lists.php.net
Cc: 
Subject: Re: [PHP] sprintf problem... (with simplified code )


Here is a simplifie version of my code :

?php
$total = 0;
$ht = 10.03;
$vat = 19.6;
$total += $ht*($vat/100+1);
print(Total = .sprintf(%0.2f, $total));
$total += $ht*($vat/100+1);
print( - Total 2 = .sprintf(%0.2f, $total));
?

I get 12.00 and 23.99 ... what should I do to get 12.00 and 24.00 ?


Richard a écrit :


Hello, I'm trying to write a invoice script but I have encountered
a  slight problem.
Each product needs to be listed without tax, and at the end of the 
file I need to show the VAT. In France VAT is 19.6%

So €10.03 without vat = €12.00 with vat.
So I do this :

$totalwithoutvat = 0;
$totalwithoutvat = 0;
$totalvat =0;
while ( $itemwithoutvat) = each( $px ) )
{
$totalwithoutvat += $itemwithoutvat;
$totalwithoutvat += sprintf(%0.2f, $itemwithoutvat * ( 1 +
19.6/100 )); $totalvat += sprintf(%0.2f,$itemwithoutvat *
19.6/100); }
print (Total Vat =.sprintf(%0.2f,$totalvat). - Total without
vat  = .sprintf(%0.2f,$totalwithoutvat). - Total with vat = 
.sprintf(%0.2f,$totalwithvat));


But I'm not sure I am using sprintf correctly, maybe I should use
a  different function because :
When I have one item at 10.03, the result is : Total Vat = 1.97 - 
Total without vat = 10.03 Total with vat = 12.00

but if I have two items at 10.03 the result is : Total vat = 

[PHP] Including files for templates

2008-03-23 Thread Terry Burns-Dyson
I'm trying to write a template system, my template is the HTML layout, and 
my content is fetched from another source. However I don't quite understand 
how to output the template so that all the variables are parsed by PHP. 
Simple version of what I'm trying to do;


ob_start( );

extract( $params, EXTR_PREFIX_SAME, am_);

$pageContent = file_get_contents( page_to_display.html);

include( template.html);

echo ob_get_clean( );


$pageTitle is in the template, it's replaced, $pageContent is in the 
template, it's replaced. But any variables within the page_to_display are 
simply output into the page rather than processed by PHP.  I realise that 
file_get_contents is basically returning a string and Im just doing string 
replacement when I include the template.html, so my only question is, what's 
the actual way of doing this?


Thanks 



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



Re: [PHP] spider

2008-03-23 Thread Michelle Konzack
Am 2008-03-21 19:15:13, schrieb Børge Holen:
 wget is fast and easy though... umm I'm on an direct 100mbit connection... 
 wget does it brute

Sometimes it is too fast for me...  :-)
Specialy If I work in Paris on my Dual-STM-4 network...

Then, --limit-rate=rate is my friend.

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: [PHP] spider

2008-03-23 Thread Michelle Konzack
Am 2008-03-21 14:12:04, schrieb Wolf:
 OK, so I stand corrected there...  But has anyone seen a PHP port of
 wget or is curl the only one of the 2 which does it natively in a
 compiled version of php with curl?  :)

AFAIK, there is no native port.  But why do you want one?  -- wget is
working perfectly so you can use a shell exeute command to do it.

In my experience, there are MANY native PHP implementations which should
be droped because its poor speed and/or quality.

And of course, the code must be maintained twice which is definitivly a
waste of resources.

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: [PHP] spider

2008-03-23 Thread Michelle Konzack
Am 2008-03-21 13:58:59, schrieb Wolf:
 Both are pretty effecitve and give pretty much the same results,
 however with the CURL you can pass other things alone (user:pass)
 which with wget you can not do.

???

wget http://${USER}:[EMAIL PROTECTED]/

is working and

wget --http-user=${USER} --http-passwd=${PASS} http://some.url.tld/

too.  And since it is visible to any users on the local machine which
can excute ps, you can put the user/passwd into your ~/.wgetrc.

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


[PHP] Manipulating PDF

2008-03-23 Thread Aschwin Wesselius

Hi,

I know it is possible to create PDF's and read them within PHP. But I'm 
after a method to read a PDF file, analyze it (dump structure or 
whatever) and being able to modify it in a valid way.


And with modifying I don't mean just replacing text. I want to be able 
to remap layout, change fonts, change standards (if possible, I don't 
know). In other words, I want to have full control on the PDF and output 
it to my definitions. At least I want to be able to analyze PDF's so 
maybe I can built things myself upon the format.


Has anyone seen such a thing for PHP? Or does anybody has a hint how to 
start doing it myself (maybe examples in Python or C which can be ported)?


Again, I'm not after PHPLib or FPDF, since these libraries are either 
old or insufficient for what I want.


Thanks in advance.

Aschwin Wesselius


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



Re: [PHP] Manipulating PDF

2008-03-23 Thread tedd

At 4:36 PM +0100 3/23/08, Aschwin Wesselius wrote:
Again, I'm not after PHPLib or FPDF, since these libraries are 
either old or insufficient for what I want.


Hey, don't discount old things. :-)

I can do just about anything I want with those old files.

http://webbytedd.com/bb/pdf/

Cheers,

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] Including files for templates

2008-03-23 Thread Daniel Brown
On Sun, Mar 23, 2008 at 6:32 AM, Terry Burns-Dyson
[EMAIL PROTECTED] wrote:
[snip!]
  $pageTitle is in the template, it's replaced, $pageContent is in the
  template, it's replaced. But any variables within the page_to_display are
  simply output into the page rather than processed by PHP.  I realise that
  file_get_contents is basically returning a string and Im just doing string
  replacement when I include the template.html, so my only question is, what's
  the actual way of doing this?

The simples way would be like so:

?php
// content/page1.php
#
# Define the variables for the content of the page.
#


$page_title = Welcome To My Website!;

$paragraph_a =EOT
Welcome to my website!

This is a HEREDOC that we'll be using in the template to display some
text, formatted with HTML line breaks and all.

It's that simple!
EOT;

$paragraph_a = nl2br($paragraph_a);

$main_image = images/main.png;

$main_image_link = http://www.other-website.tld;;
?

?
// templates/page1.php
#
# The formatting for the page.
#


/* All of your headers and starting
HTML should be included by your
switching script.  This file will also
require that short_open_tags is on.
If you can't/don't want it on, just
modify the tags herein. */
?
div
?=$paragraph_a;?
/div
diva href=?=$main_image_link;?img src=?=$main_image;?
border=0/a/div
? // End of templates/page1.php ?

?php
// templates/header.php
#
# A very basic sample header.
#


?
html
 head
  title?=$page_title;?/title
 /head
 body
?php // End of templates/header.php ?

?php
// templates/footer.php
#
# A very basic sample footer.
#


?
 /body
/html
?php // End of templates/footer.php ?

?
// index.php
#
# A simple index switch page.
#


if(isset($_GET['s'])  strlen($_GET['s'])  1) {
switch($_GET['s']) {
case page1:
$section = $_GET['s'];
break;
case contact:
$section = $_GET['s'];
break;
case about:
// We'll pretend the page name was changed here.
$section = about_us;
break;
default:
$section = home;
break;
}
} else {
$section = home;
}

include('content/'.$section.'.php');
include('templates/header.php');
include('templates/'.$section.'.php');
include('templates/footer.php');
/* This means that the content file with the
variables is parsed first, and defines the
variables within the scope of this execution.
It's included before the header.php file so
that the $page_title variable is defined. */
?


Everything herein was typed directly into this email and is
untested, so it's by no means guaranteed to work, has not been
properly sanitized or tested, and is for informational purposes only,
to get you started in the right direction.

-- 
/Daniel P. Brown
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] strange list behavior when replying to message on list

2008-03-23 Thread Daniel Brown
On Sun, Mar 23, 2008 at 1:48 AM, Mark Weaver [EMAIL PROTECTED] wrote:

  by the way... I thought everyone would be rather interested to know that
  because of the way the list is setup and running at the moment and not
  hiding the senders email address, it's extremely easy to harvest
  addresses from messages. That means that if someone got infected or a
  spammer, scammer, etc... ever subscribed to the list it wouldn't be any
  trouble at all to get list members' addresses.

It almost sounds like this is the first mailing list to which
you've subscribed.

1.) Hit reply-all.  It takes a second and isn't a big deal.
2.) Any mailing list in the world that you subscribe to opens you
up to the exact same threats as which you've mentioned here, whether
or not the email address is masked.
3.) A mailing list which masks the email is called an anonymous
distribution list.  That means going off-list for non-topic discussion
is a pain in the ass.

It's configured this way for a reason, and I personally don't see
any problem with it.

-- 
/Daniel P. Brown
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] strange list behavior when replying to message on list

2008-03-23 Thread Daniel Brown
On Sun, Mar 23, 2008 at 5:22 AM, Nilesh Govindrajan [EMAIL PROTECTED] wrote:

  It is not possible. This is one of the major drawbacks of mailing lists
  / news groups.

It's unnecessary, but it's certainly possible. It's all in the
configuration of the mailing list software (mailman, in this case)
itself.

Doing so, however, would cause more problems than gains, and would
certainly piss some people off (myself included).

-- 
/Daniel P. Brown
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] sprintf problem...

2008-03-23 Thread Daniel Brown
On Sat, Mar 22, 2008 at 3:37 PM, Richard [EMAIL PROTECTED] wrote:
[snip=code!]
  When I have one item at 10.03, the result is : Total Vat = 1.97 - Total
  without vat = 10.03 Total with vat = 12.00
  but if I have two items at 10.03 the result is : Total vat = 3.93 -
  Total without vat = 20.06 Total with vat = 23.99
  but I need it to be : Total vat = 3.94 - Total without vat = 20.06 Total
  with vat = 24.00

Check your math, Richard.  You're using sprintf() with the float
correctly, you're just missing how it's rounding.

(10.03 * 19.6) / 100 = 1.96588 (rounded to 1.97)
((10.03 * 19.6) / 100) * 2 = 3.93176 (rounded to 3.93)

If you want it to come out to an even number with the VAT added,
simply round the amount first, then multiply it.

-- 
/Daniel P. Brown
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] spider

2008-03-23 Thread Børge Holen
On Sunday 23 March 2008 12:12:04 Michelle Konzack wrote:
 Am 2008-03-21 19:15:13, schrieb Børge Holen:
  wget is fast and easy though... umm I'm on an direct 100mbit
  connection... wget does it brute

 Sometimes it is too fast for me...  :-)
 Specialy If I work in Paris on my Dual-STM-4 network...

wanna share?


 Then, --limit-rate=rate is my friend.

 Thanks, Greetings and nice Day
 Michelle Konzack
 Systemadministrator
 24V Electronic Engineer
 Tamay Dogan Network
 Debian GNU/Linux Consultant



-- 
---
Børge Holen
http://www.arivene.net

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



[PHP] De-Duplicate A Query Result List

2008-03-23 Thread [EMAIL PROTECTED]
Newbie Question:

Using let's say, a contacts database table -  I would like to get a unique
list of categories for whatever was selected. So, let's say I chose to find
everyone in California - then I would like to create a unique list of
categories (for California) -  with no duplicates - (to be used for other
things - like a pull down menu of these very categories).

Q: Is there a way to process the query result to de-duplicate the result
list?




--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists]




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



Re: [PHP] De-Duplicate A Query Result List

2008-03-23 Thread Greg Bowser
Sounds like you want something like the following:

SELECT DISTINCT category FROM `contacts` WHERE state='california';

--GREG


[PHP] ob_start: Capturing STDOUT and STDERR

2008-03-23 Thread Greg Sims
Hey There,

I looked at the ob_start manual and found a segment of code that can be used
to capture the output of a shell script and place it into a log file.  One
of the entries indicates this should work for both STDOUT and STDERR
(29-Mar-2007).  I wrote the following piece of code to test it out.

function logger($buffer)
  {
$handle = fopen('/var/log/test.log', 'a');
fwrite($handle, $buffer);
fclose($handle);
  }

  ob_start(logger);

This will capture the output buffer until the shell terminates when the
buffer is dumped to the test.log file.  This is a simple mechanism and it
works really well to keep STDOUT from going to the console and logging it.
Unfortunately, STDERR continues to go to the console which is what I am
working to avoid.  

I would like to capture STDOUT and STDERR using this technique. I am working
to create a self contained script that does not rely on some external script
to capture the output.  The actual application needs to perform some
post-processing of the output buffer at the end of the script.

Any pointers in the correct direction would be helpful!  Thanks, Greg


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



Re: [PHP] ob_start: Capturing STDOUT and STDERR

2008-03-23 Thread Casey
On Sun, Mar 23, 2008 at 6:08 PM, Greg Sims [EMAIL PROTECTED] wrote:
 Hey There,

  I looked at the ob_start manual and found a segment of code that can be used
  to capture the output of a shell script and place it into a log file.  One
  of the entries indicates this should work for both STDOUT and STDERR
  (29-Mar-2007).  I wrote the following piece of code to test it out.

  function logger($buffer)
   {
 $handle = fopen('/var/log/test.log', 'a');
 fwrite($handle, $buffer);
 fclose($handle);
   }

   ob_start(logger);

  This will capture the output buffer until the shell terminates when the
  buffer is dumped to the test.log file.  This is a simple mechanism and it
  works really well to keep STDOUT from going to the console and logging it.
  Unfortunately, STDERR continues to go to the console which is what I am
  working to avoid.

  I would like to capture STDOUT and STDERR using this technique. I am working
  to create a self contained script that does not rely on some external script
  to capture the output.  The actual application needs to perform some
  post-processing of the output buffer at the end of the script.

  Any pointers in the correct direction would be helpful!  Thanks, Greg


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



You could use set_error_handler() and make your own function to echo
out the error.

-- 
-Casey

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



[PHP] Re: ob_start: Capturing STDOUT and STDERR

2008-03-23 Thread Jonesy
On Sun, 23 Mar 2008 18:08:19 -0700, Greg Sims wrote:
 Hey There,

 I looked at the ob_start manual and found a segment of code that can be used
 to capture the output of a shell script and place it into a log file.  One
 of the entries indicates this should work for both STDOUT and STDERR
 (29-Mar-2007).  I wrote the following piece of code to test it out.

 function logger($buffer)
   {
   $handle = fopen('/var/log/test.log', 'a');
   fwrite($handle, $buffer);
   fclose($handle);
   }

   ob_start(logger);

ob_start(logger 21);

???

Jonesy
-- 
  Marvin L Jones| jonz  | W3DHJ  | linux
   38.24N  104.55W  |  @ config.com | Jonesy |  OS/2
*** Killfiling google posts: http://jonz.net/ng.htm


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



[PHP] Date math

2008-03-23 Thread Ron Piggott
I have this math equation this list helped me generate a few weeks ago.
The purpose is to calculate how many days have passed between 2 dates.  

Right now my output ($difference) is 93.958333 days.  

I am finding this a little weird.  Does anyone see anything wrong with
the way this is calculated:

$date1 = strtotime($date1); (March 21st 2008)
$date2 = strtotime($date2); (December 18th 2007)

echo $date1 = 1206072000
echo $date2 = 1197954000

#86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days
worth of seconds)

$factor = 86400;

$difference = (($date1 - $date2) / $factor);



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



Re: [PHP] Date math

2008-03-23 Thread Simon Welsh


On 24/03/2008, at 5:17, Ron Piggott wrote:
I have this math equation this list helped me generate a few weeks  
ago.

The purpose is to calculate how many days have passed between 2 dates.

Right now my output ($difference) is 93.958333 days.

I am finding this a little weird.  Does anyone see anything wrong with
the way this is calculated:

$date1 = strtotime($date1); (March 21st 2008)
$date2 = strtotime($date2); (December 18th 2007)

echo $date1 = 1206072000
echo $date2 = 1197954000

#86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days
worth of seconds)

$factor = 86400;

$difference = (($date1 - $date2) / $factor);


Depending on what you want, wrap it in round() ceil() or floor()




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



---
Simon Welsh
Admin of http://simon.geek.nz/

Windows is a joke operating system. Hell, it's not even an operating  
system. NT is Not Tough enough for me either. 95 is how may times it  
will crash an hour.


http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e



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



Re: [PHP] Date math

2008-03-23 Thread Casey
On Sun, Mar 23, 2008 at 9:17 PM, Ron Piggott [EMAIL PROTECTED] wrote:
 I have this math equation this list helped me generate a few weeks ago.
  The purpose is to calculate how many days have passed between 2 dates.

snip

  $date1 = strtotime($date1); (March 21st 2008)
  $date2 = strtotime($date2); (December 18th 2007)

  echo $date1 = 1206072000
  echo $date2 = 1197954000

Seems to be a time zone issue.1206057600 is the actual timestamp for
March 21st, 2008 GMT. I don't know what time zone 1206072000 is is.

-- 
-Casey

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