php-general Digest 26 Oct 2008 10:57:23 -0000 Issue 5756

Topics (messages 282430 through 282436):

Re: clear a mysql table
        282430 by: Micah Gersten
        282434 by: Ashley Sheridan

Replacing with f*ck and f*cking
        282431 by: Ryan S
        282432 by: Andrew Barnett
        282433 by: Stan Vassilev | FM
        282435 by: Ashley Sheridan

Interactive canvas example
        282436 by: Richard Heyes

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 ---

Ronald Wiplinger (Lists) wrote:
> I need to clear a table (cache) from a database based on the database size.
>
> Our web site uses cached pages. Our webhost only allow us 100 MB
> storage. Usually the database is just 10 MB, but when a search engine
> crawls our calendar, then the storage is quickly 108 MB. The system
> reports then mathematically correct: Space left on database -8MB !!!
>
> I plan therefore a web page, which is triggered by cron every hour and
> will just clear the table.
>
> Can I use just:
> mysql_query("DELETE FROM cash")
> or die(mysql_error());
>
>
> or do I need to loop through all records? or is there a better solution?
>
> How can I get the database size?
>
> bye
>
> R.
>
>   
Perhaps you should not have search engines index your calendar.

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


--- End Message ---
--- Begin Message ---
On Sat, 2008-10-25 at 20:47 -0500, Micah Gersten wrote:
> 
> Ronald Wiplinger (Lists) wrote:
> > I need to clear a table (cache) from a database based on the database size.
> >
> > Our web site uses cached pages. Our webhost only allow us 100 MB
> > storage. Usually the database is just 10 MB, but when a search engine
> > crawls our calendar, then the storage is quickly 108 MB. The system
> > reports then mathematically correct: Space left on database -8MB !!!
> >
> > I plan therefore a web page, which is triggered by cron every hour and
> > will just clear the table.
> >
> > Can I use just:
> > mysql_query("DELETE FROM cash")
> > or die(mysql_error());
> >
> >
> > or do I need to loop through all records? or is there a better solution?
> >
> > How can I get the database size?
> >
> > bye
> >
> > R.
> >
> >   
> Perhaps you should not have search engines index your calendar.
> 
> Thank you,
> Micah Gersten
> onShore Networks
> Internal Developer
> http://www.onshore.com
> 
> 
Yeah, you seem to be trying to treat the effect rather than the cause,
which will more than likely have other problems down the road. Are you
sure you need to cache calendar pages too? I mean, if you look at the
web stats for your site, is it really benefiting from caching in the
calendar section?


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Hey!
I'm just trying to replace some of the more bad words with their slightly 
censored counterparts like so

$bad_words = array(/*Well you know the words so am not going to write them 
here*/);
$bad_words_replacements = array("f*ck", "f*cking");
$comment = str_replace("$bad_words",$bad_words_replacements,  $comment);

My question is this, for just two words its fine to use the above, but a pal 
tells me that if using a lot of words (eg: 15) and the $comment is big then it 
can take quite some time and be a bit of a processing strain as well because 
php first checks the first word from the good list against all the 15 words in 
the bad list against the comment then moves to the second word etc.

Is this really bad processing wise and would you recommend any other way of 
doing this?
The other question i have is, wont "f*ck" catch "f*cking" as well? so should i 
delete the longer f*cking?

I'm not really trying to stop people swearing... just trying to make it not 
"jump out" so much, this was the poster is happy coz i have not censored him to 
bits and the reader should be a bit happy coz its a bit decent.

Thanks!
R


      

--- End Message ---
--- Begin Message ---
Maybe you should look at the source code of an open source project that can
already do this such as phpBB.  I'm not exactly sure where to find it in the
phpBB code though.

Andrew


2008/10/26 Ryan S <[EMAIL PROTECTED]>

> Hey!
> I'm just trying to replace some of the more bad words with their slightly
> censored counterparts like so
>
> $bad_words = array(/*Well you know the words so am not going to write them
> here*/);
> $bad_words_replacements = array("f*ck", "f*cking");
> $comment = str_replace("$bad_words",$bad_words_replacements,  $comment);
>
> My question is this, for just two words its fine to use the above, but a
> pal tells me that if using a lot of words (eg: 15) and the $comment is big
> then it can take quite some time and be a bit of a processing strain as well
> because php first checks the first word from the good list against all the
> 15 words in the bad list against the comment then moves to the second word
> etc.
>
> Is this really bad processing wise and would you recommend any other way of
> doing this?
> The other question i have is, wont "f*ck" catch "f*cking" as well? so
> should i delete the longer f*cking?
>
> I'm not really trying to stop people swearing... just trying to make it not
> "jump out" so much, this was the poster is happy coz i have not censored him
> to bits and the reader should be a bit happy coz its a bit decent.
>
> Thanks!
> R
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
My question is this, for just two words its fine to use the above, but a pal tells me that if using a lot of words (eg: 15) and the $comment is big then it can take quite some time and be a bit of a processing strain as well because php first checks the first word from the good list against all the 15 words in the bad list against the comment then moves to the second word etc.


You should do the filtering on save, not on display, this way the processing time will drop by order of few magnitudes in comparison.

Always save the original post content as well, in case you want to tweak the filter and reprocess the messages.

Regards, Stan Vassilev
--- End Message ---
--- Begin Message ---
On Sun, 2008-10-26 at 10:18 +0200, Stan Vassilev | FM wrote:
> > My question is this, for just two words its fine to use the above, but a 
> > pal tells me that if using a lot of words (eg: 15) and the $comment is big 
> > then it can take quite some time and be a bit of a processing strain as 
> > well because php first checks the first word from the good list against 
> > all the 15 words in the bad list against the comment then moves to the 
> > second word etc.
> >
> 
> You should do the filtering on save, not on display, this way the processing 
> time will drop by order of few magnitudes in comparison.
> 
> Always save the original post content as well, in case you want to tweak the 
> filter and reprocess the messages.
> 
> Regards, Stan Vassilev 
> 
> 
What you really need to watch out for is words which you're going to
censor which might be part of other names. Sex is an obvious one, as it
appeared in the borough name of my old address: Middlesex. Instead of
using str_replace, what about using preg_replace, which gives you a bit
more control over the words that you are replacing, for example, only
words on their own, etc. This will also let you get around deliberate
mis-spellings of a profanity, such as 'fcuk', by using an expression
like "/f[uc]k/iw"

Obviously, this list could get pretty comprehensive, so like Andrew
said, maybe you should look to see how some of the open source projects
do it.


Ash
www.ashleysheridan.co.uk


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

Had to show this off - I'm so proud. READ: full of myself... I've
tried it in Firefox 3, Opera 9.6, Chrome and Safari, all on Windows.

http://dev.rgraph.org/examples/interactive.html

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated October 25th)

--- End Message ---

Reply via email to