Chat anpassen

Bei Problemen zu EasyHP wird dir hier gerne geholfen.

Moderator: Supporter

matze93
Inaktiv
Beiträge: 314
Registriert: 21. Januar 2009, 14:10

Chat anpassen

Beitrag von matze93 »

Deine EasyHP Version: 1.2.2
EasyHP-Code verändert: Nein
Dein Wissensstand: Fortgeschritten

Was hast Du gemacht, bevor das Problem aufgetreten ist?


Was hast Du bereits versucht um das Problem zu lösen?


Fehlerbeschreibung und Nachricht
Hey Leute,
ich habe aus einem Tutorial einen Chat gebastelt. Der funktioniert zwar, ist aber nicht mit dem Usersystem von easyhp angepasst. Außerdem muss man die Datenbank-Verbindung ändern und mir persönlich wäre es lieber, wenn die chat_config_daten über die MySQL-Datenbank läuft (wie Daniel es in seinem Lexikon-Script hat). Dafür muss man die settings.php bearbeiten. Aber wie?

Aber erstmal die Codes:
chat.php

Code: Alles auswählen

<?php

define("IN_easyhp", true);

session_start();

if (!isset($_SESSION['captcha']) AND $_COOKIE['captcha_set'] != 'TRUE') {
	header("Location: captcha.php?link=chat.php");
}

include "includes/mysql.php";
include "common.php";
include "includes/website.php";

?>

<div id="content" class="head"><img src="styles/likeBlog/imageset/site.png"> <strong style="color: #336699; font-size: 1.45em">Chat</strong></div>
<div id="content">
 <table cellspacing="0" cellpadding="0" border="0">
  <tr>
   <td>
    <script type="text/javascript" src="chat/script/chat.js"> </script>
    <link rel="stylesheet" type="text/css" href="chat/css/style.css" />
    <?php include 'chat/settings.php'; ?>
    <?php include 'chat/chat.php'; ?>
   </td>
  </tr>
 </table>
</div>
<?php

footer(0);

?>
chat/chat.php

Code: Alles auswählen

<div id="chatContainer" style="width:<?php echo $chat_width; ?>px;">
<div id="chatLogin">
Enter your name:<br /><br />
<input type="text" id="cuser" size="25" onkeydown="if(event.keyCode==13){enterChat();}" />&nbsp;<input type="button" value="Submit" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" onclick="enterChat();" />
</div>
<div id="adminPanel" class="hide">
<table cellpadding="0" cellspacing="4" align="center" width="60%" border="0">
<tr><td colspan="2">Enter the password:</td></tr>
<tr><td align="left"><input type="password" id="adminp" size="25" onkeydown="if(event.keyCode==13){adminPanel();}" /></td>
<td align="left"><input type="button" value="Submit" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" onclick="adminPanel();" /></td></tr>
<tr><td align="right" colspan="2"><span id="closeb"><br /><input type="button" value="[Close]" onclick="showAdmin();" /></span></td></tr>
</table>
</div>
<div id="helpPanel" class="hide">
<?php include 'help.html'; ?>
</div>
<div id="chatFilter" class="chatFilterTrue" style="width:<?php echo $chat_width; ?>px;">
<table class="boxcontent" align="center" cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td>
<div class="contentTop">
	<span class="cboxtitle"><?php echo $ctitle; ?></span>
