Turn Guestbook Strings into URL Links
Posted: Sun 26. Aug 2007, 02:59
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)
line 775:
hope this helps someone - just a little modification - there might be issues/bugs - just tested on localhost

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']));
Code: Select all
$guestbook['row']['guestbook_msg'] = html_despecialchars($guestbook['row']['guestbook_msg']);
