NullVoid-Fixed

Thursday, August 24, 2006



What is Smarty?

Smarty is a template engine for PHP. More specifically, it facilitates a manageable way to separate application logic and content from its presentation. This is best described in a situation where the application programmer and the template designer play different roles, or in most cases are not the same person.

Crash Course

For those of you who have used PHP template engines, the basic concepts of Smarty should look quite familiar. In your PHP application you assign variables for use in the template, then you display it.
index.php

include('Smarty.class.php');
// create object
$smarty = new Smarty;
// assign some content. This would typically come from
// a database or other source, but we'll use static
// values for the purpose of this example.
$smarty->assign('name', 'george smith');
$smarty->assign('address', '45th & Harris');
// display it
$smarty->display('index.tpl');

The template file then contains the output interspersed with tags that Smarty replaces with assigned content.
index.tpl

Name: {$name}
Address: {$address}
Output

html
head
titleUser Info
/head
body
User Information:


Name: george smith

Address: 45th & Harris

/body
/html

As you can see, Smarty cleanly separates your presentation elements (HTML, CSS, etc.) from your application code. However, it does not necessarily separate logic entirely from your templates. With respect to Smarty's design principles, so long as the logic in the templates is for presentation only, it is permissible to use it. For instance, looping over table row colors or including one template from another would be considered presentation logic. This is something the application should not need to accomodate (it just supplies an array of data.) The idea is to keep the template designer role and application programming role separated. You should be able to completely tear down the templates and rebuild them without touching the code base, all while retaining full control of the presentation. With this comes an important point: there is nothing stopping you from putting application logic in the template. Smarty has more than enough power to let you shoot yourself in the foot, so you must have some self discipline in this respect. Don't worry though, with a little bit of practice it becomes quite self-evident what logic belongs where.


Quick install

Windows users may want to follow this install guide

This is a simple guide to get Smarty setup and running quickly. The online
documentation includes a very thorough explanation of a Smarty installation.
This guide is meant to be a quick and painless way of getting Smarty working,
and nothing more. The guide assumes you are familiar with the UNIX system
environment. Windows users will need to make adjustments where necessary.

INSTALL SMARTY LIBRARY FILES

Copy the Smarty library files to your system. In our example, we place them in
/usr/local/lib/php/Smarty/

