Seite 1 von 1
AJAX Chat AFK Command
Verfasst: 05.05.2013 21:05
von Todi
Hallo,
Ich habe nun den AFK - Command eingebaut - Die Hilfe dazu habe ich von
https://github.com/Frug/AJAX-Chat/wiki/Mod-away-command bekommen

Nun wollte ich Fragen, ob es möglich ist den AFK - Befehl so anzupassen damit man folgendes tun kann:
Dieser "Text" sollte dann rechts im "Online-Benutzer" aufscheinen (Direkt dortstehen oder wenn man mit dir Maus drüber fährt ?).
Ist dies möglich?
PS: Bin kein Progger ich suche mir einfach über Google was soweit etwas zur Verfügung steht, aber leider habe ich dazu noch ncihts gefunden.
Re: AJAX Chat AFK Command
Verfasst: 08.05.2013 21:50
von Todi
Habe nun einen Code gefunden -->
http://core.zapto.org/blogs-news/entert ... status-mod.
Habe das originale File "CustomAJAXChat.php" vom Ajax Chat hochgeladen --> Chat funktioniert.
Kopiere dann nach der Anleitung von core.zapto den Teil damit der Befehl /afk funktioniert. Die fertige Datei hochgeladen (
fertige Datei - pastebin.
Danach wird mir folgender Fehler ausgepuckt:
Code: Alles auswählen
Parse error: syntax error, unexpected T_STRING in /home/www/web21/html/chat/lib/class/CustomAJAXChat.php on line 210
Was mir Google bis jetzt ausspuckt, ist diese Fehlermeldung eine, die leicht zu beheben ist - aber ich finde den Fehler nicht!
Hilfe

Re: AJAX Chat AFK Command
Verfasst: 08.05.2013 22:24
von HabNurNeFrage
Hi,
ist das Script stand-alone?
In der Zeile werden Variablen und Funktionen aufgerufen, die es nicht gibt...
Die Funktion
insertChatBotMessage (...) z.B.
Aber er stolpert bestimmt schon über
$textParts - eine nicht definierte Variable.
Es ist einfach kein $textParts existent, also kann auch keine Verarbeitung erfolgen.
Tue etwas mit nichts quasi...
Dies scheint die Ausgangsbasis zu sein:
https://github.com/Frug/AJAX-Chat/blob/ ... AXChat.php
Da soll zumindest der Code, den Du eingebaut hast, integriert werden, der dann diese vordefinierte Zeile einfügt "has went away from keyboard" - wenn man /afk eingibt.
LG
PS: Irgendwie ist Dein Script unvollständig...
Re: AJAX Chat AFK Command
Verfasst: 08.05.2013 22:28
von Miriam
Finde in Deinem neuen Code (2x):
Code: Alles auswählen
if(count($textParts) insertChatBotMessage($this->getChannel()
tausche aus gegen:
Code: Alles auswählen
if(count($textParts) { insertChatBotMessage($this->getChannel()
Re: AJAX Chat AFK Command
Verfasst: 08.05.2013 22:47
von Todi
@miriam
die beiden Zeilen ausgetauscht - funktioniert immer noch nicht
Edit: kommt übrigens diese Meldung wenn ich die Klammer einfüge
Code: Alles auswählen
Parse error: syntax error, unexpected '{' in /home/www/web21/html/chat/lib/class/CustomAJAXChat.php on line 210
@habnurnefrage:
Ich bin wie folgt vorgegangen:
1) originales lib/class/CustomAJAXChat.php auf dem Server --> Chat funktioniert aber ohne /afk Command
2) Die Anleitung bzgl. Befehl /afk Message von
http://core.zapto.org/blogs-news/entert ... status-mod hergenommen
3) Da meine Datei unverändert ist habe ich natürlich die BASIC INSTALLATION INSTRUCTIONS genommen weil:
Code: Alles auswählen
function parseCustomCommands($text, $textParts) {
switch($textParts[0]) {
nicht vorhanden ist.
4) Somit habe ich den geänderten Code von der Anleitung vor
}
?>
eingefügt.
und schwubst die FEhlermeldung ist da. Entweder ist die Anleitung falsch oder die originale .php File ist akuteller?!
Weitere Probleme wie Klammer gesetzt, oder ; (strichpunkt) in der IF-schleife rausgenommen usw. aber selbe Problem!
Re: AJAX Chat AFK Command
Verfasst: 09.05.2013 00:43
von Todi
Problem behoben + weitere Anpassungen - aber am Code war was falsch von der Anleitung!
Nun kann man zb.:
Ausgaben:
Gesamte Datei:
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;
}
}
}
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
);
}
}
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;
}
// ~cXc~ Custom Commands
function parseCustomCommands($text, $textParts) {
switch($textParts[0]) {
// ~cXc~ AFK Status Mod Part 1of2
case '/afk':
case '/away':
if(count($textParts)==1)
{
$this->insertChatBotMessage($this->getChannel(), $this->getLoginUserName().' has went away from keyboard');
} else {
$this->insertChatBotMessage($this->getChannel(), $this->getLoginUserName().'has went away from keyboard (with Status: [b]'.implode(' ', array_slice($textParts, 1)).'[/b])');
}
$this->setUserName($this->getLoginUserName().' - AFK');
$this->updateOnlineList();
$this->addInfoMessage($this->getUserName(), 'userName');
$this->setSessionVar('BusyAFK', true);
return true;
case '/bck':
case '/back':
if(count($textParts)==1)
{
$this->insertChatBotMessage($this->getChannel(), $this->getLoginUserName().' has returned :)');
} else {
$this->insertChatBotMessage($this->getChannel(), $this->getLoginUserName().' is back (with Status: [b]'.implode(' ', array_slice($textParts, 1))."[/b])");
}
$this->setUserName($this->getLoginUserName());
$this->updateOnlineList();
$this->addInfoMessage($this->getUserName(), 'userName');
$this->setSessionVar('BusyAFK', false);
return true;
// end ~cXc~ AFK Status Mod Part 1of2
// now close function parseCustomCommands($text, $textParts)
}
}
// end ~cXc~ Custom Commands
// ~cXc~ Better AFK Status Mod Part 2of2
function onNewMessage($text) {
// Reset AFK status on first inserted message:
if($this->getSessionVar('BusyAFK')) {
$this->setUserName($this->getLoginUserName());
$this->updateOnlineList();
$this->addInfoMessage($this->getUserName(), 'userName');
$this->setSessionVar('BusyAFK', false);
}
return true;
}
// end ~cXc~ Better AFK Status Mod Part 2of2
}
?>
Ist somit
erledigt