freichat - I have it working

Not sure if I can share the code or not as freichat is not "my software". But I have yet to see anyone who has the proper configuration to get it working with dolphin - I have that configuration.

I have seen other posts in the forums over time from people who couldn't get it working - so if anyone is interested, let me know and I can help you get it working. 

I have it working with anonymous guests before logging in, working with the members list after logging in, working with user avatar system, and linking to users profiles within the chat and messenger. 

Quote · 31 May 2015

This chat software is free..the basic version anyway, upgrades and more users cost.

The only thing is the integration, which might work for some, is vague.

Dolphin is listed for integration but it has to be done manually.

ManOfTeal.COM a Proud UNA site, six years running strong!
Quote · 31 May 2015

The integration code.

if(USER_IS_LOGGED_IN)

    $ses = LOGGED_IN_USERID; //tell freichat the userid of the current user

    setcookie("freichat_user", "LOGGED_IN", time()+3600, "/"); // *do not change -> freichat code

}

else {

    $ses = null; //tell freichat that the current user is a guest

    setcookie("freichat_user", null, time()+3600, "/"); // *do not change -> freichat code

ManOfTeal.COM a Proud UNA site, six years running strong!
Quote · 31 May 2015

 

This chat software is free..the basic version anyway, upgrades and more users cost.

It was buried under the download.; the free version has their name on it but it does have unlimited users according to the website.  If one does not mind having their brand on your chat, it might be OK.

Geeks, making the world a better place
Quote · 31 May 2015

I setup my first boonex site a month ago. One of the first things I learned is the boonex messenger, simple messenger, and chat all require flash. Absolutely none of my members have flash installed on their browser so I had to search for a different solution. Frechat was the only quality solution I could find that was 100% php/sql.

If there is a user limit, I have yet to find it, and I have over 700 active members on my site and have had as many as 65 online at the same time. Granted small numbers, but I actually don't think the version I have had user limits. It does had a small "powered by" unless one pays.

Its not as easy as the instructions make it seem to get working. Passing the logged in user to $ses took me (a non-programmer) quite some time to figure out. I actually have it set so it checks for the existance of the user cookie and if it exists set that to $ses.

After you get that properly set, you still have to modify the custom.php file to work properly with the database. Then there you have to log into the settings and enable "no conflict query" AND you have to modify the hardcode.php to change $force_load_jquery to yes.

THe software also expects avatars to be stored in the database as an image with the file extention - boonex only stores it name of the avatar. So instead of 1.jpg boonex stores 1. You have to either modify the source of freichat to reflect this, or you have to add an htaccess setting so any image called from the avatar folder automatically is converted to .jpg.

Oh any the freichat instructions claim to paste their code in the header section of your template - however that won't work with boonex. If you try you will first find most setups don't allow you to run php inside an .html page - and even if you can - it will completely make the extra-menu stop working. You must add the code as a server injection. BEcause of this you also have to re-write the javascript they give you to be pure php because the javascript they provide with not read the value of $ses if you do not do this.

Like I said in the title of the post - if anyone wants to use this solution and can't get it working, drop me a line I have it working 100% (except merging with friends lists as I didn't enable that option).

Quote · 2 Jun 2015

 

THe software also expects avatars to be stored in the database as an image with the file extention

Are you sure about this as it seems absurd?  Even small images can take up a lot of space and to have the actually bits and pieces stored in the database does not make sense.

Geeks, making the world a better place
Quote · 2 Jun 2015

There should be nothing wrong with you posting Dolphin integration of freichat so please do.

Geeks, making the world a better place
Quote · 2 Jun 2015

I don't think my last message was properly understood. No database would store the actual image. However if you look in your dolphin database, in the profiles table, at the "avatar" column you will see the value is an number, which relates to an image in the avatar folders. For example my avatar is 165.jpg in the folder so in the database it is stored simply as "165". Freichat expects it to be stored as "165.jpg" in the database.

I am on my way out the door so I will post the setup I am using when I return :)

Quote · 2 Jun 2015

First for simplicity reasons I opted to use an htaccess file to  get the avatar images working properly.

So inside /modules/boonex/avatar/data/images I added the following inside a .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}  !(\.png|\.jpg|\.gif|\.jpeg|\.bmp)$
RewriteRule (.*)  $1.jpg [QSA]

