Seite 1 von 1

AJAXChat

Verfasst: 03.03.2009 12:55
von mx-sports-zone
Huhu!

Ich habe soeben laut der Anleitung hier versucht, weitere Räume in den Chat einzufügen, indem ich folgende Zeilen in der "lib/class/customAJAXChat.php" ergänzt habe:

Code: Alles auswählen

$this->_channels = array_merge($this->_channels, array('Eingang'=>12, '[K|B]'=>34, '[CUBA]'=>56, '[WOOKIE]'=>78));

Code: Alles auswählen

$this->_allChannels = array_merge($this->_allChannels, array('Eingang'=>12, '[K|B]'=>34, '[CUBA]'=>56, '[WOOKIE]'=>78));
In der "lib/config.php" habe ich den Channel "Eingang" als default gesetzt. Alles funktioniert ohne Probleme.

Allerdings habe ich in der Auswahlliste einen weiteren Raum Namens "-", den man jedoch nicht betreten kann.

Code: Alles auswählen

ChatBot: Fehler: Ungültiger Raumname:
erscheint bei Auswahl dieses Raumes als Fehlermeldung.

Wie kann ich die Ursache für diesen Fehler beheben?

Außerdem würde ich gerne wissen, ob und wo man die Smilies erweitern bzw. ersetzen kann. :(

Re: AJAXChat

Verfasst: 04.03.2009 10:56
von mx-sports-zone
*verzweifelt hochschieb*

:cry:

Re: AJAXChat

Verfasst: 04.03.2009 18:59
von Detlef67
ich gehe mal nach der anleitung die du hier verlinkt hast hast du auch die Nr. in array angegeben

Code: Alles auswählen

// Defines an array of channelIDs (e.g. array(0, 1)) to limit the number of available channels, will be ignored if set to null:
$config['limitChannelList'] = array(123,456,789);

Re: AJAXChat

Verfasst: 04.03.2009 21:58
von mx-sports-zone
Wo müsste ich das denn eintragen?

Meine /lib/class/CustomAJAXChat.php sieht wie folgt aus:

Code: Alles auswählen

<?php
/*
 * @package AJAX_Chat
 * @author Sebastian Tschan
 * @copyright (c) Sebastian Tschan
 * @license GNU Affero General Public License
 * @link https://blueimp.net/ajax/
 * 
 * phpBB3 integration:
 * http://www.phpbb.com/
 */

class CustomAJAXChat extends AJAXChat {

	// Initialize custom configuration settings
	function initCustomConfig() {
		global $db;
		
		// Use the existing phpBB database connection:
		$this->setConfig('dbConnection', 'link', $db->db_connect_id);
	}

	// Initialize custom request variables:
	function initCustomRequestVars() {
		global $user;

		// Auto-login phpBB users:
		if(!$this->getRequestVar('logout') && ($user->data['user_id'] != ANONYMOUS)) {
			$this->setRequestVar('login', true);
		}
	}

	// Replace custom template tags:
	function replaceCustomTemplateTags($tag, $tagContent) {
		global $user;
		
		switch($tag) {

			case 'FORUM_LOGIN_URL':
				if($user->data['is_registered']) {
					return ($this->getRequestVar('view') == 'logs') ? './?view=logs' : './';
				} else {
					return $this->htmlEncode(generate_board_url().'/ucp.php?mode=login');
				}
				
			case 'REDIRECT_URL':
				if($user->data['is_registered']) {
					return '';
				} else {
					return $this->htmlEncode($this->getRequestVar('view') == 'logs' ? $this->getChatURL().'?view=logs' : $this->getChatURL());
				}
			
			default:
				return null;
		}
	}

	// Returns true if the userID of the logged in user is identical to the userID of the authentication system
	// or the user is authenticated as guest in the chat and the authentication system
	function revalidateUserID() {
		global $user;
		
		if($this->getUserRole() === AJAX_CHAT_GUEST && $user->data['user_id'] == ANONYMOUS || ($this->getUserID() === $user->data['user_id'])) {
			return true;
		}
		return false;
	}

	// Returns an associative array containing userName, userID and userRole
	// Returns null if login is invalid
	function getValidLoginUserData() {
		global $auth,$user;
		
		// Return false if given user is a bot:
		if($user->data['is_bot']) {
			return false;
		}
		
		// Check if we have a valid registered user:
		if($user->data['is_registered']) {
			$userData = array();
			$userData['userID'] = $user->data['user_id'];

			$userData['userName'] = $this->trimUserName($user->data['username']);
			
			if($auth->acl_get('a_'))
				$userData['userRole'] = AJAX_CHAT_ADMIN;
			elseif($auth->acl_get('m_'))
				$userData['userRole'] = AJAX_CHAT_MODERATOR;
			else
				$userData['userRole'] = AJAX_CHAT_USER;

			return $userData;
			
		} else {
			// Guest users:
			return $this->getGuestUser();
		}
	}

	// Store the channels the current user has access to
	// Make sure channel names don't contain any whitespace
	function &getChannels() {
		if($this->_channels === null) {
			global $auth;

			$this->_channels = array();

			$allChannels = $this->getAllChannels();

			foreach($allChannels as $key=>$value) {
				// Check if we have to limit the available channels:
				if($this->getConfig('limitChannelList') && !in_array($value, $this->getConfig('limitChannelList'))) {
					continue;
				}

				// Add the valid channels to the channel list (the defaultChannelID is always valid):
				if($value == $this->getConfig('defaultChannelID') || $auth->acl_get('f_read', $value)) {
					$this->_channels[$key] = $value;
				}
			}
		$this->_channels = array_merge($this->_channels, array('Eingang'=>12, '[K|B]'=>34, '[CUBA]'=>56, '[WOOKIE]'=>78));
		}
		return $this->_channels;
	}

	// Store all existing channels
	// Make sure channel names don't contain any whitespace
	function &getAllChannels() {
		if($this->_allChannels === null) {
			global $db;

			$this->_allChannels = array();

			// Get valid phpBB forums:
			$sql = 'SELECT
							forum_id,
							forum_name
						FROM
							'.FORUMS_TABLE.'
						WHERE
							forum_type=1
						AND
							forum_password=\'\';';
			$result = $db->sql_query($sql);

			$defaultChannelFound = false;

			while ($row = $db->sql_fetchrow($result)) {
				$forumName = $this->trimChannelName($row['forum_name']);

				$this->_allChannels[$forumName] = $row['forum_id'];

				if(!$defaultChannelFound && $row['forum_id'] == $this->getConfig('defaultChannelID')) {
					$defaultChannelFound = true;
				}
			}
			$db->sql_freeresult($result);

			if(!$defaultChannelFound) {
				// Add the default channel as first array element to the channel list:
				$this->_allChannels = array_merge(
					array(
						$this->trimChannelName($this->getConfig('defaultChannelName'))=>$this->getConfig('defaultChannelID')
					),
					$this->_allChannels
				);
			}
		$this->_allChannels = array_merge($this->_allChannels, array('Eingang'=>12, '[K|B]'=>34, '[CUBA]'=>56, '[WOOKIE]'=>78));
		}
		return $this->_allChannels;
	}

	// Method to set the style cookie depending on the phpBB user style
	function setStyle() {
		global $config,$user,$db;
		
		if(isset($_COOKIE[$this->getConfig('sessionName').'_style']) && in_array($_COOKIE[$this->getConfig('sessionName').'_style'], $this->getConfig('styleAvailable')))
			return;
		
		$styleID = (!$config['override_user_style'] && $user->data['user_id'] != ANONYMOUS) ? $user->data['user_style'] : $config['default_style'];
		$sql = 'SELECT
						style_name
					FROM
						'.STYLES_TABLE.'
					WHERE
						style_id = \''.$db->sql_escape($styleID).'\';';
		$result = $db->sql_query($sql);
		$styleName = $db->sql_fetchfield('style_name');
		$db->sql_freeresult($result);
		
		if(!in_array($styleName, $this->getConfig('styleAvailable'))) {
			$styleName = $this->getConfig('styleDefault');
		}
		
		setcookie(
			$this->getConfig('sessionName').'_style',
			$styleName,
			time()+60*60*24*$this->getConfig('sessionCookieLifeTime'),
			$this->getConfig('sessionCookiePath'),
			$this->getConfig('sessionCookieDomain'),
			$this->getConfig('sessionCookieSecure')
		);
		return;
	}

}
?>

Re: AJAXChat

Verfasst: 04.03.2009 23:11
von mx-sports-zone
Kann es sein, dass man gar nicht mehr als 3 Räume festlegen kann? Ich habe nämlich jetzt in der "/lib/class/CustomAJAXChat.php" die Räume wie folgt festlegt:

Code: Alles auswählen

$this->_channels = array_merge($this->_channels, array('Eingang'=>123, '[K|B]'=>456, 'Small-Talk'=>789));

Code: Alles auswählen

$this->_allChannels = array_merge($this->_allChannels, array('Eingang'=>123, '[K|B]'=>456, 'Small-Talk'=>789));
und in der "/lib/config.php" das array so:

Code: Alles auswählen

// Defines an array of channelIDs (e.g. array(0, 1)) to limit the number of available channels, will be ignored if set to null:
$config['limitChannelList'] = array(123,456,789);
In selbiger Datei habe ich auch den Default-Channel bei Betreten des Chats festgelegt:

Code: Alles auswählen

// Default channelName used together with the defaultChannelID if no channel with this ID exists:
$config['defaultChannelName'] = 'Eingang';
// ChannelID used when no channel is given:
$config['defaultChannelID'] = 12;
Funktioniert alles ohne Probleme, nur hätte ich gerne 4 und nicht 3 Räume. :(

Re: AJAXChat

Verfasst: 06.03.2009 12:45
von Mysticus
Hallo,

bei mir wurde automatisch für jedes Forum ein Raum angelegt... zu viele. Wenn ich es aber manuell herunter stelle, erkennt er nicht mehr den Raum Public, bzw ich kann nicht darin Posten. Doch dass ist das kleinere Übel.

Viel unangenehmer ist es aber, wenn ich mich im Forum angemeldet habe, dann in den Chat gehe, zeigt er mir diesen für ca. 2-3 Sekunden und wirft mich dann wieder heraus. Dadurch habe ich keine Möglichkeit den Chat als Admin zu betreten.

Kann mir da jemand weiterhelfen?

Re: AJAXChat

Verfasst: 31.10.2009 22:15
von allesweg
Hallo,

Vielleicht hilft es ja noch, auch wenn der Thread schon ein bisschen älter ist ;) aber dank Forensuche braucht das ja vielleicht doch nochmal jemand.
Das mit dem automatisch alle Foren als Räume definieren ist glaube ich erstmal eine Standard-Einstellung.

Ich hab das folgendermaßen geändert:

Wie schon in dem Link oben beschrieben:
In der /chat/lib/config.php einfügen:

Code: Alles auswählen

// Defines an array of channelIDs (e.g. array(0, 1)) to limit the number of available channels, will be ignored if set to null:
$config['limitChannelList'] = array(xx,xx,xx);
xx steht einfach für die Definition der Räume. Man kann ziemlich viele (hab nicht ausprobiert wieviele) Räume erstellen. Am sinnvollsten ist es, Zahlenkombnationen zu vergeben. 123, 234, 345, usw.

Dann in der /chat/lib/class/CustomAJAXChat.php

vor

Code: Alles auswählen

}
return $this->_channels;
das hier einfügen:

Code: Alles auswählen

$this->_channels = array_merge($this->_channels, array('Extra_Public_Channel_1'=>xx, 'Extra_Public_Channel_2'=>xx, 'Extra_Public_Channel_3'=>xx));
dabei die xx wieder durch die vorher gewählten Zahlenkombinationen ersetzen und "Extra-Public_Channel_1/2/3" usw. durch die gewünschten Raumnamen.

das gleiche nochmal hier:

vor

Code: Alles auswählen

}
return $this->_allChannels;
das enfügen:

Code: Alles auswählen

$this->_allChannels = array_merge($this->_allChannels, array('Extra_Public_Channel_1'=>xx, 'Extra_Public_Channel_2'=>xx, 'Extra_Public_Channel_3'=>xx));
wie oben beschrieben xx und "Extra-Public_Channel_1/2/3" anpassen

Den ersten Raum habe ich dann im ACP als Standardchannel ausgewählt.

Man kann also nicht nur drei Räume einrichten ;)


Ich hab jetzt nur noch das Problem mit den Smileys. Ich würde gerne ein Popup erstellen, in dem die Smileys dargestellt werden, im Prinzip wie das bei der Schriftfarbe.
Vielleicht hat da jemand einen Tipp?

Viele Güße,
Anke

Re: AJAXChat

