php-general Digest 26 Sep 2006 19:18:03 -0000 Issue 4369
Topics (messages 242216 through 242233):
Re: Print or Echo takes lots of time
242216 by: Colin Guthrie
242224 by: David Tulloh
242232 by: Børge Holen
Re: How would you do this ?
242217 by: Kae Verens
242218 by: Kae Verens
242221 by: Alex Turner
242222 by: Kae Verens
242223 by: Kae Verens
Re: manage/modify linux file/folder structure...
242219 by: Kae Verens
242220 by: Kae Verens
People who bought this also bought (amazon style) functionality...logic problem
242225 by: Ryan A
242227 by: David Tulloh
Mysql_free_result() doubt
242226 by: suresh kumar
Re: Frustrated trying to get help from your site
242228 by: Michelle Konzack
242229 by: Michelle Konzack
Mail Problem
242230 by: php.swimwebs.com
242231 by: Kevin Murphy
242233 by: travis.referable.com
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:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Google Kreme wrote:
> On 25 Sep 2006, at 06:11 , Sancar Saran wrote:
>> $strPage = "<html> yada dayda";
>> ...
>> $strPage.= " another html tags";
>> ...
>> $strPage.= getSqlDataAndCreateSomeHtmlCOde();
>
> If this is generating hundred of K of HTML, use ' instead of "
>
> (yes, it's faster).
In this example tho', it is not the string processing that is taking up
the time. The $ expansion etc. will be done when building the string
$strPage, not at the echo stage which is where the OP is seeing the delay.
Col.
--- End Message ---
--- Begin Message ---
Google Kreme wrote:
> On 25 Sep 2006, at 06:11 , Sancar Saran wrote:
> ...
>
> If this is generating hundred of K of HTML, use ' instead of "
>
> (yes, it's faster).
>
I've seen this stated several times and at first glance it seems to make
sense. The double quoted version has all the \n and related characters
that need to be handled.
Except that php is a C program and uses the printf family of functions.
This means that all the single quoted strings actually have to be
converted to escaped versions of double quoted strings, so internally
'\n' becomes "\\n".
You can see this in some benchmarks, I ran the following script and a
single quoted version from the command line. I ran each 10 times,
interleaved to try to balance changes in the system load.
<?php
$str="";
for($i=0; $i<10000000; $i++)
$str.="foo";
?>
I found that the double quoted version averaged 5.5516 seconds against
the single quoted script of 5.5627. Which really goes to show that
while the double quoted version is faster the difference is almost
completely irrelevent.
David
--- End Message ---
--- Begin Message ---
On Tuesday 26 September 2006 02:07, Robert Cummings wrote:
> On Mon, 2006-09-25 at 17:39 -0600, Google Kreme wrote:
> > I'm sitting here with 4 Gigs of RAM trying to figure out how to use
> > it all... :-) (Me, in 2005)
>
> Not really related to the post... but I find a good way to eat up 4 gigs
> of RAM is to run several VMWare nodes :) Depending on what these nodes
> do, it can also be a great way to eat up those dual core processors :)
Forget 'bout em vmware stuff. Imagine putting those ramdisks to good use.
>
> Cheers,
> Rob.
> --
> .------------------------------------------------------------.
>
> | InterJinn Application Framework - http://www.interjinn.com |
> |
> :------------------------------------------------------------:
> :
> | An application and templating framework for PHP. Boasting |
> | a powerful, scalable system for accessing system services |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for |
> | creating re-usable components quickly and easily. |
>
> `------------------------------------------------------------'
--
---
Børge
Kennel Arivene
http://www.arivene.net
---
--- End Message ---
--- Begin Message ---
Jad madi wrote:
I'm building an RSS aggregator so I'm trying to find out the best way to
parse users account feeds equally so Lets say we have 20.000 user with
average of 10 feeds in account so we have about
200.000 feed
How would you schedule the parsing process to keep all accounts always
updated without killing the server? NOTE: that some of the 200.000 feeds
might be shared between more than one user
this is just an idle thought, but could you base it on prime numbers?
for instance, let's say you have 6 feeds which in the last week have generated
(a=10, b=8, c=5, d=7, e=13, f=2) articles.
order them by article amount descending in last week: e, a, b, d, c, f
assign primes to them: e=1, a=2, b=3, d=5, c=7, f=11
let $i=1
every 6 hours, check feeds who's primes are divisible by $i, then add 1 to $i
at the end of the week, recalculate the primes.
in this example, the feed checks would be:
monday (1,2,3,4) = (e), (e,a), (e,b), (e,a)
tuesday (5,6,7,8) = (e,d), (e,a,b), (e,c), (e,a)
wednesday (9,10,11,12) = (e,b), (e,a,d), (e,f), (e,a,b)
thursday (13,14,15,16) = (e), (e,a,c), (e,b,d), (e,a)
friday (17,18,19,20) = (e), (e,a,b), (e), (e,a,d)
saturday (21,22,23,24) = (e,b,c), (e,a,f), (e), (e,a,b)
sunday (25,26,27,28) = (e,d), (e,a), (e,a,b), (e,a,c)
in this example, at most three out of six are being checked for at a time, but
everything gets at least a chance.
e had 13 articles, is checked 28 times
a had 10 articles, is checked 14 times
b had 8 articles, is checked 9 times
d had 7 articles, is checked 5 times
c had 5 articles, is checked 4 times
f had 2 articles, is checked 2 times
Kae
--- End Message ---
--- Begin Message ---
Jad madi wrote:
I'm building an RSS aggregator so I'm trying to find out the best way to
parse users account feeds equally so Lets say we have 20.000 user with
average of 10 feeds in account so we have about
200.000 feed
How would you schedule the parsing process to keep all accounts always
updated without killing the server? NOTE: that some of the 200.000 feeds
might be shared between more than one user
this is just an idle thought, but could you base it on prime numbers?
for instance, let's say you have 6 feeds which in the last week have generated
(a=10, b=8, c=5, d=7, e=13, f=2) articles.
order them by article amount descending in last week: e, a, b, d, c, f
assign primes to them: e=1, a=2, b=3, d=5, c=7, f=11
let $i=1
every 6 hours, check feeds who's primes are divisible by $i, then add 1 to $i
at the end of the week, recalculate the primes.
in this example, the feed checks would be:
monday (1,2,3,4) = (e), (e,a), (e,b), (e,a)
tuesday (5,6,7,8) = (e,d), (e,a,b), (e,c), (e,a)
wednesday (9,10,11,12) = (e,b), (e,a,d), (e,f), (e,a,b)
thursday (13,14,15,16) = (e), (e,a,c), (e,b,d), (e,a)
friday (17,18,19,20) = (e), (e,a,b), (e), (e,a,d)
saturday (21,22,23,24) = (e,b,c), (e,a,f), (e), (e,a,b)
sunday (25,26,27,28) = (e,d), (e,a), (e,a,b), (e,a,c)
in this example, at most three out of six are being checked for at a time, but
everything gets at least a chance.
e had 13 articles, is checked 28 times
a had 10 articles, is checked 14 times
b had 8 articles, is checked 9 times
d had 7 articles, is checked 5 times
c had 5 articles, is checked 4 times
f had 2 articles, is checked 2 times
Kae
--- End Message ---
--- Begin Message ---
Jad madi wrote:
I'm building an RSS aggregator so I'm trying to find out the best way to
parse users account feeds equally so Lets say we have 20.000 user with
average of 10 feeds in account so we have about
200.000 feed
How would you schedule the parsing process to keep all accounts always
updated without killing the server? NOTE: that some of the 200.000 feeds
might be shared between more than one user
Now, what I was thinking of is to split users into
1-) Idle users (check their account once a week, no traffic on their RSS
feeds)
2-) Idle++ (check their account once a week, but got traffic on their
RSS feeds)
2-) Active users (Check their accounts regularly and they got traffic on
their RSS feeds)
NOTE: The week is just an example but at the end it’s going to be
dynamic ratio
so with this classification I can split the parsing power and time to
1-) 10% idle users
2-) 20% idle++ users
3-) 70% active users.
NOTE: There is another factors that should be included but I don’t want
to get the idea messy now (CPU usage, Memory usage, connectivity issues
(if feed site is down) in general the MAX execution time for the
continues parsing loop shouldn’t be more than 30 minutes 60 minutes)
Actually I’m thinking of writing a daemon to do it “just keep checking
CPU/memory” and excute whenever a reasonable amount of resource
available without killing the server.
Please elaborate.
I would suggest using a queue/pool system. Have one mechanism the loads
request for update into a queue and anther that takes the requests out
of the pool at the fixed rate (or several at once over different
threads/processes). You then limit the rate the messages are consumed
to the maximum you want the server to use up. You can then add update
requests into the queue based on how often the user checks their feed.
That way, the more often they check it, the more often it is updated.
OK - this needs a bit of polishing, but I suspect it would do what you
wanted. A database table would make a nice queue as you insert at the
bottom and read/delete off the top and let the DB engine synchronize up
the separate threads of action.
Cheers
AJ
--
www.deployview.com
www.nerds-central.com
www.project-network.com
--- End Message ---
--- Begin Message ---
Kae Verens wrote:
every 6 hours, check feeds who's primes are divisible by $i, then add
1 to $i
of course, this should be "check feeds where $i%(the prime) is 0"
Kae
--- End Message ---
--- Begin Message ---
Kae Verens wrote:
every 6 hours, check feeds who's primes are divisible by $i, then add
1 to $i
of course, this should be "check feeds where $i%(the prime) is 0"
Kae
--- End Message ---
--- Begin Message ---
bruce wrote:
i should state... while i've seen different apps... i'm more interested in
any that have actually been used by you, or someone you know!!
an app that comes with references!
try this?
http://kfm.verens.com/
I'm biased, though - I wrote the thing.
Kae
--- End Message ---
--- Begin Message ---
bruce wrote:
i should state... while i've seen different apps... i'm more interested in
any that have actually been used by you, or someone you know!!
an app that comes with references!
try this?
http://kfm.verens.com/
I'm biased, though - I wrote the thing.
Kae
--- End Message ---
--- Begin Message ---
Hey all,
I want to write a "module" for xcart (a commercial
'shopping cart') which would be like what Amazon.com
offers when you go to shop on their site... when you
click on a product to see its details you get a little
box below that recommends more products based on what
others have purchased
eg:
If you click on a toy helicopter it would recommend
extra rotor blades,landing gear etc
eg 2:
If you click on Eminem's latest album it would show
you his other two albums that people bought with this
album
etc
I'm trying to work out the logic to do this... and
quite frankly have hit a brick wall.
So far:
-------
I was thinking when someone (Joe) purchases X with
product id Y I would put that in a seperate table,
then when someone (Jane) else comes looking at item Y
I would display everything that Joe bought...
but then it gets a little complicated, if Jane buys Y
and other stuff that Joe didnt buy... how do I merge
what Joe and Jane bought to display to the next
visitor? (I can only dispaly 5 recommendations at
once)
I would appreciate any tips/advise and code you can
give me, would be fantastic of course if you have
worked with xcart or have already done this.
(shameless plug)
I think this was one of the suggested features of
Dan's open source PHPCart
(http://code.google.com/p/phpcart) unfortunatly I dont
have the OO skill to take part in that project and no
time either as we need a cart immd.
Note:
I dont get anything for recommending the above cart
(or xcart for that matter) but if you are interested
in joining a free os cart project, you might want to
think of looking into the above.
Thanks in advance,
Ryan
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
You have a User table and a Product table, then a linking table that
joins users with products that they have bought.
Given product A you get all users {B} who have bought product A, you
then get a list of all products {C} that they have bought. You group
{C} by product and get a count, order by the count, return the product
and limit the query to return only 5 entries. All this is possible in
one SQL statement, the SQL is left as an exercise to the reader.
As this is an O(n^2) query it won't scale particularily well, so you
should cache the results somewhere, probably in the product table. This
could be regenerated every week or two as it doesn't actually need to be
very current.
David
Ryan A wrote:
> Hey all,
>
> I want to write a "module" for xcart (a commercial
> 'shopping cart') which would be like what Amazon.com
> offers when you go to shop on their site... when you
> click on a product to see its details you get a little
> box below that recommends more products based on what
> others have purchased
>
> eg:
> If you click on a toy helicopter it would recommend
> extra rotor blades,landing gear etc
>
> eg 2:
> If you click on Eminem's latest album it would show
> you his other two albums that people bought with this
> album
>
> etc
>
> I'm trying to work out the logic to do this... and
> quite frankly have hit a brick wall.
>
> So far:
> -------
> I was thinking when someone (Joe) purchases X with
> product id Y I would put that in a seperate table,
> then when someone (Jane) else comes looking at item Y
> I would display everything that Joe bought...
> but then it gets a little complicated, if Jane buys Y
> and other stuff that Joe didnt buy... how do I merge
> what Joe and Jane bought to display to the next
> visitor? (I can only dispaly 5 recommendations at
> once)
>
>
>
> I would appreciate any tips/advise and code you can
> give me, would be fantastic of course if you have
> worked with xcart or have already done this.
>
> (shameless plug)
> I think this was one of the suggested features of
> Dan's open source PHPCart
> (http://code.google.com/p/phpcart) unfortunatly I dont
> have the OO skill to take part in that project and no
> time either as we need a cart immd.
> Note:
> I dont get anything for recommending the above cart
> (or xcart for that matter) but if you are interested
> in joining a free os cart project, you might want to
> think of looking into the above.
>
> Thanks in advance,
> Ryan
>
> ------
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
--- End Message ---
--- Begin Message ---
Hi to all,
I am little bit confused to use the mysql_free_result($result)
function.because i searched google - they told dont use this function to php
4.X and also it says clearly "When you are done with a result set, you must
free the memory it uses by calling mysql_free_result()".
I mean something like when to use or not to use it? I already
know that only SELECT queries that retrieve rows require to free resources,
but maybe when all data is retrieved the resources are free automatically or we
need to call mysql_free_result() to free the memory. and also this function
will free only one row at a time or all the rows of the result set .
A.suresh
---------------------------------
Find out what India is talking about on - Yahoo! Answers India
Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it
NOW
--- End Message ---
--- Begin Message ---
Am 2006-09-25 23:00:15, schrieb David Robley:
> xchm is probably what you are thinking of - xchm.sourceforge.net
This afternoon I will go downloading it.
Greetings
Michelle Konzack
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
--- End Message ---
--- Begin Message ---
Am 2006-09-25 08:33:52, schrieb Ray Hauge:
> It's not the best in the world, but it works.
>
> http://xchm.sourceforge.net/index.html
>
> But since the documentation is online and always updated that way, I prefer
> to
> just use the website.
Me too, but IF you live mobil like me (I have an 88-tons MAN-SuperTruck
as MotorCaravan) you wil not have Internet Access all the time. OK, I
have GlobelSat but it is quiet expensive because I pay for the traffic.
Greetings
Michelle Konzack
Systemadministrator
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
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
--- End Message ---
--- Begin Message ---
I have an issue with sending email via PHP which may be a configuration problem
with either PHP, Apache, or possibly a Sendmail, but I don't know which yet. I
figured I'd start here first.
Here's the situation. I have several webpages that send email to users for
various reasons. We have our webserver, an intranet webserver, configured to
connect to our smtp server which sits on a different box. The script looks like
this:
<?PHP
$from = "[EMAIL PROTECTED]";
$to = "[EMAIL PROTECTED]";
$subject = "Test";
$msg = "This is a test from my site\n\nTimestamp: " . date("r");
$headers = "From:$from\r\n";
if(!mail($to,$subject,$msg,$headers)) { die("Unable to send"); }
?>
This works great when it works. Users receive email as expected and when they
hit reply it goes back to the webmaster email address. The problem is if the
to email address isn't a valid one. When this happens, the mail server bounces
the message back to [EMAIL PROTECTED] instead of [EMAIL PROTECTED]
I've tried adding reply-to to the mail headers and that doesn't work either.
We tried sending the same failed message using webmin and that worked great,
which is why I believe this to be a PHP or Apache problem.
Any ideas?
Thanks,
Robbert
--- End Message ---
--- Begin Message ---
Why not validate the email address before you send. I use something
like this to kick back an error that says you put in a bad email
address. It won't tell you about a wrong email address, but it will
tell you if they forgot to put in the @ sign and stuff.
if (!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $data))
{ $email_error = "yes"; }
--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326
On Sep 26, 2006, at 9:09 AM, [EMAIL PROTECTED] wrote:
I have an issue with sending email via PHP which may be a
configuration problem with either PHP, Apache, or possibly a
Sendmail, but I don't know which yet. I figured I'd start here first.
Here's the situation. I have several webpages that send email to
users for various reasons. We have our webserver, an intranet
webserver, configured to connect to our smtp server which sits on a
different box. The script looks like this:
<?PHP
$from = "[EMAIL PROTECTED]";
$to = "[EMAIL PROTECTED]";
$subject = "Test";
$msg = "This is a test from my site\n\nTimestamp: " . date("r");
$headers = "From:$from\r\n";
if(!mail($to,$subject,$msg,$headers)) { die("Unable to send"); }
?>
This works great when it works. Users receive email as expected and
when they hit reply it goes back to the webmaster email address.
The problem is if the to email address isn't a valid one. When
this happens, the mail server bounces the message back to
[EMAIL PROTECTED] instead of [EMAIL PROTECTED]
I've tried adding reply-to to the mail headers and that doesn't
work either. We tried sending the same failed message using webmin
and that worked great, which is why I believe this to be a PHP or
Apache problem.
Any ideas?
Thanks,
Robbert
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
> I have an issue with sending email via PHP which may be a configuration
> problem with either PHP, Apache, or possibly a Sendmail, but I don't know
> which yet. I figured I'd start here first.
>
> Here's the situation. I have several webpages that send email to users for
> various reasons. We have our webserver, an intranet webserver, configured to
> connect to our smtp server which sits on a different box. The script looks
> like this:
>
> <?PHP
> $from = "[EMAIL PROTECTED]";
> $to = "[EMAIL PROTECTED]";
> $subject = "Test";
> $msg = "This is a test from my sitennTimestamp: " . date("r");
> $headers = "From:$fromrn";
> if(!mail($to,$subject,$msg,$headers)) { die("Unable to send"); }
> ?>
>
> This works great when it works. Users receive email as expected and when they
> hit reply it goes back to the webmaster email address. The problem is if the
> to email address isn't a valid one. When this happens, the mail server
> bounces the message back to [EMAIL PROTECTED] instead of [EMAIL PROTECTED]
>
> I've tried adding reply-to to the mail headers and that doesn't work either.
> We tried sending the same failed message using webmin and that worked great,
> which is why I believe this to be a PHP or Apache problem.
Is it a UNIX box? Sendmail takes the -f parameter in your php.ini to configure
its envelope from address... Does not extract it from message headers. The
fifth argument to mail() also supports doing this if you need to change it on a
per-mail basis. I would just set it in php.ini. (like: sendmail_path =
'/usr/bin/sendmail -f [EMAIL PROTECTED]')
If its a Win box there is a sendmail_from config param in php.ini.
php.net/manual/function.mail.php read for 'Additional Params' the fifth
argument, it specifically deals with this case.
Travis
--- End Message ---