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

2008-10-26 Thread php-general-digest-help

php-general Digest 26 Oct 2008 10:57:23 - 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]


--
---BeginMessage---


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

php-general Digest 26 Oct 2008 23:43:23 -0000 Issue 5757

2008-10-26 Thread php-general-digest-help

php-general Digest 26 Oct 2008 23:43:23 - Issue 5757

Topics (messages 282437 through 282459):

Re: Replacing with f*ck and f*cking
282437 by: Maciek Sokolewicz
282438 by: Colin Guthrie
282439 by: Ashley Sheridan
282441 by: Dotan Cohen
282457 by: Larry Garfield

Re: Interactive canvas example
282440 by: Nick Stinemates
282442 by: Yeti
282443 by: Richard Heyes
282446 by: Shawn McKenzie
282448 by: Yeti
282450 by: tedd
282451 by: Richard Heyes
282452 by: Richard Heyes
282453 by: Richard Heyes
282454 by: Richard Heyes
282456 by: Richard Heyes

PHP XSLT caching
282444 by: vladimirn
282447 by: Colin Guthrie
282449 by: vladimirn
282455 by: Colin Guthrie
282458 by: Per Jessen

Re: PHP/mySQL question using ORDER BY with logic
282445 by: Carlos Medina

Re: clear a mysql table
282459 by: Chris

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]


--
---BeginMessage---

Ryan S wrote:

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.
The above isn't fine since it will never work. The reason for that is 
the fact that you enclose your array in quotes. This is something I've 
never understood, I've seen tons of people do it, and to me it looks 
like someone doesn't have a CLUE what he's doing. Why am I ranting about 
this? This is why:


$some_string = 'this used to be an a, but is now also a b';
$bad_words = array('a','b');
echo str_replace($bad_words, 'something else', $some_string);

What does this mean ? If you remove all variables, you'll get:
echo str_replace('array', 'O', 'this used to be an a, but is now also a b');
And the result you'll get:
this used to be an a, but is now also a b

However, leaving away the quotes, since they're useless around a single 
variable anyway (what, don't you think PHP knows the variable is a 
string without you adding quotes around it?), like so:
echo str_replace(array('a','b'), 'O', 'this used to be an a, but is now 
also a b');

you'll get:
this used to Oe On O, Out is now Olso O O

Hmm, there's a difference! :o

- Tul
P.S. IMO people should never write $var, if they REALLY want to cast 
it to a string, do it explicitly like so: (string) $var; it keeps things 
obvious and simple, not to mention working.
---End Message---
---BeginMessage---

Ashley Sheridan wrote:

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.


I can't believe you didn't use the infamous Scunthorpe as your example :p

Col


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

---End Message---
---BeginMessage---
On Sun, 2008-10-26 at 11:06 +, Colin Guthrie wrote:
 Ashley Sheridan wrote:
  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.
 
 I can't believe you didn't use the infamous Scunthorpe as your example :p
 
 Col
 
 
 -- 
 
 Colin Guthrie
 gmane(at)colin.guthr.ie
 http://colin.guthr.ie/
 
 Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
 Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
 
 
I forgot about that one to be honest. I did have a friend whose last
name is Hancock though, and I remember she had a lot of problems trying
to register for a hotmail email address!


Ash
www.ashleysheridan.co.uk

---End Message---
---BeginMessage---
2008/10/26 Colin Guthrie [EMAIL PROTECTED]:
 Ashley Sheridan wrote:

 What you really need to watch out for is words which you're going to
 censor which might be part of 

Re: [PHP] Replacing with f*ck and f*cking

2008-10-26 Thread Stan Vassilev | FM
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 



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



Re: [PHP] clear a mysql table

2008-10-26 Thread Ashley Sheridan
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


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



Re: [PHP] Replacing with f*ck and f*cking

2008-10-26 Thread Ashley Sheridan
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


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



[PHP] Interactive canvas example

2008-10-26 Thread Richard Heyes
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)

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



[PHP] Re: Replacing with f*ck and f*cking

2008-10-26 Thread Maciek Sokolewicz

Ryan S wrote:

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.
The above isn't fine since it will never work. The reason for that is 
the fact that you enclose your array in quotes. This is something I've 
never understood, I've seen tons of people do it, and to me it looks 
like someone doesn't have a CLUE what he's doing. Why am I ranting about 
this? This is why:


$some_string = 'this used to be an a, but is now also a b';
$bad_words = array('a','b');
echo str_replace($bad_words, 'something else', $some_string);

