Skip to content

Commit 1e1b71c

Browse files
author
rvelices
committed
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
1 parent 5331c7f commit 1e1b71c

14 files changed

Lines changed: 94 additions & 39 deletions

‎admin/include/updates.class.php‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ function dump_database($include_history=false)
316316

317317
include(PHPWG_ROOT_PATH.'admin/include/mysqldump.php');
318318

319-
$path = $conf['local_data_dir'].'/update';
319+
$path = PHPWG_ROOT_PATH.$conf['data_location'].'update';
320320

321321
if (@mkgetdir($path)
322322
and ($backupFile = tempnam($path, 'sql'))
@@ -350,7 +350,7 @@ function dump_database($include_history=false)
350350
}
351351

352352
@readfile($backupFile);
353-
self::deltree($conf['local_data_dir'].'/update');
353+
self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
354354
exit();
355355
}
356356
else
@@ -386,7 +386,7 @@ function upgrade_to($upgrade_to, &$step)
386386

387387
if (empty($page['errors']))
388388
{
389-
$path = $conf['local_data_dir'].'/update';
389+
$path = PHPWG_ROOT_PATH.$conf['data_location'].'update';
390390
$filename = $path.'/'.$code.'.zip';
391391
@mkgetdir($path);
392392

@@ -449,7 +449,7 @@ function upgrade_to($upgrade_to, &$step)
449449
if (empty($error))
450450
{
451451
self::process_obsolete_list($obsolete_list);
452-
self::deltree($conf['local_data_dir'].'/update');
452+
self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
453453
invalidate_user_cache(true);
454454
$template->delete_compiled_templates();
455455
unset($_SESSION['need_update']);
@@ -465,20 +465,19 @@ function upgrade_to($upgrade_to, &$step)
465465
}
466466
else
467467
{
468-
file_put_contents($conf['local_data_dir'].'/update/log_error.txt', $error);
469-
$relative_path = trim(str_replace(dirname(dirname(dirname(dirname(__FILE__)))), '', $conf['local_data_dir']), '/\\');
468+
file_put_contents(PHPWG_ROOT_PATH.$conf['data_location'].'update/log_error.txt', $error);
470469
array_push(
471470
$page['errors'],
472471
sprintf(
473472
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>.'),
474-
PHPWG_ROOT_PATH.$relative_path.'/update/log_error.txt'
473+
get_root_url().$conf['data_location'].'update/log_error.txt'
475474
)
476475
);
477476
}
478477
}
479478
else
480479
{
481-
self::deltree($conf['local_data_dir'].'/update');
480+
self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
482481
array_push($page['errors'], l10n('An error has occured during upgrade.'));
483482
}
484483
}

‎feed.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function ts_to_iso8601($ts)
193193
$rss->addItem($item);
194194
}
195195

196-
$fileName= $conf['local_data_dir'].'/tmp';
196+
$fileName= PHPWG_ROOT_PATH.$conf['data_location'].'tmp';
197197
mkgetdir($fileName); // just in case
198198
$fileName.='/feed.xml';
199199
// send XML feed

‎i.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
2727

2828
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');
29-
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', PWG_LOCAL_DIR.'i/');
29+
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', $conf['data_location'].'i/');
3030

3131
function trigger_action() {}
3232
function get_extension( $filename )

‎include/common.inc.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ function sanitize_mysql_kv(&$v, $k)
8888

8989
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
9090
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
91+
if (!isset($conf['local_data_dir'])) $conf['local_data_dir'] = realpath(PHPWG_ROOT_PATH.$conf['data_location']); // temp 2.4 for backward compatibility
92+
9193
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');
9294

9395

‎include/config_default.inc.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,10 @@
719719
// Every plugin from 1.7 would be design to manage light_slideshow case.
720720
$conf['light_slideshow'] = true;
721721

722-
// the local data directory is used to store data such as compiled templates
723-
// or other plugin variables etc
724-
$conf['local_data_dir'] = dirname(dirname(__FILE__)).'/_data';
722+
// the local data directory is used to store data such as compiled templates,
723+
// plugin variables, combined css/javascript or resized images. Beware of
724+
// mandatory trailing slash.
725+
$conf['data_location'] = '_data/';
725726

726727
// where should the API/UploadForm add photos? This path must be relative to
727728
// the Piwigo installation directory (but can be outside, as long as it's
@@ -756,6 +757,5 @@
756757
// 0-'auto', 1-'derivative' 2-'script'
757758
$conf['derivative_url_style']=0;
758759

759-
$conf['chmod_value']=0777;
760-
760+
$conf['chmod_value']= substr_compare(PHP_SAPI, 'apa', 0, 3)==0 ? 0777 : 0755;
761761
?>

‎include/constants.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
define('PHPWG_DEFAULT_TEMPLATE', 'Sylvia');
2828

2929
define('PHPWG_THEMES_PATH', $conf['themes_dir'].'/');
30-
defined('PWG_COMBINED_DIR') or define('PWG_COMBINED_DIR', PWG_LOCAL_DIR.'combined/');
31-
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', PWG_LOCAL_DIR.'i/');
30+
defined('PWG_COMBINED_DIR') or define('PWG_COMBINED_DIR', $conf['data_location'].'combined/');
31+
defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', $conf['data_location'].'i/');
3232