$> cd YOUR_DOWNLOAD_DIRECTORY
$> gtar -zxvf Smarty-2.6.7.tar.gz
$> mkdir /usr/local/lib/php/Smarty
$> cp -r Smarty-2.6.7/libs/* /usr/local/lib/php/Smarty

You should now have the following file structure:

/usr/local/lib/php/Smarty/
Config_File.class.php
debug.tpl
internals/
plugins/
Smarty.class.php
Smarty_Compiler.class.php


SETUP SMARTY DIRECTORIES

You will need four directories setup for Smarty to work. These files are for
templates, compiled templates, cached templates and config files. You may or
may not use caching or config files, but it is a good idea to set them up
anyways. It is also recommended to place them outside of the web server
document root. The web server PHP user will need write access to the cache and
compile directories as well.

In our example, the document root is /web/www.domain.com/docs and the
web server username is "nobody". We will keep our Smarty files under
/web/www.domain.com/smarty

$> cd /web/www.domain.com
$> mkdir smarty
$> mkdir smarty/templates
$> mkdir smarty/templates_c
$> mkdir smarty/cache
$> mkdir smarty/configs
$> chown nobody:nobody smarty/templates_c
$> chown nobody:nobody smarty/cache
$> chmod 775 smarty/templates_c
$> chmod 775 smarty/cache

Wednesday, August 16, 2006

How do I import a MySQL dumpfile into my database?


After you have dumped out your data into a file as described here, FTP or scp that dump file to the home directory (/) on our system.

Once you have uploaded the dump file to your account here, get a shell prompt on our system using telnet or ssh.

Now import the dump file into MySQL by typing all the following on 1 single line at the shell prompt:

mysql -p -h DBSERVER dbname < dbname.sql

The above assumes that your database name on our system is "dbname" and the dumpfile that you uploaded was named "dbname.sql". Replace those with your correct database name and dumpfile filename. Also replace DBSERVER with your correct database server name.

If you have followed this other FAQ on how to create a .my.cnf preference file, you would not have to type so much when connecting to the MySQL Monitor from the shell prompt. With a proper .my.cnf file you could have imported the dump by just typing this at the shell prompt:

mysql < dbname.sql

How do I export and move my database tables between servers or copy databases?



The first step is to dump out the contents of the database running on the old server.

You can do this by using the "mysqldump" command.
-> This command will create all the sql necessary to recreate all the tables in your database,
and is called a "dump".
-> A dump can either be printed to your screen, or if there is a lot of data, the dump can be
directed into to a file.

How to dump in a shell prompt using telnet or ssh type this all on 1 single line:

mysqldump -u DBUSER -p DBNAME > DBNAME.sql

substituting DBUSER with your MySQL username at the old host and DBNAME with your database name from the old host.

You will be prompted for your old host's password, which will not echo back at you as you type. After you provide the right password, you will have a file in your current directory called DBNAME.sql containing your entire database.

You'll need to get this file moved onto our system by either 1) FTP'ing it down to your own computer and then uploading it from there to your account on our system, or, 2) by moving the file directly from the host to your account here with the 'ftp' or 'scp' command.

After you have the moved the dumpfile from the old host to your account here, follow these instructions on how to import the dump into your MySQL database running here.

Tuesday, August 15, 2006

Prison Break



Lincoln Burrows is on death row for the murder of the Vice President's brother. He insists he's innocent, but no one other than his brother Michael Scofield believes him. An engineer who was hired to renovate the prison where Lincoln is being held, Michael takes drastic measures to help his brother. He robs a bank and is sent to the same prison, so that with his knowledge of the building the two of them can escape together. However, the plan soon becomes more complicated than Michael intended as other prisoners find out about the plot and want to escape too. Michael also discovers a massive governmental conspiracy that is determined to see Lincoln executed when two crooked federal agents try to silence Burrows' ex-wife and son. Breaking out will be more difficult than he thought, but he's still going to give it his all.

Update on Prison Break

Latest Episode: 01x22: Flight (15/May/2006)

Summary:
With the escape in motion, Michael, Lincoln and the inmates take flight outside the prison walls, risking life and limb to evade capture. Warden Pope and Captain Bellick embark on a relentless pursuit to capture the escapees; the Vice President fears she will lose her command as well as her life; and Veronica tracks down the most significant piece of evidence to prove Lincoln's innocence.

Upcoming Episode: 02x01: Manhunt (21/Aug/2006)

Summary:
Picking up eight hours after their escape from Fox River, Michael, Lincoln, Sucre, Abruzzi and C-Note are on the run for their lives as a vengeful Bellick leads the prison guards seeking to capture their escaped quarry; Dr. Sara is in critical condition from her overdose; Veronica finds herself a prisoner with Terrance; T-Bag tries to get the upper hand while fleeing from the authorities; and a new take-charge FBI investigator proves to be Scofield's match.

Update on LOST

Season three will begin airing in the United States and Canada beginning on October 4, 2006. It will feature 23 episodes that will be delivered in two blocks: an initial autumn arc of six episodes and a second run of seventeen consecutive episodes beginning in February 2007. The story will continue 65 days after the crash, and Lindelof and Carlton Cuse have planned for the coming season to focus on the Others (as led by "Henry Gale") and their history, ranks, and goals.According to executive producer Damon Lindelof, the audience will meet more survivors of the plane crash as new characters in the third season, and these new survivors' flashbacks will be featured as a unique and central component of the series (existing cast members' flashbacks will accordingly be fewer than in previous seasons).

New casts members


Kiele Sanchez


Rodrigo Santoro

Kiele Sanchez will play "Nikki" on Lost in season three -- a possible love interest for another new character that Brazilian actor Rodrigo Santoro will play, according to Variety.