From c74fd789935e19074e2799b5201654ffe3bfce5c Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 10 Jul 2014 21:34:52 -0700 Subject: [PATCH] move smarty compiled files to store/[data]/smarty3 - which puts all writeable areas of the server except the config file and logs under the "store" directory. We'll do logs at a future time. --- boot.php | 14 ++++++++------ doc/Install.md | 6 +++--- doc/faq_admins.bb | 2 +- doc/install.bb | 6 +++--- doc/problems-following-an-update.bb | 2 +- doc/red2pi.bb | 4 ++-- include/friendica_smarty.php | 2 +- install/INSTALL.txt | 8 +++----- install/update.php | 11 ++++++++--- mod/setup.php | 8 ++++---- util/precompile_smarty3.php | 6 +++--- 11 files changed, 37 insertions(+), 32 deletions(-) diff --git a/boot.php b/boot.php index c3ea2a854..e6bbbee2f 100755 --- a/boot.php +++ b/boot.php @@ -47,11 +47,12 @@ define ( 'RED_PLATFORM', 'Red Matrix' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1116 ); +define ( 'DB_UPDATE_VERSION', 1117 ); define ( 'EOL', '
' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); +define ( 'TEMPLATE_BUILD_PATH', 'store/[data]/smarty3' ); define ( 'DIRECTORY_MODE_NORMAL', 0x0000); // This is technically DIRECTORY_MODE_TERTIARY, but it's the default, hence 0x0000 define ( 'DIRECTORY_MODE_PRIMARY', 0x0001); @@ -1062,8 +1063,8 @@ class App { /*if ($engine) { case 'smarty3': - if(!is_writable('view/tpl/smarty3/')) - echo "ERROR folder view/tpl/smarty3/ must be writable by webserver."; killme(); + if(!is_writable(TEMPLATE_BUILD_PATH)) + echo "ERROR folder " . TEMPLATE_BUILD_PATH . " must be writable by webserver."; killme(); break; default: @@ -1256,10 +1257,11 @@ function check_config(&$a) { $func = 'update_r' . $x; $retval = $func(); if($retval) { + // Prevent sending hundreds of thousands of emails by creating - // a lockfile. view/tpl/smarty3 is the only place we can - // guarantee the server can write to. - $lockfile = 'view/tpl/smarty3/mailsent'; + // a lockfile. + + $lockfile = 'store/[data]/mailsent'; if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) return; diff --git a/doc/Install.md b/doc/Install.md index 8adfe3ccd..1ff6e69e7 100644 --- a/doc/Install.md +++ b/doc/Install.md @@ -49,11 +49,11 @@ you might have trouble getting everything to work.] `git pull` - - make sure folder *view/tpl/smarty3* exists and is writable by webserver + - make sure folder *store/[data]/smarty3* exists and is writable by webserver - `mkdir view/tpl/smarty3` + `mkdir -p "store/\[data\]/smarty3"` - `chmod 777 view/smarty3` + `chmod 777 "store/\[data\]/smarty3"` - For installing addons diff --git a/doc/faq_admins.bb b/doc/faq_admins.bb index bf3364f98..1679ec246 100644 --- a/doc/faq_admins.bb +++ b/doc/faq_admins.bb @@ -17,7 +17,7 @@ Most likely, your session table has crashed. Run the MySQL command [code]repair [*][b]When I switch theme, I sometimes get elements of one theme superimposed on top of the other[/b] -a) view/tpl/smarty3 isn't writeable by the webserver. Make it so. +a) store/[data]/smarty3 isn't writeable by the webserver. Make it so. b) You're using Midori, or with certain themes, Konqueror in KHTML mode. diff --git a/doc/install.bb b/doc/install.bb index 81fc7f844..bf6578e59 100644 --- a/doc/install.bb +++ b/doc/install.bb @@ -41,11 +41,11 @@ you might have trouble getting everything to work.] `git pull` - - make sure folder *view/tpl/smarty3* exists and is writable by webserver + - make sure folder *store/[data]/smarty3* exists and is writable by webserver - `mkdir view/tpl/smarty3` + `mkdir -p "store/\[data\]/smarty3"` - `chmod 777 view/smarty3` + `chmod 777 "store/\[data\]/smarty3"` - For installing addons diff --git a/doc/problems-following-an-update.bb b/doc/problems-following-an-update.bb index bb2e07a07..0b2c2e11a 100644 --- a/doc/problems-following-an-update.bb +++ b/doc/problems-following-an-update.bb @@ -24,7 +24,7 @@ Symptoms: 2) Missing icons, tabs, menus or features. -We use the Smarty3 template engine to generate pages. These templates are compiled before they are displayed. Occasionally, a new or modified template will fail to overwrite the old compiled version. To clear the Smarty cache, delete all the files in view/tpl/smarty3/compiled [b]but do not delete the directory itself[/b]. Templates will then be recompiled on their next access. +We use the Smarty3 template engine to generate pages. These templates are compiled before they are displayed. Occasionally, a new or modified template will fail to overwrite the old compiled version. To clear the Smarty cache, delete all the files in store/[data]/smarty3/compiled [b]but do not delete the directory itself[/b]. Templates will then be recompiled on their next access. [b]Theme Issues[/b] diff --git a/doc/red2pi.bb b/doc/red2pi.bb index c29de91e9..4ca58a382 100644 --- a/doc/red2pi.bb +++ b/doc/red2pi.bb @@ -260,8 +260,8 @@ Check if you can update the addons [code]pi@pi /var/www $ cd addon/ pi@pi /var/www/addon $ sudo git pull[/code] -Make sure folder view/tpl/smarty3 exists and is writable by the webserver -[code]pi@pi /var/www $ sudo chmod ou+w view/tpl/smarty3/[/code] +Make sure folder store/[data]/smarty3 exists and is writable by the webserver +[code]pi@pi /var/www $ sudo chmod ou+w "store/\[data\]/smarty3"[/code] Create .htconfig.php and is writable by the webserver [code]pi@pi /var/www $ sudo touch .htconfig.php diff --git a/include/friendica_smarty.php b/include/friendica_smarty.php index 12a789c9a..c2fcc4097 100755 --- a/include/friendica_smarty.php +++ b/include/friendica_smarty.php @@ -50,7 +50,7 @@ class FriendicaSmartyEngine implements ITemplateEngine { public function __construct(){ $a = get_app(); $basecompiledir = ((array_key_exists('smarty3_folder',$a->config['system'])) ? $a->config['system']['smarty3_folder'] : ''); - if (!$basecompiledir) $basecompiledir = dirname(__dir__)."/view/tpl/smarty3"; + if (!$basecompiledir) $basecompiledir = dirname(__dir__)."/store/[data]/smarty3"; if (!is_dir($basecompiledir)) { echo "ERROR: folder $basecompiledir does not exist."; killme(); } diff --git a/install/INSTALL.txt b/install/INSTALL.txt index 6080ff6c7..946e83ca3 100644 --- a/install/INSTALL.txt +++ b/install/INSTALL.txt @@ -94,13 +94,11 @@ directory/path component in the URL) is REQUIRED. git pull - - make sure folders *view/tpl/smarty3* and *store* exist and are writable by webserver + - make sure folders *store/[data]/smarty3* and *store* exist and are writable by webserver - mkdir view/tpl/smarty3 - mkdir store + mkdir -p "store/\[data\]/smarty3" - chmod 777 view/tpl/smarty3 - chmod 777 store + chmod -R 777 store [This permission (777) is very dangerous and if you have sufficient privilege and knowledge you should make this directory writeable only diff --git a/install/update.php b/install/update.php index 60e8497dc..3d4ed2cf9 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ setTemplateDir($folders); -$s->setCompileDir('view/tpl/smarty3/compiled/'); -$s->setConfigDir('view/tpl/smarty3/config/'); -$s->setCacheDir('view/tpl/smarty3/cache/'); +$s->setCompileDir(TEMPLATE_BUILD_PATH . '/compiled/'); +$s->setConfigDir(TEMPLATE_BUILD_PATH . '/config/'); +$s->setCacheDir(TEMPLATE_BUILD_PATH . '/cache/'); $s->left_delimiter = "{{"; $s->right_delimiter = "}}";