</div>
	<div style="height:<?php echo $chat_height; ?>px;">
        <div id="chat_display" style="width: 70%; margin-left:1px;">
        Loading...
        </div> 
        <div id="chat_users" style="width: 29%;">
        <font style='display:block; width:210; background-color:white; color:#000;'>Users Chatting:</font>
        </div>
    </div><br />
    <table width="100%" class="chatm" cellpadding="0" cellspacing="0">
    	<tr>
    		<td class="chattd" width="70%" align="left">
            	<form name="chatbox">
            	<input type="text" id="txtmsg" name="msg" style="width: 88%;" onkeydown="if(event.keyCode==13){sendMsg();this.value='';}" disabled="disabled" /><input type="button" value="Send" disabled="disabled" id="btnsub" onclick="sendMsg();chatbox.txtmsg.value='';" class="pointer" /><img src="chat/img/smile.gif" name="smile" alt="Smile" onClick="sendText(document.chatbox.txtmsg, ':)')" class="pointer" /><img src="chat/img/biggrin.gif" name="biggrin" alt="Grin" onClick="sendText(document.chatbox.txtmsg, ':D')" class="pointer" /><img src="chat/img/wink.gif" name="wink" alt="Wink" onClick="sendText(document.chatbox.txtmsg, ';)')" class="pointer" /><img src="chat/img/blink.gif" name="blink" alt="Blink" onClick="sendText(document.chatbox.txtmsg, 'o_O')" class="pointer" /><img src="chat/img/sad.gif" name="sad" alt="Sad" onClick="sendText(document.chatbox.txtmsg, ':(')" class="pointer" /><img src="chat/img/tongue.gif" name="tongue" alt="Tongue" onClick="sendText(document.chatbox.txtmsg, ':P')" class="pointer" /><img src="chat/img/mad.gif" name="mad" alt="Mad" onClick="sendText(document.chatbox.txtmsg, '>.<')" class="pointer" /><input type="text" name="hide" size="1" style="visibility:hidden" /></form>
            </td>
    	</tr>
    </table>     	
</td></tr>
</table>
</div>
</div>
chat/settings.php

Code: Alles auswählen

<?php
session_start();

// This is the password for the administration panel
$admin_pass = "Max_Mustermann";

// This is the number of messages shown in the chat box
// default: 20
$num_messages = 20;

// This is the width of the chatbox in pixels
// default: 595
$chat_width = 595;

// This is the height of the chatbox in pixels
// default: 550
$chat_height = 550;

// This is the title of the Chat Box
// default: Chat
$ctitle = "Chat";

// Welcome message
// default: Welcome to chat, enter /? to get help
$welcome_message = "Welcome to chat, enter /? to get help";

// These are the mySQL details, you should edit these
$mysql_host = "localhost";
$mysql_user = "root";
$mysql_pass = "Max_Mustermann";
$mysql_db = "Max_Mustermann";

// Connection to mysql database, do not edit
mysql_connect($mysql_host, $mysql_user, $mysql_pass);
mysql_select_db($mysql_db);

?>
chat/help.html

Code: Alles auswählen

<table width="95%" border="0" cellspacing="2" cellpadding="2">
<tr>
	<td><h3 style="color:#0CF">Help File</h3></td>
</tr>
<tr>
	<td class="helpfile">This is a brief help file to help you use this chat application.</td>
<tr>
	<td style="text-decoration:underline; font-weight:bold">Chat</td>
</tr>
<tr>
	<td class="helpfile">Chatting is simple, all you have to do is type your message in the textbox under the chat display area and then either hit enter or click on the submit button.
    <br />You can also use emoticons in your message, do so by clicking on their picture. They also have their own text shortcuts which you will see entered when you click on one. e.g.<br />
    <img src="chat/img/tongue.gif" name="tongue" alt="Tongue"  /> Shortcut: ':P'<br />
    <img src="chat/img/sad.gif" name="sad" alt="Sad" /> Shortcut: ':('
    </td>
<tr>

<tr><td align="right" colspan="2"><span id="closeb"><br /><input type="button" value="[Close]" onclick="closeHelp();" /></span></td></tr>
</table>
chat/css/style.css

Code: Alles auswählen

input {
	border: solid #000 1px;
}

#copy {
	font-size: 10px;
	font-family: Arial, Helvetica, sans-serif;
	color: #000;
}

.helpfile {
	font-size: 12px;
}

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Filters
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
#chatFilter {
	overflow: auto;
	background-color:#EEE; 
	z-index:1000;
}

.chatFilterTrue {
	filter:alpha(opacity=50);
	opacity:0.2;
}

.chatFilterFalse {
	filter:none;
	opacity:1;
}
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Filter Boxes
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
#chatContainer {
	position: relative;
}

#chatLogin {
	font-family: Verdana, Geneva, sans-serif;
	position: absolute;
	border: solid #000 2px;
	top:30%; 
	left:150px;
	padding:10px;
	width:45%;
	z-index:1001;
	background-color:#EEE;
	color:#000;
}

#adminPanel {
	font-family: Verdana, Geneva, sans-serif;
	position: absolute;
	border: solid #000 2px;
	top:30%; 
	left:80px;
	padding:10px;
	width:70%;
	z-index:1002;
	background-color:#EEE;
	color:#000;
}

#helpPanel {
	font-family: Verdana, Geneva, sans-serif;
	position: absolute;
	border: solid #000 2px;
	top:2%; 
	left:50px;
	padding:2px;
	width:80%;
	z-index:1003;
	background-color:#EEE;
	color:#000;
}

.hide {
	visibility: hidden;
}

.show {
	visibility: visible;
}

#closeb input {
	background-color: #EEE;
	color: #000;
	cursor: pointer;
}

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Content
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/

.contentTop {
	height: 20px;
	padding-left: 5px;
	margin-bottom: 10px;
	background: #EEE;
	border: solid #000 1px;
	font-family: Verdana, Geneva, sans-serif;
	text-align: left;
	}

.contentBottom {
	height: 20px;
	padding-bottom: 4px;
	background: #EEE;
	border: solid #000 1px;
	}
.boxcontent {
	background: #EEE;
}
.cboxtitle {
	font-size: 16px;
	font-weight: bold;
	color: #000;
	padding-left: 4px;
}
.btn {
	padding-top: 1px;
	padding-bottom: 1px;
	border: none;
	cursor: pointer;
	background-color: #EEE;
	color: #000;
	padding-left: 8px;
	padding-right: 8px;
}
.btnhov {
	background-color: #EEE;
}
.pointer {
	cursor: pointer;
}

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Chat
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
#chat_display {
	float: left;
	border-top: solid #EEE 1px;
	border-left: solid #EEE 1px;
	border-right: solid #EEE 1px;
	background-color: #EEE;
	overflow: auto;
	height: 100%;
	color: #000;
	font-size: 14px;
	font-family: Verdana, Geneva, sans-serif;
	text-align: left;
}

#chat_users {
	float: left;
	border: solid #EEE 1px;
	background-color: #EEE;
	color: #000;
	height: 100%;
	overflow: hidden;
	font-family: Verdana, Geneva, sans-serif;
	font-size: 14px;
	text-align: left;
}

.chatm {
	position: relative;
	top: -18px;
	margin-bottom: -15px;
}

.chattd {
	background-color: #EEE;
	padding-left: 4px;
}

a.chatl {
	font-weight: bold;
}
a.chatl:link {
	color: #00008b;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px; 
	text-decoration: none;
}
a.chatl:visited {
	color: #00008b;
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px; 
	text-decoration: none;
}

a.chatl:hover {
	color: #00008b;
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px; 
	text-decoration: none;
}

a.chatl:active {
	color: #00008b;
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px; 
	text-decoration: none;
}
chat/img/
Hier befinden sich die Smilies: ajax-loader.gif; biggrin.gif; blink.gif; mad.gif; sad.gif; smile.gif; tongue.gif; wink.gif

chat/install/chat_install.php

Code: Alles auswählen

<?php

require_once '../chat/settings.php';


$chat_tbl = "CREATE TABLE IF NOT EXISTS `chat` (`ID` int(20) NOT NULL AUTO_INCREMENT, `User` varchar(50) NOT NULL, `Message` text NOT NULL, PRIMARY KEY (`ID`)) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";


$chatlog_tbl = "CREATE TABLE IF NOT EXISTS `chat_log` (`ID` int(20) NOT NULL AUTO_INCREMENT, `User` varchar(50) NOT NULL, PRIMARY KEY (`ID`)) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";

if (!mysql_query("SELECT * FROM chat") || !mysql_query("SELECT * FROM chat_log")){
	mysql_query ($chat_tbl) or die(mysql_error());
	mysql_query ($chatlog_tbl) or die(mysql_error());
	
	echo "Congratulations! The chat has been installed successfully.";
	echo "<p>To be safe, make sure you now either delete or rename chat_install.php</p>";
	
} else {
	echo "It seems that 1 or more of the tables you are trying to create already exists!<br />";
	echo "is it installed already?";
}

