Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

[SOLVED] Unable to load template file 'login.tpl'

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
innerspace
Smarty n00b


Joined: 02 Oct 2012
Posts: 2

PostPosted: Wed Oct 03, 2012 2:32 am    Post subject: [SOLVED] Unable to load template file 'login.tpl' Reply with quote

I'm new to Smarty, having been introduced while attempting to install Calibre-PHP (content server for calibre-server), and I'm having serious issues with the install. After having resolved a number of errors (stream not found, Permission Denied etc) I've ended up stuck at the following roadblock, and I'm completely stumped... seems like my 'templates' path is incorrect, however I've attempted every combination of paths (both relative and absolute) and the issue persists. I'm hoping someone here can help me defeat this, I've been at it all night.

The error...

Code:
PHP Fatal error:  Uncaught exception 'SmartyException' with message 'Unable to load template file 'login.tpl'' in /usr/local/lib/php/Smarty/sysplugins/smarty_internal_templatebase.php:127\nStack trace:\n#0 /usr/local/lib/php/Smarty/sysplugins/smarty_internal_templatebase.php(374): Smarty_Internal_TemplateBase->fetch('login.tpl', NULL, NULL, NULL, true)\n#1 /var/www/calibre-php/index.php(140): Smarty_Internal_TemplateBase->display('login.tpl')\n#2 {main}\n  thrown in /usr/local/lib/php/Smarty/sysplugins/smarty_internal_templatebase.php on line 127


My Environment
Code:
uname -a
Linux KOMPOOTR 3.5.0-16-generic #25-Ubuntu SMP Fri Sep 28 22:32:21 UTC 2012 i686 athlon i686 GNU/Linux


I'm using the latest stable build of Smarty (Build 3.1.12) and have extracted it's contents to /usr/local/lib/php/Smarty

Code:

ls -la /usr/local/lib/php/Smarty/
total 84
drwxr-xr-x 4 root root  4096 Oct  2 10:37 .
drwxr-xr-x 3 root root  4096 Oct  2 10:35 ..
-rw-r--r-- 1 root root  2863 Oct  2 10:37 debug.tpl
drwxr-xr-x 2 root root  4096 Oct  2 10:37 plugins
-rw-r--r-- 1 root root 12903 Oct  2 10:37 SmartyBC.class.php
-rw-r--r-- 1 root root 45404 Oct  2 10:37 Smarty.class.php
drwxr-xr-x 2 root root  4096 Oct  2 13:09 sysplugins


Loaded Modules:
Code:

apache2ctl -M
apache2: Could not reliably determine the server's fully qualified domain name, using KOMPUTER for ServerName
Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 reqtimeout_module (shared)
 setenvif_module (shared)
 ssl_module (shared)
 status_module (shared)
Syntax OK



Calibre-PHP Specifics

My directory structure is as follows:

Code:
ls -la /var/www/calibre-php/
total 128
drwxr-xr-x 5 root     root      4096 Oct  2 20:05 .
drwxr-xr-x 3 root     root      4096 Oct  2 11:20 ..
-rw-r--r-- 1 root     root      4656 Feb 15  2012 config_default.php
-rw-r--r-- 1 root     root      4724 Oct  2 20:05 config_local.php
-rw-r--r-- 1 root     root     16384 Oct  2 20:05 .config_local.php.swp
-rw-r--r-- 1 root     root       255 Nov  5  2010 config.php
-rw-r--r-- 1 root     root     24970 Feb 15  2012 db.php
drw-r--r-- 2 root     root      4096 Oct  2 10:13 images
-rw-r--r-- 1 root     root      3999 Feb 15  2012 index.php
-rw-r--r-- 1 root     root      6678 Dec 15  2010 INSTALL
-rw-r--r-- 1 root     root       221 Oct 30  2010 LICENSE
-rw-r--r-- 1 root     root      1203 Jan 20  2011 mimetypes.php
drwxr-xr-x 2 root     root      4096 Oct  2 10:13 modules
-rw-r--r-- 1 root     root     10273 Nov  7  2010 query.php
drw-r--r-- 6 www-data www-data  4096 Oct  2 12:48 smarty
-rw-r--r-- 1 root     root       883 Oct  2 19:49 smarty.php
-rw-r--r-- 1 root     root      5116 Feb 15  2012 utilities.php


