FreiChat related discussions
Custom login not passing id

So basicly i have a custom php site,

Followed the steps of the intergration tutorial

All users stay as guest after loging in


Login Page

<?php // *******************************
// accesscontrol.php
//
// Login control for site
// *******************************

session_cache_expire( 360 );
if( session_id() == "" ) session_start();

include 'common.php';
include 'db.php';
include 'globals.inc.php';

if( !isset($_SESSION['UID']) & $_POST['username'] == "") {
?><!--==========================FreiChatX===START========================--><!-- For uninstalling ME , first remove/comment all FreiChatX related code i.e below code
Then remove FreiChatX tables frei_session & frei_chat if necessary
The best/recommended way is using the module for installation --><?php $ses=$_SESSION['UID'];

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

if(is_file("/home/buncombe/public_html/freichat/hardcode.php")){

require "/home/buncombe/public_html/freichat/hardcode.php";

$temp_id = $ses . $uid;

return md5($temp_id);

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

return 0;
}
}
?>
<script type="text/javascript" language="javascipt" src="http://buncombenotifier.us/freichat/client/main.php?id=<?php%20echo%20%24ses;?>&xhash=<?php%20echo%20freichatx_get_hash(%24ses);%20?>">
</script><link rel="stylesheet" href="http://buncombenotifier.us/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css"><!--===========================FreiChatX====END=========================--><title><?php echo $global_title; ?></title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><h1 align="center">Login Required</h1>
<p align="center">You must log in to access this area of the site.</p>
<p>
</p><form method="post" action="<?%20echo%20%24_SERVER%5B'PHP_SELF'%5D?>">
<table align="center"><tr><td align="right">User ID:</td>
<td><input type="text" name="username" size="8"></td>
</tr><tr><td align="right">Password:</td>
<td><input type="password" name="password" size="8"></td>
</tr><tr><td></td>
<td><input type="submit" value=" Log in "></td>
</tr></table></form>





<?php exit;
}

if( !isset($_SESSION['UID']) ) {
$_SESSION['UID'] = $_POST['username'];
$_SESSION['PWD'] = $_POST['password'];
$uid = $_SESSION['UID'];
$pwd = $_SESSION['PWD'];
} else {
$uid = $_SESSION['UID'];
$pwd = $_SESSION['PWD'];
}

dbConnect( $global_dbdata );

$sql = "select * from tblCADUser where cadUsername = '$uid' and cadPassword = md5('$pwd')";

$result = mysql_query($sql);
if (!$result) {
error("A database error occurred while checking your login details. If this error persists, please contact your administrator .");
}

if (mysql_num_rows($result) == 0) {
unset($_SESSION['UID']);
unset($_SESSION['PWD']);
?><title>
<?php echo $global_title; ?> - Access Denied</title>

Access Denied


Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click
here.




<?php exit;
}

$data = mysql_fetch_object($result);

$username = $data->cadUsername;
$accessLevel = $data->cadAccessLevel;
$_SESSION['id']= $data->id;

?>

Index Page

<?php // *******************************
// index.php
//
// Main index
// *******************************

include 'functions.php';
include 'accesscontrol.php';
include_once 'globals.inc.php';
include_once 'common.php';

if (!isset($_GET['class'])) $class = "";
else $class = $_GET['class'];

if (!isset($_GET['function'])) $function = "";
else $function = $_GET['function'];

?><!--==========================FreiChatX===START========================--><!-- For uninstalling ME , first remove/comment all FreiChatX related code i.e below code
Then remove FreiChatX tables frei_session & frei_chat if necessary
The best/recommended way is using the module for installation --><?php $ses=$_SESSION['UID'];

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

if(is_file("/home/buncombe/public_html/freichat/hardcode.php")){

require "/home/buncombe/public_html/freichat/hardcode.php";

$temp_id = $ses . $uid;

return md5($temp_id);

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

return 0;
}
}
?>
<script type="text/javascript" language="javascipt" src="http://buncombenotifier.us/freichat/client/main.php?id=<?php%20echo%20%24ses;?>&xhash=<?php%20echo%20freichatx_get_hash(%24ses);%20?>">
</script><link rel="stylesheet" href="http://buncombenotifier.us/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css"><!--===========================FreiChatX====END=========================--><title><?php if( $class == "calls" & $function == "manage" && isset($_GET['id']) ) {
include_once 'dbaccess.inc.php';
include_once 'error_process.inc.php';

$id = $_GET['id'];

echo "$global_title - ";

$sql = "select * from tblCallUnits join tblUnit on (tblCallUnits.callUnitsAssigned = tblUnit.unitID) where callUnitsCall = $id ";
$sql .= "and callUnitsActive = 1";

$result = mysql_query( $sql, $db );
if( !$result ) error_process( $db );

for( $x = 0; $x < mysql_num_rows( $result ); $x++ ) {
$data = mysql_fetch_object( $result );
echo "$data->unitCallSign ";
}
} else {
echo $global_title;
}

