• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

URL?

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
13 posts • Page 1 of 1

Postby guerby » Sat Mar 17, 2007 6:19 pm

when I paste an URL it doesn't display properly on phpfreechat-1.0-beta9

Not sure if it's a bug report or feature request :)
guerby
New member
 
Posts: 6
Joined: Sat Mar 17, 2007 6:17 pm
Top

Postby phpfreechat » Tue Mar 20, 2007 9:37 am

Which url ?
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby eazolan » Wed Mar 21, 2007 6:06 pm

Which URL? All of them. I have to have my users remove everything before the www otherwise it turns into garbage.

This is what comes up on the screen as a clickable link:
Code: Select all
/www.google.com/" onclick="window.open(this.href,'_blank');return false;">http://www.google.com/

And this is what the link contains:
Code: Select all
http://erikz.homedns.org/chat2/http%3Cimg%20src=

I'm checking out the code that does this, I think. It's in phpfreechat.class.php right?
eazolan
New member
 
Posts: 6
Joined: Wed Mar 21, 2007 5:54 pm
Top

Postby eazolan » Wed Mar 21, 2007 6:46 pm

Ah, here it is. In pfcclient.js

I don't know anything about javascript though. I've been able to narrow it down to the "parse urls" area.
eazolan
New member
 
Posts: 6
Joined: Wed Mar 21, 2007 5:54 pm
Top

Postby guerby » Thu Mar 22, 2007 9:05 pm

Here is a small hack that assumes there is only one URL wich starts with "http:" and disables most of other smart parsing features (...).

If you type:

here is my blog: http://guerby.org/blog/

It should work just like BBforum (don't forget to refresh your page in your browser after changing the script on your server to force a reload of javascript code)

Patch:
Code: Select all
--- pfcclient.js.save   2007-02-18 22:23:11.000000000 +0100
+++ pfcclient.js        2007-03-22 21:01:38.000000000 +0100
@@ -1170,6 +1170,12 @@
    */
   parseMessage: function(msg)
   {
+    var ii=msg.indexOf("http:");
+    if (ii<0) return msg;
+    var nn=msg.length;
+    url=msg.substring(ii,nn)
+    before=msg.substring(0,ii)
+    return before+'<a href="'+url+'">'+url+'</a>'
     var rx = null;
   
     // parse urls

If you don't know what a patch is, lines to paste just before the "var rx = null;"
Code: Select all
    var ii=msg.indexOf("http:");
    if (ii<0) return msg;
    var nn=msg.length;
    url=msg.substring(ii,nn)
    before=msg.substring(0,ii)
    return before+'<a href="'+url+'">'+url+'</a>'
guerby
New member
 
Posts: 6
Joined: Sat Mar 17, 2007 6:17 pm
Top

Postby eazolan » Thu Mar 22, 2007 9:59 pm

That fixed it perfectly! Thank you so much. :)

Javascript is my one weakness. PHP, HTML, CSS, etc, I know those.
eazolan
New member
 
Posts: 6
Joined: Wed Mar 21, 2007 5:54 pm
Top

Postby guerby » Thu Mar 22, 2007 10:05 pm

Note a small improvement: clicking on the URL open in a new window if you replace the last return by:

Code: Select all
return before+'<a href="'+url+'" onclick="window.open(this.href); return false;">'+url+'</a>'

(otherwise you have to right click open new window not to leave the chat)
guerby
New member
 
Posts: 6
Joined: Sat Mar 17, 2007 6:17 pm
Top

Postby eazolan » Thu Mar 22, 2007 10:34 pm

uh oh.

Well, I applied all the code. And URLs work fine now. But smileys are broken. All it shows is the :) instead of the icon.
eazolan
New member
 
Posts: 6
Joined: Wed Mar 21, 2007 5:54 pm
Top

Postby guerby » Thu Mar 22, 2007 11:29 pm

quick hack bis:
Code: Select all
  parseMessage: function(msg)
  {
    var ii=msg.indexOf("http:");
    var url="";
    var before=msg;
    if (ii>=0) {
       nn=msg.length;
       url=msg.substring(ii,nn)
       before=msg.substring(0,ii);
    }
    // try to parse smileys
    var rx = null;
    var smileys = this.res.getSmileyHash();
    var sl = smileys.keys();
    for(var i = 0; i < sl.length; i++)
    {
      rx = new RegExp(RegExp.escape(sl[i]),'g');
      before = before.replace(rx, '<img src="'+ smileys[sl[i]] +'" alt="' + sl[i] + '" title="' + sl[i] + '" />');
    }
    if(url=="") return before;
    return before+'<a href="'+url+'" onclick="window.open(this.href); return false;">'+url+'</a>';
guerby
New member
 
Posts: 6
Joined: Sat Mar 17, 2007 6:17 pm
Top

Postby eazolan » Fri Mar 23, 2007 3:30 am

That fixed it. :)

I really appreciate the time you took to bang this out.
eazolan
New member
 
Posts: 6
Joined: Wed Mar 21, 2007 5:54 pm
Top

Postby phpfreechat » Fri Mar 23, 2007 10:39 am

I'd like to include this patch in the next release. However could you tell me if this is a IE7 specific problem ?
I'm using FF and IE6 but I am not able to reproduce the problem.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby eazolan » Fri Mar 23, 2007 1:33 pm

I helped install phpfreechat on a friend's site, and she doesn't have the problem either.

It was coming up in Firefox and IE. I have no idea why it was happening, it looks like it's something on the server.

I posted the results of the old code in my original post to help you figure it out.
eazolan
New member
 
Posts: 6
Joined: Wed Mar 21, 2007 5:54 pm
Top

Postby guerby » Fri Mar 23, 2007 10:59 pm

kerphi, I was using firefox 2.0.2 (on ubuntu). I have no knowledge of javascript :).
Last edited by guerby on Fri Mar 23, 2007 11:00 pm, edited 1 time in total.
guerby
New member
 
Posts: 6
Joined: Sat Mar 17, 2007 6:17 pm
Top


Post a reply
13 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 16 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub