fetaure 2542 replace $conf['local_data_dir'] with $conf['data_location'] and move combined files and image derivatives from local to _data

git-svn-id: http://piwigo.org/svn/trunk@12802 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices 2011-12-29 05:48:16 +00:00
parent 5331c7f940
commit 1e1b71c6f6
14 changed files with 94 additions and 39 deletions

View file

@ -316,7 +316,7 @@ class updates
include(PHPWG_ROOT_PATH.'admin/include/mysqldump.php');
$path = $conf['local_data_dir'].'/update';
$path = PHPWG_ROOT_PATH.$conf['data_location'].'update';
if (@mkgetdir($path)
and ($backupFile = tempnam($path, 'sql'))
@ -350,7 +350,7 @@ class updates
}
@readfile($backupFile);
self::deltree($conf['local_data_dir'].'/update');
self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
exit();
}
else
@ -386,7 +386,7 @@ class updates
if (empty($page['errors']))
{
$path = $conf['local_data_dir'].'/update';
$path = PHPWG_ROOT_PATH.$conf['data_location'].'update';
$filename = $path.'/'.$code.'.zip';
@mkgetdir($path);
@ -449,7 +449,7 @@ class updates
if (empty($error))
{
self::process_obsolete_list($obsolete_list);
self::deltree($conf['local_data_dir'].'/update');
self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
invalidate_user_cache(true);
$template->delete_compiled_templates();
unset($_SESSION['need_update']);
@ -465,20 +465,19 @@ class updates
}
else
{
file_put_contents($conf['local_data_dir'].'/update/log_error.txt', $error);
$relative_path = trim(str_replace(dirname(dirname(dirname(dirname(__FILE__)))), '', $conf['local_data_dir']), '/\\');
file_put_contents(PHPWG_ROOT_PATH.$conf['data_location'].'update/log_error.txt', $error);
array_push(
$page['errors'],
sprintf(
l10n('An error has occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.'),
PHPWG_ROOT_PATH.$relative_path.'/update/log_error.txt'
get_root_url().$conf['data_location'].'update/log_error.txt'
)
);
}
}
else
{
self::deltree($conf['local_data_dir'].'/update');
self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
array_push($page['errors'], l10n('An error has occured during upgrade.'));
}
}

View file

@ -193,7 +193,7 @@ foreach($dates as $date_detail)
$rss->addItem($item);
}
$fileName= $conf['local_data_dir'].'/tmp';
$fileName= PHPWG_ROOT_PATH.$conf['data_location'].'tmp';
mkgetdir($fileName); // just in case
$fileName.='/feed.xml';
// send XML feed

2
i.php
View file

@ -26,7 +26,7 @@ include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', PWG_LOCAL_DIR.'i/');
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', $conf['data_location'].'i/');
function trigger_action() {}
function get_extension( $filename )

View file

