php-general Digest 5 Sep 2008 05:38:18 -0000 Issue 5664

Topics (messages 279515 through 279548):

Re: Google Chrome
        279515 by: Ovidiu Rosoiu
        279516 by: Bastien Koert
        279517 by: Boyd, Todd M.
        279518 by: TG
        279519 by: Stephen Wong
        279520 by: Wolf
        279523 by: Eugene Mah
        279525 by: Boyd, Todd M.
        279529 by: Dan Shirah
        279531 by: Bastien Koert
        279532 by: Jochem Maas
        279533 by: Jay Moore
        279537 by: Bastien Koert
        279543 by: Jochem Maas
        279544 by: Robert Cummings

unset($_GET['i'])
        279521 by: Bill
        279522 by: Dan Shirah
        279524 by: Bill
        279526 by: Wolf
        279527 by: Boyd, Todd M.
        279528 by: Micah Gersten
        279530 by: Dan Shirah
        279538 by: Bill

Summing array indexes.
        279534 by: Tom Shaw
        279535 by: Eric Gorr
        279536 by: Micah Gersten
        279539 by: Diogo Neves
        279540 by: Tom Shaw
        279541 by: Jochem Maas

Re: Mulitiple Arrary Sort
        279542 by: Jochem Maas
        279547 by: Jim Lucas

fsockopen in phpmailer and tls
        279545 by: Larry Brown
        279546 by: Robert Cummings

Re: Chisimba-2.0.3 Released!
        279548 by: Paul Scott

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]


----------------------------------------------------------------------
--- Begin Message ---
Richard Heyes wrote:
Hi,

Is it just me, or is everyones disk thrshing more since installing (if
you have) Chrome? Oh, and to keep it in-line with list, isn't PHP
great? :-)

I uninstalled it precisely beacause of this behaviour. The disk was running crazy every time chrome was started. And I don't know how to do "lsof | grep chrome" on Windows to see what's going on.
--- End Message ---
--- Begin Message ---
On Thu, Sep 4, 2008 at 1:55 PM, Ovidiu Rosoiu
<[EMAIL PROTECTED]>wrote:

> Richard Heyes wrote:
>
>> Hi,
>>
>> Is it just me, or is everyones disk thrshing more since installing (if
>> you have) Chrome? Oh, and to keep it in-line with list, isn't PHP
>> great? :-)
>>
>>
>>
> I uninstalled it precisely beacause of this behaviour. The disk was running
> crazy every time chrome was started.
> And I don't know how to do "lsof | grep chrome" on Windows to see what's
> going on.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Strange, I am not seeing that behavior at all. I am currently running an
older Dell machine with 1.5Gb ram and have

Firefox 3  (5 tabs open including gmail and yahoo)
IE8  ( 1 tab open)
Chrome ( 1 tab open )

among a half dozen other apps open and I am not high in the disk or cpu
usage...

The biggest cpu hog for me right now is WMPlayer 11

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Ovidiu Rosoiu [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 04, 2008 12:56 PM
> To: Richard Heyes
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Google Chrome
> 
> Richard Heyes wrote:
> > Hi,
> >
> > Is it just me, or is everyones disk thrshing more since installing
> (if
> > you have) Chrome? Oh, and to keep it in-line with list, isn't PHP
> > great? :-)
> >
> >
> I uninstalled it precisely beacause of this behaviour. The disk was
> running crazy every time chrome was started.
> And I don't know how to do "lsof | grep chrome" on Windows to see
> what's
> going on.

You can at least track memory + cpu usage through the Task Manager
(Ctrl-Alt-Del + T on most distros). In the Task Manager, I also noticed
that GoogleUpdate.exe is running even when Chrome.exe is not. This made
me a bit curious, so I went into msconfig (the Microsoft GUI utility for
modifying startup programs, services, and system INI files) and saw that
GoogleUpdate.exe had been added to the list of programs to run on
Windows startup.

I hate, hate, HATE it when programs install resident agents that eat my
memory and perform background network activity. Rrgh! Points taken away
from Google for this app's EULA and its methods. Slick otherwise, though
(aside from the lack of XMLDOM instantiation support for Javascript)...


Todd Boyd
Web Programmer



--- End Message ---
--- Begin Message ---
There's an option for pre-buffering things, I believe.  It may be doing that. 
 Or it may be just indexing your whole HD and sending it's contents back to 
Google.  :)

-TG

----- Original Message -----
From: Ovidiu Rosoiu <[EMAIL PROTECTED]>
To: Richard Heyes <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Date: Thu, 04 Sep 2008 20:55:33 +0300
Subject: Re: [PHP] Google Chrome

> Richard Heyes wrote:
> > Hi,
> >
> > Is it just me, or is everyones disk thrshing more since installing (if
> > you have) Chrome? Oh, and to keep it in-line with list, isn't PHP
> > great? :-)
> >
> >   
> I uninstalled it precisely beacause of this behaviour. The disk was 
> running crazy every time chrome was started.
> And I don't know how to do "lsof | grep chrome" on Windows to see what's 
> going on.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
Wow, didn't notice the GoogleUpdate.exe, thanks for the heads up on
that.  Agreed about programs adding items in our startup.

