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);
?>
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();}" /> <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>
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);
?>
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>
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;
}
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?";
}
?>
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 ;
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>";
}
?>
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 />";
}
?>
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";
}
?>
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";
}
?>
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]