ErrorDocument 404 http://yoururl.com/modules/boonex/avatar/data/images/man.gif
</IfModule>

This makes it so a .jpg is added to all files called from the directory. It also makes it so if a user doesn't add an avatar, a default man.gif is used (because a 404 will be returned). You must add the man.gif to the folder yourself.

Next you need to  modify your /freichat/server/drivers/custom.php file

To get users from database change the public function get users to

    public function get_users() {

        //do not delete below comment
        //CUSTOM_USERS_QUERY_START
            $query = "SELECT DISTINCT f.status_mesg,f.username,f.session_id,f.status,f.guest,f.in_room,a.avatar
                   FROM frei_session AS f LEFT JOIN profiles AS u ON u.id = f.session_id
                    LEFT JOIN profiles AS a ON u.avatar = a.avatar
                  WHERE f.time>" . $this->online_time2 . "
                   AND f.session_id!=" . $_SESSION[$this->uid . 'usr_ses_id'] . "
                   AND f.status!=2
                   AND f.status!=0
                   AND f.guest=0";
//CUSTOM_USERS_QUERY_END
        //do not delete above comment

        $list = $this->db->query($query)->fetchAll();
        return $list;
    }


TO make members avatars work Under Avatar URL Start


    //AVATAR_URL_START
        public function avatar_url($res) {
            $root = 'http://yoururl.com/modules/boonex/avatar/data/images';
            $avatar = $res[$this->avatar_field_name];
            $avatar = str_replace(' ','%20',$avatar);
        if (strpos($avatar, 'http://') === FALSE && strpos($avatar, 'https://') === FALSE) {
                $slash = '/';
                if($avatar[0] == '/') $slash = '';
       
                return $root.$slash.$avatar;
            }else{
                return $avatar;
            }
        }
        //AVATAR_URL_END

To link member avatars to profiles Under Linke Profile Url

    public function linkprofile_url($result, $r_path, $def_avatar) {
        $iden = $result['username']; //additional data
        $id = $result['session_id'];
        $str = "<span id = 'freichat_profile_link_" . $id . "'  class='freichat_linkprofile_s'>";

        $path = "<a href='$r_path$iden'>";

        $str = $str . $path . "<img title = '" . $this->frei_trans['profilelink'] . "' class ='freichat_linkprofile' src='" . $def_avatar . "' alt='view' />
                </a></span>";

        return $str;
        //return '';
    }

After the above changes are made, run freichat installer to connect to your database. The table I used was "profiles", set userid to id, and avatar to avatar.  When it gets to the cut & paste section, close the page.

Open frechat/hardcode.php and change $force_load_jquery = 'NO'; to $force_load_jquery = 'YES';
Also make sure $installed=true;

Next login to the freichat admin interface under client side, find the option Remove Jquery Conflicts and set to yes.

Finally open your phpmyadmin and enter your dolphin database. Find the table sys_injections. Add a new line:

Name: freichat
Page_Index: 0
Key: injection_head
Type: php
data: if(isset($_COOKIE['memberID']))
 {
 $_SESSION['userid'] = $_COOKIE['memberID'];
 
 if(isset($_SESSION['userid']))
   {
   if($_SESSION['userid'] != null)      {
     $ses=$_SESSION['userid'];
     setcookie("freichat_user", $ses, time()+3600, "/");
     }
   }
}
else
 {
$ses = null;
setcookie("freichat_user", null, time()+3600, "/");
 }

   if(!function_exists("freichatx_get_hash")){
   function freichatx_get_hash($ses){
   if(is_file("\path\to\hardcode.php")){

               require "\path\to\hardcode.php";

               $temp_id =  $ses . $uid;

               return md5($temp_id);

       }
       else
       {
               echo "<script>alert('module freichatx says: hardcode.php file not found!');</script>";
       }
       return null;
}
}

echo '
<script type="text/javascript" language="javascipt" src="http://yoururl.com/freichat/client/main.php?id=';echo $ses;echo '&xhash=';echo freichatx_get_hash($ses);echo '"></script>
<link rel="stylesheet" href="yoururl.com/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">
';

I think thats everything :)

Quote · 2 Jun 2015
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.