Verfasst: 04.11.2009 07:38
von oecherjung
Hallo,

ich habe hier euren Ajax Chat Beitrag durch Zufall gefunden.

Vielleicht habt Ihr ja neine Lösung für mich.

Hier die Frage (http://www.phpbb.de/community/viewtopic ... 6&t=198398)

Wie bekomme ich es hin, das bestimmte Räume nur für bestimmte Benutzergruppen zugänglich sind.
Am besten wäre auch nur sichtbar.


Gruß

oechi

Re: AJAXChat

Verfasst: 09.12.2009 08:02
von engelchen
Ich hab alles genau nach anleitung gemacht, nur werden mir immer noch die ganzen räume angezeigt und nur die zwei die ich eigentlich haben wollte sind hinzugefügt und betretbar die anderen werden aber trotzdem angezeigt. und ich bekomm folgende fehlermeldungen

Code: Alles auswählen

[phpBB Debug] PHP Notice: in file /chat/lib/class/AJAXChat.php on line 2471: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /chat/lib/config.php:1)
[phpBB Debug] PHP Notice: in file /chat/lib/class/AJAXChatHTTPHeader.php on line 36: Cannot modify header information - headers already sent by (output started at /chat/lib/config.php:1)
[phpBB Debug] PHP Notice: in file /chat/lib/class/AJAXChatHTTPHeader.php on line 37: Cannot modify header information - headers already sent by (output started at /chat/lib/config.php:1)
[phpBB Debug] PHP Notice: in file /chat/lib/class/AJAXChatHTTPHeader.php on line 41: Cannot modify header information - headers already sent by (output started at /chat/lib/config.php:1)
[phpBB Debug] PHP Notice: in file /chat/lib/class/AJAXChatHTTPHeader.php on line 45: Cannot modify header information - headers already sent by (output started at /chat/lib/config.php:1)
Kann mir bitte jemand helfen? ich möchte nicht alle meine foren als chaträume haben, aber ich finde einfach die fehler nicht, hab alles genau nach anleitung gemacht.

lg engelchen

Die session start hab ich jetzt hinbekommen, aber der rest bleibt, der chat ist im prinzip jetzt genauso wie ich ihn haben wollte nur geht eben nix, kein schreiben usw. und es kommen immer noch die fehler, kann mir bitte jemand helfen?