php-general Digest 4 Mar 2010 11:34:02 -0000 Issue 6620

Topics (messages 302515 through 302532):

Re: Memory investigation
        302515 by: dsiembab01.gmail.com
        302516 by: larry.garfieldtech.com
        302522 by: Rene Veerman
        302525 by: dsiembab01.gmail.com
        302526 by: larry.garfieldtech.com

Re: Database design
        302517 by: dsiembab01.gmail.com

basic authentication and redirection
        302518 by: Bill Rausch
        302521 by: Rene Veerman
        302523 by: Jay Blanchard
        302524 by: Robert Cummings

Best os shopping cart
        302519 by: Haig Davis
        302520 by: Robert Cummings
        302527 by: Ashley Sheridan
        302528 by: tedd
        302529 by: Shawn McKenzie

Re: inexplicable behaviour of pre- and post-increment  operators
        302530 by: clancy_1.cybec.com.au

XMLRPC issue
        302531 by: Dmitry Ruban

Re: App to put a whole PHP Site in CD/DVD
        302532 by: David Robley

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
function check_memory_usage(&$memory)
{
    $memory[] = memory_get_usage();
    return $memory;
}

something like this?
you can put it wherever you like and returns an array for further processing. You could optionally add a second argument to set the index to a name and check if the name exists to add 1 to the end of the name so your indexes stay maintained.
--- End Message ---
--- Begin Message ---
That's not really what I'm after.  Let me try an example:

