Osclass forums

Support forums => Tips, tricks, and tutorials => Topic started by: nektm on April 26, 2014, 01:43:20 am

Title: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: nektm on April 26, 2014, 01:43:20 am
I think there are many who may wants to integrate Chat option in Osclass, if not interested then just ignore this tutorial :)

1) First of all download friechat from https://bitbucket.org/evnix/freichat-free-chat-script/downloads/FreiChat.V.9.6.zip (https://bitbucket.org/evnix/freichat-free-chat-script/downloads/FreiChat.V.9.6.zip)

2) Extract friechat folder in osclass root directory

3) Open main.php from current theme folder and place the below code between <head></head>

NOTE: DON'T FORGET TO CHANGE "YOURDOMAINNAME.COM" IN BELOW CODE

Code: [Select]
            <?php

       if(
osc_is_web_user_logged_in())
      
{
      
    $ses osc_logged_user_id() ; //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"nulltime() 3600"/"); // *do not change -> freichat code
      
}


      
if(!function_exists("freichatx_get_hash")){
      
function freichatx_get_hash($ses){

      
       if(is_file("/home/www/YOURDOMAINNAME.COM/freichat/hardcode.php")){

      
               require "/home/www/YOURDOMAINNAME.COM/freichat/hardcode.php";

      
               $temp_id =  $ses $uid;

      
               return md5($temp_id);

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

      
return 0;
      
}
      
}

      
?>


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



4) Place the below code where you want the online/offline icon to be shown, i place this inside description DIV

Code: [Select]
<div class="onlineuser">
        <?php $user User::newInstance()->findByPrimaryKey(osc_item_user_id()); ?>
         <?php if(useronline_show_user_status() == 1) { ?>
                  <a class="chat_online_inline" id="onlineuser" href="javascript:void(0)" onClick="FreiChat.create_chat_window(<?php echo "'".$user['s_name']."'" ?>, <?php echo osc_item_user_id(); ?>)"></a>
          <?php } else { ?>
                  <a class="chat_offline_inline" href="javascript:void(0)"></a>
           <?php ?>
</div>


Now its time to install friechat in order to integrate with osclass

5) Open browser and install friechat by http://YOURDOMAINNAME.COM/FRIECHAT/ (http://YOURDOMAINNAME.COM/FRIECHAT/) and follow the instruction, You must select "CUSTOMIZED" option from dropdown during installtion, remember you should be logged in to your site using any user before you install friechat, because friechat will search if any user is logged in to your site.

Note: you don't need to copy the code during friechat installation and paste in osclass, because we already did it in <head></head> section. If you didn't then do it before you start installation

6) Download Useronline plugin from http://forums.osclass.org/plugins/(new-plugin)-user-online/?action=dlattach;attach=16512 (http://forums.osclass.org/plugins/(new-plugin)-user-online/?action=dlattach;attach=16512) install and activate it from admin panel.

7) Go to the ../oc-content/plugins/useronline foder and open index.php file

Find and replace this

function useronline_show_user_status() {
   $itemUserId = osc_item_user_id();
   $conn   = getConnection();
   $userOnline=$conn->osc_dbFetchResult("SELECT * FROM %st_useronline WHERE userid = '%s'",DB_TABLE_PREFIX, $itemUserId);
   if($userOnline !=''){
      echo '<img src="'.osc_base_url().'oc-content/plugins/useronline/images/online.png" />' ;
   } else {
      echo '<img src="'.osc_base_url().'oc-content/plugins/useronline/images/offline.png" />' ;
      }
}

With This

function useronline_show_user_status() {
   $itemUserId = osc_item_user_id();
   $conn   = getConnection();
   $userOnline=$conn->osc_dbFetchResult("SELECT * FROM %st_useronline WHERE userid = '%s'",DB_TABLE_PREFIX, $itemUserId);
   if($userOnline !=''){
      return 1;
   } else {
      return 0;
      }
}

8 ) Copy the oc-content/plugins/useronline/images/online.png and paste in your current theme image folder

9) Copy the oc-content/plugins/useronline/images/offline.png and paste in your current theme image folder


10) Open style.css file of your current theme and place below style code anywhere you want

Code: [Select]
.chat_online_inline{background:url(images/online.png) no-repeat;}
 .chat_offline_inline{background:url(images/offline.png) no-repeat;}
.chat_online_inline,.chat_offline_inline{float:right; display: block; cursor:pointer;}


Thanks to cartagena68 for useronline plugin :)
any better suggestions are welcomed :)
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: creat15 on April 26, 2014, 09:12:58 am
thanks for tutorial :)

this safe from SPAM or hacker?

Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: creat15 on April 26, 2014, 09:17:14 am
thanks for tutorial :)

this safe from SPAM or hacker?
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: nektm on April 26, 2014, 09:36:09 am
thanks for tutorial :)

this safe from SPAM or hacker?