?>
</title><link rel="StyleSheet" href="dtree.css" type="text/css"><script type="text/javascript" src="dtree.js"></script><table align="center" cellspacing="3" width="100%"><tr><td width="20%" align="center">
<a href="index.php"><?php //<img src="img/logo.jpg" alt="Logo" border=0>?></a>
</td>
<td width="80%">
<h1 align="center"><?php echo $global_title; ?> Administration</h1>
</td>
</tr><tr><td width="20%" valign="top">
<?php include 'menu.inc.php'; ?></td>
<td width="80%" valign="top">
<?php if( $class == "inquiry" & $accessLevel >= 0 ) include 'inquiry.php';
if( $class == "calls" && $accessLevel >= 1 ) include 'calls.php';
if( $class == "address" && $accessLevel >= 2 ) include 'address.php';
if( $class == "reports" && $accessLevel >= 2 ) include 'reports.php';
if( $class == "system" && $accessLevel >= 3 ) include 'system.php';
if( $class == "logout" && $accessLevel >= 0 ) include 'logout.php';
?>
</td>
</tr></table><?php echo $_SESSION['id'] ?>


Any ideas
Thanks in advanced
!!!!
So basicly i have a custom php site, Followed the steps of the intergration tutorial All users stay as guest after loging in Login Page &amp;lt;code&amp;gt; &amp;lt;?php // ******************************* // accesscontrol.php // // Login control for site // ******************************* session_cache_expire( 360 ); if( session_id() == &quot;&quot; ) session_start(); include &#039;common.php&#039;; include &#039;db.php&#039;; include &#039;globals.inc.php&#039;; if( !isset($_SESSION[&#039;UID&#039;]) &amp;&amp; $_POST[&#039;username&#039;] == &quot;&quot;) { ?&amp;gt; &amp;lt;html&amp;gt; &amp;lt;head&amp;gt; &amp;lt;!--==========================FreiChatX===START========================--&amp;gt; &amp;lt;!-- For uninstalling ME , first remove/comment all FreiChatX related code i.e below code Then remove FreiChatX tables frei_session &amp; frei_chat if necessary The best/recommended way is using the module for installation --&amp;gt; &amp;lt;?php $ses=$_SESSION[&#039;UID&#039;]; if(!function_exists(&quot;freichatx_get_hash&quot;)){ function freichatx_get_hash($ses){ if(is_file(&quot;/home/buncombe/public_html/freichat/hardcode.php&quot;)){ require &quot;/home/buncombe/public_html/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://buncombenotifier.us/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://buncombenotifier.us/freichat/client/jquery/freichat_themes/freichatcss.php&quot; type=&quot;text/css&quot;&amp;gt; &amp;lt;!--===========================FreiChatX====END=========================--&amp;gt; &amp;lt;title&amp;gt;&amp;lt;?php echo $global_title; ?&amp;gt;&amp;lt;/title&amp;gt; &amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;&amp;gt; &amp;lt;/head&amp;gt; &amp;lt;body text=&quot;color_white&quot; bgcolor=&quot;#000000&quot;&amp;gt; &amp;lt;h1 align=center&amp;gt;Login Required&amp;lt;/h1&amp;gt; &amp;lt;p align=center&amp;gt;You must log in to access this area of the site.&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt; &amp;lt;form method=&quot;post&quot; action=&quot;&amp;lt;? echo $_SERVER[&#039;PHP_SELF&#039;]?&amp;gt;&quot;&amp;gt; &amp;lt;table align=center&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;td align=right&amp;gt;User ID:&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;text&quot; name=&quot;username&quot; size=&quot;8&quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;td align=right&amp;gt;Password:&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;password&quot; name=&quot;password&quot; SIZE=&quot;8&quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;submit&quot; value=&quot; Log in &quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/table&amp;gt; &amp;lt;/form&amp;gt;&amp;lt;/p&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;/html&amp;gt; &amp;lt;?php exit; } if( !isset($_SESSION[&#039;UID&#039;]) ) { $_SESSION[&#039;UID&#039;] = $_POST[&#039;username&#039;]; $_SESSION[&#039;PWD&#039;] = $_POST[&#039;password&#039;]; $uid = $_SESSION[&#039;UID&#039;]; $pwd = $_SESSION[&#039;PWD&#039;]; } else { $uid = $_SESSION[&#039;UID&#039;]; $pwd = $_SESSION[&#039;PWD&#039;]; } dbConnect( $global_dbdata ); $sql = &quot;select * from tblCADUser where cadUsername = &#039;$uid&#039; and cadPassword = md5(&#039;$pwd&#039;)&quot;; $result = mysql_query($sql); if (!$result) { error(&quot;A database error occurred while checking your login details. If this error persists, please contact your administrator .&quot;); } if (mysql_num_rows($result) == 0) { unset($_SESSION[&#039;UID&#039;]); unset($_SESSION[&#039;PWD&#039;]); ?&amp;gt; &amp;lt;html&amp;gt; &amp;lt;head&amp;gt; &amp;lt;title&amp;gt;&amp;lt;?php echo $global_title; ?&amp;gt; - Access Denied&amp;lt;/title&amp;gt; &amp;lt;/head&amp;gt; &amp;lt;body&amp;gt; &amp;lt;h1&amp;gt;Access Denied &amp;lt;/h1&amp;gt; &amp;lt;p&amp;gt;Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click &amp;lt;a href=&quot;&amp;lt;?=$_server[&#039;php_self&#039;]?&amp;gt;&quot;&amp;gt;here&amp;lt;/a&amp;gt;. &amp;lt;/p&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;/html&amp;gt; &amp;lt;?php exit; } $data = mysql_fetch_object($result); $username = $data-&amp;gt;cadUsername; $accessLevel = $data-&amp;gt;cadAccessLevel; $_SESSION[&#039;id&#039;]= $data-&amp;gt;id; ?&amp;gt;&amp;lt;/code&amp;gt; Index Page &amp;lt;code&amp;gt; &amp;lt;?php // ******************************* // index.php // // Main index // ******************************* include &#039;functions.php&#039;; include &#039;accesscontrol.php&#039;; include_once &#039;globals.inc.php&#039;; include_once &#039;common.php&#039;; if (!isset($_GET[&#039;class&#039;])) $class = &quot;&quot;; else $class = $_GET[&#039;class&#039;]; if (!isset($_GET[&#039;function&#039;])) $function = &quot;&quot;; else $function = $_GET[&#039;function&#039;]; ?&amp;gt; &amp;lt;html&amp;gt; &amp;lt;head&amp;gt; &amp;lt;!--==========================FreiChatX===START========================--&amp;gt; &amp;lt;!-- For uninstalling ME , first remove/comment all FreiChatX related code i.e below code Then remove FreiChatX tables frei_session &amp; frei_chat if necessary The best/recommended way is using the module for installation --&amp;gt; &amp;lt;?php $ses=$_SESSION[&#039;UID&#039;]; if(!function_exists(&quot;freichatx_get_hash&quot;)){ function freichatx_get_hash($ses){ if(is_file(&quot;/home/buncombe/public_html/freichat/hardcode.php&quot;)){ require &quot;/home/buncombe/public_html/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://buncombenotifier.us/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://buncombenotifier.us/freichat/client/jquery/freichat_themes/freichatcss.php&quot; type=&quot;text/css&quot;&amp;gt; &amp;lt;!--===========================FreiChatX====END=========================--&amp;gt; &amp;lt;title&amp;gt; &amp;lt;?php if( $class == &quot;calls&quot; &amp;&amp; $function == &quot;manage&quot; &amp;&amp; isset($_GET[&#039;id&#039;]) ) { include_once &#039;dbaccess.inc.php&#039;; include_once &#039;error_process.inc.php&#039;; $id = $_GET[&#039;id&#039;]; echo &quot;$global_title - &quot;; $sql = &quot;select * from tblCallUnits join tblUnit on (tblCallUnits.callUnitsAssigned = tblUnit.unitID) where callUnitsCall = $id &quot;; $sql .= &quot;and callUnitsActive = 1&quot;; $result = mysql_query( $sql, $db ); if( !$result ) error_process( $db ); for( $x = 0; $x &amp;lt; mysql_num_rows( $result ); $x++ ) { $data = mysql_fetch_object( $result ); echo &quot;$data-&amp;gt;unitCallSign &quot;; } } else { echo $global_title; } ?&amp;gt; &amp;lt;/title&amp;gt; &amp;lt;link rel=&quot;StyleSheet&quot; href=&quot;dtree.css&quot; type=&quot;text/css&quot;&amp;gt; &amp;lt;script type=&quot;text/javascript&quot; src=&quot;dtree.js&quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;/head&amp;gt; &amp;lt;body bgcolor=&quot;#C0C0C0&quot;&amp;gt; &amp;lt;table align=center cellspacing=3 width=100%&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;td width=20% align=center&amp;gt; &amp;lt;a href=&quot;index.php&quot;&amp;gt;&amp;lt;?php //&amp;lt;img src=&quot;img/logo.jpg&quot; alt=&quot;Logo&quot; border=0&amp;gt;?&amp;gt;&amp;lt;/a&amp;gt; &amp;lt;/td&amp;gt; &amp;lt;td width=80%&amp;gt; &amp;lt;h1 align=center&amp;gt;&amp;lt;?php echo $global_title; ?&amp;gt; Administration&amp;lt;/h1&amp;gt; &amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;td width=20% valign=top&amp;gt; &amp;lt;?php include &#039;menu.inc.php&#039;; ?&amp;gt; &amp;lt;/td&amp;gt; &amp;lt;td width=80% valign=top&amp;gt; &amp;lt;?php if( $class == &quot;inquiry&quot; &amp;&amp; $accessLevel &amp;gt;= 0 ) include &#039;inquiry.php&#039;; if( $class == &quot;calls&quot; &amp;&amp; $accessLevel &amp;gt;= 1 ) include &#039;calls.php&#039;; if( $class == &quot;address&quot; &amp;&amp; $accessLevel &amp;gt;= 2 ) include &#039;address.php&#039;; if( $class == &quot;reports&quot; &amp;&amp; $accessLevel &amp;gt;= 2 ) include &#039;reports.php&#039;; if( $class == &quot;system&quot; &amp;&amp; $accessLevel &amp;gt;= 3 ) include &#039;system.php&#039;; if( $class == &quot;logout&quot; &amp;&amp; $accessLevel &amp;gt;= 0 ) include &#039;logout.php&#039;; ?&amp;gt; &amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/table&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;?php echo $_SESSION[&#039;id&#039;] ?&amp;gt; &amp;lt;/html&amp;gt;&amp;lt;/code&amp;gt; Any ideas Thanks in advanced !!!!

