FreiChat related discussions
freichat smart custom installation - step 3

hi guys how are you?

User Authentication found on freichat smart custom installation - step 3 I have no idea what to do!

I've copy and paste the first code already now this is what i got

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
}

and these are the only instructions

You need to edit above code in such a way that the userid is stored in the $ses variable of the current user and null if the user is a guest
Then replace $ses=0; in your copy-pasted code with your edited code

so this is what I've done go to the first code and look for

$ses=null;

then change it to

$ses=0;

then i got this message "smile Could not authenticate user . Please verify your edited copy-paste code and make any required changes "

Please help me

**hi** guys how are you? User Authentication found on freichat smart custom installation - step 3 I have no idea what to do! I've copy and paste the first code already now this is what i got ```` 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 } ```` and these are the only instructions You need to edit above code in such a way that the userid is stored in the $ses variable of the current user and null if the user is a guest Then replace $ses=0; in your copy-pasted code with your edited code so this is what I've done go to the first code and look for ```` $ses=null; ```` then change it to ```` $ses=0; ```` then i got this message ":( Could not authenticate user . Please verify your edited copy-paste code and make any required changes " Please help me

What does your website use to store the user id of the current logged in user ?

If your website stores the user in session like this .

$_SESSION['user_id'] = 12;

Where 12 is the current user's user id which can be fetched from the database during login .
And if the user is not yet logged in , there is no data in session

Assuming above case , your code will look like below :