On Thu, Sep 4, 2008 at 2:23 PM, Boyd, Todd M. <[EMAIL PROTECTED]> wrote:
>> -----Original Message-----
>> From: Ovidiu Rosoiu [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, September 04, 2008 12:56 PM
>> To: Richard Heyes
>> Cc: [EMAIL PROTECTED]
>> Subject: Re: [PHP] Google Chrome
>>
>> Richard Heyes wrote:
>> > Hi,
>> >
>> > Is it just me, or is everyones disk thrshing more since installing
>> (if
>> > you have) Chrome? Oh, and to keep it in-line with list, isn't PHP
>> > great? :-)
>> >
>> >
>> I uninstalled it precisely beacause of this behaviour. The disk was
>> running crazy every time chrome was started.
>> And I don't know how to do "lsof | grep chrome" on Windows to see
>> what's
>> going on.
>
> You can at least track memory + cpu usage through the Task Manager
> (Ctrl-Alt-Del + T on most distros). In the Task Manager, I also noticed
> that GoogleUpdate.exe is running even when Chrome.exe is not. This made
> me a bit curious, so I went into msconfig (the Microsoft GUI utility for
> modifying startup programs, services, and system INI files) and saw that
> GoogleUpdate.exe had been added to the list of programs to run on
> Windows startup.
>
> I hate, hate, HATE it when programs install resident agents that eat my
> memory and perform background network activity. Rrgh! Points taken away
> from Google for this app's EULA and its methods. Slick otherwise, though
> (aside from the lack of XMLDOM instantiation support for Javascript)...
>
>
> Todd Boyd
> Web Programmer
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
<!-- SNIP -->
> You can at least track memory + cpu usage through the Task Manager
> (Ctrl-Alt-Del + T on most distros). In the Task Manager, I also noticed
> that GoogleUpdate.exe is running even when Chrome.exe is not. This made
> me a bit curious, so I went into msconfig (the Microsoft GUI utility for
> modifying startup programs, services, and system INI files) and saw that
> GoogleUpdate.exe had been added to the list of programs to run on
> Windows startup.
> 
> I hate, hate, HATE it when programs install resident agents that eat my
> memory and perform background network activity. Rrgh! Points taken away
> from Google for this app's EULA and its methods. Slick otherwise, though
> (aside from the lack of XMLDOM instantiation support for Javascript)...

startup monitor -> sure it runs at startup, but that little bugger keeps an eye 
on my startup and asks me if I want to allow my startup to be modified.

:-)

--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:

> Will somebody volunteer to test on Wine or Mono?
> 
> -Shawn
> 
already done by this guy
http://www.myscienceisbetter.info/2008/09/install-google-chrome-on-linux-using-wine.html

eugene
-- 
---------------------------------------------------------------------
Eugene Mah, M.Sc., DABR               [EMAIL PROTECTED]
Medical Physicist/Misplaced Canuck    [EMAIL PROTECTED]
Department of Radiology               [EMAIL PROTECTED]
Medical University of South Carolina  "For I am a Bear of Very Little
Charleston, South Carolina             Brain, and long words Bother
http://www.netcom.com/~eugenem/        me."   Winnie the Pooh
http://radinfo.musc.edu/~eugenem/blog/
PGP KeyID = 0x1F9779FD, 0x319393F4
PGP keys available on request         ICQ 3113529                 O-
---------------------------------------------------------------------

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Wolf [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 04, 2008 1:34 PM
> To: Boyd, Todd M.
> Cc: [EMAIL PROTECTED]
> Subject: RE: [PHP] Google Chrome
> 
> <!-- SNIP -->
> > You can at least track memory + cpu usage through the Task Manager
> > (Ctrl-Alt-Del + T on most distros). In the Task Manager, I also
> noticed
> > that GoogleUpdate.exe is running even when Chrome.exe is not. This
> made
> > me a bit curious, so I went into msconfig (the Microsoft GUI utility
> for
> > modifying startup programs, services, and system INI files) and saw
> that
> > GoogleUpdate.exe had been added to the list of programs to run on
> > Windows startup.
> >
> > I hate, hate, HATE it when programs install resident agents that eat
> my
> > memory and perform background network activity. Rrgh! Points taken
> away
> > from Google for this app's EULA and its methods. Slick otherwise,
> though
> > (aside from the lack of XMLDOM instantiation support for
> Javascript)...
> 
> startup monitor -> sure it runs at startup, but that little bugger
> keeps an eye on my startup and asks me if I want to allow my startup to
> be modified.

Yeah, I used to use a program that had similar functionality. Haven't really 
bothered putting much of my "familiar" software on my work PC, but maybe I 
should after this... it has been bogging down a bit lately, after all.


Todd Boyd
Web Programmer




--- End Message ---
--- Begin Message ---
Yippie, Chrome already exploited for DoS attacks?

http://blogs.zdnet.com/security/?p=1847&tag=nl.e539

--- End Message ---
--- Begin Message ---
On Thu, Sep 4, 2008 at 4:31 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:

> Yippie, Chrome already exploited for DoS attacks?
>
> http://blogs.zdnet.com/security/?p=1847&tag=nl.e539
>

Its not a DoS, its just a browser crash

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
Bastien Koert schreef:
On Thu, Sep 4, 2008 at 4:31 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:

Yippie, Chrome already exploited for DoS attacks?

http://blogs.zdnet.com/security/?p=1847&tag=nl.e539


Its not a DoS, its just a browser crash

so forcing a browser to crash is not 'Denial of Service'?

I think your confused with DDoS




--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
Bastien Koert schreef:
On Thu, Sep 4, 2008 at 4:31 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:

Yippie, Chrome already exploited for DoS attacks?

http://blogs.zdnet.com/security/?p=1847&tag=nl.e539


Its not a DoS, its just a browser crash

so forcing a browser to crash is not 'Denial of Service'?

I think your confused with DDoS



It depends on what site he planned to visit.

Google - DoS
Zombo.com - Not DoS.

;)

--- End Message ---
--- Begin Message ---
On Thu, Sep 4, 2008 at 5:22 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:

> Bastien Koert schreef:
>
>> On Thu, Sep 4, 2008 at 4:31 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:
>>
>>  Yippie, Chrome already exploited for DoS attacks?
>>>
>>> http://blogs.zdnet.com/security/?p=1847&tag=nl.e539
>>>
>>>
>> Its not a DoS, its just a browser crash
>>
>
> so forcing a browser to crash is not 'Denial of Service'?
>
> I think your confused with DDoS
>
>
>>
>
DDoS is a Distributed Denial of Service attack where a server is attacked
via multiple computers (like a bot net) at the same time AFAIK

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
Bastien Koert schreef:
On Thu, Sep 4, 2008 at 5:22 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:

Bastien Koert schreef:

On Thu, Sep 4, 2008 at 4:31 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:

 Yippie, Chrome already exploited for DoS attacks?
http://blogs.zdnet.com/security/?p=1847&tag=nl.e539


Its not a DoS, its just a browser crash

so forcing a browser to crash is not 'Denial of Service'?

I think your confused with DDoS


DDoS is a Distributed Denial of Service attack where a server is attacked
via multiple computers (like a bot net) at the same time AFAIK

no shit. so if you drop the 'Distributed' you get 'Denial of Service'. DoS
is rather general, code that keeps crashing your browser on purpose is denying
you the service it provides (viewing webpages).

rather like someone running off with your girlfriend ... you get denied service.




--- End Message ---
--- Begin Message ---
On Fri, 2008-09-05 at 03:15 +0200, Jochem Maas wrote:
> Bastien Koert schreef:
> > On Thu, Sep 4, 2008 at 5:22 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> > 
> >> Bastien Koert schreef:
> >>
> >>> On Thu, Sep 4, 2008 at 4:31 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:
> >>>
> >>>  Yippie, Chrome already exploited for DoS attacks?
> >>>> http://blogs.zdnet.com/security/?p=1847&tag=nl.e539
> >>>>
> >>>>
> >>> Its not a DoS, its just a browser crash
> >>>
> >> so forcing a browser to crash is not 'Denial of Service'?
> >>
> >> I think your confused with DDoS
> >>
> >>
> > DDoS is a Distributed Denial of Service attack where a server is attacked
> > via multiple computers (like a bot net) at the same time AFAIK
> 
> no shit. so if you drop the 'Distributed' you get 'Denial of Service'. DoS
> is rather general, code that keeps crashing your browser on purpose is denying
> you the service it provides (viewing webpages).
> 
> rather like someone running off with your girlfriend ... you get denied 
> service.

I thought Chrome was set up so if your current page caused a crash other
loaded pages didn't crash also. In which case DoS doesn't apply if only
the requested page crashes since you're still getting service.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
Hi

given page1 has a list of goods and sends $i as a variable into a link to page2, ie, <a href="page2.php?i=3">send</a>

Page2 adds the items recieved in an array.

In page2 how can I unset the $_GET['i'] so that if I press F5(refresh) it doesn't add the same item to the array ?

I tried unset($_GET['i']) but no success.

Thanks

--- End Message ---
--- Begin Message ---
>
> Hi
>
> given page1 has a list of goods and sends $i as a variable into a link to
> page2, ie, <a href="page2.php?i=3">send</a>
>
> Page2 adds the items recieved in an array.
>
> In page2 how can I unset the $_GET['i'] so that if I press F5(refresh) it
> doesn't add the same item to the array ?
>
> I tried unset($_GET['i']) but no success.
>
> Thanks


How about just adding a simple counter on your page.

if ($count == "0") {

Run through your script
At the end update the variable: $count == "1";

} else {

Don't run throught script because the value has already been added

}

