Oppure

Loading
19/04/10 20:02
cassin.simone
Salve a tutti, ho appena installato la famosa chat che sto integrando con joomla. Inseriti però i dati dell'utente joomla nel db della chat ho provato varie volte ma non sono riuscito ad impostare un cookie e una sessione che funzionino...
Naturalmente mi aspetto che nel cookie ci sia qualcosa che si colleghi alla sessione ma nella sessione...cosa c'è?
Grazie mille in anticipo...mi manca solo questo pezzo del puzzle...:k:
Ultima modifica effettuata da cassin.simone 20/04/10 11:33
aaa
20/04/10 3:24
pierotofy
Non ho capito. Spiegati meglio.
Il mio blog: piero.dev
20/04/10 11:34
cassin.simone
Postato originariamente da pierotofy:

Non ho capito. Spiegati meglio.


Va bene. Scusami ma ieri sera ero di fretta perchè dovevo andare a letto (causa: forze maggiori hem hem :rotfl:).
In pratica, come tu ben saprai, la chat blueimp che è per altro installata su pierotofy.it ha una tabella nel db chiamata "ajax_chat_online" dove vengono memorizzati gli users online. In effetti inserendo una riga in quella tabella l'utente con id e username da me scelti viene segnalato come online. Il mio problema è come associare a quell'utente la sessione e/o il cookie della chat blueimp.
Magari sono sulla strada sbagliata :-|
Potresti (se sono sulla falsa strada) spiegarmi come tu l'hai integrata?
Grazie mille :hail: ;)
Ultima modifica effettuata da cassin.simone 20/04/10 11:34
aaa
20/04/10 14:42
pierotofy
Ho modificato uno dei files della chat per leggere gli users dalla tabella degli utenti di pierotofy.it anziche' dalla tabella predefinita. Non mi ricordo esattamente quale pero'.
Il mio blog: piero.dev
20/04/10 16:29
cassin.simone
Postato originariamente da pierotofy:

Ho modificato uno dei files della chat per leggere gli users dalla tabella degli utenti di pierotofy.it anziche' dalla tabella predefinita. Non mi ricordo esattamente quale pero'.

:-|
Piero ma...gli utenti vengono memorizzati in lib/data/users.php...non capisco come tu abbia fatto O.o
Dal file users.php predefinito il code è questo (ho tolto le mie pass :))
<?php
/*
 * @package AJAX_Chat
 * @author Sebastian Tschan
 * @copyright (c) Sebastian Tschan
 * @license GNU Affero General Public License
 * @link https://blueimp.net/ajax/
 */

// List containing the registered chat users:
$users = array();

// Default guest user (don't delete this one):
$users[0] = array();
$users[0]['userRole'] = AJAX_CHAT_GUEST;
$users[0]['userName'] = null;
$users[0]['password'] = null;
$users[0]['channels'] = array(0);

// Sample admin user:
$users[1] = array();
$users[1]['userRole'] = AJAX_CHAT_ADMIN;
$users[1]['userName'] = '***';
$users[1]['password'] = '***';
$users[1]['channels'] = array(0,1);

// Sample moderator user:
$users[2] = array();
$users[2]['userRole'] = AJAX_CHAT_MODERATOR;
$users[2]['userName'] = '***';
$users[2]['password'] = '***';
$users[2]['channels'] = array(0,1);

// Sample registered user:
$users[3] = array();
$users[3]['userRole'] = AJAX_CHAT_USER;
$users[3]['userName'] = '***';
$users[3]['password'] = '***';
$users[3]['channels'] = array(0,1);
?>

E' un ottima idea quella di modificare questo file...ma mi chiedo come...:-|
Grazie ancora ;)

Edit: un secondo...sto provando...forse ho capito come fare :) Se funziona posto tutto :)
Ultima modifica effettuata da cassin.simone 20/04/10 16:31
aaa
20/04/10 18:49
pierotofy
In lib/class/CustomAJAXChat.php c'e' una funzione getValidLoginUserData(). Ho modificato quella per autenticare l'utente.
Il mio blog: piero.dev
21/04/10 10:56
cassin.simone
Postato originariamente da pierotofy:

In lib/class/CustomAJAXChat.php c'e' una funzione getValidLoginUserData(). Ho modificato quella per autenticare l'utente.


Ok piero...sto provando. Ho modificato la funzione da te indicata così:
function getValidLoginUserData() {
	$host="localhost";
	$username="simonecassin";
	$password="";
	$db="my_simonecassin";
	mysql_connect($host, $username, $password);
	mysql_select_db($db);
	$getall=mysql_query("SELECT username, id FROM site_users ORDER BY id") or die ("Errore nella query");
	while ($user=mysql_fetch_array($getall)){
		if ($_COOKIE['webchat_username']==$user['username']){
			$userData=array();
			$userData['userID']=$user['id'];
			$userData['userName']=$user['username'];
			$userData['userRole']='AJAX_CHAT_USER';
			return $userData;
		}
	}
	return null;
}