Yes it's safe.
1) You should disable the public chat module from freichat admin panel after installation.
2) Hide the freichat user list & "powered by" --   Go to ../freichat/client/theme/basic/ folder and open style.css file then replace below:

Code: [Select]
#freichat {
  position: fixed;
  right: 0px;
  bottom: 0px;
  margin-right: 5px;
  font-family: helvetica, arial, sans-serif;
  font-size: 13px;
  visibility: hidden;
}
.freichat {
  position: relative;
  padding: 0px;
  background-color: none;
  color: #000000;
  text-align: justify;
  font-size: 14px;
  width: 200px;
  background-image: none;
  border: none;
  line-height: 1.4em;
  margin: 0px;
  visibility: hidden;
}

above style code will hide the friechat user list in your website. Chat window will open only when clicked by mouse on online user icon.

:):):)
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: renzols on April 26, 2014, 10:31:50 am
whre wp-config ?
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: nektm on April 26, 2014, 11:17:17 am
whre wp-config ?

Did you installed Wordpress in the same root folder? because Wp-Config.php file is related to the wordpress.

Where did you extracted freichat folder? it should be inside <Yourdomainname.com>

You must select "CUSTOMIZED" OPTION from dropdown during installation
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: renzols on April 26, 2014, 11:39:14 am
i got this error when i enter this code
Parse error: syntax error, unexpected '3600' (T_LNUMBER) in



Code: [Select]
            <?php

       if(
osc_is_web_user_logged_in())
      
{
      
    $ses osc_logged_user_id() ; //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"nulltime() 3600"/"); // *do not change -> freichat code
      
}


      
if(!function_exists("freichatx_get_hash")){
      
function freichatx_get_hash($ses){

      
       if(is_file("/home/www/YOURDOMAINNAME.COM/freichat/hardcode.php")){

      
               require "/home/www/YOURDOMAINNAME.COM/freichat/hardcode.php";

      
               $temp_id =  $ses $uid;

      
               return md5($temp_id);

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

      
return 0;
      
}
      
}

      
?>
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: nektm on April 26, 2014, 11:47:43 am
i got this error when i enter this code
Parse error: syntax error, unexpected '3600' (T_LNUMBER) in



Code: [Select]
            <?php

       if(
osc_is_web_user_logged_in())
      
{
      
    $ses osc_logged_user_id() ; //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"nulltime() 3600"/"); // *do not change -> freichat code
      
}


      
if(!function_exists("freichatx_get_hash")){
      
function freichatx_get_hash($ses){

      
       if(is_file("/home/www/YOURDOMAINNAME.COM/freichat/hardcode.php")){

      
               require "/home/www/YOURDOMAINNAME.COM/freichat/hardcode.php";

      
               $temp_id =  $ses $uid;

      
               return md5($temp_id);

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

      
return 0;
      
}
      
}

      
?>

paste below code after the ?>
Code: [Select]
<script type="text/javascript" language="javascipt" src="http://www.YOURDOMAINNAME.com/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script>
    <link rel="stylesheet" href="http://www.YOURDOMAINNAME.com/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">
     

Note: change "YOUDOMAINNAME"
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: cartagena68 on May 02, 2014, 11:13:52 am
@ nektm

first of all, nice tutorial!  ;)

But, i have to say, there some errors to correct and some improvement to do.
Now is to late, but tomorrow i will replay with the changes you need to make and also i will upload a new version of useronline plugin that include the functions needed to work with freichat, so you don't have to change the plugin code.
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: cartagena68 on May 03, 2014, 01:37:37 am
THIS  TUTORIAL IS OUT OF DATE.

CHECK OUT THIS PLUGIN



http://forums.osclass.org/plugins/freichat/




Here is useronline plugin freichat integration ready.
the tutorial for integration is in plugin help but i'm posting it also here.

FreiChat Integration

1) Download freichat from https://bitbucket.org/evnix/freichat-free-chat-script/downloads/FreiChat.V.9.6.zip (https://bitbucket.org/evnix/freichat-free-chat-script/downloads/FreiChat.V.9.6.zip)
2) Extract freichat folder in osclass root directory 
3) Place the below code between <head></head>, usually in header.php in your theme folder.
IMPORTANT! in the code below, at the 2 lines saying  time() 3600 should be time()plus sign3600 i don't know why, but posting is deleting the plus sign. DO NOT WRITE "plus sign", JUST THE SYMBOL. Or copy this code from HELP in plugin.

               
Code: [Select]
<!--===========================FreiChat=======START=========================-->
<!-- For uninstalling ME , first remove/comment all FreiChat related code i.e below code
Then remove FreiChat tables frei_session & frei_chat if necessary
         The best/recommended way is using the module for installation                         -->

<?php
if(USER_IS_LOGGED_IN)

    
$ses osc_logged_user_id() ; //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"nulltime() 3600"/"); // *do not change -> freichat code