--- End Message ---
--- Begin Message ---
Dan Shirah a écrit :
How about just adding a simple counter on your page.


That's what I do but that "counter" resets when you press F5 and is not functionnal.

Why $_GET['i'] doesn't unsets ?

--- End Message ---
--- Begin Message ---
---- Bill <[EMAIL PROTECTED]> wrote: 
> Dan Shirah a écrit :
> > How about just adding a simple counter on your page.
> > 
> 
> That's what I do but that "counter" resets when you press F5 and is not 
> functionnal.
> 
> Why $_GET['i'] doesn't unsets ?

Because you get a new i from the URL, hence the GET

What you can do is set a session variable when you GET the first i, then just 
check and if the session variable is present, you don't process the next time 
you GET i.

Wolf

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Bill [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 04, 2008 3:23 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] unset($_GET['i'])
> 
> Dan Shirah a écrit :
> > How about just adding a simple counter on your page.
> >
> 
> That's what I do but that "counter" resets when you press F5 and is not
> functionnal.
> 
> Why $_GET['i'] doesn't unsets ?

Your page URL has ?i=asdf in it. As such, $_GET['i'] is being set every time 
you refresh that particular URL. Unsetting $_GET['i'] will only erase the 
variable for that instance of that PHP script. As soon as you refresh, you are 
calling a new instance of that PHP script and assigning $_GET['i'] the value 
"asdf" (or whatever).

If clearing that value on refresh is truly important to you, then don't use GET.


Todd Boyd
Web Programmer




--- End Message ---
--- Begin Message ---
The $_GET array comes from the URL which is resent every time someone
hits F5.  unset works on the server, not on the browser.  You could
capture it, add it to the session and then redirect without it in the URL.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Bill wrote:
> Dan Shirah a écrit :
>> How about just adding a simple counter on your page.
>>
>
> That's what I do but that "counter" resets when you press F5 and is
> not functionnal.
>
> Why $_GET['i'] doesn't unsets ?
>


-- 


Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


--- End Message ---
--- Begin Message ---
>
> Dan Shirah a écrit :
>
>> How about just adding a simple counter on your page.
>>
>>
> That's what I do but that "counter" resets when you press F5 and is not
> functionnal.
>
> Why $_GET['i'] doesn't unsets ?



Are you saving the array to a database once it is created?  If not, wouldn't
the array be recreated once someone refreshes the page as well?

--- End Message ---
--- Begin Message ---

Why $_GET['i'] doesn't unsets ?

Your page URL has ?i=asdf in it. As such, $_GET['i'] is being set every time you refresh 
that particular URL. Unsetting $_GET['i'] will only erase the variable for that instance 
of that PHP script. As soon as you refresh, you are calling a new instance of that PHP 
script and assigning $_GET['i'] the value "asdf" (or whatever).


Not using GET means rewriting all the pages.
Ok then I'll use a session variable.


Thanks you all.

--- End Message ---
--- Begin Message ---
Is there an easy way to loop thru the array below and add the incremented
total price indexes so the order_total_price index contains the correct sum.
Any help would be greatly appreciated.

 

 

