Skip to content

Commit

Permalink
bug 860: display a more readable error when the _data directory is no…
Browse files Browse the repository at this point in the history
…t writable

git-svn-id: http://piwigo.org/svn/trunk@5985 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Apr 28, 2010
1 parent deb73a9 commit 056668c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 8 additions & 3 deletions include/functions_html.inc.php
Expand Up @@ -361,10 +361,15 @@ function page_not_found($msg, $alternate_url=null)
* this method can be called at any time (does not use template/language/user etc...)
* @param string msg a message to display
*/
function fatal_error($msg)
function fatal_error($msg, $title=null, $show_trace=true)
{
if (empty($title))
{
$title = 'Piwigo encountered a non recoverable error';
}

$btrace_msg = '';
if (function_exists('debug_backtrace'))
if ($show_trace and function_exists('debug_backtrace'))
{
$bt = debug_backtrace();
for ($i=1; $i<count($bt); $i++)
Expand All @@ -377,7 +382,7 @@ function fatal_error($msg)
}

$display = "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<h1>Piwigo encountered a non recoverable error</h1>
<h1>$title</h1>
<pre style='font-size:larger;background:white;color:red;padding:1em;margin:0;clear:both;display:block;width:auto;height:auto;overflow:auto'>
<b>$msg</b>
$btrace_msg
Expand Down
12 changes: 12 additions & 0 deletions include/template.class.php
Expand Up @@ -52,6 +52,18 @@ function Template($root = ".", $theme= "", $path = "template")
$this->smarty->compile_check = $conf['template_compile_check'];
$this->smarty->force_compile = $conf['template_force_compile'];

if (!is_writable($conf['local_data_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'])
),
l10n('an error happened'),
false // show trace
);
}
$compile_dir = $conf['local_data_dir'].'/templates_c';
mkgetdir( $compile_dir );

Expand Down

0 comments on commit 056668c

Please sign in to comment.