Author Topic: Add links to canned messages  (Read 15357 times)

0 Members and 1 Guest are viewing this topic.

g0dd3rz

  • Jr. Member
  • **
  • Posts: 4
Add links to canned messages
« on: July 19, 2012, 11:02:02 AM »
Hi all,

New to this tool so just getting to grips with it at the moment.

Is there a way I can add links to my canned messages.

I've attempted this and manually during a live chat to no avail - any ideas?

Example:
<a href="http://www.google.co.uk">Link</a>

Thanks,

Lee

g0dd3rz

  • Jr. Member
  • **
  • Posts: 4
Re: Add links to canned messages
« Reply #1 on: July 19, 2012, 11:05:17 AM »
Found a part solution....

You need to use the full http://blah blah.co.uk to get links working on the chat and in the canned messages.

Is there any way to code the links though... Sometimes you don't want to show the actual link but instead wanna put something like "Click Here"

I've also noticed that if you try to use a https link it doesn't work either.

Would appreciate any input,

Thanks.


« Last Edit: July 19, 2012, 11:14:40 AM by g0dd3rz »

hjalmjall

  • Jr. Member
  • **
  • Posts: 3
Re: Add links to canned messages
« Reply #2 on: December 04, 2012, 11:39:52 AM »
I found a way! :-)

In the file libs/chat.php, function prepare_html_message($text):
Change this line:
$text_w_links = preg_replace('/(http|ftp):\/\/\S*/', '<a href="$0" target="_blank">$0</a>', $escaped_text);
...to:
$text_w_links = preg_replace('/(http|https|ftp):\/\/\S*/', '<a href="$0" target="_blank">$0</a>', $escaped_text);

To hide http/https/ftp:// in the link, change it to this:
$text_w_links = preg_replace('/(http|https|ftp):\/\/(\S*)/', '<a href="$0" target="_blank">$2</a>', $escaped_text);

To allow links with your own text, add the following line after the changed one:
$text_w_links = preg_replace('/(http|https|ftp)link:\/\/(\S*)\*(\S*)/', '<a href="$1://$2" target="_blank">$3</a>', $text_w_links);
To get a link with your own text, add link behind http/https/ftp, add * after the URL and then the text for the link.
E.g: httpslink://yourdomain.com*your_text
...will give the link: <a href=https://yourdomain.com>your_text</a>

bobscan

  • Full Member
  • ***
  • Posts: 10
Re: Add links to canned messages
« Reply #3 on: December 05, 2012, 07:08:12 PM »
on a sidenote, i just found that you can allow the use of html tags in the chat itself by removing the

htmlspecialchars();

from the previous line. If your setup doesn't have a terrible concern for potential html hacks, it allows for enhanced usability for your operators. It appears this would also work for users too, so it might be handy if we could use some  sort of syntax  like bbcode or something instead of allowing the use of html. If anyone would like to elaborate on the pitfalls of this, please do.

mysql escaping still happens later in the script or elsewhere, so it should be safe there.

line 90:
   $escaped_text = $text;
« Last Edit: December 05, 2012, 07:12:34 PM by bobscan »