?>
oder als sql
chat/install/chat_install.sql

Code: Alles auswählen

-- phpMyAdmin SQL Dump
-- version 3.1.3.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 23, 2009 at 09:08 PM
-- Server version: 5.1.33
-- PHP Version: 5.2.9-2

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

-- --------------------------------------------------------

--
-- Table structure for table `EasyHP_chat`
--

CREATE TABLE IF NOT EXISTS `chat` (
  `ID` int(20) NOT NULL AUTO_INCREMENT,
  `User` varchar(50) NOT NULL,
  `Message` text NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


--
-- Table structure for table `EasyHPchat_log`
--

CREATE TABLE IF NOT EXISTS `chat_log` (
  `ID` int(20) NOT NULL AUTO_INCREMENT,
  `User` varchar(50) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
chat/php/getChat.php

Code: Alles auswählen

<?php
// Do not edit!
require_once '../settings.php';

$msg_sql = "SELECT * FROM chat ORDER BY ID Desc LIMIT $num_messages";
$msg_query = mysql_query($msg_sql);
$num = mysql_num_rows($msg_query);
$i = 1;

if ($num >= 1) {
	while ($result = mysql_fetch_array($msg_query)){
		$data = $result['Message'];
		//smiles array
		$smiles = array(':)', ':D', ';)', 'o_O', ':(', ':P', '>.<');
		//replace values array
		$vals = array('<img src=chat/img/smile.gif border=0>', '<img src=chat/img/biggrin.gif border=0>', '<img src=chat/img/wink.gif border=0>', '<img src=chat/img/blink.gif border=0>', '<img src=chat/img/sad.gif border=0>', '<img src=chat/img/tongue.gif border=0>', '<img src=chat/img/mad.gif border=0>');
		//replace
		$smiledata = str_replace($smiles, $vals, $data);
		$outarray[$i] = "<font color='#666'>".$result['User'] . ":</font> " . $smiledata . "<br />";
		$i++;
	}
	$i = $i - 1;
	echo "<span style=\"color:#06C\">" . $welcome_message . "</span><br />";
	while ($i != 0) {
		echo $outarray[$i];
		$i--;
	}
} else {
	echo "<strong>Chat has been cleared!</strong>";
}

?>
chat/php/getChatLog.php

Code: Alles auswählen

<?php
// Do not edit!
require_once '../settings.php';

$log_sql = "SELECT * FROM chat_log";
$log_query = mysql_query($log_sql);

echo "<font style='display:block; width:210; background-color:white; color:#000;'>Users Chatting:</font>";

while ($result = mysql_fetch_array($log_query)){
	echo $result['User']."<br />";
}

?>
chat/php/loginChat.php

Code: Alles auswählen

<?php
// Do not edit!
require_once '../settings.php';
$user = $_POST['user'];

$plog_sql = "SELECT * FROM chat_log WHERE User = '$user'";
$plog_query = mysql_query($plog_sql);
$num = mysql_num_rows($plog_query);

if (isset($_SESSION['user'])){
	$delete_sql = "DELETE FROM chat_log WHERE User = '$_SESSION[user]'";
	mysql_query($delete_sql);
	
	$_SESSION['user'] = $user;
	$_SESSION['admin'] = "false";
	$insert_sql = "INSERT INTO chat_log (ID, User) VALUES ('', '$user')";
	mysql_query($insert_sql);
	
	echo "true";
} elseif ($num < 1) {
	$_SESSION['user'] = $user;
	$_SESSION['admin'] = "false";
	$insert_sql = "INSERT INTO chat_log (ID, User) VALUES ('', '$user')";
	mysql_query($insert_sql);
	echo "true";
} else {
	echo "false";
}

?>
chat/php/sendmsg.php

Code: Alles auswählen

<?php
// Do not edit!
require_once '../settings.php';

if (isset($_SESSION['user']) && isset($_POST['msg'])){
	$msg = $_POST['msg'];
	$msg = mysql_real_escape_string($msg);
	$user = $_SESSION['user'];
	
	$chat_sql = "INSERT INTO chat (ID, User, Message) VALUES ('', '$user', '$msg')";
	mysql_query($chat_sql);
	
	include 'getChat.php';
} else {
	echo "Either you are not logged in or no message was set, please try again";
}
?>
chat/script/chat.js
kann ich auf Wunsch auch noch hochladen

So das waren die Codes! Ist eigentlich relativ einfach aufgebaut. Nur ich weiß nicht ganz weiter. Eigentlich wäre ich damit zufrieden, wenn jeder angemeldete User von EasyHP den Namen mit in den Chat nihmt.
Wie kann man da so eine Brücke bauen?

Danke schon mal für eure Hilfe
Matze[/i]
Benutzeravatar
daniel
Ehemaliger
Beiträge: 413
Registriert: 13. März 2008, 16:49
Wie bist du auf EasyHP gekommen?: Werbung auf phpBB.de
Wohnort: Bremen
Kontaktdaten:

Re: Chat anpassen

Beitrag von daniel »

wenn die chat_config_daten über die MySQL-Datenbank läuft (wie Daniel es in seinem Lexikon-Script hat)
Die Konfiguration läuft doch bei dem Lexikon über die lexikon.conf.php und nicht über die Datenbank.

allgemein wäre es ganz nett, wenn du alle Dateien als Zipdatei hochlädst und eine kleine anleitung schreibst, wie man es installiert. (für Die Datenbank die entsprechenden tabellen exportieren), denn man kann ein script besser verstehen, wenn man es selbst ausprobieren kann. ;)
wenn du möchtest, kann ich meine Versuche auch mal hochladen. Hast du dieses Script komplett selbst geschrieben oder irgendeine Vorlage genommen?
ist aber nicht mit dem Usersystem von easyhp angepasst. Außerdem muss man die Datenbank-Verbindung ändern[...]
Dafür würde ich mal vorschlagen erstmal Header und Footer von EasyHP zu implementieren.

MfG.: Daniel
matze93
Inaktiv
Beiträge: 314
Registriert: 21. Januar 2009, 14:10

Re: Chat anpassen

Beitrag von matze93 »

Ok, jetzt bin ich gerade einen einem Chat dran. Der wird anders als dieser hier. Habt ihr mit einem Chat schon Erfahrung gemacht. Danke!
Benutzeravatar
daniel
Ehemaliger
Beiträge: 413
Registriert: 13. März 2008, 16:49
Wie bist du auf EasyHP gekommen?: Werbung auf phpBB.de
Wohnort: Bremen
Kontaktdaten:

Re: Chat anpassen

Beitrag von daniel »

hier. das habe ich geschafft. Das Grundgerüst also den AJax-chat habe ich mir irgendwo runtergeladen und das ein wenig an EasyHP angepasst.
Chat.zip
(45.76 KiB) 601-mal heruntergeladen
In der Datenbank habe ich zwei Spallten in der _config hinzugefügt:
chat_aktiv(int) - 0 wenn Chat inaktiv 1 wenn chat aktiv
chat_inaktive_msg(longtext) - Nachricht der angezeigt wird, wenn der Chat deaktiviert ist.

und in der _session diese spalte:
im_chat (int) - wird mit 1 gefüllt wenn der User im Chat ist, mit 0 gefüllt, wenn er nicht drin ist. standart ist 0

aufrufen solltest du die chat.php (mit styles)oder die chat/chat.htm (ohne styles).
Chatten ist nur für eingeloggte User möglich und bei deaktiviertem Chat nur für Admins erlaubt.

Chats sind übrigends eine der wenigen Ausnahmen, bei denen ich (Inline-)Frames für sinnvoll finde.
matze93
Inaktiv
Beiträge: 314
Registriert: 21. Januar 2009, 14:10

Re: Chat anpassen

Beitrag von matze93 »

Danke,
ich werds zu Hause dann mal testen. Bin grad auf einem Tennisturnier.
matze93
Inaktiv
Beiträge: 314
Registriert: 21. Januar 2009, 14:10

Re: Chat anpassen

Beitrag von matze93 »

Okay ich habe jetzt den Chat eingebaut. Geht aber nicht. Vielleicht ist ja Java ausgeschalten. Aber beim Admin-Bereich kommt ein Fehler:

Code: Alles auswählen

Warning: file_get_contents(style/template/configuration/admin_chat.html) [function.file-get-contents]: failed to open stream: No such file or directory in /var/kunden/webs/web2s6027/includes/functions.php on line 265
Muss ich die Datei dann ertstellen, wie soll die dann aussehen?
Meine EasyHP Version ist 1.2.2 .

Und chat.txt und log.txt kann ich ja leeren oder?
Benutzeravatar
daniel
Ehemaliger
Beiträge: 413
Registriert: 13. März 2008, 16:49
Wie bist du auf EasyHP gekommen?: Werbung auf phpBB.de
Wohnort: Bremen
Kontaktdaten:

Re: Chat anpassen

Beitrag von daniel »

matze93 hat geschrieben:Okay ich habe jetzt den Chat eingebaut. Geht aber nicht. Vielleicht ist ja Java ausgeschalten.
Für den Chat muss Javascript aktiviert werden.
matze93 hat geschrieben:Aber beim Admin-Bereich kommt ein Fehler:

Code: Alles auswählen

Warning: file_get_contents(style/template/configuration/admin_chat.html) [function.file-get-contents]: failed to open stream: No such file or directory in /var/kunden/webs/web2s6027/includes/functions.php on line 265
Muss ich die Datei dann erstellen, wie soll die dann aussehen?
hab ich vergessen. Sorry. hier ist sie:
admin_chat.zip
(1.04 KiB) 566-mal heruntergeladen
matze93 hat geschrieben:Und chat.txt und log.txt kann ich ja leeren oder?
Ja. das sind die Dateien, in denen die Chatnachrichten gespeichert werden. chat.txt nur das aktuelle und in der log.txt alles, was jemals geschrieben wurde.
matze93
Inaktiv
Beiträge: 314
Registriert: 21. Januar 2009, 14:10

Re: Chat anpassen

Beitrag von matze93 »

Wie nur das aktuelle? Was muss drin bleiben !?!
matze93
Inaktiv
Beiträge: 314
Registriert: 21. Januar 2009, 14:10

Re: Chat anpassen

Beitrag von matze93 »

Ok, der Admin-Bereich geht jetzt. Die Tabellen existieren auch richtig. Doch schreiben geht immer noch nicht, obwohl Java installiert ist. Sicher, dass das hier stimmt?

Code: Alles auswählen

//
//
//php ENDE
// Javascript ANFANG
//
//
?>

var lines    = 35;
var title    = '';
var offset   = 0;
var userNr   = 0;
var messages = new Array();
var message  = document.getElementById('message');
var chat     = document.getElementById('chat');
var userlist = document.getElementById('userlist');
var tmrRead  = setTimeout('chat_read();', 1000);
var user     = new Array();

//Verbindung zum schreiben
function request_write(url, post) {
  r = false;
  if (window.XMLHttpRequest) {
    r = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      r = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        r = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
      }
    }
  }
  if (!r) return false;
  r.onreadystatechange = alert_write;
  if (post == null) {
    r.open('GET', url, true);
    r.send(null);
  } else {
    r.open('POST', url, true);
    r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    r.send(post);
  }
}