In teoria, siccome il cookie webchat_username è vivo e vegeto dovrebbe funzionare ma quando tento il login cliccando su "Entra" non mi logga...:-|
Ah...stavo dimenticando che ho modificato anche il file di template "loggedOut.html" così (prendendo spunto dal tuo sito):
<?xml version="1.0" encoding="[CONTENT_ENCODING/]"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="[LANG_CODE/]" lang="[LANG_CODE/]" dir="[BASE_DIRECTION/]">

<head>
	<meta http-equiv="Content-Type" content="[CONTENT_TYPE/]" />
	<title>[LANG]title[/LANG]</title>
	<style type="text/css">
		body {
			padding:0;
			margin:0;
		}
	</style>
	[STYLE_SHEETS/]
	<!--[if lt IE 7]>
		<link rel="stylesheet" type="text/css" href="css/ie5-6.css"/>
	<![endif]-->
	<script src="js/chat.js" type="text/javascript" charset="UTF-8"></script>
	<script src="js/lang/[LANG_CODE/].js" type="text/javascript" charset="UTF-8"></script>
	<script src="js/config.js" type="text/javascript" charset="UTF-8"></script>
	<script type="text/javascript">
		// <![CDATA[
			function initializeLoginPage() {
				document.getElementById('userNameField').focus();
				if(!ajaxChat.isCookieEnabled()) {
					var node = document.createElement('div');
					var text = document.createTextNode(ajaxChatLang['errorCookiesRequired']);
					node.appendChild(text);
					document.getElementById('errorContainer').appendChild(node);
				}
			}
			
			ajaxChatConfig.sessionName = '[SESSION_NAME/]';
			ajaxChatConfig.cookieExpiration = parseInt('[COOKIE_EXPIRATION/]');
			ajaxChatConfig.cookiePath = '[COOKIE_PATH/]';
			ajaxChatConfig.cookieDomain = '[COOKIE_DOMAIN/]';
			ajaxChatConfig.cookieSecure = '[COOKIE_SECURE/]';

			ajaxChat.init(ajaxChatConfig, ajaxChatLang, true, true, false);
		// ]]>
	</script>
</head>

<body onload="initializeLoginPage();">
	<div id="loginContent">
		<div id="loginHeadlineContainer">
			<h1>[LANG]title[/LANG]</h1>
		</div>
		<form id="loginForm" action="[LOGIN_URL/]" method="post" enctype="application/x-www-form-urlencoded">
			<div id="loginFormContainer">
				<input type="hidden" name="login" id="loginField" value="login"/>
				<input type="hidden" name="redirect" id="redirectField" value=""/>
				<div><input type="submit" name="submit" id="loginButton" value="Entra"/></div>
			</div>
		</form>
		<div id="errorContainer">[ERROR_MESSAGES/]<noscript><div>[LANG]requiresJavaScript[/LANG]</div></noscript></div>
		<!--
			Please retain the full copyright notice below including the link to blueimp.net.
			This not only gives respect to the amount of time given freely by the developer
			but also helps build interest, traffic and use of AJAX Chat.
			
			Thanks,
			Sebastian Tschan
		//-->
		<div id="copyright"><a href="https://blueimp.net/ajax/">AJAX Chat</a> &copy; <a href="https://blueimp.net">blueimp.net</a></div>
	</div>
</body>

</html>

Perdona la mia ignoranza :hail: :)
Ultima modifica effettuata da cassin.simone 21/04/10 11:36
aaa
21/04/10 13:25
pierotofy
Qui:

function getValidLoginUserData() {
    $host="localhost";
    $username="simonecassin";
    $password="";
    $db="my_simonecassin";
    mysql_connect($host, $username, $password);
    mysql_select_db($db);
    $getall=mysql_query("SELECT username, id FROM site_users ORDER BY id") or die ("Errore nella query");
    while ($user=mysql_fetch_array($getall)){
        if ($_COOKIE['webchat_username']==$user['username']){
            $userData=array();
            $userData['userID']=$user['id'];
            $userData['userName']=$user['username'];
            $userData['userRole']='AJAX_CHAT_USER';
            return $userData;
        }
    }
    return NULL;
} 


E' sbagliato; la funzione deve ritornare solamente un utente. Ad esempio per pierotofy.it io ho un'istanza $currentUser che punta all'utente loggato al momento. Quindi devi modificare la funzione cosi' che:
- Se l'utente non e' loggato sul tuo sito, ritorna NULL.
- Se l'utente e' loggato sul tuo sito, ritorna l'hash table ($userData) con userID, userName e userRole.

function getValidLoginUserData() {
    global $currentUser;
    
    if ($currentUser->isLogged()){
            $userData=array();
            $userData['userID']=$currentUser->id;
            $userData['userName']=$currentUser->username;
            $userData['userRole']='AJAX_CHAT_USER';
            return $userData;
    }else return NULL;
} 
Il mio blog: piero.dev