diff options
-rw-r--r-- | admin/include/updates.class.php | 15 | ||||
-rw-r--r-- | feed.php | 2 | ||||
-rw-r--r-- | i.php | 2 | ||||
-rw-r--r-- | include/common.inc.php | 2 | ||||
-rw-r--r-- | include/config_default.inc.php | 10 | ||||
-rw-r--r-- | include/constants.php | 4 | ||||
-rw-r--r-- | include/dblayer/functions_pdo-sqlite.inc.php | 2 | ||||
-rw-r--r-- | include/dblayer/functions_sqlite.inc.php | 2 | ||||
-rw-r--r-- | include/functions_mail.inc.php | 2 | ||||
-rw-r--r-- | include/template.class.php | 27 | ||||
-rw-r--r-- | install.php | 6 | ||||
-rw-r--r-- | install/db/112-database.php | 54 | ||||
-rw-r--r-- | install/db/94-database.php | 4 | ||||
-rw-r--r-- | local/combined/index.htm | 1 |
14 files changed, 94 insertions, 39 deletions
diff --git a/admin/include/updates.class.php b/admin/include/updates.class.php index 71ce1ca5a..0e3831d52 100644 --- a/admin/include/updates.class.php +++ b/admin/include/updates.class.php @@ -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.'));
}
}
@@ -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 @@ -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 ) diff --git a/include/common.inc.php b/include/common.inc.php index 5cc3317e7..093aca08a 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -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/'); diff --git a/include/config_default.inc.php b/include/config_default.inc.php index e01f3a7c8..c1329b96f 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -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; ?>
\ No newline at end of file diff --git a/include/constants.php b/include/constants.php index f77bd739e..d116d652c 100644 --- a/include/constants.php +++ b/include/constants.php @@ -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'); diff --git a/include/dblayer/functions_pdo-sqlite.inc.php b/include/dblayer/functions_pdo-sqlite.inc.php index a5b4af600..12348fd5c 100644 --- a/include/dblayer/functions_pdo-sqlite.inc.php +++ b/include/dblayer/functions_pdo-sqlite.inc.php @@ -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) diff --git a/include/dblayer/functions_sqlite.inc.php b/include/dblayer/functions_sqlite.inc.php index b260e7ada..c93923a3e 100644 --- a/include/dblayer/functions_sqlite.inc.php +++ b/include/dblayer/functions_sqlite.inc.php @@ -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') { diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php index 76567ce40..383fab61e 100644 --- a/include/functions_mail.inc.php +++ b/include/functions_mail.inc.php @@ -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'); diff --git a/include/template.class.php b/include/template.class.php index 3542d8b58..a7a7d9124 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -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) diff --git a/install.php b/install.php index 1ba8ab5ca..17c1c578f 100644 --- a/install.php +++ b/install.php @@ -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); diff --git a/install/db/112-database.php b/install/db/112-database.php new file mode 100644 index 000000000..9034981c2 --- /dev/null +++ b/install/db/112-database.php @@ -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" +; +?>
\ No newline at end of file diff --git a/install/db/94-database.php b/install/db/94-database.php index 1121e22f4..854b9d4d9 100644 --- a/install/db/94-database.php +++ b/install/db/94-database.php @@ -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; } diff --git a/local/combined/index.htm b/local/combined/index.htm deleted file mode 100644 index f76458b31..000000000 --- a/local/combined/index.htm +++ /dev/null @@ -1 +0,0 @@ -Not allowed!
\ No newline at end of file |