3333
// Required versions
3434
define('REQUIRED_PHP_VERSION', '5.0.0');

‎include/dblayer/functions_pdo-sqlite.inc.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function pwg_db_connect($host, $user, $password, $database)
3737
{
3838
global $conf;
3939

40-
$db_file = sprintf('sqlite:%s/%s.db', $conf['local_data_dir'], $database);
40+
$db_file = sprintf('sqlite:%s/%s.db', PHPWG_ROOT_PATH.$conf['data_location'], $database);
4141

4242
$link = new PDO($db_file);
4343
if (!$link)

‎include/dblayer/functions_sqlite.inc.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function pwg_db_connect($host, $user, $password, $database)
3737
{
3838
global $conf;
3939

40-
$db_file = sprintf('%s/%s.db', $conf['local_data_dir'], $database);
40+
$db_file = sprintf('%s/%s.db', PHPWG_ROOT_PATH.$conf['data_location'], $database);
4141

4242
if (script_basename()=='install')
4343
{

‎include/functions_mail.inc.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ function move_ccs_rules_to_body($content)
791791
function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
792792
{
793793
global $conf, $user, $lang_info;
794-
$dir = $conf['local_data_dir'].'/tmp';
794+
$dir = PHPWG_ROOT_PATH.$conf['data_location'].'tmp';
795795
if ( mkgetdir( $dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR) )
796796
{
797797
$filename = $dir.'/mail.'.stripslashes($user['username']).'.'.$lang_info['code'].'.'.$args['theme'].'-'.date('YmdHis');

‎include/template.class.php‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,32 @@ function Template($root = ".", $theme= "", $path = "template")
5959
$this->smarty->compile_check = $conf['template_compile_check'];
6060
$this->smarty->force_compile = $conf['template_force_compile'];
6161

62-
if (!isset($conf['local_data_dir_checked']))
62+
if (!isset($conf['data_dir_checked']))
6363
{
64-
mkgetdir($conf['local_data_dir'], MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
65-
if (!is_writable($conf['local_data_dir']))
64+
$dir = PHPWG_ROOT_PATH.$conf['data_location'];
65+
mkgetdir($dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
66+
if (!is_writable($dir))
6667
{
6768
load_language('admin.lang');
6869
fatal_error(
6970
sprintf(
7071
l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
71-
basename($conf['local_data_dir'])
72+
$conf['data_location']
7273
),
7374
l10n('an error happened'),
7475
false // show trace
7576
);
7677
}
7778
if (function_exists('pwg_query')) {
78-
conf_update_param('local_data_dir_checked', 'true');
79+
conf_update_param('data_dir_checked', 1);
7980
}
8081
}
8182

8283
if (!isset($conf['combined_dir_checked']))
8384
{
84-
mkgetdir(PWG_COMBINED_DIR, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
85-
if (!is_writable(PWG_COMBINED_DIR))
85+
$dir = PHPWG_ROOT_PATH.PWG_COMBINED_DIR;
86+
mkgetdir($dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
87+
if (!is_writable($dir))
8688
{
8789
load_language('admin.lang');
8890
fatal_error(
@@ -95,12 +97,12 @@ function Template($root = ".", $theme= "", $path = "template")
9597
);
9698
}
9799
if (function_exists('pwg_query')) {
98-
conf_update_param('combined_dir_checked', 'true');
100+
conf_update_param('combined_dir_checked', 1);
99101
}
100102
}
101103

102104

103-
$compile_dir = $conf['local_data_dir'].'/templates_c';
105+
$compile_dir = PHPWG_ROOT_PATH.$conf['data_location'].'templates_c';
104106
mkgetdir( $compile_dir );
105107

106108
$this->smarty->compile_dir = $compile_dir;
@@ -1181,7 +1183,6 @@ private static function cmp_by_mode_and_order($s1, $s2)
11811183
/*Allows merging of javascript and css files into a single one.*/
11821184
final class FileCombiner
11831185
{
1184-
const OUT_SUB_DIR = PWG_COMBINED_DIR;
11851186
private $type; // js or css
11861187
private $files = array();
11871188
private $versions = array();
@@ -1193,11 +1194,11 @@ function FileCombiner($type)
11931194

11941195
static function clear_combined_files()
11951196
{
1196-
$dir = opendir(PHPWG_ROOT_PATH.self::OUT_SUB_DIR);
1197+
$dir = opendir(PHPWG_ROOT_PATH.PWG_COMBINED_DIR);
11971198
while ($file = readdir($dir))
11981199
{
11991200
if ( get_extension($file)=='js' || get_extension($file)=='css')
1200-
unlink(PHPWG_ROOT_PATH.self::OUT_SUB_DIR.$file);
1201+
unlink(PHPWG_ROOT_PATH.PWG_COMBINED_DIR.$file);
12011202
}
12021203
closedir($dir);
12031204
}
@@ -1242,7 +1243,7 @@ function combine(&$out_file, &$out_version)
12421243
$key = join('>', $key);
12431244

12441245
$file = base_convert(crc32($key),10,36);
1245-
$file = self::OUT_SUB_DIR . $file . '.' . $this->type;
1246+
$file = PWG_COMBINED_DIR . $file . '.' . $this->type;
12461247

12471248
$exists = file_exists( PHPWG_ROOT_PATH . $file );
12481249
if ($exists)

0 commit comments

Comments
 (0)