if(!
function_exists("freichatx_get_hash")){
function 
freichatx_get_hash($ses){

       if(
is_file(osc_base_path()."/freichat/hardcode.php")){

               require 
osc_base_path()."/freichat/hardcode.php";

               
$temp_id =  $ses $uid;

               return 
md5($temp_id);

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

       return 
0;
}
}
?>

<script type="text/javascript" language="javascipt" src="<?php echo osc_base_url() ; ?>freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script>
<link rel="stylesheet" href="<?php echo osc_base_url() ; ?>freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">
<!--===========================FreiChatX=======END=========================-->   
               
4) Place the below code in item.php where you want the chat icon/text to be shown

                   
Code: [Select]
<?php if(function_exists('useronline_show_chat')) {useronline_show_chat();} ?>
               
Now its time to install freichat in order to integrate with osclass

5) Open browser and install freichat by http://YOURDOMAINNAME.COM/freichat/ (http://YOURDOMAINNAME.COM/freichat/) and follow exactly the instruction, You must select "CUSTOMIZED" option from dropdown menu regarding integration during installation.
During intallation you will be asked for database information(db name, password etc.) then they will also ask about user information table,
the user table is: YOUR TABLE PREFIX_t_user
the user name row is: s_name
and the user id row is: pk_i_id
Remember you should be logged in to your site (front end) using any user before you install freichat, because freichat will search if any user is logged in to your site.
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: nektm on May 03, 2014, 08:26:58 am


@cartagena68

Thanks you for simplifying tutorial and modifying useronline plugin:)


Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: cartagena68 on May 03, 2014, 08:36:37 am
You are welcome,
is a good tutorial from the beginning.
The error i was talking about is not your fault, is that this forum don't aloud to write the plus symbol, so it just desappear when you post ( that is why he was giving the error to renzols).
The rest was ok, i just include the new functions to the plugin and i use the osclass function for site path and site url.

Thank you for starting this tutorial.
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: frosticek on May 03, 2014, 10:08:31 am
@nektm
Looks cool, I will need to test it :)
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: cartagena68 on May 09, 2014, 08:01:34 am
Now is availabe this

http://forums.osclass.org/plugins/freichat/ (http://forums.osclass.org/plugins/freichat/)

with this plugin you don't need to copy and paste the freichat code, just follow the instructions.
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: praveend06 on July 15, 2014, 01:31:57 pm
I have installed freichat with osclass 3.3.2 (twitter theme), and it show chat icon in item page.
BUT I am facing two issues.

1. If I open login with two user different user in different browser and send message from on to other it does not display to other. (for other user chat window should open with message).

2. If I open chat window to send message and close it  and click again on chat icon it give javascript error
ReferenceError: FreiChat is not defined

Please help me to resolve this.
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: praveend06 on July 15, 2014, 03:07:18 pm
Click on chat link form item page and send message to this user.
message does not display on another user page.
as well always show The user is offline, message will be delivered once user will be online.

Please help me to resolve this issue.
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: praveend06 on July 23, 2014, 08:55:45 am
Above problem is soldved. I missed to copy js code in header.php
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: praveend06 on July 23, 2014, 08:58:39 am
I installed freichat and its working fine.

Only one problem I facing if seller closed chat and want o reconnect with buyer. then there is no option at seller site.
As well if user wan to see previously with whom he has been chat than there is no such feature available.

Is there a way to achieve this?
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: cartagena68 on July 23, 2014, 11:13:52 am
Sorry. i don't think is possible
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: cartagena68 on July 23, 2014, 06:50:00 pm
Sorry. i don't think is possible

Actually, if you have the plugin installed, you can click on "Show regular freichat box" in oc-admin and a chat box with the users online will show at the bottom of the page
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: habijabimail1 on May 21, 2017, 06:49:31 am
Useronline plugin link is not workingxcvrun
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: habijabimail1 on May 21, 2017, 06:56:26 am
Useronline plugin download link not working.....
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: WEBmods on January 20, 2018, 05:03:14 pm
Hello everyone,

I was also looking for "User online" and "Freichat" plugins for osclass and links on the forum weren't working.
However, I managed to found that plugins on the following website: plugins-zone.com.
I don't know if the plugins are outdated, but here are the links from which you can download the plugins (it not from original site because you need to fill a long form to register and download)

User online: https://www.dropbox.com/s/ls5lmfs4zjgh7be/useronline-v-1.0.2.zip?dl=1
Freichat (definitely outdated, but still...): https://www.dropbox.com/s/vpf91c25yduo41i/freichat-v1.0.5.zip?dl=0
Title: Re: [TUTORIAL] Step-By-Step chat (Buyer to seller) integration in osclass
Post by: allindiabookhub on July 18, 2018, 01:14:36 pm
hi actually i dont know much about coding. could you please tell me that where to find osclass root directory or i request you to please make a full tutorial video on this topic