2004-08-06 11:35:07 +02:00
|
|
|
<?php
|
|
|
|
// +-----------------------------------------------------------------------+
|
2011-01-18 01:02:52 +01:00
|
|
|
// | Piwigo - a PHP based photo gallery |
|
2008-04-05 00:57:23 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
2011-01-18 01:02:52 +01:00
|
|
|
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
|
2008-04-05 00:57:23 +02:00
|
|
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
|
|
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-08-06 11:35:07 +02:00
|
|
|
// | 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. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2004-10-23 11:00:26 +02:00
|
|
|
/**
|
|
|
|
* returns the list of categories as a HTML string
|
|
|
|
*
|
|
|
|
* categories string returned contains categories as given in the input
|
2007-02-28 04:07:12 +01:00
|
|
|
* array $cat_informations. $cat_informations array must be an array
|
|
|
|
* of array( id=>?, name=>?, permalink=>?). If url input parameter is null,
|
2004-10-23 11:00:26 +02:00
|
|
|
* returns only the categories name without links.
|
|
|
|
*
|
|
|
|
* @param array cat_informations
|
|
|
|
* @param string url
|
|
|
|
* @param boolean replace_space
|
|
|
|
* @return string
|
|
|
|
*/
|
2004-10-21 23:17:46 +02:00
|
|
|
function get_cat_display_name($cat_informations,
|
2006-03-22 02:01:47 +01:00
|
|
|
$url = '',
|
2004-10-21 23:17:46 +02:00
|
|
|
$replace_space = true)
|
2004-08-06 11:35:07 +02:00
|
|
|
{
|
2004-12-12 22:06:39 +01:00
|
|
|
global $conf;
|
2006-03-21 02:27:21 +01:00
|
|
|
|
2010-04-18 11:11:10 +02:00
|
|
|
//$output = '<a href="'.get_absolute_root_url().$conf['home_page'].'">'.l10n('Home').'</a>';
|
|
|
|
$output = '';
|
2010-04-20 09:05:58 +02:00
|
|
|
$is_first=true;
|
2010-12-23 06:22:19 +01:00
|
|
|
|
2007-02-28 04:07:12 +01:00
|
|
|
foreach ($cat_informations as $cat)
|
2004-08-06 11:35:07 +02:00
|
|
|
{
|
2007-02-27 02:56:16 +01:00
|
|
|
is_array($cat) or trigger_error(
|
2007-02-28 04:07:12 +01:00
|
|
|
'get_cat_display_name wrong type for category ', E_USER_WARNING
|
2007-02-27 02:56:16 +01:00
|
|
|
);
|
2008-07-12 16:57:24 +02:00
|
|
|
|
|
|
|
$cat['name'] = trigger_event(
|
|
|
|
'render_category_name',
|
|
|
|
$cat['name'],
|
|
|
|
'get_cat_display_name'
|
|
|
|
);
|
2010-04-20 09:05:58 +02:00
|
|
|
|
|
|
|
if ($is_first)
|
|
|
|
{
|
|
|
|
$is_first=false;
|
|
|
|
}
|
|
|
|
else
|
2010-04-18 11:11:10 +02:00
|
|
|
{
|
|
|
|
$output.= $conf['level_separator'];
|
|
|
|
}
|
2004-10-21 23:17:46 +02:00
|
|
|
|
2006-03-22 02:01:47 +01:00
|
|
|
if ( !isset($url) )
|
2004-10-21 23:17:46 +02:00
|
|
|
{
|
2007-02-27 02:56:16 +01:00
|
|
|
$output.= $cat['name'];
|
2004-10-21 23:17:46 +02:00
|
|
|
}
|
2006-03-22 02:01:47 +01:00
|
|
|
elseif ($url == '')
|
|
|
|
{
|
2007-02-08 02:31:05 +01:00
|
|
|
$output.= '<a href="'
|
2007-01-23 23:03:06 +01:00
|
|
|
.make_index_url(
|
2006-04-06 04:23:54 +02:00
|
|
|
array(
|
2007-02-27 02:56:16 +01:00
|
|
|
'category' => $cat,
|
2007-01-23 23:03:06 +01:00
|
|
|
)
|
2006-04-06 04:23:54 +02:00
|
|
|
)
|
|
|
|
.'">';
|
2007-02-27 02:56:16 +01:00
|
|
|
$output.= $cat['name'].'</a>';
|
2006-03-22 02:01:47 +01:00
|
|
|
}
|
2004-10-21 23:17:46 +02:00
|
|
|
else
|
|
|
|
{
|
2007-02-28 04:07:12 +01:00
|
|
|
$output.= '<a href="'.PHPWG_ROOT_PATH.$url.$cat['id'].'">';
|
2007-02-27 02:56:16 +01:00
|
|
|
$output.= $cat['name'].'</a>';
|
2004-10-21 23:17:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($replace_space)
|
|
|
|
{
|
|
|
|
return replace_space($output);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $output;
|
2004-08-06 11:35:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-20 18:23:42 +01:00
|
|
|
/**
|
|
|
|
* returns the list of categories as a HTML string, with cache of names
|
|
|
|
*
|
|
|
|
* categories string returned contains categories as given in the input
|
|
|
|
* array $cat_informations. $uppercats is the list of category ids to
|
|
|
|
* display in the right order. If url input parameter is empty, returns only
|
|
|
|
* the categories name without links.
|
|
|
|
*
|
|
|
|
* @param string uppercats
|
|
|
|
* @param string url
|
|
|
|
* @param boolean replace_space
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function get_cat_display_name_cache($uppercats,
|
2006-03-22 02:01:47 +01:00
|
|
|
$url = '',
|
2011-02-24 14:49:48 +01:00
|
|
|
$replace_space = true,
|
|
|
|
$single_link = false,
|
|
|
|
$link_class = null)
|
2004-11-20 18:23:42 +01:00
|
|
|
{
|
2007-02-27 02:56:16 +01:00
|
|
|
global $cache, $conf;
|
2004-11-20 18:23:42 +01:00
|
|
|
|
2007-02-27 02:56:16 +01:00
|
|
|
if (!isset($cache['cat_names']))
|
2004-11-20 18:23:42 +01:00
|
|
|
{
|
|
|
|
$query = '
|
2007-02-28 04:07:12 +01:00
|
|
|
SELECT id, name, permalink
|
2004-11-20 18:23:42 +01:00
|
|
|
FROM '.CATEGORIES_TABLE.'
|
|
|
|
;';
|
2007-02-28 04:07:12 +01:00
|
|
|
$cache['cat_names'] = hash_from_query($query, 'id');
|
2004-11-20 18:23:42 +01:00
|
|
|
}
|
2006-03-21 02:27:21 +01:00
|
|
|
|
2004-11-20 18:23:42 +01:00
|
|
|
$output = '';
|
2011-02-24 14:49:48 +01:00
|
|
|
if ($single_link)
|
|
|
|
{
|
|
|
|
$single_url = get_root_url().$url.array_pop(explode(',', $uppercats));
|
|
|
|
$output.= '<a href="'.$single_url.'"';
|
|
|
|
if (isset($link_class))
|
|
|
|
{
|
|
|
|
$output.= ' class="'.$link_class.'"';
|
|
|
|
}
|
|
|
|
$output.= '>';
|
|
|
|
}
|
2004-11-20 18:23:42 +01:00
|
|
|
$is_first = true;
|
|
|
|
foreach (explode(',', $uppercats) as $category_id)
|
|
|
|
{
|
2007-02-27 02:56:16 +01:00
|
|
|
$cat = $cache['cat_names'][$category_id];
|
2006-03-21 02:27:21 +01:00
|
|
|
|
2008-07-12 16:57:24 +02:00
|
|
|
$cat['name'] = trigger_event(
|
|
|
|
'render_category_name',
|
|
|
|
$cat['name'],
|
|
|
|
'get_cat_display_name_cache'
|
|
|
|
);
|
|
|
|
|
2004-11-20 18:23:42 +01:00
|
|
|
if ($is_first)
|
|
|
|
{
|
|
|
|
$is_first = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-12 22:06:39 +01:00
|
|
|
$output.= $conf['level_separator'];
|
2004-11-20 18:23:42 +01:00
|
|
|
}
|
|
|
|
|
2011-02-24 14:49:48 +01:00
|
|
|
if ( !isset($url) or $single_link )
|
2004-11-20 18:23:42 +01:00
|
|
|
{
|
2007-02-27 02:56:16 +01:00
|
|
|
$output.= $cat['name'];
|
2004-11-20 18:23:42 +01:00
|
|
|
}
|
2006-03-22 02:01:47 +01:00
|
|
|
elseif ($url == '')
|
|
|
|
{
|
|
|
|
$output.= '
|
2007-02-08 02:31:05 +01:00
|
|
|
<a href="'
|
2006-04-06 04:23:54 +02:00
|
|
|
.make_index_url(
|
|
|
|
array(
|
2007-02-27 02:56:16 +01:00
|
|
|
'category' => $cat,
|
2006-04-06 04:23:54 +02:00
|
|
|
)
|
|
|
|
)
|
2007-02-27 02:56:16 +01:00
|
|
|
.'">'.$cat['name'].'</a>';
|
2006-03-22 02:01:47 +01:00
|
|
|
}
|
2004-11-20 18:23:42 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$output.= '
|
2007-02-27 02:56:16 +01:00
|
|
|
<a href="'.PHPWG_ROOT_PATH.$url.$category_id.'">'.$cat['name'].'</a>';
|
2004-11-20 18:23:42 +01:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 14:49:48 +01:00
|
|
|
|
|
|
|
if ($single_link and isset($single_url))
|
|
|
|
{
|
|
|
|
$output.= '</a>';
|
|
|
|
}
|
|
|
|
|
2004-11-20 18:23:42 +01:00
|
|
|
if ($replace_space)
|
|
|
|
{
|
|
|
|
return replace_space($output);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
/**
|
|
|
|
* returns HTMLized comment contents retrieved from database
|
|
|
|
*
|
|
|
|
* newlines becomes br tags, _word_ becomes underline, /word/ becomes
|
|
|
|
* italic, *word* becomes bolded
|
|
|
|
*
|
|
|
|
* @param string content
|
|
|
|
* @return string
|
|
|
|
*/
|
2010-12-23 06:22:19 +01:00
|
|
|
function render_comment_content($content)
|
2004-10-23 19:56:46 +02:00
|
|
|
{
|
2010-12-23 06:22:19 +01:00
|
|
|
$content = htmlspecialchars($content);
|
2006-02-10 03:10:41 +01:00
|
|
|
$pattern = '/(https?:\/\/\S*)/';
|
|
|
|
$replacement = '<a href="$1" rel="nofollow">$1</a>';
|
2006-02-09 21:38:07 +01:00
|
|
|
$content = preg_replace($pattern, $replacement, $content);
|
2006-02-10 03:10:41 +01:00
|
|
|
|
|
|
|
$content = nl2br($content);
|
2006-03-21 02:27:21 +01:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
// replace _word_ by an underlined word
|
2006-02-09 21:38:07 +01:00
|
|
|
$pattern = '/\b_(\S*)_\b/';
|
|
|
|
$replacement = '<span style="text-decoration:underline;">$1</span>';
|
2004-10-23 19:56:46 +02:00
|
|
|
$content = preg_replace($pattern, $replacement, $content);
|
2006-03-21 02:27:21 +01:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
// replace *word* by a bolded word
|
2006-02-09 21:38:07 +01:00
|
|
|
$pattern = '/\b\*(\S*)\*\b/';
|
|
|
|
$replacement = '<span style="font-weight:bold;">$1</span>';
|
2004-10-23 19:56:46 +02:00
|
|
|
$content = preg_replace($pattern, $replacement, $content);
|
2006-03-21 02:27:21 +01:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
// replace /word/ by an italic word
|
2006-02-10 03:10:41 +01:00
|
|
|
$pattern = "/\/(\S*)\/(\s)/";
|
|
|
|
$replacement = '<span style="font-style:italic;">$1$2</span>';
|
|
|
|
$content = preg_replace($pattern, $replacement, $content);
|
2004-10-23 19:56:46 +02:00
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
2005-08-17 16:25:38 +02:00
|
|
|
|
|
|
|
function get_cat_display_name_from_id($cat_id,
|
2006-03-22 02:01:47 +01:00
|
|
|
$url = '',
|
2005-08-17 16:25:38 +02:00
|
|
|
$replace_space = true)
|
|
|
|
{
|
|
|
|
$cat_info = get_cat_info($cat_id);
|
2007-02-27 02:56:16 +01:00
|
|
|
return get_cat_display_name($cat_info['upper_names'], $url, $replace_space);
|
2005-08-17 16:25:38 +02:00
|
|
|
}
|
2006-03-30 02:37:07 +02:00
|
|
|
|
2006-04-03 00:26:19 +02:00
|
|
|
/**
|
|
|
|
* Returns an HTML list of tags. It can be a multi select field or a list of
|
|
|
|
* checkboxes.
|
|
|
|
*
|
|
|
|
* @param string HTML field name
|
|
|
|
* @param array selected tag ids
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function get_html_tag_selection(
|
|
|
|
$tags,
|
|
|
|
$fieldname,
|
|
|
|
$selecteds = array(),
|
|
|
|
$forbidden_categories = null
|
|
|
|
)
|
|
|
|
{
|
|
|
|
global $conf;
|
2006-04-06 04:23:54 +02:00
|
|
|
|
2006-04-19 00:57:05 +02:00
|
|
|
if (count ($tags) == 0 )
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
2006-04-03 00:26:19 +02:00
|
|
|
$output = '<ul class="tagSelection">';
|
|
|
|
foreach ($tags as $tag)
|
|
|
|
{
|
|
|
|
$output.=
|
|
|
|
'<li>'
|
|
|
|
.'<label>'
|
|
|
|
.'<input type="checkbox" name="'.$fieldname.'[]"'
|
2007-02-14 02:37:38 +01:00
|
|
|
.' value="'.$tag['id'].'"'
|
2006-04-03 00:26:19 +02:00
|
|
|
;
|
|
|
|
|
2007-02-14 02:37:38 +01:00
|
|
|
if (in_array($tag['id'], $selecteds))
|
2006-04-03 00:26:19 +02:00
|
|
|
{
|
|
|
|
$output.= ' checked="checked"';
|
|
|
|
}
|
2006-04-06 04:23:54 +02:00
|
|
|
|
2006-04-03 00:26:19 +02:00
|
|
|
$output.=
|
2009-03-09 20:41:45 +01:00
|
|
|
'>'
|
2011-01-17 21:49:14 +01:00
|
|
|
.$tag['name']
|
2006-04-03 00:26:19 +02:00
|
|
|
.'</label>'
|
|
|
|
.'</li>'
|
|
|
|
."\n"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
$output.= '</ul>';
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
function name_compare($a, $b)
|
|
|
|
{
|
2006-05-15 23:22:43 +02:00
|
|
|
return strcmp(strtolower($a['name']), strtolower($b['name']));
|
2006-04-03 00:26:19 +02:00
|
|
|
}
|
|
|
|
|
2008-07-01 04:09:21 +02:00
|
|
|
function tag_alpha_compare($a, $b)
|
|
|
|
{
|
|
|
|
return strcmp(strtolower($a['url_name']), strtolower($b['url_name']));
|
|
|
|
}
|
|
|
|
|
2006-03-30 02:37:07 +02:00
|
|
|
/**
|
|
|
|
* exits the current script (either exit or redirect)
|
|
|
|
*/
|
|
|
|
function access_denied()
|
|
|
|
{
|
2008-03-08 02:38:37 +01:00
|
|
|
global $user;
|
2006-03-30 02:37:07 +02:00
|
|
|
|
|
|
|
$login_url =
|
|
|
|
get_root_url().'identification.php?redirect='
|
|
|
|
.urlencode(urlencode($_SERVER['REQUEST_URI']));
|
|
|
|
|
2008-09-17 03:48:31 +02:00
|
|
|
set_status_header(401);
|
2007-06-06 00:01:15 +02:00
|
|
|
if ( isset($user) and !is_a_guest() )
|
2006-03-30 02:37:07 +02:00
|
|
|
{
|
2008-11-19 16:44:04 +01:00
|
|
|
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
|
2010-03-02 15:54:22 +01:00
|
|
|
echo '<div style="text-align:center;">'.l10n('You are not authorized to access the requested page').'<br>';
|
2010-05-24 01:44:45 +02:00
|
|
|
echo '<a href="'.get_root_url().'identification.php">'.l10n('Identification').'</a> ';
|
2010-03-02 15:54:22 +01:00
|
|
|
echo '<a href="'.make_index_url().'">'.l10n('Home').'</a></div>';
|
2008-09-17 03:48:31 +02:00
|
|
|
echo str_repeat( ' ', 512); //IE6 doesn't error output if below a size
|
2006-03-30 02:37:07 +02:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-12-11 07:04:53 +01:00
|
|
|
redirect_html($login_url);
|
2006-03-30 02:37:07 +02:00
|
|
|
}
|
|
|
|
}
|
2006-04-28 07:12:25 +02:00
|
|
|
|
2006-12-13 02:05:38 +01:00
|
|
|
/**
|
|
|
|
* exits the current script with 403 code
|
|
|
|
* @param string msg a message to display
|
|
|
|
* @param string alternate_url redirect to this url
|
|
|
|
*/
|
|
|
|
function page_forbidden($msg, $alternate_url=null)
|
|
|
|
{
|
|
|
|
set_status_header(403);
|
|
|
|
if ($alternate_url==null)
|
|
|
|
$alternate_url = make_index_url();
|
|
|
|
redirect_html( $alternate_url,
|
|
|
|
'<div style="text-align:left; margin-left:5em;margin-bottom:5em;">
|
2009-03-09 20:41:45 +01:00
|
|
|
<h1 style="text-align:left; font-size:36px;">Forbidden</h1><br>'
|
2006-12-13 02:05:38 +01:00
|
|
|
.$msg.'</div>',
|
|
|
|
5 );
|
|
|
|
}
|
|
|
|
|
2007-02-23 14:18:34 +01:00
|
|
|
/**
|
|
|
|
* exits the current script with 400 code
|
|
|
|
* @param string msg a message to display
|
|
|
|
* @param string alternate_url redirect to this url
|
|
|
|
*/
|
|
|
|
function bad_request($msg, $alternate_url=null)
|
|
|
|
{
|
|
|
|
set_status_header(400);
|
|
|
|
if ($alternate_url==null)
|
|
|
|
$alternate_url = make_index_url();
|
|
|
|
redirect_html( $alternate_url,
|
|
|
|
'<div style="text-align:left; margin-left:5em;margin-bottom:5em;">
|
2009-03-09 20:41:45 +01:00
|
|
|
<h1 style="text-align:left; font-size:36px;">Bad request</h1><br>'
|
2007-02-23 14:18:34 +01:00
|
|
|
.$msg.'</div>',
|
|
|
|
5 );
|
|
|
|
}
|
|
|
|
|
2006-04-28 07:12:25 +02:00
|
|
|
/**
|
|
|
|
* exits the current script with 404 code when a page cannot be found
|
|
|
|
* @param string msg a message to display
|
|
|
|
* @param string alternate_url redirect to this url
|
|
|
|
*/
|
|
|
|
function page_not_found($msg, $alternate_url=null)
|
|
|
|
{
|
2006-12-08 01:12:44 +01:00
|
|
|
set_status_header(404);
|
2006-04-28 07:12:25 +02:00
|
|
|
if ($alternate_url==null)
|
|
|
|
$alternate_url = make_index_url();
|
2006-12-11 07:04:53 +01:00
|
|
|
redirect_html( $alternate_url,
|
2006-04-28 07:12:25 +02:00
|
|
|
'<div style="text-align:left; margin-left:5em;margin-bottom:5em;">
|
2009-03-09 20:41:45 +01:00
|
|
|
<h1 style="text-align:left; font-size:36px;">Page not found</h1><br>'
|
2006-04-28 07:12:25 +02:00
|
|
|
.$msg.'</div>',
|
|
|
|
5 );
|
|
|
|
}
|
2006-11-14 03:53:24 +01:00
|
|
|
|
2008-09-05 03:24:01 +02:00
|
|
|
/**
|
|
|
|
* exits the current script with 500 http code
|
|
|
|
* this method can be called at any time (does not use template/language/user etc...)
|
|
|
|
* @param string msg a message to display
|
|
|
|
*/
|
2010-04-28 18:11:07 +02:00
|
|
|
function fatal_error($msg, $title=null, $show_trace=true)
|
2008-09-05 03:24:01 +02:00
|
|
|
{
|
2010-04-28 18:11:07 +02:00
|
|
|
if (empty($title))
|
|
|
|
{
|
|
|
|
$title = 'Piwigo encountered a non recoverable error';
|
|
|
|
}
|
2010-12-23 06:22:19 +01:00
|
|
|
|
2008-09-05 03:24:01 +02:00
|
|
|
$btrace_msg = '';
|
2010-04-28 18:11:07 +02:00
|
|
|
if ($show_trace and function_exists('debug_backtrace'))
|
2008-09-05 03:24:01 +02:00
|
|
|
{
|
|
|
|
$bt = debug_backtrace();
|
|
|
|
for ($i=1; $i<count($bt); $i++)
|
|
|
|
{
|
|
|
|
$class = isset($bt[$i]['class']) ? (@$bt[$i]['class'].'::') : '';
|
|
|
|
$btrace_msg .= "#$i\t".$class.@$bt[$i]['function'].' '.@$bt[$i]['file']."(".@$bt[$i]['line'].")\n";
|
|
|
|
}
|
|
|
|
$btrace_msg = trim($btrace_msg);
|
|
|
|
$msg .= "\n";
|
|
|
|
}
|
|
|
|
|
2008-10-15 19:50:12 +02:00
|
|
|
$display = "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
2010-04-28 18:11:07 +02:00
|
|
|
<h1>$title</h1>
|
2008-09-05 03:24:01 +02:00
|
|
|
<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
|
|
|
|
</pre>\n";
|
|
|
|
|
|
|
|
@set_status_header(500);
|
2008-09-17 03:48:31 +02:00
|
|
|
echo $display.str_repeat( ' ', 300); //IE6 doesn't error output if below a size
|
2008-09-05 03:24:01 +02:00
|
|
|
|
|
|
|
if ( function_exists('ini_set') )
|
|
|
|
{// if possible turn off error display (we display it)
|
|
|
|
ini_set('display_errors', false);
|
|
|
|
}
|
|
|
|
error_reporting( E_ALL );
|
|
|
|
trigger_error( strip_tags($msg).$btrace_msg, E_USER_ERROR );
|
|
|
|
die(0); // just in case
|
|
|
|
}
|
|
|
|
|
2006-11-14 03:53:24 +01:00
|
|
|
/* returns the title to be displayed above thumbnails on tag page
|
|
|
|
*/
|
|
|
|
function get_tags_content_title()
|
|
|
|
{
|
|
|
|
global $page;
|
2010-03-02 15:54:22 +01:00
|
|
|
$title = count($page['tags']) > 1 ? l10n('Tag') : l10n('Tag');
|
2006-11-14 03:53:24 +01:00
|
|
|
$title.= ' ';
|
|
|
|
|
|
|
|
for ($i=0; $i<count($page['tags']); $i++)
|
|
|
|
{
|
|
|
|
$title.= $i>0 ? ' + ' : '';
|
|
|
|
|
|
|
|
$title.=
|
|
|
|
'<a href="'
|
|
|
|
.make_index_url(
|
|
|
|
array(
|
|
|
|
'tags' => array( $page['tags'][$i] )
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.'" title="'
|
2011-01-14 22:19:15 +01:00
|
|
|
.l10n('display photos linked to this tag')
|
2006-11-14 03:53:24 +01:00
|
|
|
.'">'
|
|
|
|
.$page['tags'][$i]['name']
|
|
|
|
.'</a>';
|
|
|
|
|
2010-04-08 10:49:40 +02:00
|
|
|
$remove_url = null;
|
|
|
|
if (count($page['tags']) == 1)
|
|
|
|
{
|
|
|
|
$remove_url = get_root_url().'tags.php';
|
|
|
|
}
|
|
|
|
else
|
2006-11-14 03:53:24 +01:00
|
|
|
{
|
|
|
|
$other_tags = $page['tags'];
|
2010-04-08 10:49:40 +02:00
|
|
|
unset($other_tags[$i]);
|
|
|
|
$remove_url = make_index_url(
|
|
|
|
array(
|
|
|
|
'tags' => $other_tags
|
2006-11-14 03:53:24 +01:00
|
|
|
)
|
2010-04-08 10:49:40 +02:00
|
|
|
);
|
2006-11-14 03:53:24 +01:00
|
|
|
}
|
2010-12-23 06:22:19 +01:00
|
|
|
|
2010-04-08 10:49:40 +02:00
|
|
|
$title.=
|
|
|
|
'<a href="'.$remove_url.'" style="border:none;" title="'
|
|
|
|
.l10n('remove this tag from the list')
|
|
|
|
.'"><img src="'
|
|
|
|
.get_root_url().get_themeconf('icon_dir').'/remove_s.png'
|
|
|
|
.'" alt="x" style="vertical-align:bottom;" class="button">'
|
|
|
|
.'</a>';
|
2006-11-14 03:53:24 +01:00
|
|
|
}
|
|
|
|
return $title;
|
|
|
|
}
|
2006-12-08 01:12:44 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the http status header (200,401,...)
|
|
|
|
*/
|
|
|
|
function set_status_header($code, $text='')
|
|
|
|
{
|
|
|
|
if (empty($text))
|
|
|
|
{
|
|
|
|
switch ($code)
|
|
|
|
{
|
|
|
|
case 200: $text='OK';break;
|
|
|
|
case 301: $text='Moved permanently';break;
|
|
|
|
case 302: $text='Moved temporarily';break;
|
|
|
|
case 304: $text='Not modified';break;
|
|
|
|
case 400: $text='Bad request';break;
|
|
|
|
case 401: $text='Authorization required';break;
|
|
|
|
case 403: $text='Forbidden';break;
|
|
|
|
case 404: $text='Not found';break;
|
2007-07-07 04:10:11 +02:00
|
|
|
case 500: $text='Server error';break;
|
2008-09-17 03:48:31 +02:00
|
|
|
case 501: $text='Not implemented';break;
|
2007-07-07 04:10:11 +02:00
|
|
|
case 503: $text='Service unavailable';break;
|
2006-12-08 01:12:44 +01:00
|
|
|
}
|
|
|
|
}
|
2010-04-05 22:49:32 +02:00
|
|
|
$protocol = $_SERVER["SERVER_PROTOCOL"];
|
|
|
|
if ( ('HTTP/1.1' != $protocol) && ('HTTP/1.0' != $protocol) )
|
|
|
|
$protocol = 'HTTP/1.0';
|
2007-07-07 04:10:11 +02:00
|
|
|
|
2010-12-23 06:22:19 +01:00
|
|
|
header( "$protocol $code $text", true, $code );
|
2007-01-23 02:22:52 +01:00
|
|
|
trigger_action('set_status_header', $code, $text);
|
2006-12-08 01:12:44 +01:00
|
|
|
}
|
2007-01-30 08:00:17 +01:00
|
|
|
|
2007-10-02 07:38:54 +02:00
|
|
|
/** returns the category comment for rendering in html textual mode (subcatify)
|
|
|
|
* this is an event handler. don't call directly
|
|
|
|
*/
|
|
|
|
function render_category_literal_description($desc)
|
|
|
|
{
|
|
|
|
return strip_tags($desc, '<span><p><a><br><b><i><small><big><strong><em>');
|
2007-01-30 08:00:17 +01:00
|
|
|
}
|
2008-05-17 22:40:27 +02:00
|
|
|
|
2008-08-28 02:32:39 +02:00
|
|
|
/*event handler for menu*/
|
|
|
|
function register_default_menubar_blocks( $menu_ref_arr )
|
|
|
|
{
|
|
|
|
$menu = & $menu_ref_arr[0];
|
|
|
|
if ($menu->get_id() != 'menubar')
|
|
|
|
return;
|
|
|
|
$menu->register_block( new RegisteredBlock( 'mbLinks', 'Links', 'piwigo'));
|
2010-09-21 23:14:54 +02:00
|
|
|
$menu->register_block( new RegisteredBlock( 'mbCategories', 'Albums', 'piwigo'));
|
2008-08-28 02:32:39 +02:00
|
|
|
$menu->register_block( new RegisteredBlock( 'mbTags', 'Related tags', 'piwigo'));
|
2010-03-18 20:21:17 +01:00
|
|
|
$menu->register_block( new RegisteredBlock( 'mbSpecials', 'Specials', 'piwigo'));
|
|
|
|
$menu->register_block( new RegisteredBlock( 'mbMenu', 'Menu', 'piwigo'));
|
|
|
|
$menu->register_block( new RegisteredBlock( 'mbIdentification', 'Identification', 'piwigo') );
|
2008-08-28 02:32:39 +02:00
|
|
|
}
|
|
|
|
|
2010-09-21 23:14:54 +02:00
|
|
|
?>
|