function alert_write() {
  try {
    if ((r.readyState == 4) && (r.status == 200)) parse(r.responseText);
  } catch(e) {
  }
}

//Verbindung zum lesen
function request_read(url, post) {
  r2 = false;
  if (window.XMLHttpRequest) {
    r2 = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      r2 = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        r2 = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
      }
    }
  }
  if (!r2) return false;
  r2.abort();
  r2.onreadystatechange = alert_read;
  if (post == null) {
    r2.open('GET', url, true);
    r2.send(null);
  } else {
    r2.open('POST', url, true);
    r2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    r2.send(post);
  }
}

//Verbindungzum User auslesen
function request_user(url, post) {
  r3 = false;
  if (window.XMLHttpRequest) {
    r3 = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      r3 = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        r3 = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
      }
    }
  }
  if (!r3) return false;
  r3.abort();
  r3.onreadystatechange = alert_user;
  if (post == null) {
    r3.open('GET', url, true);
    r3.send(null);
  } else {
    r3.open('POST', url, true);
    r3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    r3.send(post);
  }
}

function us(o, u) {
    user[o] = '<span id="C">'+u+'</span><br />';
}

function user_display() {
  html2 = '<b>Userliste:</b><br /><br />';
  for (var i = 0; i < user.length; i++) {
    html2 = html2 + user[i];
  }
  userlist.innerHTML = html2;
}