function foo($id) {
  static $foos = array();

  if (empty($foos[$id]) {
    $foos[$id] = load_foo($id);
  }
  return $foos[$id];
}

When load_foo() is slow (e.g., lots of DB traffic or remote-server calls or whatever), such caching can have a significant performance boost. Sometime after foo() has been called 15 times from 30 places in code, when I get to the end of the request (or just every time I call foo() would be fine) I want to be able to do something like:

$cost = get_memory_used_by($foos);

So that I can determine how much memory that caching is costing me over the lifetime of the page, and determine if it's a worthwhile trade-off.

--Larry Garfield

dsiemba...@gmail.com wrote:
function check_memory_usage(&$memory)
{
    $memory[] = memory_get_usage();
    return $memory;
}

something like this?
you can put it wherever you like and returns an array for further processing. You could optionally add a second argument to set the index to a name and check if the name exists to add 1 to the end of the name so your indexes stay maintained.


--- End Message ---
--- Begin Message ---
global $fooSize = 0;

function foo($id) {
....
global $fooSize;
if (empty($foos($id)) {
  $b = get_memory_usage(true);
  $foos[$id] = load_foo($id);
  $fooSize+= $b - get_memory_usage(true);
}
...
}
On Wed, Mar 3, 2010 at 8:16 PM, la...@garfieldtech.com
<la...@garfieldtech.com> wrote:
> That's not really what I'm after.  Let me try an example:
>
> function foo($id) {
>  static $foos = array();
>
>  if (empty($foos[$id]) {
>    $foos[$id] = load_foo($id);
>  }
>  return $foos[$id];
> }
>
> When load_foo() is slow (e.g., lots of DB traffic or remote-server calls or
> whatever), such caching can have a significant performance boost. Sometime
> after foo() has been called 15 times from 30 places in code, when I get to
> the end of the request (or just every time I call foo() would be fine) I
> want to be able to do something like:
>
> $cost = get_memory_used_by($foos);
>
> So that I can determine how much memory that caching is costing me over the
> lifetime of the page, and determine if it's a worthwhile trade-off.
>
> --Larry Garfield
>
> dsiemba...@gmail.com wrote:
>>
>> function check_memory_usage(&$memory)
>> {
>>    $memory[] = memory_get_usage();
>>    return $memory;
>> }
>>
>> something like this?
>> you can put it wherever you like and returns an array for further
>> processing. You could optionally add a second argument to set the index to a
>> name and check if the name exists to add 1 to the end of the name so your
>> indexes stay maintained.
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message --- couple questions Larry is this application composed of classes or straight up no holes barred procedural code?

la...@garfieldtech.com wrote:
That's not really what I'm after.  Let me try an example:

function foo($id) {
  static $foos = array();

  if (empty($foos[$id]) {
    $foos[$id] = load_foo($id);
  }
  return $foos[$id];
}

When load_foo() is slow (e.g., lots of DB traffic or remote-server calls or whatever), such caching can have a significant performance boost. Sometime after foo() has been called 15 times from 30 places in code, when I get to the end of the request (or just every time I call foo() would be fine) I want to be able to do something like:

$cost = get_memory_used_by($foos);

So that I can determine how much memory that caching is costing me over the lifetime of the page, and determine if it's a worthwhile trade-off.

--Larry Garfield

dsiemba...@gmail.com wrote:
function check_memory_usage(&$memory)
{
    $memory[] = memory_get_usage();
    return $memory;
}

something like this?
you can put it wherever you like and returns an array for further processing. You could optionally add a second argument to set the index to a name and check if the name exists to add 1 to the end of the name so your indexes stay maintained.


--- End Message ---
--- Begin Message --- Currently it's mostly procedural with some components that are OO. I suspect most of the memory sinks are large arrays (we have a lot of them), but I am not certain of that. Hence my interest in more accurate investigation tools.

--Larry Garfield

dsiemba...@gmail.com wrote:
couple questions Larry is this application composed of classes or straight up no holes barred procedural code?

la...@garfieldtech.com wrote:
That's not really what I'm after.  Let me try an example:

function foo($id) {
  static $foos = array();

  if (empty($foos[$id]) {
    $foos[$id] = load_foo($id);
  }
  return $foos[$id];
}

When load_foo() is slow (e.g., lots of DB traffic or remote-server calls or whatever), such caching can have a significant performance boost. Sometime after foo() has been called 15 times from 30 places in code, when I get to the end of the request (or just every time I call foo() would be fine) I want to be able to do something like:

$cost = get_memory_used_by($foos);

So that I can determine how much memory that caching is costing me over the lifetime of the page, and determine if it's a worthwhile trade-off.

--Larry Garfield

dsiemba...@gmail.com wrote:
function check_memory_usage(&$memory)
{
    $memory[] = memory_get_usage();
    return $memory;
}

something like this?
you can put it wherever you like and returns an array for further processing. You could optionally add a second argument to set the index to a name and check if the name exists to add 1 to the end of the name so your indexes stay maintained.



--- End Message ---
--- Begin Message ---
a good tool for mapping mysql databases is mysql-workbench.
the real question is how much normalization is normal?
http://wb.mysql.com

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


Hi there,

In certain circumstances controlled by my users, I'd like to redirect my users to another site, a third party whom we have contracted with. The second site uses basic authentication with a simple username and password. Can I write my PHP code so my users do not have to login (or even know the username/password) on the remote site?

This isn't intended to stop serious hackers, just enough security to stop casual passers-by.

Thanks,

Bill


--
Bill Rausch

We first make our habits and then our habits make us. --John Dryden

--- End Message ---
--- Begin Message ---
depends on how that site does its authentication...

if it's a form, it may need an extra setting to allow you to go to a
specific page on that site after authentication.

On Wed, Mar 3, 2010 at 8:25 PM, Bill Rausch <brau...@owt.com> wrote:
>
>
> Hi there,
>
> In certain circumstances controlled by my users, I'd like to redirect my
> users to another site, a third party whom we have contracted with. The
> second site uses basic authentication with a simple username and password.
> Can I write my PHP code so my users do not have to login (or even know the
> username/password) on the remote site?
>
> This isn't intended to stop serious hackers, just enough security to stop
> casual passers-by.
>
> Thanks,
>
> Bill
>
>
> --
> Bill Rausch
>
> We first make our habits and then our habits make us. --John Dryden
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
[snip]
In certain circumstances controlled by my users, I'd like to redirect 
my users to another site, a third party whom we have contracted with. 
The second site uses basic authentication with a simple username and 
password. Can I write my PHP code so my users do not have to login 
(or even know the username/password) on the remote site?

This isn't intended to stop serious hackers, just enough security to 
stop casual passers-by.
[/snip]

Have a look at cURL (http://www.php.net/curl) as it will allow you to
perform remote POST's which may be enough to get you through.

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
[snip]
In certain circumstances controlled by my users, I'd like to redirect my users to another site, a third party whom we have contracted with. The second site uses basic authentication with a simple username and password. Can I write my PHP code so my users do not have to login (or even know the username/password) on the remote site?

This isn't intended to stop serious hackers, just enough security to stop casual passers-by.
[/snip]

Have a look at cURL (http://www.php.net/curl) as it will allow you to
perform remote POST's which may be enough to get you through.

Or you can use JavaScript on an intermediate page to post directly to the remote site's login form. If JavaScript is disabled, just have a button "Please continue to XXX" which then performs the post tot he remote site.

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

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

I apologise if this is not strictly php related. What Open Source Shopping
cart system do you recommend between osCommerce and Zen-Cart for ease of use
and a php guy with dangerously little javascript knowledge?

This is not for a massive shopping site, simply a cart to power a
subscription sign-up page.

Thanks for the advice.

Haig

--- End Message ---
--- Begin Message ---
Haig Davis wrote:
Hi,

I apologise if this is not strictly php related. What Open Source Shopping
cart system do you recommend between osCommerce and Zen-Cart for ease of use
and a php guy with dangerously little javascript knowledge?

This is not for a massive shopping site, simply a cart to power a
subscription sign-up page.

At this point in time I would choose ZenCart over osCommerce since development of osCommerce has languished for the past 3+ years at version 2.2 and version 3.0 has been in alpha for just as long.

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

--- End Message ---
--- Begin Message ---
On Wed, 2010-03-03 at 14:46 -0500, Robert Cummings wrote:

> Haig Davis wrote:
> > Hi,
> > 
> > I apologise if this is not strictly php related. What Open Source Shopping
> > cart system do you recommend between osCommerce and Zen-Cart for ease of use
> > and a php guy with dangerously little javascript knowledge?
> > 
> > This is not for a massive shopping site, simply a cart to power a
> > subscription sign-up page.
> 
> At this point in time I would choose ZenCart over osCommerce since 
> development of osCommerce has languished for the past 3+ years at 
> version 2.2 and version 3.0 has been in alpha for just as long.
> 
> Cheers,
> Rob.
> -- 
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 


If it's an option, I'd recommend Magento. I've not used it, but I've
heard a lot of good things about it.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
At 11:29 AM -0800 3/3/10, Haig Davis wrote:
Hi,

I apologise if this is not strictly php related. What Open Source Shopping
cart system do you recommend between osCommerce and Zen-Cart for ease of use
and a php guy with dangerously little javascript knowledge?

This is not for a massive shopping site, simply a cart to power a
subscription sign-up page.

Thanks for the advice.

Haig

Haig:

A subscription sign-up page? That doesn't sound like a shopping cart problem.

You mean something like this:

http://webbytedd.com/b/sub-email/

Cheers,

tedd


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

--- End Message ---
--- Begin Message ---
Haig Davis wrote:
> Hi,
> 
> I apologise if this is not strictly php related. What Open Source Shopping
> cart system do you recommend between osCommerce and Zen-Cart for ease of use
> and a php guy with dangerously little javascript knowledge?
> 
> This is not for a massive shopping site, simply a cart to power a
> subscription sign-up page.
> 
> Thanks for the advice.
> 
> Haig
> 

For just a subscription sign-up I use a PayPal button.  PayPal supports
subscription based billing.


-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
On Wed, 3 Mar 2010 08:21:06 -0600, halip...@gmail.com (haliphax) wrote:

>> On Fri, Feb 26, 2010 at 11:01 PM, <clanc...@cybec.com.au> wrote:
>> > while ($i < $j) { $b[$i] = $a[$i++]; }          B.
>> >
>> > You get $b[0] = $a[1], and so on (as you would expect).
>>
>
>Wouldn't that be $b[0] = $a[0], with the value of $i being 1 *after* the
>statement was finished executing? You used a post-decrement operator on $i
>at the end of your statement, so I don't think that $i would be increased
>before being used to index into the $a array.

Try it!

Clancy

--- End Message ---
--- Begin Message ---
Hi all,

I was upgrading php from 5.6 to 5.11 and came across one odd issue. Hope someone could point out what is the problem.

Following code demonstrates it:

$xml = '<?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value>&lt;Test/&gt;</value></param></params></methodResponse>';

echo xmlrpc_decode($xml);

I suspect to get "<Test/>" as a result, but for some reason < and > are cut out and i'm getting "Test/". So basically all entities are dropped from response.

I have 2nd server running same OS (CentOS 5) which has been upgraded first and it works as i suspect, code above shows "<Test/>".

Any advice will be much appreciated.

Currently I have temporary workaround for this:

$xml = str_replace(array('&lt;','&gt;'), array('&#60;','&#62;'), $xml);

but would like to fix xmlrpc somehow.

Regards,
Dmitry Ruban




--- End Message ---
--- Begin Message ---
Juan wrote:

> Hi,
> I need an application to run mysql/php/apache or similar in one cd, to
> make a presentation.
> 
> The presentation itself is a php site that uses mysql to do some
> queries, to show data, and I would like to know how to embbed php and
> mysql to one cd for a presentation. I mean; one cd containing the
> whole site, and when the user inserts it on the cd/dvd reader it's
> able to use the website like if him/her would be using the http
> protocol. So, this application should let me put mysql/php/apache in
> the cd, then it should work from the cd.
> 
> I would like to use some free software application, I would like to
> avoid using commercial branches because I need this for a commercial
> project that isn't able to pay licenses. Also I preffer Free Software.
> 
> So, if you know some appplication that helps me to develop this, and
> also if I would be able to make the cd multiplatform for the principal
> OS ( Gnu/linux, win, mac ) even better.
> 
> Thanks a lot.
> 
> Juan

Rather than providing an identical environment, you could use HTTrack
http://www.httrack.com/ to create a static mirror of the site which has all
the functionality of the dynamic site in static html form. Just stick the
mirror on a CD with an appropriate autorun.inf if you want it to autostart.



Cheers
-- 
David Robley

Sure, it's clean laundry. The cat's sitting on it, isn't he?
Today is Pungenday, the 63rd day of Chaos in the YOLD 3176. 


--- End Message ---

Reply via email to