Code:
 ls -la /var/www/calibre-php/smarty
total 24
drw-r--r-- 6 www-data www-data 4096 Oct  2 12:48 .
drwxr-xr-x 5 root     root     4096 Oct  2 20:05 ..
drw-r--r-- 2 root     root     4096 Oct  2 10:52 cache
drw-r--r-- 3 root     root     4096 Oct  2 12:21 configs
drw-r--r-- 2 root     root     4096 Oct  2 12:48 templates
drwxr-xr-x 2 root     root     4096 Oct  2 12:29 templates_c



Code:
ls -la /var/www/calibre-php/smarty/templates
total 44
drw-r--r-- 2 root     root     4096 Oct  2 12:48 .
drw-r--r-- 6 www-data www-data 4096 Oct  2 12:48 ..
-rwxr-xr-x 1 root     root     1959 Nov 20  2011 books_section.tpl
-rwxr-xr-x 1 root     root      281 Dec 14  2010 books.tpl
-rwxr-xr-x 1 root     root      867 Dec 14  2010 category.tpl
-rwxr-xr-x 1 root     root      231 Oct 28  2010 error.tpl
-rwxr-xr-x 1 root     root      653 Dec 14  2010 footer.tpl
-rwxr-xr-x 1 root     root     2936 Nov 22  2011 header.tpl
-rwxr-xr-x 1 root     root      922 Nov 20  2011 index.tpl
-rwxr-xr-x 1 root     root      723 Dec 16  2010 login.tpl
-rwxr-xr-x 1 root     root      242 Oct 29  2010 titles.tpl



Calibre-PHP's config file is config_local.php, the relevant bits setting paths:
Code:
<?php
   $config = array();
   /*
    * The directory containing calibre's metadata.db file, with sub-directories
    * containing all the formats.
    */
   $config['library_dir'] = '/path/to/media/library/';

   /*
    * The directory containing the PHP code.
    */
   $config['web_dir'] = '/var/www/calibre-php';

   /*
    * The directory in web space where smarty will find the templates.
    */

   $config['smarty_web_dir'] = $config['web_dir'] . '/var/www/calibre-php/smarty/templates';

   /*
    * The directory where smarty is to store its caches and the like. The web
    * server must have write access here.
    */

   $config['smarty_dir'] = '/var/www/calibre-php/smarty/configs';

   /*
    * The directory containing the Smarty PHP files, and in particular the file
    * Smarty.class.php.
    */
   $config['smarty'] = '/usr/local/lib/php/Smarty/';

?>



So, even with absolute paths, serving content fails with Unable to load template file 'login.tpl'

Some troubleshooting...

Attempting to browse to http://127.0.0.1/calibre-php/smarty/templates/login.tpl yields "Forbidden - You don't have permission to access /calibre-php/smarty/templates/login.tpl on this server."

This seems like a permissions issue to me, so I fiddle my way through it...