function alert_read() {
  clearTimeout(tmrRead);
  try {
    if ((r2.readyState == 4) && (r2.status == 200)) {
      parse(r2.responseText);
      tmrRead = setTimeout('chat_read();', 30);
    }
  } catch(e) {
    tmrRead = setTimeout('chat_read();', 3000);
  }
}

function chat_read() {
  clearTimeout(tmrRead);
  request_read('chat.php?r='+offset, null); 
}

function keyup(e) {
  if (window.event) k = window.event.keyCode;
  else if (e) k = e.which;
  else return true;
  if (k == 13) chat_write();
}

function chat_display() {
  html = '';
  i = 0;
  while ((i < lines) && (i < offset)) {
    h = offset-i;
    if (messages[h]) html = messages[h] + html;
    i++;
  }
  chat.innerHTML = html;
  if (title != '') {
    title = title.replace(/&/g, '&');
    title = title.replace(/"/g, '"');
    title = title.replace(/'/g, '\'');
    title = title.replace(/</g, '<');
    title = title.replace(/>/g, '>');
    document.title = title + ' - Chat by WebTemp.org';
  }
}

function chat_write() {
  request_write('chat.php', 'w='+escape(message.value));
  message.value = '';
}

function cs(o, i, t, u, m, c) {
  if (m == '<E>') {
    if (u != '') messages[o] = '<span id="C'+i+'">['+t+'] * '+u+' has entered the chat *</span><br />';
  } else if (m == '<L>') {
    if (u != '') messages[o] = '<span id="C'+i+'">['+t+'] * '+u+' has left the chat *</span><br />';
  } else {
    if (u != '') {
      u += ':';
      spaces = 5 - u.length;
      for (j = 0; j < spaces; j++) u += "&nbsp;";
      u += ' ';
    }
    if (title == '') title = m;
    m = m.replace(/ /g, '&nbsp;');
    messages[o] = '<span id="C'+i+'">['+t+'] '+u+'<b>'+m+'</b></span><br />';
  }
  if (o > offset) {
    offset = o;
    window.focus();
    message.focus();
  }
}

function parse(s) {
  if (s != '') {
	//delete user;
    var l = user.length;
	for (var i = 0; i < l; i++) {
		user.pop();
	}
	s = unescape(s);	
    eval(s);
    chat_display();
	user_display()
  }
}

Ich habs mit script versucht. Aber es geht nicht. Mein Name steht auch nicht in Userlist und es steht connecting da. Aber eigentlich ist CHMOD 7777?!?
Benutzeravatar
daniel
Ehemaliger
Beiträge: 413
Registriert: 13. März 2008, 16:49
Wie bist du auf EasyHP gekommen?: Werbung auf phpBB.de
Wohnort: Bremen
Kontaktdaten:

Re: Chat anpassen

Beitrag von daniel »

matze93 hat geschrieben:Wie nur das aktuelle? Was muss drin bleiben !?!
Ne die dateien werden sowieso neu geschrieben, wenn die gelöscht werden. kannste also einfach löschen
obwohl Java installiert ist. Sicher, dass das hier stimmt?
Der Code sollte richtig sein. Javascript kann ich nicht wirklich gut. habe es kopiert ;)

rufe mal die chat/chat.php auf und guck nach, ob da ne Fehlermeldung kommt.

und ist auch Javascript aktiviert? Java != Javascript
Antworten