Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: MOD Implementation
 Having Cookie issues .... "CuteChat with Snitz"
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

lovduv
Starting Member

40 Posts

Posted - 09 March 2007 :  21:47:25  Show Profile
I am trying to get CuteChat to work with snitz, my forum is in a folder that is not a virtual directory, so CuteChat has to be stored outside my forum folder. I am testing this on a MSSQL DB.

I have the chat working, but it treats a user as a guest.
i.e I am logged in, but CuteChat doesn't recognize this.

I spoke with Adam at CuteChat and he is trying to help me, but he is not familiar enough with Snitz. This is what he had to say and the post over there he directed me to:
quote:


I know it's a cookie path issue.

But I can't figure out the solution because I am not familiar with Snitz forum.

I am asking help from another user right now.

http://cutesoft.net/forums/thread/26790.aspxhttp://cutesoft.net/forums/thread/26790.aspx[url]



The other user is not responding, any ideas on how I can get this working?

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 10 March 2007 :  03:59:55  Show Profile  Visit HuwR's Homepage
If i remember correctly cutechat has to be in your Snitz directory

http://cutesoft.net/ASP.NET+Chat/Developer-Guide/deploymensnitz.htm
Go to Top of Page

lovduv
Starting Member

40 Posts

Posted - 10 March 2007 :  05:35:36  Show Profile
It does say to do that in their read me, however according to their support, it can be outside the forum folder. Adam says that another cutechat user had this problem on shared hosting. Something to do with the cookie name. This cutechat user solved his problem, but this was all he posted:
quote:

Problem solved.

Indeed it is the name of the cookie. The application has to be a root application (why is that not mentioned in the documentation).



Does that mean the only way he fixed it was to put everything in the snitz forum folder?

I don't even know where to start with "cookie path" and "cookie name" issues, would that be the snitz cookie or the cutechat script reading the cookie? I am determined to get this working as chat adds value to my site, and I need a robust solution. With cutechat using asp.net and AJAX, this seems the way to go...Do you of another good chat program, that will work on shared hosting, snitz, and MSSQL?

Adam tried getting a hold of this user to no avail. The cutechat works really well, if it would only read my users cookie correctly. :\
Go to Top of Page

lovduv
Starting Member

40 Posts

Posted - 10 March 2007 :  05:45:46  Show Profile
I went ahead and added the code for cutechats web.config file and the global.asax file. Somewhere in here I need to change a path so that cutechat will read the snitz cookie. My forum folder is titled: forum_copy(1)

This is web.config
quote:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SnitzUniqueID" value="Snitz00" />
<add key="SnitzPrefix" value="FORUM_" />
<add key="ConnectionString" value="xxxxx;database=xxxxx;uid=xxxxx;pwd=xxxxxx" />
<add key="CuteChat.DataDirectory" value="/CuteChat" />
</appSettings>
<system.web>
<compilation defaultLanguage="c#" debug="false" />
<customErrors mode="Off" />
<authentication mode="None" />
<trace enabled="false" requestLimit="100" pageOutput="false" localOnly="true" />
<sessionState mode="Off" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
</configuration>



Here is the global.asax
quote:

<%@ Application ClassName="Global" %>
<%@ Implements Interface="CuteSoft.Chat.IHttpApplicationConnectionStringProvider" %>
<%@ Implements Interface="CuteSoft.Chat.IHttpApplicationUserAdapter" %>
<%@ Implements Interface="CuteSoft.Chat.IHttpApplicationDataProvider" %>
<%@ Implements Interface="CuteSoft.Chat.IHttpApplicationSupportLogin" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Security.Cryptography"%>
<%@ Import Namespace="CuteSoft.Chat" %>

<script runat=server>


static string _connstr;
public string ConnectionString
{
get
{
if(_connstr==null)
{
string connstr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
if(connstr==null||connstr=="")
{
throw(new Exception("Missing web.config appSettings : ConnectionString"));
}
_connstr=connstr;
}
return _connstr;
}
}
public SqlConnection CreateConnection()
{
return new SqlConnection(ConnectionString);
}
private void FillParameters(SqlCommand cmd,object[] parameters)
{
if(parameters==null)return;
for(int i=0;i<parameters.Length;i++)
{
SqlParameter param;
object pvalue=parameters[i];
if(pvalue==null||Convert.IsDBNull(pvalue))
{
param=new SqlParameter("@p"+i,SqlDbType.NVarChar,50);
param.Value=DBNull.Value;
}
else if(pvalue is string)
{
param=new SqlParameter("@p"+i,SqlDbType.NVarChar,pvalue.ToString().Length+100);
param.Value=pvalue;
}
else if(pvalue is SqlParameter)
{
param=(SqlParameter)pvalue;
}
else
{
param=new SqlParameter("@p"+i,(object)pvalue);
}
cmd.Parameters.Add(param);
}
}
public SqlCommand CreateCommand(string cmdtext,params object[] parameters)
{
SqlCommand cmd = new SqlCommand(cmdtext,CreateConnection());
FillParameters(cmd,parameters);
return cmd;
}
public SqlDataAdapter CreateAdapter(string cmdtext,params object[] parameters)
{
SqlCommand cmd = new SqlCommand(cmdtext,CreateConnection());
FillParameters(cmd,parameters);
return new SqlDataAdapter(cmd);
}
public SqlDataReader ExecuteReader(string cmdtext,params object[] parameters)
{
SqlCommand cmd = new SqlCommand(cmdtext,CreateConnection());
FillParameters(cmd,parameters);
cmd.Connection.Open();
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
public object ExecuteScaler(string cmdtext,params object[] parameters)
{
SqlCommand cmd = new SqlCommand(cmdtext,CreateConnection());
FillParameters(cmd,parameters);
cmd.Connection.Open();
using(SqlDataReader sdr=cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
if(!sdr.Read())
return null;

if(sdr.IsDBNull(0))
return DBNull.Value;

return sdr.GetValue(0);
}
}

static string _prefix;
public string SnitzPrefix
{
get
{
if(_prefix==null)
{
string pre = System.Configuration.ConfigurationSettings.AppSettings["SnitzPrefix"];
if(pre==null||pre=="")
{
throw(new Exception("Missing web.config appSettings : SnitzPrefix"));
}
_prefix=pre;
}
return _prefix;
}
}

static string _snitzid;
public string SnitzID
{
get
{
if(_snitzid==null)
{
string id = System.Configuration.ConfigurationSettings.AppSettings["SnitzUniqueID"];
if(id==null||id=="")
{
throw(new Exception("Missing web.config appSettings : SnitzUniqueID"));
}
_snitzid=id;
}
return _snitzid;
}
}

public string SHA256(string str)
{
byte[] data=ConvertToWordArray(str);
byte[] hash;

SHA256Managed sha=new SHA256Managed();
try
{
hash=sha.ComputeHash(data);
}
finally
{
sha.Clear();
}
return BitConverter.ToString(hash).Replace("-","");
}

//Snitz/inc_sha256
private byte[] ConvertToWordArray(string str)
{
//OK,,Only support ascii code , for the password only..
return System.Text.Encoding.ASCII.GetBytes(str);
}

public bool CheckUser(string username,string pwdencry)
{
if(username==null||username=="")return false;
if(pwdencry==null||pwdencry=="")return false;

using(SqlDataReader sdr=ExecuteReader("SELECT M_PASSWORD FROM "+SnitzPrefix+"MEMBERS WHERE M_NAME=@p0 AND M_STATUS=1"
,username))
{
if(!sdr.Read())
return false;

string pwd=sdr.GetString(0);

if(pwd==null||pwd=="")
return false;

return pwd.ToUpper()==pwdencry.ToUpper();
}
}

//Public Property/Method for...

#region CuteSoft.Chat.IHttpApplication..

public string GetConnectionString(CuteSoft.Chat.UserIdentity user)
{
return ConnectionString;
}

public string GetUserUniqueName()
{
HttpCookie cookie = Request.Cookies[SnitzID+"User"];
if(cookie==null)
return null;

string username=cookie["Name"];
string pwdencry=cookie["Pword"];

if(CheckUser(username,pwdencry))
return username;

return null;
}

public CuteSoft.Chat.UserIdentity GetUserIdentity()
{
string uniquename=GetUserUniqueName();
if(uniquename==null)
return CuteSoft.Chat.UserIdentity.CreateNull();

return new CuteSoft.Chat.UserIdentity(uniquename,null,Request.UserHostAddress);
}


public bool IsLobbyAdmin(string useruniquename, CuteSoft.Chat.CuteChatLobby lobby)
{
return false;
}

public string[] SearchUserUniqueNameByDisplayName(string userDisplaName)
{
if(userDisplaName==null||userDisplaName=="")
return new string[0];

ArrayList list=new ArrayList();
using(SqlDataReader sdr=ExecuteReader("SELECT M_NAME FROM "+SnitzPrefix+"MEMBERS WHERE M_NAME LIKE '%'+@p0+'%'"
,userDisplaName))
{
while(sdr.Read())
list.Add(sdr.GetString(0));
}
return (string[])list.ToArray(typeof(string));
}

public string GetUserDisplayName(string useruniquename)
{
return useruniquename;
}

public bool IsAdministrator(string useruniquename)
{
//M_LEVEL>3
object level=ExecuteScaler("SELECT M_LEVEL FROM "+SnitzPrefix+"MEMBERS WHERE M_NAME=@p0"
,useruniquename);
if(level==null)
return false;

return Convert.ToInt32(level)>=3;
}

public string[] ListUserUniqueName()
{
ArrayList list=new ArrayList();
using(SqlDataReader sdr=ExecuteReader("SELECT M_NAME FROM "+SnitzPrefix+"MEMBERS"))
{
while(sdr.Read())
list.Add(sdr.GetString(0));
}
return (string[])list.ToArray(typeof(string));
}


public void SupportInit()
{
}

public bool SupportLogin(string username, string password)
{
if(username==null||username=="")return false;
if(password==null||password=="")return false;

password=SHA256(password);

if( ! CheckUser(username,password) )
return false;

if( CuteSoft.Chat.ChatApi.FindOperator(username) == null )
return false;

HttpCookie cookie=Response.Cookies[SnitzID+"User"];
cookie["Name"]=username;
cookie["Pword"]=password;//encrypted..

return true;
}

#endregion

</script>

Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 10 March 2007 :  06:06:37  Show Profile  Visit HuwR's Homepage
in your forums "Admin Options", do you have "Set Cookie To" set to website or forum ?

if you have it set to forum, try setting it to website.

other than that I have no idea, if CuteChat advertise their product as being Snitz compatible then it is up to them to figure out your problem not us, you are after all paying for their product.
Go to Top of Page

lovduv
Starting Member

40 Posts

Posted - 10 March 2007 :  07:08:43  Show Profile
I will try the changing for the cookies.
Thanks for trying HuwR at least you are giving me some ideas....I love how the support guy Adam said:
quote:

I know it's a cookie path issue.

But I can't figure out the solution because I am not familiar with Snitz forum.



Well who is at your company, then? Someone had to create the snitz cutechat version!
I agree don't tout your product as being snitz compatible and not have instructions that cover all your users. Thankfully I was using the trial version (which you have to ask for the trial license), 300.00 is alot to spend and have it not work. I am sure that I am not the only person on shared hosting, that is having this problem or had a problem.

Anyway I love Snitz, you guys did an amazing job! I knew that someone would try and help me here! If I get anywhere I will post back with a solution.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 10 March 2007 :  07:15:42  Show Profile  Visit HuwR's Homepage
let me know if changing the cookie mode in Snitz doesn't work, I will try and think of something else to try
Go to Top of Page

lovduv
Starting Member

40 Posts

Posted - 10 March 2007 :  07:24:59  Show Profile
Darn....no, didn't work.
I did have my cookies set to forum, though, and I bet they do have to be set to the site, when cutechat is outside the forum folder. That just makes sense, so I have left cookies set to the site for now.

In the above code for web.config this catches my eye:
<add key="SnitzPrefix" value="FORUM_" />

In the script for global.asax it has code like this:
ArrayList list=new ArrayList();
using(SqlDataReader sdr=ExecuteReader("SELECT M_NAME FROM "+SnitzPrefix+"MEMBERS WHERE M_NAME LIKE '%'+@p0+'%'"
,userDisplaName))

If their code is going to ask for data using "SnitzPrefix" wouldn"t that "prefix" need to be my forum folder name?
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 10 March 2007 :  09:43:55  Show Profile  Visit JJenson's Homepage
Lovduv someone a while back implemented I think conquer chat with snitz if you look around I am sure you will find some posts about it and how to do it. I am not sure if that helps but maybe it is a better option.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 10 March 2007 :  10:26:39  Show Profile  Visit HuwR's Homepage
you (and any other users) may need to clear your cookies in order to pick up any changes after re-setting the forums cookie mode.

no SnitzPrefix relates to the tablename prefix for the database, not your site folders
Go to Top of Page

lovduv
Starting Member

40 Posts

Posted - 10 March 2007 :  10:28:39  Show Profile
Darn.. I will go and clear out my cookies again just in case...

Thanks for that JJenson, I will definetly check that out if I can't get this to work. I have looked at several chat programs I chose cutechat, because it was "compatitable" with Snitz.

I thought it would be easy *sigh*

It really is a cool chat with alot of features, I am still hoping I can get it working with snitz log-in.

Edited by - lovduv on 10 March 2007 10:29:41
Go to Top of Page

lovduv
Starting Member

40 Posts

Posted - 10 March 2007 :  10:45:19  Show Profile
I rebooted my whole system, cleared cookies, and prayed....no luck, I could use it with anonymous access, but that is not what I wanted.

CuteChat needs better documentation.

Again *sigh*
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 10 March 2007 :  12:34:51  Show Profile  Visit HuwR's Homepage
have you tried installing snitz and cutechat into the same directory as it says in their installation guide ? I know you said
quote:
It does say to do that in their read me, however according to their support, it can be outside the forum folder.
but if that is the case then you should ask their support how to do it.
Go to Top of Page

lovduv
Starting Member

40 Posts

Posted - 10 March 2007 :  14:01:10  Show Profile
yeah, I tried it both ways in and out...

Support at cutechat says the guy who did the integration with snitz will be looking into this issue next week, I will let you know what happens.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.4 seconds. Powered By: Snitz Forums 2000 Version 3.4.07