Here is the script that I am currently using.. Anyone see why this code would not pass the password to the Raidersoft server?? Should I be using $md5password in the chatbit template??? I have tested that too, but it still will not auth.. any help is greatly appreciated!
PHP Code:
<?php
/*
SigmaChat Authentication Script v1.0
Tested with vBulletin 2.3.0, SigmaChat Platinum 7.1
Copyright (C) 2003, RaiderSoft. All Rights Reserved.
This script allows you to authenticate access to your SigmaChat
Java Chat room via a vBulletin MySQL database.
Place this file in the same directory as your vBulletin config.php
file (usually /upload/admin/)
This software is free for commercial, non-profit, and individual use.
Please read included README.txt file for installation instructions.
RaiderSoft Support Team
support@raidersoft.com
*/
require_once('../admin/config.php');
$username = dbparam("username");
$password = dbparam("password");
$ip = param("ip");
$usergroupid = -1;
$retval = 0;
header('Content-type: text/plain');
db_connect();
$md5password = md5($password);
$query1 = "SELECT usergroupid FROM user WHERE username='$username' AND PASSWORD='$md5password'";
$result = mysql_query($query1, $dbcxn);
if($row = mysql_fetch_row($result))
{
$usergroupid = $row[0];
@mysql_free_result($result);
$query2 = "SELECT canpostnew, cancontrolpanel FROM usergroup WHERE usergroupid=$usergroupid";
$result = mysql_query($query2, $dbcxn);
if($row = mysql_fetch_row($result))
{
$canpostnew = int($row[0]);
$cancontrolpanel = int($row[1]);
if($canpostnew > 0) { $retval = 1; }
if($cancontrolpanel > 0) { $retval = 2; }
}
}
echo "$retval\n";
db_disconnect();
/*
Database Related Functions...
*/
function db_connect()
{
global $dbcxn;
global $servername, $dbusername, $dbpassword, $dbname;
if(!($dbcxn = mysql_connect($servername, $dbusername, $dbpassword)))
dferror("db_connect:mysql_connect");
if(!(mysql_select_db("$dbname", $dbcxn)))
auth_error("Error connecting to database.");
}
function db_disconnect()
{
global $dbcxn;
@mysql_close($dbcxn);
}
function db_executeQuery($query)
{
global $dbcxn;
$result = mysql_query($query, $dbcxn);
@mysql_free_result($result);
}
function auth_error($errorstr)
{
echo $errorstr;
}
/*
CGI, Misc.. Related Functions...
*/
function param($cgiparam)
{
$value = isset($_POST[$cgiparam])
? $_POST[$cgiparam]
: $_GET[$cgiparam];
return ini_get('magic_quotes_gpc')
? stripslashes($value)
: $value;
}
function dbparam($cgiparam)
{
$value = isset($_POST[$cgiparam])
? $_POST[$cgiparam]
: $_GET[$cgiparam];
return $value;
}
function int($strval)
{
return intval($strval);
}
?>