@ -88,6 +88,8 @@ foreach( array(
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
if (!isset($conf['local_data_dir'])) $conf['local_data_dir'] = realpath(PHPWG_ROOT_PATH.$conf['data_location']); // temp 2.4 for backward compatibility
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');

View file

@ -719,9 +719,10 @@ $conf['slideshow_repeat'] = true;
// Every plugin from 1.7 would be design to manage light_slideshow case.
$conf['light_slideshow'] = true;
// the local data directory is used to store data such as compiled templates
// or other plugin variables etc
$conf['local_data_dir'] = dirname(dirname(__FILE__)).'/_data';
// the local data directory is used to store data such as compiled templates,
// plugin variables, combined css/javascript or resized images. Beware of
// mandatory trailing slash.
$conf['data_location'] = '_data/';
// where should the API/UploadForm add photos? This path must be relative to
// the Piwigo installation directory (but can be outside, as long as it's
@ -756,6 +757,5 @@ $conf['upload_form_automatic_rotation'] = true;
// 0-'auto', 1-'derivative' 2-'script'
$conf['derivative_url_style']=0;
$conf['chmod_value']=0777;
$conf['chmod_value']= substr_compare(PHP_SAPI, 'apa', 0, 3)==0 ? 0777 : 0755;
?>

View file

@ -27,8 +27,8 @@ define('PHPWG_DEFAULT_LANGUAGE', 'en_UK');
define('PHPWG_DEFAULT_TEMPLATE', 'Sylvia');
define('PHPWG_THEMES_PATH', $conf['themes_dir'].'/');
defined('PWG_COMBINED_DIR') or define('PWG_COMBINED_DIR', PWG_LOCAL_DIR.'combined/');
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', PWG_LOCAL_DIR.'i/');
defined('PWG_COMBINED_DIR') or define('PWG_COMBINED_DIR', $conf['data_location'].'combined/');
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', $conf['data_location'].'i/');
// Required versions
define('REQUIRED_PHP_VERSION', '5.0.0');

View file

@ -37,7 +37,7 @@ function pwg_db_connect($host, $user, $password, $database)
{
global $conf;
$db_file = sprintf('sqlite:%s/%s.db', $conf['local_data_dir'], $database);
$db_file = sprintf('sqlite:%s/%s.db', PHPWG_ROOT_PATH.$conf['data_location'], $database);
$link = new PDO($db_file);
if (!$link)

View file

@ -37,7 +37,7 @@ function pwg_db_connect($host, $user, $password, $database)
{
global $conf;
$db_file = sprintf('%s/%s.db', $conf['local_data_dir'], $database);
$db_file = sprintf('%s/%s.db', PHPWG_ROOT_PATH.$conf['data_location'], $database);
if (script_basename()=='install')
{

View file

@ -791,7 +791,7 @@ function move_ccs_rules_to_body($content)
function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
{
global $conf, $user, $lang_info;
$dir = $conf['local_data_dir'].'/tmp';
$dir = PHPWG_ROOT_PATH.$conf['data_location'].'tmp';
if ( mkgetdir( $dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR) )
{
$filename = $dir.'/mail.'.stripslashes($user['username']).'.'.$lang_info['code'].'.'.$args['theme'].'-'.date('YmdHis');

View file

@ -59,30 +59,32 @@ class Template {
$this->smarty->compile_check = $conf['template_compile_check'];
$this->smarty->force_compile = $conf['template_force_compile'];
if (!isset($conf['local_data_dir_checked']))
if (!isset($conf['data_dir_checked']))
{
mkgetdir($conf['local_data_dir'], MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
if (!is_writable($conf['local_data_dir']))
$dir = PHPWG_ROOT_PATH.$conf['data_location'];
mkgetdir($dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
if (!is_writable($dir))
{
load_language('admin.lang');
fatal_error(
sprintf(
l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
basename($conf['local_data_dir'])
$conf['data_location']
),
l10n('an error happened'),
false // show trace
);
}
if (function_exists('pwg_query')) {
conf_update_param('local_data_dir_checked', 'true');
conf_update_param('data_dir_checked', 1);
}
}
if (!isset($conf['combined_dir_checked']))
{
mkgetdir(PWG_COMBINED_DIR, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
if (!is_writable(PWG_COMBINED_DIR))
$dir = PHPWG_ROOT_PATH.PWG_COMBINED_DIR;
mkgetdir($dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
if (!is_writable($dir))
{
load_language('admin.lang');
fatal_error(
@ -95,12 +97,12 @@ class Template {
);
}
if (function_exists('pwg_query')) {
conf_update_param('combined_dir_checked', 'true');
conf_update_param('combined_dir_checked', 1);
}
}
$compile_dir = $conf['local_data_dir'].'/templates_c';
$compile_dir = PHPWG_ROOT_PATH.$conf['data_location'].'templates_c';
mkgetdir( $compile_dir );
$this->smarty->compile_dir = $compile_dir;
@ -1181,7 +1183,6 @@ class ScriptLoader
/*Allows merging of javascript and css files into a single one.*/
final class FileCombiner
{
const OUT_SUB_DIR = PWG_COMBINED_DIR;
private $type; // js or css
private $files = array();
private $versions = array();
@ -1193,11 +1194,11 @@ final class FileCombiner
static function clear_combined_files()
{
$dir = opendir(PHPWG_ROOT_PATH.self::OUT_SUB_DIR);
$dir = opendir(PHPWG_ROOT_PATH.PWG_COMBINED_DIR);
while ($file = readdir($dir))
{
if ( get_extension($file)=='js' || get_extension($file)=='css')
unlink(PHPWG_ROOT_PATH.self::OUT_SUB_DIR.$file);
unlink(PHPWG_ROOT_PATH.PWG_COMBINED_DIR.$file);
}
closedir($dir);
}
@ -1242,7 +1243,7 @@ final class FileCombiner
$key = join('>', $key);
$file = base_convert(crc32($key),10,36);
$file = self::OUT_SUB_DIR . $file . '.' . $this->type;
$file = PWG_COMBINED_DIR . $file . '.' . $this->type;
$exists = file_exists( PHPWG_ROOT_PATH . $file );
if ($exists)

View file

@ -110,9 +110,9 @@ include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');
// download database config file if exists
if (!empty($_GET['dl']) && file_exists($conf['local_data_dir'].'/pwg_'.$_GET['dl']))
if (!empty($_GET['dl']) && file_exists(PHPWG_ROOT_PATH.$conf['data_location'].'pwg_'.$_GET['dl']))
{
$filename = $conf['local_data_dir'].'/pwg_'.$_GET['dl'];
$filename = PHPWG_ROOT_PATH.$conf['data_location'].'pwg_'.$_GET['dl'];
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Disposition: attachment; filename="database.inc.php"');
@ -281,7 +281,7 @@ define(\'DB_COLLATE\', \'\');
if ( !($fp = @fopen( $config_file, 'w' )))
{
$tmp_filename = md5(uniqid(time()));
$fh = @fopen( $conf['local_data_dir'] . '/pwg_' . $tmp_filename, 'w' );
$fh = @fopen( PHPWG_ROOT_PATH.$conf['data_location'] . 'pwg_' . $tmp_filename, 'w' );
@fputs($fh, $file_content, strlen($file_content));
@fclose($fh);

View file

@ -0,0 +1,54 @@
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Change combined dir';
// Add column
$query = 'DELETE FROM '.CONFIG_TABLE.'
WHERE param IN (\'local_data_dir_checked\', \'combined_dir_checked\') ';
pwg_query($query);
$dir=PHPWG_ROOT_PATH.'local/combined/';
if (is_dir($dir))
{
foreach (glob($dir.'*.css') as $file)
{
@unlink($file);
}
foreach (glob($dir.'*.js') as $file)
@unlink($file);
@unlink($dir.'index.htm');
@rmdir($dir);
}
echo
"\n"
. $upgrade_description
."\n"
;
?>

View file

@ -60,7 +60,7 @@ while ($row = pwg_db_fetch_assoc($result)) {
}
// save configuration for a future use by the Community plugin
$backup_filepath = $conf['local_data_dir'].'/plugins/core_user_upload_to_community.php';
$backup_filepath = PHPWG_ROOT_PATH.$conf['data_location'].'plugins/core_user_upload_to_community.php';
$save_conf = true;
if (is_dir(dirname($backup_filepath)))
{
@ -69,7 +69,7 @@ if (is_dir(dirname($backup_filepath)))
$save_conf = false;
}
}
elseif (!is_writable($conf['local_data_dir']))
elseif (!is_writable( PHPWG_ROOT_PATH.$conf['data_location'] ))
{
$save_conf = false;
}

View file

@ -1 +0,0 @@
Not allowed!