Code:
chmod 755 smarty/templates/*.*

ls -la smarty/templates/*.*

-rwxr-xr-x 1 root root 1959 Nov 20  2011 smarty/templates/books_section.tpl
-rwxr-xr-x 1 root root  281 Dec 14  2010 smarty/templates/books.tpl
-rwxr-xr-x 1 root root  867 Dec 14  2010 smarty/templates/category.tpl
-rwxr-xr-x 1 root root  231 Oct 28  2010 smarty/templates/error.tpl
-rwxr-xr-x 1 root root  653 Dec 14  2010 smarty/templates/footer.tpl
-rwxr-xr-x 1 root root 2936 Nov 22  2011 smarty/templates/header.tpl
-rwxr-xr-x 1 root root  922 Nov 20  2011 smarty/templates/index.tpl
-rwxr-xr-x 1 root root  723 Dec 16  2010 smarty/templates/login.tpl
-rwxr-xr-x 1 root root  242 Oct 29  2010 smarty/templates/titles.tpl

/etc/init.d/apache2 restart


PROGRESS! A new error, heading in the right direction:
Code:
[Tue Oct 02 20:53:16 2012] [error] [client 127.0.0.1] (13)Permission denied: access to /calibre-php/smarty/templates/login.tpl denied, referer: http://127.0.0.1/calibre-php/smarty/templates/login.tpl


It would seem that apache doesn't have rights to that file... changing ownership to www-data:www-data changes nothing, chmod 777 /smarty/templates/*.* makes no difference either, so who needs permission to login.tpl???

Referencing the Troubleshooting steps outlined here,

Quote:
3) file/directory existence and permissions

OK, now for the test that should tell us everything. Try this script and see if the contents of your template file gets displayed:

Code:
<?php
// setup smarty here
$smarty = new Smarty();
$smarty->template_dir = "/path/to/my/templates";

// use your template filename, and be sure to put the "/" in there
// if your template_dir does not have a trailing "/"
$myfile = $smarty->template_dir . "/foo.tpl";
echo "attempting to read $myfile\n";
readfile($myfile);
?>


If the above script fails with an error, this is certainly the problem. Double check that the file exists, then check the file permissions. For unix systems, you have to check both the file permissions and all directory permissions leading up to it. Files commonly have a chmod of 644 (-rw-r--r--) and directories have a chmod of 755 (drwxr-xr-x). It is important that the user executing the script (either you from the command line or the php user via apache) have access to the template files. This is the most common problem, so check all those file permissions.

Once you get that working, Smarty should be able to read the template file.



I created the following file at /var/www/calibre-php/smarty/test.php

Code:
<?php
// setup smarty here
$smarty = new Smarty();
$smarty->template_dir = "/var/www/calibre-php/smarty/templates";

// use your template filename, and be sure to put the "/" in there
// if your template_dir does not have a trailing "/"
$myfile = $smarty->template_dir . "/login.tpl";
echo "attempting to read $myfile\n";
readfile($myfile);
?>



and rebooted apache but alas, Permission Denied... seems like the relevant bits of the troubleshooting steps quoted above is as follows:
Quote:
For unix systems, you have to check both the file permissions and all directory permissions leading up to it.


So, armed with our new knowledge we double-check and verify permissions match the following statement:
Quote:
Files commonly have a chmod of 644 (-rw-r--r--) and directories have a chmod of 755 (drwxr-xr-x)

Lines marked in RED are errors, items marked in GREEN are the fixes, process included below for posterity.
Quote:
root@KOMPUTER:/var/www# ls -la
total 16
drwxr-xr-x 3 root root 4096 Oct 2 11:20 .
drwxr-xr-x 16 root root 4096 Oct 2 10:41 ..
drwxr-xr-x 5 root root 4096 Oct 2 21:14 calibre-php
-rw-r--r-- 1 root root 21 Jul 10 18:30 info.php
root@KOMPUTER:/var/www# chmod 755 calibre-php/
root@KOMPUTER:/var/www# ls -la
total 16
drwxr-xr-x 3 root root 4096 Oct 2 11:20 .
drwxr-xr-x 16 root root 4096 Oct 2 10:41 ..
drwxr-xr-x 5 root root 4096 Oct 2 21:14 calibre-php
-rw-r--r-- 1 root root 21 Jul 10 18:30 info.php
root@KOMPUTER:/var/www# cd calibre-php/
root@KOMPUTER:/var/www/calibre-php# ls -la
total 112
drwxr-xr-x 5 root root 4096 Oct 2 21:14 .
drwxr-xr-x 3 root root 4096 Oct 2 11:20 ..
-rw-r--r-- 1 root root 4656 Feb 15 2012 config_default.php
-rw-r--r-- 1 root root 4760 Oct 2 20:41 config_local.php
-rw-r--r-- 1 root root 255 Nov 5 2010 config.php
-rw-r--r-- 1 root root 24970 Feb 15 2012 db.php
drw-r--r-- 2 root root 4096 Oct 2 10:13 images
-rw-r--r-- 1 root root 3999 Feb 15 2012 index.php
-rw-r--r-- 1 root root 6678 Dec 15 2010 INSTALL
-rw-r--r-- 1 root root 221 Oct 30 2010 LICENSE
-rw-r--r-- 1 root root 1203 Jan 20 2011 mimetypes.php
drwxr-xr-x 2 root root 4096 Oct 2 10:13 modules
-rw-r--r-- 1 root root 10273 Nov 7 2010 query.php
drw-r--r-- 6 www-data www-data 4096 Oct 2 21:24 smarty
-rw-r--r-- 1 root root 883 Oct 2 19:49 smarty.php
-rw-r--r-- 1 root root 5116 Feb 15 2012 utilities.php
root@KOMPUTER:/var/www/calibre-php# chmod 755 images/
root@KOMPUTER:/var/www/calibre-php# chmod 755 modules/
root@KOMPUTER:/var/www/calibre-php# chmod 755 smarty
root@KOMPUTER:/var/www/calibre-php# ls -la
total 112
drwxr-xr-x 5 root root 4096 Oct 2 21:14 .
drwxr-xr-x 3 root root 4096 Oct 2 11:20 ..
-rw-r--r-- 1 root root 4656 Feb 15 2012 config_default.php
-rw-r--r-- 1 root root 4760 Oct 2 20:41 config_local.php
-rw-r--r-- 1 root root 255 Nov 5 2010 config.php
-rw-r--r-- 1 root root 24970 Feb 15 2012 db.php
drwxr-xr-x 2 root root 4096 Oct 2 10:13 images
-rw-r--r-- 1 root root 3999 Feb 15 2012 index.php
-rw-r--r-- 1 root root 6678 Dec 15 2010 INSTALL
-rw-r--r-- 1 root root 221 Oct 30 2010 LICENSE
-rw-r--r-- 1 root root 1203 Jan 20 2011 mimetypes.php
drwxr-xr-x 2 root root 4096 Oct 2 10:13 modules
-rw-r--r-- 1 root root 10273 Nov 7 2010 query.php
drwxr-xr-x 6 www-data www-data 4096 Oct 2 21:24 smarty
-rw-r--r-- 1 root root 883 Oct 2 19:49 smarty.php
-rw-r--r-- 1 root root 5116 Feb 15 2012 utilities.php
root@KOMPUTER:/var/www/calibre-php# cd smarty
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la
total 28
drwxr-xr-x 6 www-data www-data 4096 Oct 2 21:24 .
drwxr-xr-x 5 root root 4096 Oct 2 21:14 ..
drw-r--r-- 2 root root 4096 Oct 2 10:52 cache
drw-r--r-- 3 root root 4096 Oct 2 12:21 configs
drwxr-xr-x 2 root root 4096 Oct 2 21:13 templates
drwxr-xr-x 2 root root 4096 Oct 2 12:29 templates_c
-rwxr-xr-x 1 root root 354 Oct 2 21:24 test.php
root@KOMPUTER:/var/www/calibre-php/smarty# chmod 755 cache/
root@KOMPUTER:/var/www/calibre-php/smarty# chmod 755 configs/
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la
total 28
drwxr-xr-x 6 www-data www-data 4096 Oct 2 21:24 .
drwxr-xr-x 5 root root 4096 Oct 2 21:14 ..
drwxr-xr-x 2 root root 4096 Oct 2 10:52 cache
drwxr-xr-x 3 root root 4096 Oct 2 12:21 configs
drwxr-xr-x 2 root root 4096 Oct 2 21:13 templates
drwxr-xr-x 2 root root 4096 Oct 2 12:29 templates_c
-rwxr-xr-x 1 root root 354 Oct 2 21:24 test.php
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la cache/
total 8
drwxr-xr-x 2 root root 4096 Oct 2 10:52 .
drwxr-xr-x 6 www-data www-data 4096 Oct 2 21:24 ..
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la configs/
total 12
drwxr-xr-x 3 root root 4096 Oct 2 12:21 .
drwxr-xr-x 6 www-data www-data 4096 Oct 2 21:24 ..
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la templates
total 44
drwxr-xr-x 2 root root 4096 Oct 2 21:13 .
drwxr-xr-x 6 www-data www-data 4096 Oct 2 21:24 ..
-rw-r--r-- 1 root root 1959 Nov 20 2011 books_section.tpl
-rw-r--r-- 1 root root 281 Dec 14 2010 books.tpl
-rw-r--r-- 1 root root 867 Dec 14 2010 category.tpl
-rw-r--r-- 1 root root 231 Oct 28 2010 error.tpl
-rw-r--r-- 1 root root 653 Dec 14 2010 footer.tpl
-rw-r--r-- 1 root root 2936 Nov 22 2011 header.tpl
-rw-r--r-- 1 root root 922 Nov 20 2011 index.tpl
-rw-r--r-- 1 root root 723 Dec 16 2010 login.tpl
-rw-r--r-- 1 root root 242 Oct 29 2010 titles.tpl
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la templates_c/
total 8
drwxr-xr-x 2 root root 4096 Oct 2 12:29 .
drwxr-xr-x 6 www-data www-data 4096 Oct 2 21:24 ..



Looking at File permissions I saw a few issues in /images, made sure all files were chmodded 0644...

Code:

root@KOMPUTER:/var/www/calibre-php# ls -la
total 112
drwxr-xr-x 5 root     root      4096 Oct  2 21:14 .
drwxr-xr-x 3 root     root      4096 Oct  2 11:20 ..
-rw-r--r-- 1 root     root      4656 Feb 15  2012 config_default.php
-rw-r--r-- 1 root     root      4760 Oct  2 20:41 config_local.php
-rw-r--r-- 1 root     root       255 Nov  5  2010 config.php
-rw-r--r-- 1 root     root     24970 Feb 15  2012 db.php
drwxr-xr-x 2 root     root      4096 Oct  2 10:13 images
-rw-r--r-- 1 root     root      3999 Feb 15  2012 index.php
-rw-r--r-- 1 root     root      6678 Dec 15  2010 INSTALL
-rw-r--r-- 1 root     root       221 Oct 30  2010 LICENSE
-rw-r--r-- 1 root     root      1203 Jan 20  2011 mimetypes.php
drwxr-xr-x 2 root     root      4096 Oct  2 10:13 modules
-rw-r--r-- 1 root     root     10273 Nov  7  2010 query.php
drwxr-xr-x 6 www-data www-data  4096 Oct  2 21:24 smarty
-rw-r--r-- 1 root     root       883 Oct  2 19:49 smarty.php
-rw-r--r-- 1 root     root      5116 Feb 15  2012 utilities.php
root@KOMPUTER:/var/www/calibre-php# cd images/
root@KOMPUTER:/var/www/calibre-php/images# ls -la
total 60
drwxr-xr-x 2 root root  4096 Oct  2 10:13 .
drwxr-xr-x 5 root root  4096 Oct  2 21:14 ..
-rw-rw-r-- 1 root root  1566 Oct 25  2010 book.png
-rw-rw-r-- 1 root root  1545 Oct 25  2010 column.png
-rw-rw-r-- 1 root root 10643 Oct 28  2010 default_cover.jpg
-rw-rw-r-- 1 root root  1948 Oct 25  2010 drawer.png
-rw-rw-r-- 1 root root  1618 Oct 29  2010 five_stars.png
-rw-rw-r-- 1 root root  1569 Oct 25  2010 news.png
-rw-rw-r-- 1 root root  1749 Oct 25  2010 publisher.png
-rw-rw-r-- 1 root root  1473 Oct 25  2010 rating.png
-rw-rw-r-- 1 root root  1403 Oct 25  2010 series.png
-rw-rw-r-- 1 root root  1428 Oct 25  2010 tags.png
-rw-rw-r-- 1 root root  1094 Oct 25  2010 user_profile.png
root@KOMPUTER:/var/www/calibre-php/images# chmod 644 *.png
root@KOMPUTER:/var/www/calibre-php/images# ls -la
total 60
drwxr-xr-x 2 root root  4096 Oct  2 10:13 .
drwxr-xr-x 5 root root  4096 Oct  2 21:14 ..
-rw-r--r-- 1 root root  1566 Oct 25  2010 book.png
-rw-r--r-- 1 root root  1545 Oct 25  2010 column.png
-rw-rw-r-- 1 root root 10643 Oct 28  2010 default_cover.jpg
-rw-r--r-- 1 root root  1948 Oct 25  2010 drawer.png
-rw-r--r-- 1 root root  1618 Oct 29  2010 five_stars.png
-rw-r--r-- 1 root root  1569 Oct 25  2010 news.png
-rw-r--r-- 1 root root  1749 Oct 25  2010 publisher.png
-rw-r--r-- 1 root root  1473 Oct 25  2010 rating.png
-rw-r--r-- 1 root root  1403 Oct 25  2010 series.png
-rw-r--r-- 1 root root  1428 Oct 25  2010 tags.png
-rw-r--r-- 1 root root  1094 Oct 25  2010 user_profile.png
root@KOMPUTER:/var/www/calibre-php/images# chmod 644 *.jpg
root@KOMPUTER:/var/www/calibre-php/images# ls -la
total 60
drwxr-xr-x 2 root root  4096 Oct  2 10:13 .
drwxr-xr-x 5 root root  4096 Oct  2 21:14 ..
-rw-r--r-- 1 root root  1566 Oct 25  2010 book.png
-rw-r--r-- 1 root root  1545 Oct 25  2010 column.png
-rw-r--r-- 1 root root 10643 Oct 28  2010 default_cover.jpg
-rw-r--r-- 1 root root  1948 Oct 25  2010 drawer.png
-rw-r--r-- 1 root root  1618 Oct 29  2010 five_stars.png
-rw-r--r-- 1 root root  1569 Oct 25  2010 news.png
-rw-r--r-- 1 root root  1749 Oct 25  2010 publisher.png
-rw-r--r-- 1 root root  1473 Oct 25  2010 rating.png
-rw-r--r-- 1 root root  1403 Oct 25  2010 series.png
-rw-r--r-- 1 root root  1428 Oct 25  2010 tags.png
-rw-r--r-- 1 root root  1094 Oct 25  2010 user_profile.png

root@KOMPUTER:/var/www/calibre-php# cd modules
root@KOMPUTER:/var/www/calibre-php/modules# ls
book_base.php  book_format.php  book.php  category.php  catval.php  cover.php  home.php  login.php  module.php  rating.php  standard_vars.php  titles.php
root@KOMPUTER:/var/www/calibre-php/modules# ls -la
total 56
drwxr-xr-x 2 root root 4096 Oct  2 10:13 .
drwxr-xr-x 5 root root 4096 Oct  2 21:14 ..
-rw-r--r-- 1 root root 1984 Nov 20  2011 book_base.php
-rw-r--r-- 1 root root 2034 Feb 15  2012 book_format.php
-rw-r--r-- 1 root root 1095 Dec  8  2010 book.php
-rw-r--r-- 1 root root 1718 Nov 20  2011 category.php
-rw-r--r-- 1 root root 1574 Nov 20  2011 catval.php
-rw-r--r-- 1 root root 2109 Jun 29  2011 cover.php
-rw-r--r-- 1 root root  908 Nov 20  2011 home.php
-rw-r--r-- 1 root root  517 Dec 14  2010 login.php
-rw-r--r-- 1 root root  311 Oct 30  2010 module.php
-rw-r--r-- 1 root root 1191 Jun 29  2011 rating.php
-rw-r--r-- 1 root root 1151 Dec 14  2010 standard_vars.php
-rw-r--r-- 1 root root  961 Dec 13  2010 titles.php
root@KOMPUTER:/var/www/calibre-php/modules# chmod 644 *.php
root@KOMPUTER:/var/www/calibre-php/modules# ls -la
total 56
drwxr-xr-x 2 root root 4096 Oct  2 10:13 .
drwxr-xr-x 5 root root 4096 Oct  2 21:14 ..
-rw-r--r-- 1 root root 1984 Nov 20  2011 book_base.php
-rw-r--r-- 1 root root 2034 Feb 15  2012 book_format.php
-rw-r--r-- 1 root root 1095 Dec  8  2010 book.php
-rw-r--r-- 1 root root 1718 Nov 20  2011 category.php
-rw-r--r-- 1 root root 1574 Nov 20  2011 catval.php
-rw-r--r-- 1 root root 2109 Jun 29  2011 cover.php
-rw-r--r-- 1 root root  908 Nov 20  2011 home.php
-rw-r--r-- 1 root root  517 Dec 14  2010 login.php
-rw-r--r-- 1 root root  311 Oct 30  2010 module.php
-rw-r--r-- 1 root root 1191 Jun 29  2011 rating.php
-rw-r--r-- 1 root root 1151 Dec 14  2010 standard_vars.php
-rw-r--r-- 1 root root  961 Dec 13  2010 titles.php
root@KOMPUTER:/var/www/calibre-php# cd smarty
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la
total 28
drwxr-xr-x 6 www-data www-data 4096 Oct  2 21:24 .
drwxr-xr-x 5 root     root     4096 Oct  2 21:14 ..
drwxr-xr-x 2 root     root     4096 Oct  2 10:52 cache
drwxr-xr-x 2 root     root     4096 Oct  2 21:32 configs
drwxr-xr-x 2 root     root     4096 Oct  2 21:13 templates
drwxr-xr-x 2 root     root     4096 Oct  2 12:29 templates_c
-rwxr-xr-x 1 root     root      354 Oct  2 21:24 test.php
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la cache/
total 8
drwxr-xr-x 2 root     root     4096 Oct  2 10:52 .
drwxr-xr-x 6 www-data www-data 4096 Oct  2 21:24 ..
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la configs/
total 8
drwxr-xr-x 2 root     root     4096 Oct  2 21:32 .
drwxr-xr-x 6 www-data www-data 4096 Oct  2 21:24 ..
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la templates
total 44
drwxr-xr-x 2 root     root     4096 Oct  2 21:13 .
drwxr-xr-x 6 www-data www-data 4096 Oct  2 21:24 ..
-rw-r--r-- 1 root     root     1959 Nov 20  2011 books_section.tpl
-rw-r--r-- 1 root     root      281 Dec 14  2010 books.tpl
-rw-r--r-- 1 root     root      867 Dec 14  2010 category.tpl
-rw-r--r-- 1 root     root      231 Oct 28  2010 error.tpl
-rw-r--r-- 1 root     root      653 Dec 14  2010 footer.tpl
-rw-r--r-- 1 root     root     2936 Nov 22  2011 header.tpl
-rw-r--r-- 1 root     root      922 Nov 20  2011 index.tpl
-rw-r--r-- 1 root     root      723 Dec 16  2010 login.tpl
-rw-r--r-- 1 root     root      242 Oct 29  2010 titles.tpl
root@KOMPUTER:/var/www/calibre-php/smarty# cd templates
root@KOMPUTER:/var/www/calibre-php/smarty/templates# ls -la
total 44
drwxr-xr-x 2 root     root     4096 Oct  2 21:13 .
drwxr-xr-x 6 www-data www-data 4096 Oct  2 21:24 ..
-rw-r--r-- 1 root     root     1959 Nov 20  2011 books_section.tpl
-rw-r--r-- 1 root     root      281 Dec 14  2010 books.tpl
-rw-r--r-- 1 root     root      867 Dec 14  2010 category.tpl
-rw-r--r-- 1 root     root      231 Oct 28  2010 error.tpl
-rw-r--r-- 1 root     root      653 Dec 14  2010 footer.tpl
-rw-r--r-- 1 root     root     2936 Nov 22  2011 header.tpl
-rw-r--r-- 1 root     root      922 Nov 20  2011 index.tpl
-rw-r--r-- 1 root     root      723 Dec 16  2010 login.tpl
-rw-r--r-- 1 root     root      242 Oct 29  2010 titles.tpl
root@KOMPUTER:/var/www/calibre-php/smarty/templates# chmod 644 *.tpl
root@KOMPUTER:/var/www/calibre-php/smarty/templates# ls -la
total 44
drwxr-xr-x 2 root     root     4096 Oct  2 21:13 .
drwxr-xr-x 6 www-data www-data 4096 Oct  2 21:24 ..
-rw-r--r-- 1 root     root     1959 Nov 20  2011 books_section.tpl
-rw-r--r-- 1 root     root      281 Dec 14  2010 books.tpl
-rw-r--r-- 1 root     root      867 Dec 14  2010 category.tpl
-rw-r--r-- 1 root     root      231 Oct 28  2010 error.tpl
-rw-r--r-- 1 root     root      653 Dec 14  2010 footer.tpl
-rw-r--r-- 1 root     root     2936 Nov 22  2011 header.tpl
-rw-r--r-- 1 root     root      922 Nov 20  2011 index.tpl
-rw-r--r-- 1 root     root      723 Dec 16  2010 login.tpl
-rw-r--r-- 1 root     root      242 Oct 29  2010 titles.tpl
root@KOMPUTER:/var/www/calibre-php/smarty/templates# cd ../
root@KOMPUTER:/var/www/calibre-php/smarty# ls -la templates_c/
total 8
drwxr-xr-x 2 root     root     4096 Oct  2 12:29 .
drwxr-xr-x 6 www-data www-data 4096 Oct  2 21:24 ..



Clearly, some errors on my part... sadly, a quick reboot of Apache reveals we've made a little progress... browsing http://127.0.0.1/calibre-php/ still yields:

Code:
[Tue Oct 02 22:04:11 2012] [error] [client 127.0.0.1] PHP Fatal error:  Uncaught exception 'SmartyException' with message 'Unable to load template file 'login.tpl'' in /usr/local/lib/php/Smarty/sysplugins/smarty_internal_templatebase.php:127\nStack trace:\n#0 /usr/local/lib/php/Smarty/sysplugins/smarty_internal_templatebase.php(374): Smarty_Internal_TemplateBase->fetch('login.tpl', NULL, NULL, NULL, true)\n#1 /var/www/calibre-php/index.php(140): Smarty_Internal_TemplateBase->display('login.tpl')\n#2 {main}\n  thrown in /usr/local/lib/php/Smarty/sysplugins/smarty_internal_templatebase.php on line 127


HOWEVER browsing to http://127.0.0.1/calibre-php/smarty/templates/login.tpl now displays the contents of the PHP file but does not process it:

Code:

{{*<!--
        Name:       Calibre PHP webserver
        License:    GPL v3
        Copyright:    2010, Charles Haley <charles@haleys.org
-->*}}
{{include file="header.tpl" title="Home"}}

<form action="index.php" method="post">
<table align="center">
<tr>
<td style="text-align:center;" colspan="2">
    {{$message}}<br>Please Login
</td>
</tr>
<tr>
<td>
    User name:</td>
<td>
    <input name="name" type="text"></td>
</tr>
<tr>
<td>
    Password:
</td>
<td>
    <input name="password" type="password"></td>
</tr>
<tr>
<td style="text-align:center;" colspan="2">
    <input name="Login" type="submit" value="login">
</td>
</tr>
</table>
    </form>
{{include file='footer.tpl' foo='bar'}}



Which leads me to believe I'm having issues with PHP/Apache, as the file is accessible to Apache (after repairing recursive directory and file permissions)...

I've verified (so it seems) that all Smarty paths are correct.
I've verified all directory permissions are correct.
I've verified all file permissions are correct.



So - I'm stumped, can anyone offer some guidance? I am at a loss. Any assistance would be greatly appreciated.


Finally - there is one thing nagging at me... the following file exists in /var/www/calibre-php/

Code:


 cat smarty.php
<?php
    /*
        Name:       Calibre PHP webserver
        license:    GPL v3
        copyright:    2010, Charles Haley
                    http://charles.haleys.org
    */

    require_once 'config.php';
    require_once $config['smarty'] . '/Smarty.class.php';

    $smarty = new Smarty;
   
    /*
     * Initialize smarty, giving it the various locations.
     */

    $smarty->template_dir =  $config['smarty_web_dir'] . '/var/www/calibre-php/smarty/templates';
    $smarty->config_dir = $config['smarty_web_dir'] . '/var/www/calibre-php/smarty/configs';
    $smarty->cache_dir = $config['smarty_dir'] . '/var/www/calibre-php/smarty/cache';
    $smarty->compile_dir = $config['smarty_dir'] . '/var/www/calibre-php/smarty/templates_c';
   
    /*
     * Change the delimiters to avoid conflicts with style declarations.
     */
    $smarty->left_delimiter = '{{';
    $smarty->right_delimiter = '}}';
?>


I am mildly curious as to whether or not this file is causing some sort of conflict... I've included it at the end of this post because I am truly frazzled and can't wrap my head around the problem anymore...


Last edited by innerspace on Sun Dec 09, 2012 4:21 am; edited 1 time in total
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Oct 03, 2012 4:42 am    Post subject: Reply with quote

You use wrong file pathes.

Exampe:
$smarty->template_dir = $config['smarty_web_dir'] . '/var/www/calibre-php/smarty/templates';

Here you prepend $config['smarty_web_dir'] to the already correct absolute filepath.

You made same sort of error also in config_local.php.

After configuring Smarty you could call
$smarty->testInstall();
to check your configuration and check permissions.
Back to top
View user's profile Send private message
innerspace
Smarty n00b


Joined: 02 Oct 2012
Posts: 2

PostPosted: Sun Dec 09, 2012 4:23 am    Post subject: thought i marked this solved... Reply with quote

Have done so now - indeed, i had filepath issues in my config and a third party was able to help me get things straightened out.

thank you for pointing me in the right direction, initial config dox provided by third-party package left me a bit confused.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP