Turn Guestbook Strings into URL Links

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Turn Guestbook Strings into URL Links

Post by jsw_nz »

I needed a way to add hyperlinks to submitted strings inside the guestbook contentpart,
so I made minor modifications to the contentpart core:

include/inc_front/content/cnt18.article.inc.php

The following changes enable strings to be converted to working url links:
http://www.mydomain.com
http://www.mydomain.com
(as shown above)
- they open in a blank window

lines 95-97 (two new lines)

Code: Select all

$guestbook['post']['msg'] = preg_replace("'(\w+)://([\w\+\-\@\=\?\.\%\/\:\&\;~\|]+)(\.)?'", "<a href=\"\\1://\\2\" target=\"blank\">\\1://\\2</a>", $_POST['guestbook_msg']);
$guestbook['post']['msg'] = preg_replace("'(\w\s+)www\.([\w\+\-\@\=\?\.\%\/\:\&\;~\|]+)(\.\s|\s)'", "\\1<a href=\"http://www.\\2\" target=\"blank\">www.\\2</a>\\3" , $guestbook['post']['msg']);
$guestbook['post']['msg'] = trim(remove_unsecure_rptags($guestbook['post']['msg']));
line 775:

Code: Select all

$guestbook['row']['guestbook_msg'] = html_despecialchars($guestbook['row']['guestbook_msg']);
hope this helps someone - just a little modification - there might be issues/bugs - just tested on localhost
:)
Post Reply