Caching PHP applications using Smarty
Using Smarty is daunting at first, there’s so much it can do. Here’s a way to take advantage of Smarty’s caching functionality in your pre-existing applications.
What we’re going to do is use the PHP4 output buffering and cache the output of your script through that.
Create a simple template on your webserver somewhere. It doesn’t even have to reside in the visible path of the server. In fact, it probably shouldn’t! In that file will be one Smarty variable, $text. This variables is going to hold the entire contents of your script output.
Your script is going to have various inputs that define what gets shown, ie. username, message number, etc. We’re going to cache the output based on those bit of information. In our example that’ll be the uid, $uid of the user.
$smarty = new Smarty;
$smarty->caching = true;
$template = “/home/www/include/templates/text.tpl”;
if($smarty->is_cached( $template, $uid )==false)
// Create new content, cached data is stale or isn’t cached.
$text = “Hello World”;
// Call legacy code that prints directly to the browser
// Get data from database, do other expensive things.
$text .= ob_get_contents();
$smarty->assign(‘text’, $text );
$smarty->display( $template, $uid );
If your legacy code has to interogate the database then you’re saving a huge amount of time doing this. Even if it’s nothing but print statements, chances are Smarty will do it quicker if it’s cached.
Tight rope walker wears hard hat – because of British safety laws. and for my next trick…
The Irish abortion referendum is going to happen on March 6th.
The Catholic Bishops of Ireland released a leaflet describing their stance on the abortion issue. They’re calling for a YES vote. The Pope is also calling for a YES vote. Unfortunately they don’t have a website I can link to but here’s a Google search to find related links.
If you vote NO then the status-quo will still be maintained. That is,
- The threat of suicide is a ground for abortion in this country.
- Women will have the right to information and travel.
- I think that it’s possible that abortions happen in this country already to save womens lives. At least that how I interpret point 3 below.
If you vote YES then:
- Suicide will be removed as a ground for abortion.
- Provide for a law on abortion that can only be changed by another referendum.
- Give constitutional and legal safeguards to medical practices where interventions are made to protect the life of the mother.
Nobody likes to think about abortion. It’s easiest to simply vote NO and get on with life. Fortunately there’s been plenty of arguments on radio, television and other media so people are getting some information. The booklet provided by refcom.ie is also very informative.
Here’s some arguements for voting YES:
- The threat of suicide is a phsycological issue that can be treated by councilling and treatment. Research and studies show that pregnant women are less likely to commit suicide. Other research shows that abortion itself appeared to be a significant factor for suicide.
- Acting on the above, we should protect all life, this is how I perceived the Catholic stance. They want to protect life, full stop. Catholic priests read out a letter from the Bishops this morning at masses, in which they stated that (to paraphrase), “a YES vote is the most appropriate in this case”.
And for NO:
- At present a woman can get an abortion in this country if she is suicidal. She should have as many options as possible for treatment of that condition.
- It’s up to every woman to decide whether or not she should have an abortion, not someone else. (ie. the voter)
- The Labour Party is advocating a NO vote. Party Leader, Ruairi Quinn says, “Whatever else this proposal is, it’s bad law and law making. What the Government through the Attorney General Michael McDowell is proposing to do is to write a Bill into the Constitution. What this means is that if it is passed, the only way it can be amended – even if it is found to be flawed – is through another referendum.” He also states that it is, “an attempt to roll back on women’s rights, and is asking questions of the electrorate that we have benn asked before.” The referendum of 1992 asked the same question.
- The Mother and Child Campaign advocates a NO vote because it sees in the proposals the potential for the introduction of a more liberal abortion regime than currently exists in this jurisdiction. As Tommy Keaveney, a spokesperson on behalf of the group, explains, “The proposal allows for the intentional killing of the unborn. It states that abortions can be carried out based upon the reasonable opinion of an indicifual doctor. As far as we’re concerned this isn’t good enough, as it allows for unscrupulous doctors to dismember an indiividual child.”
The issues are not as clear-cut as they appear above. It does appear that the referendum is flawed in ways I cannot summarise here, but hopefully the links above may help you decide which way you’ll vote on Wednesday.
“. . . but you didn’t mention that it’s a hack of a piece of legislation that Microsoft would be proud of.” – Liam.
“. . . that abortion will be only the second crime that is entered into our constition, the other being treason. Yep that’s right no murder, rape etc in the constitution. And considering that the recommended sentence being talked about is a 12 year sentence, whereas sex offenders etc get 6/12 months, me thinks the yes campaign is talking through their ass.” – Gearoid.
Ananova – Spike Milligan has died. He died at his home in Sussex at the age of 83.
CERT Advisory CA-2002-08 Multiple vulnerabilities in Oracle Servers
Original release date: March 14, 2002
Last revised: —
A complete revision history can be found at the end of this file.
* Systems running Oracle8i Database
* Systems running Oracle9i Database
* Systems running Oracle9i Application Server
Multiple vulnerabilities in Oracle Application Server have recently
been discovered. These vulnerabilities include buffer overflows,
insecure default settings, failures to enforce access controls, and
failure to validate input. The impacts of these vulnerabilities
include the execution of arbitrary commands or code, denial of
service, and unauthorized access to sensitive information.
So, who wants scones? I spent my last five quid on 8 scones (with currants of course!) and a cake of brown bread. Yum. Oh and of course, some dog food for Spring. The rest of the change went into the charity box in Super Valu here in Ballincollig!
Except for the Irish money I’m “hoarding” away at home (numerous millenium coins, one of each of the other coins, and a few notes), I’m all Euro now!
Gonna enjoy those scones tonight!