if(isset($_SESSION['user_id']))
{ 
    $ses = $_SESSION['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", null, time()+3600, "/"); // *do not change -> freichat code
}

Let us know if you still have any problems

What does your website use to store the user id of the current logged in user ? If your website stores the user in session like this . ```` $_SESSION['user_id'] = 12; ```` Where _12_ is the current user's user id which can be fetched from the database during login . And if the user is not yet logged in , there is no data in session Assuming above case , your code will look like below : ```` if(isset($_SESSION['user_id'])) { $ses = $_SESSION['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", null, time()+3600, "/"); // *do not change -> freichat code } ```` Let us know if you still have any problems
Necessity is the mother of all inventions!

well that's great but where do I make these changes? is it from the first set of codes that must go in header files? or is it somewhere else? And also I see in my login.php file it shows "userid" instead of 'user_id' I don't know if that makes a different? I want this so bad that i'm willing to try anything.

Anticipating thanks

well that's great but where do I make these changes? is it from the first set of codes that must go in header files? or is it somewhere else? And also I see in my login.php file it shows "userid" instead of 'user_id' I don't know if that makes a different? I want this so bad that i'm willing to try anything. Anticipating thanks

Hi,

If you remember , during the installation i.e before you reached this step , you had to copy/paste some lines of code something like :

                    <!--===========================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
$ses=null;

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

       if(is_file("/opt/lampp/htdocs/j3/freichat/hardcode.php")){

               require "/opt/lampp/htdocs/j3/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://localhost/j3/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script>
    <link rel="stylesheet" href="http://localhost/j3/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">
<!--===========================FreiChatX=======END=========================-->

I assume you have copy/pasted the above code in the header file .

Now, the code in our current step i.e

if(isset($_SESSION['user_id']))
{ 
    $ses = $_SESSION['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", null, time()+3600, "/"); // *do not change -> freichat code
}

will be merged before that but after the <?php tag

So the final result will look like


<?php

if(isset($_SESSION['user_id']))
{ 
    $ses = $_SESSION['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", null, time()+3600, "/"); // *do not change -> freichat code
}  

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

       if(is_file("/opt/lampp/htdocs/j3/freichat/hardcode.php")){

               require "/opt/lampp/htdocs/j3/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://localhost/j3/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script>
    <link rel="stylesheet" href="http://localhost/j3/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">
<!--===========================FreiChatX=======END=========================-->

Don't just copy paste above code , i have given so that you understand the format and the order of the code .

And also I see in my login.php file it shows "userid" instead of 'user_id'

That makes a difference . It should be according to your login.php
What i gave was just code for your reference . So if it is userid , then change the code to reflect that .

So

$_SESSION['user_id']

will become

$_SESSION['userid']
Hi, If you remember , during the installation i.e before you reached this step , you had to copy/paste some lines of code something like : ```` &amp;lt;!--===========================FreiChat=======START=========================--&amp;gt; &amp;lt;!-- For uninstalling ME , first remove/comment all FreiChat related code i.e below code Then remove FreiChat tables frei_session &amp; frei_chat if necessary The best/recommended way is using the module for installation --&amp;gt; &amp;lt;?php $ses=null; if(!function_exists(&quot;freichatx_get_hash&quot;)){ function freichatx_get_hash($ses){ if(is_file(&quot;/opt/lampp/htdocs/j3/freichat/hardcode.php&quot;)){ require &quot;/opt/lampp/htdocs/j3/freichat/hardcode.php&quot;; $temp_id = $ses . $uid; return md5($temp_id); } else { echo &quot;&amp;lt;script&amp;gt;alert(&#039;module freichatx says: hardcode.php file not found!&#039;);&amp;lt;/script&amp;gt;&quot;; } return 0; } } ?&amp;gt; &amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascipt&quot; src=&quot;http://localhost/j3/freichat/client/main.php?id=&amp;lt;?php echo $ses;?&amp;gt;&amp;xhash=&amp;lt;?php echo freichatx_get_hash($ses); ?&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;http://localhost/j3/freichat/client/jquery/freichat_themes/freichatcss.php&quot; type=&quot;text/css&quot;&amp;gt; &amp;lt;!--===========================FreiChatX=======END=========================--&amp;gt; ```` I assume you have copy/pasted the above code in the header file . Now, the code in our current step i.e ```` if(isset($_SESSION[&#039;user_id&#039;])) { $ses = $_SESSION[&#039;user_id&#039;] //tell freichat the userid of the current user setcookie(&quot;freichat_user&quot;, &quot;LOGGED_IN&quot;, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code } else { $ses = null; //tell freichat that the current user is a guest setcookie(&quot;freichat_user&quot;, null, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code } ```` will be merged before that but after the &amp;lt;?php tag So the final result will look like ```` &amp;lt;?php if(isset($_SESSION[&#039;user_id&#039;])) { $ses = $_SESSION[&#039;user_id&#039;] //tell freichat the userid of the current user setcookie(&quot;freichat_user&quot;, &quot;LOGGED_IN&quot;, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code } else { $ses = null; //tell freichat that the current user is a guest setcookie(&quot;freichat_user&quot;, null, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code } if(!function_exists(&quot;freichatx_get_hash&quot;)){ function freichatx_get_hash($ses){ if(is_file(&quot;/opt/lampp/htdocs/j3/freichat/hardcode.php&quot;)){ require &quot;/opt/lampp/htdocs/j3/freichat/hardcode.php&quot;; $temp_id = $ses . $uid; return md5($temp_id); } else { echo &quot;&amp;lt;script&amp;gt;alert(&#039;module freichatx says: hardcode.php file not found!&#039;);&amp;lt;/script&amp;gt;&quot;; } return 0; } } ?&amp;gt; &amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascipt&quot; src=&quot;http://localhost/j3/freichat/client/main.php?id=&amp;lt;?php echo $ses;?&amp;gt;&amp;xhash=&amp;lt;?php echo freichatx_get_hash($ses); ?&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;http://localhost/j3/freichat/client/jquery/freichat_themes/freichatcss.php&quot; type=&quot;text/css&quot;&amp;gt; &amp;lt;!--===========================FreiChatX=======END=========================--&amp;gt; ```` Don&#039;t just copy paste above code , i have given so that you understand the format and the order of the code . &amp;gt;And also I see in my login.php file it shows &quot;userid&quot; instead of &#039;user_id&#039; That makes a difference . It should be according to your login.php What i gave was just code for your reference . So if it is userid , then change the code to reflect that . So ```` $_SESSION[&#039;user_id&#039;] ```` will become ```` $_SESSION[&#039;userid&#039;] ````
Necessity is the mother of all inventions!

Hi thanks a lot however i've followed everything to the letter yet i'm still having the same message
smile Could not authenticate user . Please verify your edited copy-paste code and make any required changes

So here is a copy of my final code that I've placed on my site, maybe I've missed something please help me out

<!--===========================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(isset($_SESSION['userid']))
{ 
    $ses = $_SESSION['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
}  

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

       if(is_file("/opt/lampp/htdocs/j3/freichat/hardcode.php")){

               require "/opt/lampp/htdocs/j3/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://localhost/j3/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script>
    <link rel="stylesheet" href="http://localhost/j3/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">
<!--===========================FreiChatX=======END=========================-->
Hi thanks a lot however i&#039;ve followed everything to the letter yet i&#039;m still having the same message :( Could not authenticate user . Please verify your edited copy-paste code and make any required changes So here is a copy of my final code that I&#039;ve placed on my site, maybe I&#039;ve missed something please help me out ```` &amp;lt;!--===========================FreiChat=======START=========================--&amp;gt; &amp;lt;!-- For uninstalling ME , first remove/comment all FreiChat related code i.e below code Then remove FreiChat tables frei_session &amp; frei_chat if necessary The best/recommended way is using the module for installation --&amp;gt; &amp;lt;?php if(isset($_SESSION[&#039;userid&#039;])) { $ses = $_SESSION[&#039;userid&#039;] //tell freichat the userid of the current user setcookie(&quot;freichat_user&quot;, &quot;LOGGED_IN&quot;, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code } else { $ses = null; //tell freichat that the current user is a guest setcookie(&quot;freichat_user&quot;, null, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code } if(!function_exists(&quot;freichatx_get_hash&quot;)){ function freichatx_get_hash($ses){ if(is_file(&quot;/opt/lampp/htdocs/j3/freichat/hardcode.php&quot;)){ require &quot;/opt/lampp/htdocs/j3/freichat/hardcode.php&quot;; $temp_id = $ses . $uid; return md5($temp_id); } else { echo &quot;&amp;lt;script&amp;gt;alert(&#039;module freichatx says: hardcode.php file not found!&#039;);&amp;lt;/script&amp;gt;&quot;; } return 0; } } ?&amp;gt; &amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascipt&quot; src=&quot;http://localhost/j3/freichat/client/main.php?id=&amp;lt;?php echo $ses;?&amp;gt;&amp;xhash=&amp;lt;?php echo freichatx_get_hash($ses); ?&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;http://localhost/j3/freichat/client/jquery/freichat_themes/freichatcss.php&quot; type=&quot;text/css&quot;&amp;gt; &amp;lt;!--===========================FreiChatX=======END=========================--&amp;gt; ````

Hi,

Looking at your final code:

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

The above url looks wrong , as you can see it is

"http://localhost/j3/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>

Is your website installed in http://localhost/j3 ?

Hi, Looking at your final code: ```` &amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascipt&quot; src=&quot;http://localhost/j3/freichat/client/main.php?id=&amp;lt;?php echo $ses;?&amp;gt;&amp;xhash=&amp;lt;?php echo freichatx_get_hash($ses); ?&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;http://localhost/j3/freichat/client/jquery/freichat_themes/freichatcss.php&quot; type=&quot;text/css&quot;&amp;gt; ```` The above url looks wrong , as you can see it is ```` &quot;http://localhost/j3/freichat/client/main.php?id=&amp;lt;?php echo $ses;?&amp;gt;&amp;xhash=&amp;lt;?php echo freichatx_get_hash($ses); ?&amp;gt; ```` Is your website installed in ````http://localhost/j3```` ?
Necessity is the mother of all inventions!

ok I've made the domain name correction but I'm still having the same issue

here is the updated code

<!--===========================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(isset($_SESSION['userid']))
{ 
    $ses = $_SESSION['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
$ses=null;

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

       if(is_file("/home/circuits/public_html/zone509.info/freichat/hardcode.php")){

               require "/home/circuits/public_html/zone509.info/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://zone509.info/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script>
    <link rel="stylesheet" href="http://zone509.info/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">
<!--===========================FreiChatX=======END=========================-->

and this is the error message that i'm getting
smile Could not authenticate user . Please verify your edited copy-paste code and make any required changes

hey one last thing can i make an installation request by providing my Cpanel credentials? how to proceed

ok I&#039;ve made the domain name correction but I&#039;m still having the same issue here is the updated code ```` &amp;lt;!--===========================FreiChat=======START=========================--&amp;gt; &amp;lt;!-- For uninstalling ME , first remove/comment all FreiChat related code i.e below code Then remove FreiChat tables frei_session &amp; frei_chat if necessary The best/recommended way is using the module for installation --&amp;gt; &amp;lt;?php if(isset($_SESSION[&#039;userid&#039;])) { $ses = $_SESSION[&#039;userid&#039;] //tell freichat the userid of the current user setcookie(&quot;freichat_user&quot;, &quot;LOGGED_IN&quot;, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code } else { $ses = null; //tell freichat that the current user is a guest setcookie(&quot;freichat_user&quot;, null, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code $ses=null; if(!function_exists(&quot;freichatx_get_hash&quot;)){ function freichatx_get_hash($ses){ if(is_file(&quot;/home/circuits/public_html/zone509.info/freichat/hardcode.php&quot;)){ require &quot;/home/circuits/public_html/zone509.info/freichat/hardcode.php&quot;; $temp_id = $ses . $uid; return md5($temp_id); } else { echo &quot;&amp;lt;script&amp;gt;alert(&#039;module freichatx says: hardcode.php file not found!&#039;);&amp;lt;/script&amp;gt;&quot;; } return 0; } } ?&amp;gt; &amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascipt&quot; src=&quot;http://zone509.info/freichat/client/main.php?id=&amp;lt;?php echo $ses;?&amp;gt;&amp;xhash=&amp;lt;?php echo freichatx_get_hash($ses); ?&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;http://zone509.info/freichat/client/jquery/freichat_themes/freichatcss.php&quot; type=&quot;text/css&quot;&amp;gt; &amp;lt;!--===========================FreiChatX=======END=========================--&amp;gt; ```` and this is the error message that i&#039;m getting :( Could not authenticate user . Please verify your edited copy-paste code and make any required changes hey one last thing can i make an installation request by providing my Cpanel credentials? how to proceed

Hi,

We looked at your website , and found out that the PHP code of freichat that you copy/pasted is not being executed .

This may happen if you copy/paste the code in .html files . Make sure that the file you have copy/pasted has a .php extension .

If it is not possible to copy/paste the code in a .php file , then there is another way , but that will require some more changes to the code .

Hi, We looked at your website , and found out that the PHP code of freichat that you copy/pasted is not being executed . This may happen if you copy/paste the code in **.html** files . Make sure that the file you have copy/pasted has a **.php** extension . If it is not possible to copy/paste the code in a **.php** file , then there is another way , but that will require some more changes to the code .
Necessity is the mother of all inventions!

hi
I've removed it originally because there was a portion of the code which was visible to everyone

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 $ses=null; if(!function_exists("freichatx_get_hash")){ function freichatx_get_hash($ses){ if(is_file("/home/circuits/public_html/zone509.info/freichat/hardcode.php")){ require "/home/circuits/public_html/zone509.info/freichat/hardcode.php"; $temp_id = $ses . $uid; return md5($temp_id); } else { echo ""; } return 0; } } ?> - See more at: http://zone509.info/author/index.php#sthash.MDaZsr3J.dpuf

this is still the case. now the codes have been place to my header.php file right after the <head> tag

hi I&#039;ve removed it originally because there was a portion of the code which was visible to everyone ```` freichat code } else { $ses = null; //tell freichat that the current user is a guest setcookie(&quot;freichat_user&quot;, null, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code $ses=null; if(!function_exists(&quot;freichatx_get_hash&quot;)){ function freichatx_get_hash($ses){ if(is_file(&quot;/home/circuits/public_html/zone509.info/freichat/hardcode.php&quot;)){ require &quot;/home/circuits/public_html/zone509.info/freichat/hardcode.php&quot;; $temp_id = $ses . $uid; return md5($temp_id); } else { echo &quot;&quot;; } return 0; } } ?&amp;gt; - See more at: http://zone509.info/author/index.php#sthash.MDaZsr3J.dpuf ```` this is still the case. now the codes have been place to my header.php file right after the &amp;lt;head&amp;gt; tag

Can you send us your header.php file ? You can send it via email .

Can you send us your header.php file ? You can send it via email .
Necessity is the mother of all inventions!
589
9
0
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft