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.

This commit is contained in:
friendica 2014-07-10 21:34:52 -07:00
parent f2c54cfcaf
commit c74fd78993
11 changed files with 37 additions and 32 deletions

View File

@ -47,11 +47,12 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 ); define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1116 ); define ( 'DB_UPDATE_VERSION', 1117 );
define ( 'EOL', '<br />' . "\r\n" ); define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); 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_NORMAL', 0x0000); // This is technically DIRECTORY_MODE_TERTIARY, but it's the default, hence 0x0000
define ( 'DIRECTORY_MODE_PRIMARY', 0x0001); define ( 'DIRECTORY_MODE_PRIMARY', 0x0001);
@ -1062,8 +1063,8 @@ class App {
/*if ($engine) { /*if ($engine) {
case 'smarty3': case 'smarty3':
if(!is_writable('view/tpl/smarty3/')) if(!is_writable(TEMPLATE_BUILD_PATH))
echo "<b>ERROR</b> folder <tt>view/tpl/smarty3/</tt> must be writable by webserver."; killme(); echo "<b>ERROR</b> folder <tt>" . TEMPLATE_BUILD_PATH . "</tt> must be writable by webserver."; killme();
break; break;
default: default:
@ -1256,10 +1257,11 @@ function check_config(&$a) {
$func = 'update_r' . $x; $func = 'update_r' . $x;
$retval = $func(); $retval = $func();
if($retval) { if($retval) {
// Prevent sending hundreds of thousands of emails by creating // Prevent sending hundreds of thousands of emails by creating
// a lockfile. view/tpl/smarty3 is the only place we can // a lockfile.
// guarantee the server can write to.
$lockfile = 'view/tpl/smarty3/mailsent'; $lockfile = 'store/[data]/mailsent';
if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400)))
return; return;

View File

@ -49,11 +49,11 @@ you might have trouble getting everything to work.]
`git pull` `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 - For installing addons

View File

@ -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] [*][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. b) You're using Midori, or with certain themes, Konqueror in KHTML mode.

View File

@ -41,11 +41,11 @@ you might have trouble getting everything to work.]
`git pull` `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 - For installing addons

View File

@ -24,7 +24,7 @@ Symptoms:
2) Missing icons, tabs, menus or features. 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] [b]Theme Issues[/b]

View File

@ -260,8 +260,8 @@ Check if you can update the addons
[code]pi@pi /var/www $ cd addon/ [code]pi@pi /var/www $ cd addon/
pi@pi /var/www/addon $ sudo git pull[/code] pi@pi /var/www/addon $ sudo git pull[/code]
Make sure folder view/tpl/smarty3 exists and is writable by the webserver Make sure folder store/[data]/smarty3 exists and is writable by the webserver
[code]pi@pi /var/www $ sudo chmod ou+w view/tpl/smarty3/[/code] [code]pi@pi /var/www $ sudo chmod ou+w "store/\[data\]/smarty3"[/code]
Create .htconfig.php and is writable by the webserver Create .htconfig.php and is writable by the webserver
[code]pi@pi /var/www $ sudo touch .htconfig.php [code]pi@pi /var/www $ sudo touch .htconfig.php

View File

@ -50,7 +50,7 @@ class FriendicaSmartyEngine implements ITemplateEngine {
public function __construct(){ public function __construct(){
$a = get_app(); $a = get_app();
$basecompiledir = ((array_key_exists('smarty3_folder',$a->config['system'])) ? $a->config['system']['smarty3_folder'] : ''); $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)) { if (!is_dir($basecompiledir)) {
echo "<b>ERROR:</b> folder <tt>$basecompiledir</tt> does not exist."; killme(); echo "<b>ERROR:</b> folder <tt>$basecompiledir</tt> does not exist."; killme();
} }

View File

@ -94,13 +94,11 @@ directory/path component in the URL) is REQUIRED.
git pull 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 -p "store/\[data\]/smarty3"
mkdir store
chmod 777 view/tpl/smarty3 chmod -R 777 store
chmod 777 store
[This permission (777) is very dangerous and if you have sufficient [This permission (777) is very dangerous and if you have sufficient
privilege and knowledge you should make this directory writeable only privilege and knowledge you should make this directory writeable only

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1116 ); define( 'UPDATE_VERSION' , 1117 );
/** /**
* *
@ -995,7 +995,7 @@ ADD INDEX ( `menu_flags` )");
} }
function update_r1091() { function update_r1091() {
@mkdir('store/[data]/smarty',STORAGE_DEFAULT_PERMISSIONS,true); @mkdir('store/[data]/smarty3',STORAGE_DEFAULT_PERMISSIONS,true);
@file_put_contents('store/[data]/locks',''); @file_put_contents('store/[data]/locks','');
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
} }
@ -1299,3 +1299,8 @@ function update_r1115() {
$r = q("update account set account_flags = (account_flags ^ 1) where (account_flags & 1) "); $r = q("update account set account_flags = (account_flags ^ 1) where (account_flags & 1) ");
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
} }
function update_r1116() {
@mkdir('store/[data]/smarty3',STORAGE_DEFAULT_PERMISSIONS,true);
return UPDATE_SUCCESS;
}

View File

@ -510,16 +510,16 @@ function check_htconfig(&$checks) {
function check_smarty3(&$checks) { function check_smarty3(&$checks) {
$status = true; $status = true;
$help = ""; $help = "";
if( !is_writable('view/tpl/smarty3') ) { if( !is_writable(TEMPLATE_BUILD_PATH) ) {
$status=false; $status=false;
$help = t('Red uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL; $help = t('Red uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL;
$help .= t('In order to store these compiled templates, the web server needs to have write access to the directory view/tpl/smarty3/ under the Red top level folder.').EOL; $help .= sprintf( t('In order to store these compiled templates, the web server needs to have write access to the directory %s under the Red top level folder.'), TEMPLATE_BUILD_PATH) . EOL;
$help .= t('Please ensure that the user that your web server runs as (e.g. www-data) has write access to this folder.').EOL; $help .= t('Please ensure that the user that your web server runs as (e.g. www-data) has write access to this folder.').EOL;
$help .= t('Note: as a security measure, you should give the web server write access to view/tpl/smarty3/ only--not the template files (.tpl) that it contains.').EOL; $help .= sprintf( t('Note: as a security measure, you should give the web server write access to %s only--not the template files (.tpl) that it contains.'), TEMPLATE_BUILD_PATH) . EOL;
} }
check_add($checks, t('view/tpl/smarty3 is writable'), $status, true, $help); check_add($checks, sprintf( t('%s is writable'), TEMPLATE_BUILD_PATH), $status, true, $help);
} }

View File

@ -17,9 +17,9 @@ $s = new Smarty();
$s->setTemplateDir($folders); $s->setTemplateDir($folders);
$s->setCompileDir('view/tpl/smarty3/compiled/'); $s->setCompileDir(TEMPLATE_BUILD_PATH . '/compiled/');
$s->setConfigDir('view/tpl/smarty3/config/'); $s->setConfigDir(TEMPLATE_BUILD_PATH . '/config/');
$s->setCacheDir('view/tpl/smarty3/cache/'); $s->setCacheDir(TEMPLATE_BUILD_PATH . '/cache/');
$s->left_delimiter = "{{"; $s->left_delimiter = "{{";
$s->right_delimiter = "}}"; $s->right_delimiter = "}}";