What does this mean ? If you remove all variables, you'll get:
echo str_replace('array', 'O', 'this used to be an a, but is now also a b');
And the result you'll get:
this used to be an a, but is now also a b

However, leaving away the quotes, since they're useless around a single 
variable anyway (what, don't you think PHP knows the variable is a 
string without you adding quotes around it?), like so:
echo str_replace(array('a','b'), 'O', 'this used to be an a, but is now 
also a b');

you'll get:
this used to Oe On O, Out is now Olso O O

Hmm, there's a difference! :o

- Tul
P.S. IMO people should never write $var, if they REALLY want to cast 
it to a string, do it explicitly like so: (string) $var; it keeps things 
obvious and simple, not to mention working.


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



[PHP] Re: Replacing with f*ck and f*cking

2008-10-26 Thread Colin Guthrie

Ashley Sheridan wrote:

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.


I can't believe you didn't use the infamous Scunthorpe as your example :p

Col


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Re: Replacing with f*ck and f*cking

2008-10-26 Thread Ashley Sheridan
On Sun, 2008-10-26 at 11:06 +, Colin Guthrie wrote:
 Ashley Sheridan wrote:
  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.
 
 I can't believe you didn't use the infamous Scunthorpe as your example :p
 
 Col
 
 
 -- 
 
 Colin Guthrie
 gmane(at)colin.guthr.ie
 http://colin.guthr.ie/
 
 Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
 Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
 
 
I forgot about that one to be honest. I did have a friend whose last
name is Hancock though, and I remember she had a lot of problems trying
to register for a hotmail email address!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Interactive canvas example

2008-10-26 Thread Nick Stinemates
On Sun, Oct 26, 2008 at 10:57:19AM +, Richard Heyes wrote:
 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:

Clicked a bar, nothing happened.

Google Chrome, Windows XP

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



Re: [PHP] Re: Replacing with f*ck and f*cking

2008-10-26 Thread Dotan Cohen
2008/10/26 Colin Guthrie [EMAIL PROTECTED]:
 Ashley Sheridan wrote:

 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.

 I can't believe you didn't use the infamous Scunthorpe as your example :p

 Col

There was a post on Coding Horror not long ago that brought this one up:
http://google.com/search?q=consbreastution

http://www.codinghorror.com/blog/archives/001176.html

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü


Re: [PHP] Interactive canvas example

2008-10-26 Thread Yeti
It worked for me. Although I had some quite CPU intensive processes
running, so it lagged a bit.
Had no time to look into the code, so I was wondering if you could
answer my question ...
That yellow information box popping up onclick(), is it drawn by JS or
is it something like a hidden div?

Congratulations on that one
//A yeti

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



Re: [PHP] Interactive canvas example

2008-10-26 Thread Richard Heyes
 It worked for me. Although I had some quite CPU intensive processes
 running, so it lagged a bit.
 Had no time to look into the code, so I was wondering if you could
 answer my question ...
 That yellow information box popping up onclick(), is it drawn by JS or
 is it something like a hidden div?

JS I suppose. Though it creates a DIV element on demand. The function
in question is RGraph.Tooltip() in RGraph.common.js.

-- 
Richard Heyes

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

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



[PHP] PHP XSLT caching

2008-10-26 Thread vladimirn

Hi all,
i was wondering whats the best approach to do next.
I have an xml file delivered from service of my partner. On my web server 
(windows) i have xslt files used for xml transformation. 
Those files are getting bigger, so i have request to cash them and use
cashed. I was thinkging about memcahce php(dunno if it will work on windows
server and tbh never used it before).
So i am sure that there must be several ways to cash xslt files. I google
for this, but i am not sure that i found any solution i can use.
What would be the best approach to solve this? I just would like to see more
ideas :)
LOL sure, if someone already have a good working solution i would appreciate
any link or code :0)
Greetings,
V
-- 
View this message in context: 
http://www.nabble.com/PHP-XSLT-caching-tp20173225p20173225.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



[PHP] Re: PHP/mySQL question using ORDER BY with logic

2008-10-26 Thread Carlos Medina

Rob Gould schrieb:

Question about mySQL and PHP, when using the mySQL ORDER BY method...


Basically I've got data coming from the database where a wine 
producer-name is a word like:


Château Bahans Haut-Brion

or

La Chapelle de La Mission Haut-Brion

or

Le Clarence de Haut-Brion

but I need to ORDER BY using a varient of the string:

1)  If it begins with Château, don't include Chateau in the 
string to order by.
2)  If it begins with La, don't order by La, unless the first 
word is Chateau, and then go ahead and order by La.



Example sort:  Notice how the producer as-in comes before the 
parenthesis, but the ORDER BY actually occurs after a re-ordering of the 
producer-string, using the above rules.


Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château )
Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission 
Haut-Brion, La )

Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le )
Red: Château Haut-Brion (Haut-Brion, Château )
Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château )
Red: Domaine de La Passion Haut Brion (La Passion Haut Brion, 
Domaine de )

Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château )
Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château )
Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château )


That logic between mySQL and PHP, I'm just not sure how to 
accomplish?  I think it might involve a mySQL alias-technique but I 
could be wrong.


Right now, my PHP call to generate the search is this:

$query = 'SELECT * FROM wine WHERE MATCH(producer, varietal, 
appellation, designation, region, vineyard, subregion, country, vintage) 
AGAINST ( ' . $searchstring . ')  ORDER BY producer LIMIT 0,100';




Hi,
Try to solve your Logic on your programming language and to select Data 
with your Database... Try to normalize more your Information on the 
Database.


Regars

Carlos

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



[PHP] Re: Interactive canvas example

2008-10-26 Thread Shawn McKenzie
Richard Heyes wrote:
 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
 
Very nice.  Looks good on Kubuntu FF3.  The only issue I see is that no
matter which bar I click on, it says January 2007 Sales: 80%, which
may just be your example, but I would think each bar should be different.

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

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



[PHP] Re: PHP XSLT caching

2008-10-26 Thread Colin Guthrie

vladimirn wrote:

Hi all,
i was wondering whats the best approach to do next.
I have an xml file delivered from service of my partner. On my web server 
(windows) i have xslt files used for xml transformation. 
Those files are getting bigger, so i have request to cash them and use

cashed. I was thinkging about memcahce php(dunno if it will work on windows
server and tbh never used it before).
So i am sure that there must be several ways to cash xslt files. I google
for this, but i am not sure that i found any solution i can use.
What would be the best approach to solve this? I just would like to see more
ideas :)
LOL sure, if someone already have a good working solution i would appreciate
any link or code :0)


Well you have to define what you actually want to do do here as it's a 
little unclear from your description.


Do you want to cache the XSLT files themselves or do you want to cache 
the result of *applying* the XSLT files to the input XML?


If you just want to cache the XSLT itself (e.g. loaded into a DOM 
document object) then there is little point as you would have to 
serialize and deserialize the dom document objects before storing them 
(via extending the class and adding __sleep() and __wakeup() methods) as 
I am pretty sure Dom Document doesn't do this automatically (last I 
checked which was admittedly a while ago!).


This only saves a small amount of overhead.

If you are looking for a good set of classes that can handle generic 
caching, I'd strongly recommend using the Zend_Cache system.

http://www.framework.zend.com/manual/en/zend.cache.html

Zend cache will support disk-based caching and memcache or APC too all 
via the same API.


Col





--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Re: Interactive canvas example

2008-10-26 Thread Yeti
JS I suppose. Though it creates a DIV element on demand. The function
in question is RGraph.Tooltip() in RGraph.common.js.

OK, I found it. Thank you for showing me. I was thinking of something
similar recently.

/**
* Shows a tooltip next to the mouse pointer
*
* @param text The tooltip text
* @return The tooltip object - a DIV
*/
RGraph.Tooltip = function (canvas, text, x, y)
{
/**
* Hide any currently shown tooltip
*/
if (RGraph.tooltip) {
RGraph.tooltip.style.display = 'none';
RGraph.tooltip = null;
}

/**
* Show a tool tip
*/
var obj  = document.createElement('DIV');
obj.style.position= 'absolute'
obj.style.backgroundColor = '#E1';
obj.style.border  = '1px solid #333';
obj.style.borderRight = '2px solid #333';  // Set the right and
bottom borders to be a little thicker - gives the effect of a drop
shadow
obj.style.borderBottom= '2px solid #333'; // Set the right and
bottom borders to be a little thicker - gives the effect of a drop
shadow
obj.style.display = 'block'
obj.style.visibility  = 'visible';
obj.style.paddingLeft = '3px';
obj.style.paddingRight= '3px';
obj.style.fontFamily  = 'Tahoma';
obj.style.fontSize= '10pt';
obj.innerHTML = text;

document.body.insertBefore(obj, canvas);

obj.style.left= (canvas.offsetLeft) + x + 3;
obj.style.top = (canvas.offsetTop + y) - obj.offsetHeight;

/**
* Install the function for hiding the tooltip.
*
* FIXME Not sure how this will affect any existing document.onclick 
event
*/
document.body.onclick = function ()
{
RGraph.tooltip.style.display = 'none';
}

/**
* Keep a reference to the object
*/
RGraph.tooltip = obj;
}

Now I wonder why you are creating a new tooltip each time the user
clicks on the graph?
Why not do it the following way?

RGraph.Tooltip = function (canvas, text, x, y)
{
try {
if (RGraph.tooltip) { // if tooltip already drawn
RGraph.tooltip.innerHTML = text;
RGraph.tooltip.style.left = (canvas.offsetLeft) + x + 3;
RGraph.tooltip.style.top = (canvas.offsetTop + y) -
RGraph.tooltip.offsetHeight;
} else { // create tooltip if not drawn yet
var obj  = document.createElement('DIV');

obj.style.position= 'absolute'
obj.style.backgroundColor = '#E1';
obj.style.border  = '1px solid #333';
obj.style.borderRight = '2px solid #333';  // Set 
the right and
bottom borders to be a little thicker - gives the effect of a drop
shadow
obj.style.borderBottom= '2px solid #333'; // Set 
the right and
bottom borders to be a little thicker - gives the effect of a drop
shadow
obj.style.display = 'block'
obj.style.visibility  = 'visible';
obj.style.paddingLeft = '3px';
obj.style.paddingRight= '3px';
obj.style.fontFamily  = 'Tahoma';
obj.style.fontSize= '10pt';
/*
//alternatively one could create a tooltip css 
class since this is
presentation
obj.className = 'tooltip'; //IE
obj.setAttribute('class', 'tooltip'); // W3C DOM
*/
document.body.insertBefore(obj, canvas);

RGraph.tooltip = obj;

document.body.onclick = function ()
{
RGraph.tooltip.style.left = '-999'; //older 
opera fix
}

return RGraph.Tooltip(canvas, text, x, y);
}
return RGraph.tooltip; // return tooltip obj as stated in 
functions comment
} catch(e) {
return false;   
}
}

Secondly CanvasTextFunctions.letters() really is in a class of its own.
And why dont you use prototype [1]?

[1] http://www.w3schools.com/jsref/jsref_prototype_array.asp

//A yeti

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



Re: [PHP] PHP XSLT caching

2008-10-26 Thread vladimirn

Thank you Col
I will go into Zend_Cache as you suggested.
One more thing- does Zend_Cache saces data into file or use a server memory?

Colin Guthrie-6 wrote:
 
 vladimirn wrote:
 Hi all,
 i was wondering whats the best approach to do next.
 I have an xml file delivered from service of my partner. On my web server 
 (windows) i have xslt files used for xml transformation. 
 Those files are getting bigger, so i have request to cash them and use
 cashed. I was thinkging about memcahce php(dunno if it will work on
 windows
 server and tbh never used it before).
 So i am sure that there must be several ways to cash xslt files. I google
 for this, but i am not sure that i found any solution i can use.
 What would be the best approach to solve this? I just would like to see
 more
 ideas :)
 LOL sure, if someone already have a good working solution i would
 appreciate
 any link or code :0)
 
 Well you have to define what you actually want to do do here as it's a 
 little unclear from your description.
 
 Do you want to cache the XSLT files themselves or do you want to cache 
 the result of *applying* the XSLT files to the input XML?
 
 If you just want to cache the XSLT itself (e.g. loaded into a DOM 
 document object) then there is little point as you would have to 
 serialize and deserialize the dom document objects before storing them 
 (via extending the class and adding __sleep() and __wakeup() methods) as 
 I am pretty sure Dom Document doesn't do this automatically (last I 
 checked which was admittedly a while ago!).
 
 This only saves a small amount of overhead.
 
 If you are looking for a good set of classes that can handle generic 
 caching, I'd strongly recommend using the Zend_Cache system.
 http://www.framework.zend.com/manual/en/zend.cache.html
 
 Zend cache will support disk-based caching and memcache or APC too all 
 via the same API.
 
 Col
 
 
 
 
 
 -- 
 
 Colin Guthrie
 gmane(at)colin.guthr.ie
 http://colin.guthr.ie/
 
 Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
 Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-XSLT-caching-tp20173225p20174548.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Interactive canvas example

2008-10-26 Thread tedd

At 10:57 AM + 10/26/08, Richard Heyes wrote:

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


Richard:

Very nice graph.

Instead of requiring the user to click, try using css and have it 
produce the details on roll-over, like so:


http://webbytedd.com/bbb/map/

Cheers,

tedd

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

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



Re: [PHP] Re: Interactive canvas example

2008-10-26 Thread Richard Heyes
 Very nice.  Looks good on Kubuntu FF3.  The only issue I see is that no
 matter which bar I click on, it says January 2007 Sales: 80%, which
 may just be your example, but I would think each bar should be different.

Yes, I've still got to make an easy way to tie in differing tooltips.

-- 
Richard Heyes

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

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



Re: [PHP] Re: Interactive canvas example

2008-10-26 Thread Richard Heyes
 Now I wonder why you are creating a new tooltip each time the user
 clicks on the graph?

Why not? There's no need to cache it and it lessens the complexity if I don't.

 Why not do it the following way?

Which is?

 Secondly CanvasTextFunctions.letters() really is in a class of its own.


I didn't write it, I've just incorporated it into RGraph.

-- 
Richard Heyes

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

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



Re: [PHP] Interactive canvas example

2008-10-26 Thread Richard Heyes
 Very nice graph.

 Instead of requiring the user to click, try using css and have it produce
 the details on roll-over, like so:

Hmm, should be as easy as changing the event from onclick to on
mouseover. I think. But yes, onmouseover would be far better.

-- 
Richard Heyes

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

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



Re: [PHP] Interactive canvas example

2008-10-26 Thread Richard Heyes
 Hmm, should be as easy as changing the event from onclick to on
 mouseover. I think. But yes, onmouseover would be far better.

But it's not, since the mouse is already over the canvas when you move
it over a bar, thus not triggering a new event. Ho hum.

-- 
Richard Heyes

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

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



[PHP] Re: PHP XSLT caching

2008-10-26 Thread Colin Guthrie

vladimirn wrote:

Thank you Col
I will go into Zend_Cache as you suggested.
One more thing- does Zend_Cache saces data into file or use a server memory?


As I said in my original mail, but perhaps wasn't clear, Zend_Cache can 
support file, memcache, APC and other backends.


Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Interactive canvas example

2008-10-26 Thread Richard Heyes
 ...

Ok, a little more playing and I've managed to whittle the public API
down, so animated bar charts galore!

-- 
Richard Heyes

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

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



Re: [PHP] Replacing with f*ck and f*cking

2008-10-26 Thread Larry Garfield
On Sunday 26 October 2008 5:06:09 am Ashley Sheridan wrote:

 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

The way Drupal handles such filtering is simple caching.  As a policy we never 
filter general content on save, because we may want to change the filter 
format later and destroying user-submitted data is *not cool*.  However, we 
do apply a number of possible filters on display (add line breaks, convert 
URLs to clickable, do bad word filtering, or any number of other things) 
and then just cache the result.  The cache lookup (based on a hash of the 
string being filtered and the ID of the filter set to apply) is far faster 
than reapplying the filters every time.  We've found this mechanism to scale 
very well.

-- 
Larry Garfield
[EMAIL PROTECTED]

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



Re: [PHP] PHP XSLT caching

2008-10-26 Thread Per Jessen
vladimirn wrote:

 i was wondering whats the best approach to do next.
 I have an xml file delivered from service of my partner. On my web
 server (windows) i have xslt files used for xml transformation.
 Those files are getting bigger, so i have request to cash them and use
 cashed. 

Your xslt files are source code, so why is there a need to cache them? 


/Per Jessen, Zürich


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



Re: [PHP] clear a mysql table

2008-10-26 Thread Chris

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());


If you really want to delete all rows, use

truncate cash;

otherwise the db deletes the entries row by row - which will be slow, 
and also it has to update all indexes on the tables as it is doing it.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] clear a mysql table

2008-10-26 Thread Bastien Koert


 truncate cash;


Hey, my wife does that all the time!
-- 

Bastien

Cat, the other other white meat


[PHP] question about using sql server with php

2008-10-26 Thread Sudhakar
i have a question about how to use sql database with php instead of using my
sql database

when i use my sql database the php code to connect to the my sql database is
=

$conn = mysql_connect($hostname, $user, $password);

if(!$conn)
{
echo Unable to connect to Database;
}

else
{
mysql_select_db($database, $conn);

$query = mysql_query($selectquery);

mysql_close($conn);
}


if i have to connect to a sql databse instead of my sql database as some
companies use sql database, how can i change the php code to connect, run a
query and close connection to the sql database.

apart from changing the code to connect to sql database is there something
else i need to do.

please advice.

thanks


Re: [PHP] question about using sql server with php

2008-10-26 Thread Chris



if i have to connect to a sql databse instead of my sql database as some
companies use sql database, how can i change the php code to connect, run a
query and close connection to the sql database.

apart from changing the code to connect to sql database is there something
else i need to do.


RTFM?

http://www.php.net/mssql


--
Postgresql  php tutorials
http://www.designmagick.com/


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



[PHP] Dynamically creating multi-array field

2008-10-26 Thread Martin Zvarík

PHP Version 5.2.4

?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';

print_r($tpl); // null
?


I really don't like to use the EVAL function, but do I have choice??
This sucks.

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



Re: [PHP] Dynamically creating multi-array field

2008-10-26 Thread Jim Lucas

Martin Zvarík wrote:

PHP Version 5.2.4

?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';

print_r($tpl); // null
?


I really don't like to use the EVAL function, but do I have choice??
This sucks.



You should print the results that you are looking for!

Are you looking for something like this?

Array
(
[5] = Array
(
[1] = Array
(
[0] = some text
)

)

)

how is the $node string being created?


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



Re: [PHP] Dynamically creating multi-array field

2008-10-26 Thread Martin Zvarík

No offense, but I thought it's obvious what I want to print.

print_r() shows null, and it should print what you just wrote = array field.

It works when first defining with eval():
eval('$tpl'.$node.'=array();');

I guess that's the only way.

Anyway, I appreciate your quick reply,
Martin


Jim Lucas napsal(a):

Martin Zvarík wrote:

PHP Version 5.2.4

?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';

print_r($tpl); // null
?


I really don't like to use the EVAL function, but do I have choice??
This sucks.



You should print the results that you are looking for!

Are you looking for something like this?

Array
(
[5] = Array
(
[1] = Array
(
[0] = some text
)

)

)

how is the $node string being created?




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



Re: [PHP] Dynamically creating multi-array field

2008-10-26 Thread Martin Zvarík

Nope, you have to use the eval() everytime for read/write.



Martin Zvarík napsal(a):

No offense, but I thought it's obvious what I want to print.

print_r() shows null, and it should print what you just wrote = array 
field.


It works when first defining with eval():
eval('$tpl'.$node.'=array();');

I guess that's the only way.

Anyway, I appreciate your quick reply,
Martin


Jim Lucas napsal(a):

Martin Zvarík wrote:

PHP Version 5.2.4

?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';

print_r($tpl); // null
?


I really don't like to use the EVAL function, but do I have choice??
This sucks.



You should print the results that you are looking for!

Are you looking for something like this?

Array
(
[5] = Array
(
[1] = Array
(
[0] = some text
)

)

)

how is the $node string being created?




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



Re: [PHP] Dynamically creating multi-array field

2008-10-26 Thread Jim Lucas

Martin Zvarík wrote:

Nope, you have to use the eval() everytime for read/write.




Wrong.  Their is always more then one way to skin a cat!

?php

$node = '[5][1][]';
$text = 'some text';

preg_match_all('|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER);

$recursive = $matches[1];

$recursive = array_reverse($recursive);

$index = array_shift($recursive);

$in = array((int)$index = $text);
$out = array();

foreach ( $recursive AS $index ) {

$out = array();

$out[(int)$index] = $in;

$in = $out;

}

print_r($out);
?


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



Re: [PHP] Dynamically creating multi-array field

2008-10-26 Thread Jim Lucas

Jim Lucas wrote:

Martin Zvarík wrote:

Nope, you have to use the eval() everytime for read/write.




Wrong.  Their is always more then one way to skin a cat!

?php

$node = '[5][1][]';
$text = 'some text';

preg_match_all('|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER);

$recursive = $matches[1];

$recursive = array_reverse($recursive);

$index = array_shift($recursive);

$in = array((int)$index = $text);
$out = array();

foreach ( $recursive AS $index ) {

$out = array();

$out[(int)$index] = $in;

$in = $out;

}


print_r($out);
?




Even slimmer

?php

$node = '[5][1][]';
$text = 'some text';

preg_match_all('|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER);

$recursive = $matches[1];

$recursive = array_reverse($recursive);

foreach ( $recursive AS $index ) {

$out = array();

$out[(int)$index] = $text;

$text = $out;

}

print_r($out);
?


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