as far as i can see, you are passing UID(username) in the index page to freichat, which is wrong, you must pass $_SESSION['id'] (unique id), this id is used by freichat to fetch the username.
you must also specify the user tablename, username column and the id column in freichat/hardcode.php

as far as i can see, you are passing UID(username) in the index page to freichat, which is wrong, you must pass $_SESSION[&#039;id&#039;] (unique id), this id is used by freichat to fetch the username. you must also specify the &amp;lt;strong&amp;gt;user tablename&amp;lt;/strong&amp;gt;, &amp;lt;strong&amp;gt;username column&amp;lt;/strong&amp;gt; and the &amp;lt;strong&amp;gt;id column&amp;lt;/strong&amp;gt; in freichat/hardcode.php
Necessity is the mother of all inventions!

Okay i changed it to pass the $_SESSION['id'] i also have the database stuff set but it still isn't passing the session, I check to make sure the ID was making it to the index page and its showing the correct id.

Okay i changed it to pass the $_SESSION[&#039;id&#039;] i also have the database stuff set but it still isn&#039;t passing the session, I check to make sure the ID was making it to the index page and its showing the correct id.

Check if freichat is actually getting the userid , by viewing your website source , search for the word client/main.php

You should see your userid here
client/main.php?id=YOUR_USER_ID

Also , enable PHP debug from the backend and check the file freixlog.log file in freichat/ directory for any errors.

Check if freichat is actually getting the userid , by viewing your website source , search for the word client/main.php You should see your userid here client/main.php?id=YOUR_USER_ID Also , enable PHP debug from the backend and check the file freixlog.log file in freichat/ directory for any errors.
Necessity is the mother of all inventions!
111
4
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