'
.$search[2];
return str_replace($search, $replace, $content);
}
/**
* Replace BBcode tag by a link with absolute url
*/
function replyto_parse_picture($comment)
{
if (preg_match('#\[reply=([1-9]+)\](.*)\[/reply\]#si', $comment, $matches))
{
// picture informations
$query = '
SELECT
img.id,
img.file,
cat.category_id
FROM ' . IMAGES_TABLE . ' AS img
INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS cat
ON cat.image_id = img.id
INNER JOIN ' . COMMENTS_TABLE . ' AS com
ON com.image_id = img.id
WHERE com.id = ' . $matches[1] . '
;';
$result = pwg_query($query);
// make sure the target comment exists
if (pwg_db_num_rows($result))
{
$image = pwg_db_fetch_assoc($result);
// retrieving category informations
$query = '
SELECT
id,
name,
permalink,
uppercats
FROM ' . CATEGORIES_TABLE . '
WHERE id = ' . $image['category_id'] . '
;';
$image['cat'] = pwg_db_fetch_assoc(pwg_query($query));
// link to the full size picture
$image['url'] = make_picture_url(array(
'category' => $image['cat'],
'image_id' => $image['id'],
'image_file' => $image['file'],
));
$search = "#\[reply=([1-9]+)\](.*)\[/reply\]#si";
$replace = '@
$2 :';
}
else
{
$search = "#\[reply=([1-9]+)\](.*)\[/reply\]#si";
$replace = '';
}
return preg_replace($search, $replace, $comment);
}
else
{
return $comment;
}
}
function replyto_parse_album($comment)
{
if (preg_match('#\[reply=([1-9]+)\](.*)\[/reply\]#si', $comment, $matches))
{
// check if the comment is really an album comment
// (both comments_on_albums script and default comments script are executed...
// with the same 'render_comment_content' event)
$query = '
SELECT id
FROM ' . COA_TABLE . '
WHERE content = "' . $comment .'"
;';
if (!pwg_db_num_rows(pwg_query($query)))
{
return $comment;
}
// retrieving category informations
$query = '
SELECT
cat.id,
cat.name,
cat.permalink,
cat.uppercats
FROM ' . COA_TABLE . ' AS com
INNER JOIN ' . CATEGORIES_TABLE . ' AS cat
ON cat.id = com.category_id
WHERE com.id = ' . $matches[1] . '
;';
$result = pwg_query($query);
// make sure the target comment exists
if (pwg_db_num_rows($result))
{
$category = pwg_db_fetch_assoc($result);
// link to the album
$category['url'] = make_index_url(array(
'category' => $category,
));
$search = "#\[reply=([1-9]+)\](.*)\[/reply\]#si";
$replace = '@
$2 :';
}
else
{
$search = "#\[reply=([1-9]+)\](.*)\[/reply\]#si";
$replace = '';
}
return preg_replace($search, $replace, $comment);
}
else
{
return $comment;
}
}
?>