array(5) {

  [0] => array(15) {

    ["order_date"] => string(8) "09-01-08"

    ["order_product_price_1"] => string(5) "10.00"

    ["order_product_price_2"] => string(5) "20.00"

    ["order_total_price"] => string(0) ""

  }

  [1] => array(19) {

    ["order_date"] => string(8) "09-01-08"

    ["order_product_price_1"] => string(5) "25.00"

    ["order_product_price_2"] => string(5) "15.00"

    ["order_total_price"] => string(0) ""

  }

 

Like this. 

 

array(5) {

  [0] => array(15) {

    ["order_date"] => string(8) "09-01-08"

    ["order_product_price_1"] => string(5) "10.00"

    ["order_product_price_2"] => string(5) "20.00"

    ["order_total_price"] => string(0) "30.00"

  }

  [1] => array(19) {

    ["order_date"] => string(8) "09-01-08"

    ["order_product_price_1"] => string(5) "25.00"

    ["order_product_price_2"] => string(5) "15.00"

    ["order_total_price"] => string(0) "40.00"

  }

 

Tom Shaw

 

[EMAIL PROTECTED]

 


--- End Message ---
--- Begin Message --- Not a direct answer to your question (don't worry, I hate it when people do this to me too), but one thought I had was to have all of the products ordered as their own array.

[0] => array(15) {
  ["order_date"] => string(8) "09-01-08"
  ["order_products"] => array(2) {
        [0] => string(5) "10.00"   
        [1] => string(5) "20.00"
  }
  ["order_total_price"] => string(0) ""
}

In this case, it would be trivial to write a foreach loop on the 'order_products' array to calculate the total.


Otherwise, run a foreach over the array, looking for keys which begin with order_product_price_ and, when found, grab the price and add it to order_total_price.



On Sep 4, 2008, at 6:02 PM, Tom Shaw wrote:

------=_NextPart_000_004B_01C90EAF.FA964EB0
Content-Type: text/plain;
        charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Is there an easy way to loop thru the array below and add the incremented total price indexes so the order_total_price index contains the correct sum.
Any help would be greatly appreciated.





array(5) {

 [0] => array(15) {

   ["order_date"] => string(8) "09-01-08"

   ["order_product_price_1"] => string(5) "10.00"

   ["order_product_price_2"] => string(5) "20.00"

   ["order_total_price"] => string(0) ""

 }

 [1] => array(19) {

   ["order_date"] => string(8) "09-01-08"

   ["order_product_price_1"] => string(5) "25.00"

   ["order_product_price_2"] => string(5) "15.00"

   ["order_total_price"] => string(0) ""

 }



Like this.



array(5) {

 [0] => array(15) {

   ["order_date"] => string(8) "09-01-08"

   ["order_product_price_1"] => string(5) "10.00"

   ["order_product_price_2"] => string(5) "20.00"

   ["order_total_price"] => string(0) "30.00"

 }

 [1] => array(19) {

   ["order_date"] => string(8) "09-01-08"

   ["order_product_price_1"] => string(5) "25.00"

   ["order_product_price_2"] => string(5) "15.00"

   ["order_total_price"] => string(0) "40.00"

 }



Tom Shaw



[EMAIL PROTECTED]




------=_NextPart_000_004B_01C90EAF.FA964EB0--



--- End Message ---
--- Begin Message ---
This should help:
http://us.php.net/array_walk

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Tom Shaw wrote:
> Is there an easy way to loop thru the array below and add the incremented
> total price indexes so the order_total_price index contains the correct sum.
> Any help would be greatly appreciated.
>
>  
>
>  
>
> array(5) {
>
>   [0] => array(15) {
>
>     ["order_date"] => string(8) "09-01-08"
>
>     ["order_product_price_1"] => string(5) "10.00"
>
>     ["order_product_price_2"] => string(5) "20.00"
>
>     ["order_total_price"] => string(0) ""
>
>   }
>
>   [1] => array(19) {
>
>     ["order_date"] => string(8) "09-01-08"
>
>     ["order_product_price_1"] => string(5) "25.00"
>
>     ["order_product_price_2"] => string(5) "15.00"
>
>     ["order_total_price"] => string(0) ""
>
>   }
>
>  
>
> Like this. 
>
>  
>
> array(5) {
>
>   [0] => array(15) {
>
>     ["order_date"] => string(8) "09-01-08"
>
>     ["order_product_price_1"] => string(5) "10.00"
>
>     ["order_product_price_2"] => string(5) "20.00"
>
>     ["order_total_price"] => string(0) "30.00"
>
>   }
>
>   [1] => array(19) {
>
>     ["order_date"] => string(8) "09-01-08"
>
>     ["order_product_price_1"] => string(5) "25.00"
>
>     ["order_product_price_2"] => string(5) "15.00"
>
>     ["order_total_price"] => string(0) "40.00"
>
>   }
>
>  
>
> Tom Shaw
>
>  
>
> [EMAIL PROTECTED]
>
>  
>
>
>   

--- End Message ---
--- Begin Message ---
On Thu, Sep 4, 2008 at 11:02 PM, Tom Shaw <[EMAIL PROTECTED]> wrote:

> Is there an easy way to loop thru the array below and add the incremented
> total price indexes so the order_total_price index contains the correct
> sum.
> Any help would be greatly appreciated.
>
>
>
>
>
> array(5) {
>
>  [0] => array(15) {
>
>    ["order_date"] => string(8) "09-01-08"
>
>    ["order_product_price_1"] => string(5) "10.00"
>
>    ["order_product_price_2"] => string(5) "20.00"
>
>    ["order_total_price"] => string(0) ""
>
>  }
>
>  [1] => array(19) {
>
>    ["order_date"] => string(8) "09-01-08"
>
>    ["order_product_price_1"] => string(5) "25.00"
>
>    ["order_product_price_2"] => string(5) "15.00"
>
>    ["order_total_price"] => string(0) ""
>
>  }
>
>
>
> Like this.
>
>
>
> array(5) {
>
>  [0] => array(15) {
>
>    ["order_date"] => string(8) "09-01-08"
>
>    ["order_product_price_1"] => string(5) "10.00"
>
>    ["order_product_price_2"] => string(5) "20.00"
>
>    ["order_total_price"] => string(0) "30.00"
>
>  }
>
>  [1] => array(19) {
>
>    ["order_date"] => string(8) "09-01-08"
>
>    ["order_product_price_1"] => string(5) "25.00"
>
>    ["order_product_price_2"] => string(5) "15.00"
>
>    ["order_total_price"] => string(0) "40.00"
>
>  }
>
>
>
> Tom Shaw
>
>
>
> [EMAIL PROTECTED]
>
>
>
> foreach( $arr_top as $arr_top_elem ) {
    $total = 0;
    foreach( $arr_top_elem as $key => $elem ) {
         if ( strpos( 'order_product_price_' ) === 0 ) {
            $total += $elem;
        }
    }
    $arr_top_elem['order_total_price'] = $total;
}

This should do da trick...

-- 
Thanks,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt

--- End Message ---
--- Begin Message ---
Thanks for every ones help. I just used a bunch of control structures and
issest's to add it up. Not pretty but works.

if (isset($data['order_product_amount_0'])) {
        $data['order_product_total'] =
number_format($data['order_product_amount_0'], 2, '.', '');
} 
if (isset($data['order_product_amount_1'])) {
        $data['order_product_total'] =
number_format($data['order_product_total'] +
$data['order_product_amount_1'], 2, '.', '');
}

-----Original Message-----
From: Eric Gorr [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 04, 2008 5:17 PM
To: PHP General; Tom Shaw
Subject: Re: [PHP] Summing array indexes.

Not a direct answer to your question (don't worry, I hate it when  
people do this to me too), but one thought I had was to have all of  
the products ordered as their own array.

[0] => array(15) {
   ["order_date"] => string(8) "09-01-08"
   ["order_products"] => array(2) {
        [0] => string(5) "10.00"        
        [1] => string(5) "20.00"
   }
   ["order_total_price"] => string(0) ""
}

In this case, it would be trivial to write a foreach loop on the  
'order_products' array to calculate the total.


Otherwise, run a foreach over the array, looking for keys which begin  
with order_product_price_ and, when found, grab the price and add it  
to order_total_price.



On Sep 4, 2008, at 6:02 PM, Tom Shaw wrote:

> ------=_NextPart_000_004B_01C90EAF.FA964EB0
> Content-Type: text/plain;
>       charset="US-ASCII"
> Content-Transfer-Encoding: 7bit
>
> Is there an easy way to loop thru the array below and add the  
> incremented
> total price indexes so the order_total_price index contains the  
> correct sum.
> Any help would be greatly appreciated.
>
>
>
>
>
> array(5) {
>
>  [0] => array(15) {
>
>    ["order_date"] => string(8) "09-01-08"
>
>    ["order_product_price_1"] => string(5) "10.00"
>
>    ["order_product_price_2"] => string(5) "20.00"
>
>    ["order_total_price"] => string(0) ""
>
>  }
>
>  [1] => array(19) {
>
>    ["order_date"] => string(8) "09-01-08"
>
>    ["order_product_price_1"] => string(5) "25.00"
>
>    ["order_product_price_2"] => string(5) "15.00"
>
>    ["order_total_price"] => string(0) ""
>
>  }
>
>
>
> Like this.
>
>
>
> array(5) {
>
>  [0] => array(15) {
>
>    ["order_date"] => string(8) "09-01-08"
>
>    ["order_product_price_1"] => string(5) "10.00"
>
>    ["order_product_price_2"] => string(5) "20.00"
>
>    ["order_total_price"] => string(0) "30.00"
>
>  }
>
>  [1] => array(19) {
>
>    ["order_date"] => string(8) "09-01-08"
>
>    ["order_product_price_1"] => string(5) "25.00"
>
>    ["order_product_price_2"] => string(5) "15.00"
>
>    ["order_total_price"] => string(0) "40.00"
>
>  }
>
>
>
> Tom Shaw
>
>
>
> [EMAIL PROTECTED]
>
>
>
>
> ------=_NextPart_000_004B_01C90EAF.FA964EB0--
>


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


--- End Message ---
--- Begin Message ---
Tom Shaw schreef:
Thanks for every ones help. I just used a bunch of control structures and
issest's to add it up. Not pretty but works.

if (isset($data['order_product_amount_0'])) {
        $data['order_product_total'] =
number_format($data['order_product_amount_0'], 2, '.', '');
} if (isset($data['order_product_amount_1'])) {
        $data['order_product_total'] =
number_format($data['order_product_total'] +
$data['order_product_amount_1'], 2, '.', '');
}

foreach ($orders as $data) {
        $total = 0;
        foreach ($data as $key => $val) {
                if (strpos('order_product_amount', $key) === 0)
                        $total += (float)$val;
        }

        $data['order_product_total'] = number_format($total, 2, '.', '');
}


-----Original Message-----
From: Eric Gorr [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2008 5:17 PM
To: PHP General; Tom Shaw
Subject: Re: [PHP] Summing array indexes.

Not a direct answer to your question (don't worry, I hate it when people do this to me too), but one thought I had was to have all of the products ordered as their own array.

[0] => array(15) {
   ["order_date"] => string(8) "09-01-08"
   ["order_products"] => array(2) {
        [0] => string(5) "10.00"   
        [1] => string(5) "20.00"
   }
   ["order_total_price"] => string(0) ""
}

In this case, it would be trivial to write a foreach loop on the 'order_products' array to calculate the total.


Otherwise, run a foreach over the array, looking for keys which begin with order_product_price_ and, when found, grab the price and add it to order_total_price.



On Sep 4, 2008, at 6:02 PM, Tom Shaw wrote:

------=_NextPart_000_004B_01C90EAF.FA964EB0
Content-Type: text/plain;
        charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Is there an easy way to loop thru the array below and add the incremented total price indexes so the order_total_price index contains the correct sum.
Any help would be greatly appreciated.





array(5) {

 [0] => array(15) {

   ["order_date"] => string(8) "09-01-08"

   ["order_product_price_1"] => string(5) "10.00"

   ["order_product_price_2"] => string(5) "20.00"

   ["order_total_price"] => string(0) ""

 }

 [1] => array(19) {

   ["order_date"] => string(8) "09-01-08"

   ["order_product_price_1"] => string(5) "25.00"

   ["order_product_price_2"] => string(5) "15.00"

   ["order_total_price"] => string(0) ""

 }



Like this.



array(5) {

 [0] => array(15) {

   ["order_date"] => string(8) "09-01-08"

   ["order_product_price_1"] => string(5) "10.00"

   ["order_product_price_2"] => string(5) "20.00"

   ["order_total_price"] => string(0) "30.00"

 }

 [1] => array(19) {

   ["order_date"] => string(8) "09-01-08"

   ["order_product_price_1"] => string(5) "25.00"

   ["order_product_price_2"] => string(5) "15.00"

   ["order_total_price"] => string(0) "40.00"

 }



Tom Shaw



[EMAIL PROTECTED]




------=_NextPart_000_004B_01C90EAF.FA964EB0--





--- End Message ---
--- Begin Message ---
Diogo Neves schreef:
On Wed, Sep 3, 2008 at 12:35 AM, Vernon <[EMAIL PROTECTED]> wrote:

I've gotten the one array down and I've figured out how to sort that array,
however, I need to sort the array by the modified date of the file. Here's
what I got so far:

<?php
// Open current directory
if($handle = opendir($dir)){
// Loop through all files
while(false !== ($file = readdir($handle))){
// Ignore hidden files
if(!preg_match("/^\./", $file)){
// Put dirs in $dirs[] and files in $files[]
if(is_dir($file)){
$dirs[] = $file;
}else{
$files[] = $file;
}
}
}

// Close directory
closedir($handle);


// if $files[] exists, sort it and print all elements in it.
if(is_array($files)){
//HERE IS MY CURRENT SORT WHICH I KNOW I NEED TO CHANGE BUT AM UNSURE HOW
sort($files);
foreach($files as $file){
$completeFileName = $dir . $file;
//I WANT TO SORT BY THIS
echo date("m-d-Y", filemtime($completeFileName)) . "<br>";
}
}

}
?>

Any ideas on how to fix this? Thanks

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


Hi,

<?php
$dir        = '/tmp';
$files        = scandir( $dir);
$files_new    = array( );

foreach( $files as $file ) {
    if( strrpos( $file, 'sess_' ) !== false ) {
        $files_new[filemtime( $dir . '/' . $file )] = $file;

this totally breaks because file modification time is only accurate
to a second (many files can be modified in that time) ... appending
the file name to the key will fix that:

        $files_new[filemtime( $dir . '/' . $file ).$file] = $file;

    }
}

ksort( $files_new );
var_dump( $filesnew );
?>





--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
Diogo Neves schreef:
On Wed, Sep 3, 2008 at 12:35 AM, Vernon <[EMAIL PROTECTED]> wrote:

I've gotten the one array down and I've figured out how to sort that array, however, I need to sort the array by the modified date of the file. Here's
what I got so far:

<?php
// Open current directory
if($handle = opendir($dir)){
// Loop through all files
while(false !== ($file = readdir($handle))){
// Ignore hidden files
if(!preg_match("/^\./", $file)){
// Put dirs in $dirs[] and files in $files[]
if(is_dir($file)){
$dirs[] = $file;
}else{
$files[] = $file;
}
}
}

// Close directory
closedir($handle);


// if $files[] exists, sort it and print all elements in it.
if(is_array($files)){
//HERE IS MY CURRENT SORT WHICH I KNOW I NEED TO CHANGE BUT AM UNSURE HOW
sort($files);
foreach($files as $file){
$completeFileName = $dir . $file;
//I WANT TO SORT BY THIS
echo date("m-d-Y", filemtime($completeFileName)) . "<br>";
}
}

}
?>

Any ideas on how to fix this? Thanks

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


Hi,

<?php
$dir        = '/tmp';
$files        = scandir( $dir);
$files_new    = array( );

foreach( $files as $file ) {
    if( strrpos( $file, 'sess_' ) !== false ) {
        $files_new[filemtime( $dir . '/' . $file )] = $file;

this totally breaks because file modification time is only accurate
to a second (many files can be modified in that time) ... appending
the file name to the key will fix that:

    $files_new[filemtime( $dir . '/' . $file ).$file] = $file;


or flip the association around, because files are uniq and that file can only have one modification time.

    }
}

ksort( $files_new );
var_dump( $filesnew );
?>







--- End Message ---
--- Begin Message ---
I am having a ball of a time trying to figure this one out... If anyone
has dealt with this before I'd love to get some morsels of wisdom from
you...

I am trying to connect to a postfix server I have set up remotely using
smtp auth with tls.  The postfix appears to be configured correctly at
this point.  I can telnet to port 25 and it will list tls as an option
as the howto describes it should.  I try to connect from php and get:

PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
Error messages:
error:1408F10B:SSL routines:func(143):reason(267)
in /opt/scriptsMain/include/class.smtp.php on line 122

I've googled this and someone seems very knowledgeable about it yet
describes the solution in a way that a mere mortal like myself can't
follow.  He states in part:

"Look at the error message:
error:1408F10B:SSL routines:func(143):reason(267)

Take the reason code (267) and determine the error:
grep 267 /usr/include/openssl/ssl.h
/usr/include/openssl/ssl.h:#define SSL_R_WRONG_VERSION_NUMBER           
        267

Now google for SSL_R_WRONG_VERSION_NUMBER..."

..."So in your server method configuration you must put:
      SSL_CTX *ctx = SSL_CTX_new (SSLv23_server_method())
    to correctely analyse the first client_hello message
    instead of 
      SSL_CTX *ctx = SSL_CTX_new (SSLv3_server_method())
    which i suppose you did"

So is he talking about modifying the source code in postfix and 
rebuilding it?  Have any of you guys dealt with this?...

By the way, when I started out I had a typo in the postfix 
config for the path to the certificates for ssl and was getting 
the same error message.  It wasn't until I saw in the postfix 
mail log that it couldn't read the cert.  So that was fixed but 
I continue to get the same message which I'm now thinking might 
be a red herring.


-- 
Larry Brown <[EMAIL PROTECTED]>


--- End Message ---
--- Begin Message ---
On Thu, 2008-09-04 at 23:20 -0400, Larry Brown wrote:
> I am having a ball of a time trying to figure this one out... If anyone
> has dealt with this before I'd love to get some morsels of wisdom from
> you...
> 
> I am trying to connect to a postfix server I have set up remotely using
> smtp auth with tls.  The postfix appears to be configured correctly at
> this point.  I can telnet to port 25 and it will list tls as an option
> as the howto describes it should.  I try to connect from php and get:
> 
> PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
> Error messages:
> error:1408F10B:SSL routines:func(143):reason(267)
> in /opt/scriptsMain/include/class.smtp.php on line 122
> 
> I've googled this and someone seems very knowledgeable about it yet
> describes the solution in a way that a mere mortal like myself can't
> follow.  He states in part:
> 
> "Look at the error message:
> error:1408F10B:SSL routines:func(143):reason(267)
> 
> Take the reason code (267) and determine the error:
> grep 267 /usr/include/openssl/ssl.h
> /usr/include/openssl/ssl.h:#define SSL_R_WRONG_VERSION_NUMBER           
>         267
> 
> Now google for SSL_R_WRONG_VERSION_NUMBER..."
> 
> ..."So in your server method configuration you must put:
>       SSL_CTX *ctx = SSL_CTX_new (SSLv23_server_method())
>     to correctely analyse the first client_hello message
>     instead of 
>       SSL_CTX *ctx = SSL_CTX_new (SSLv3_server_method())
>     which i suppose you did"
> 
> So is he talking about modifying the source code in postfix and 
> rebuilding it?  Have any of you guys dealt with this?...
> 
> By the way, when I started out I had a typo in the postfix 
> config for the path to the certificates for ssl and was getting 
> the same error message.  It wasn't until I saw in the postfix 
> mail log that it couldn't read the cert.  So that was fixed but 
> I continue to get the same message which I'm now thinking might 
> be a red herring.

Possibly a complete waste of your time... but maybe you need to
configure this setting:

    smtp_tls_mandatory_protocols

    http://www.postfix.org/postconf.5.html

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
The next release of the Chisimba PHP5 framework is now available.

Major enhancements included in this release are:

 - PDO and MDB2 support
 - Improved database performance
 - Bug fixes
 - Better code documentation
 - API integration for many more modules
 - Remote downloads of modules (apt like module installations)

and, of course, new modules to add onto your installation!

Please take a look, download it and give it a test drive! 
 
Chisimba, for those that don't know it already, is a PHP5 framework made
in Africa, for Africa. It is a collaboration between around 16 African
Universities, as well as around 35 active developers from around the
continent.
 
It can be downloaded from AVOIR at:
 
http://trac.uwc.ac.za/trac/chisimba/downloader/download/release/5

and the docs can be found at:
 
http://avoir.uwc.ac.za/

There are server setup instructions, as well as installation
walkthroughs available linking from the main AVOIR site:
 
For those interested in developing a module, or just getting some
additional info please join our mailing list and ask some questions:
 
http://mailman.uwc.ac.za/mailman/listinfo/nextgen-online

--Paul

-- 
------------------------------------------------------------.
| Chisimba PHP5 Framework - http://avoir.uwc.ac.za           |
:------------------------------------------------------------:

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

--- End Message ---

Reply via email to