I've created an AuthMod for my custom CMS by looking at the other authMods and modifying to suit. I reinstalled x7 chat to configure it to use the new authmod. However, after logging in to the website successfully, I go into /chat and it still takes me to the "login" screen. Obviously I need to fix something in the authMods, but I'm unsure of what!
I have tested the database calls to the CMS database via PHP MyAdmin, so I know these work. And I have checked to make sure the cookies exist with the right names. I have put echoes in the 3 custom functions in the authmod file to see if any of the functions are being called, and it does not appear that any are!
Here is my AuthMod. I'd greatly appreciate it if someone could have a look and let me know where I might be going wrong.
<?PHP
$auth_ucookie = "name"; // Name of username cookie
$auth_pcookie = "pass"; // Name of password cookie
$auth_register_link = "../join_now.php"; // Link to the registration Page
$auth_disable_guest = true; // Disable guest accounts
// Any Cookie-Translations will have to go here
session_start();
require("../ci.php"); //file defining values of dbhost, dbuser, dbpass and dbdb
$zestCms = new x7chat_db($dbhost,$dbuser,$dbpass,$dbdb);
function auth_encrypt($data){
echo "encrypt called!";
// Encrypt $data
return md5($data);
//return $data;
}
function auth_getpass($auth_ucookie){
// Get the password for user $_COOKIE[$auth_ucookie] (the user's username)
echo "getpass called!";
GLOBAL $db,$prefix,$zestCms,$g_default_settings,$txt,$x7c;
$query = $zestCms->doQuery("SELECT password FROM users WHERE username = '".$username."' ");
$password = $zestCms->Do_Fetch_Row($query);
if($password[0] != ""){
$query = $db->DoQuery("SELECT * FROM {$prefix}users WHERE username='$_COOKIE[$auth_ucookie]'");
$row = $db->Do_Fetch_Row($query);
if($row[0] == ""){
// Create an X7 Chat account for them.
$time = time();
$ip = $_SERVER['REMOTE_ADDR'];
$db->DoQuery("INSERT INTO {$prefix}users (id,username,password,status,user_group,time,settings,hideemail,ip) VALUES('0','$_COOKIE[$auth_ucookie]','$password[0]','$txt[150]','{$x7c->settings['usergroup_default']}','$time','{$g_default_settings}','0','$ip')");
}
}
return $password[0];
}
function change_pass($user,$newpass){
// Change $user's password to $newpass
echo "change pass called!";
GLOBAL $zestCms;
$query = $zestCms->DoQuery("UPDATE users SET password = '$newpass' WHERE username='$user'");
}
?>