|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Sun Mar 23 2008 - 19:37:29 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 24 Mar 2008 00:37:29 -0000 Issue 5364
Topics (messages 272006 through 272019):
Re: strange list behavior when replying to message on list
272006 by: Jason Pruim
272015 by: Daniel Brown
272016 by: Daniel Brown
Re: sprintf problem... (with simplified code )
272007 by: Richard
Including files for templates
272008 by: Terry Burns-Dyson
272014 by: Daniel Brown
Re: spider
272009 by: Michelle Konzack
272010 by: Michelle Konzack
272011 by: Michelle Konzack
272018 by: Børge Holen
Manipulating PDF
272012 by: Aschwin Wesselius
272013 by: tedd
Re: sprintf problem...
272017 by: Daniel Brown
De-Duplicate A Query Result List
272019 by: cool7.hosting4days.com
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
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
>>>>> <mdw1982
mdw1982.com>
>>>>> 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-general&m=105700032521606&w=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
>
>
attached mail follows:
On Sun, Mar 23, 2008 at 1:48 AM, Mark Weaver <mdw1982
mdw1982.com> 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
attached mail follows:
On Sun, Mar 23, 2008 at 5:22 AM, Nilesh Govindrajan <admin
itech7.com> 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
attached mail follows:
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 <php_list
ghz.fr>
>> 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 = 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
>>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> ---------- End Original Message ----------
>
>
>
attached mail follows:
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 I"m just doing string
replacement when I include the template.html, so my only question is, what's
the actual way of doing this?
Thanks
attached mail follows:
On Sun, Mar 23, 2008 at 6:32 AM, Terry Burns-Dyson
<hammerstein_02
msn.com> 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 I"m 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>
<div><a 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
attached mail follows:
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/9351947 50, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFH5jsEC0FPBMSS+BIRAm/VAKCVyjY2ekEknSeX++uzhp1o5LCVrQCg0rfJ
NDIAGK96GO5do1bOnS3x8wM=
=cRZ+
-----END PGP SIGNATURE-----
attached mail follows:
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/9351947 50, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFH5jweC0FPBMSS+BIRAtutAJ0fRJQ3TsO6HVWW4iFwkqpuWTHXcwCgk8kR
uwxnd34G94y+rTTW0GxUd3o=
=IIrH
-----END PGP SIGNATURE-----
attached mail follows:
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}:${PASS}
some.url.tld/
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/9351947 50, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFH5jpIC0FPBMSS+BIRArkpAJ9cfDxHmGjdJc6gCaFWSv6nU0n7KwCffrXx
kQjv/C0UKwIOM0gqKsCrd3A=
=ooDZ
-----END PGP SIGNATURE-----
attached mail follows:
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
attached mail follows:
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
attached mail follows:
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
attached mail follows:
On Sat, Mar 22, 2008 at 3:37 PM, Richard <php_list
ghz.fr> 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
attached mail follows:
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]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]