Koozali.org: home of the SME Server

Legacy Forums => General Discussion (Legacy) => Topic started by: Marcor on January 23, 2006, 10:49:34 PM

Title: Smarty PHP Template Engine
Post by: Marcor on January 23, 2006, 10:49:34 PM
Smarty is a easy to use PHP template program, and should be ideal to run on the SME webserver. It's easy to install http://smarty.php.net/quick_start.php . But after install I get only blank pages. Seems something in SME prevents Smarty from running.
Title: Smarty PHP Template Engine
Post by: Marcor on January 24, 2006, 01:24:39 AM
I found the solution, you need to disable the sandbox function.

1. Type in the following commands:
mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
cp /etc/e-smith/templates/etc/httpd/conf/httpd.conf/95AddType00PHP2ibays /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/95AddType00PHP2ibays
pico 95AddType00PHP2ibays

2. Look for the 'sandbox' section of the file and add hashes to the following lines:
# my $basedir = db_get_prop(%accounts, $key, 'PHPBaseDir') ||
# "/home/e-smith/files/ibays/$key";
# $OUT .=
# " php_admin_value open_basedir $basedirn";

(exit ^X)

3. Type in the following commands:
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
service httpd restart

And Enjoy Smarty also:
Title: an other solution, keeping the sandbox ?
Post by: Maelvon on January 28, 2007, 07:24:31 PM
Smarty installed here :
Code: [Select]
/usr/lib/php/smarty
My ibay is called "name", and my smarty folder (cache, configs, templates, templates_c) is here :
Code: [Select]
/home/e-smith/ibays/name/html/smarty
I've modified the "httpd.conf" file like that :
Code: [Select]
# pico /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/95AddType00PHP2ibays

added this :
Code: [Select]
              # Set the sandbox within which PHP is confined to play
                my $basedir = $ibay->prop('PHPBaseDir')
                    || ("/home/e-smith/files/ibays/" . $ibay->key . "/");
                        $OUT .= "    php_admin_value open_basedir $basedir";
                ###############
                # SMARTY for ibay "name" - Maelvon - 2007.01.28
                #
                if ($ibay->key eq 'name')
                {
                        $OUT .= ":/usr/lib/php/smarty/";
                }
                $OUT .= "\n";
                #
                ###############


Run the command expand-template :
Code: [Select]
# expand-template /etc/httpd/conf/httpd.conf
And restarted "httpd-e-smith" service :
Code: [Select]
# service httpd-e-smith restart
I don't know about the security of this code addition, but it works !

If you have any comments ?

And enjoy Smarty !

Maelvon
Title: Smarty PHP Template Engine
Post by: Marcor on January 28, 2007, 07:58:16 PM
Thanks for your contribution. I guess one of the dangers is that people can upload and execute rootkits.