Fout in chat-script

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Michiel Pil

Michiel Pil

05/04/2006 18:20:00
Quote Anchor link
Heej iedereen,
Ik heb hier een chat-script
Maar hij heeft errors
Het script:

/* //////////////// admin.php //////////////// */
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
$inc
= include "config.php";
if(!$inc) die("Dit script is niet geinstalleerd");
session_start();
?>

<link rel=stylesheet type=text/css href=chat.css>
<body>
<h2><?php echo $chatname; ?> -- Chat ADMIN</h2>
<?php
if (!empty($_POST)) {
    $pass = $_POST["pass"];

    if ($pass == $adminpass) {
        $_SESSION["admin12345"] = "jadatbenik";
        echo "<script language=\"JavaScript\">location.href = 'chatframe.php?name=".$_POST["name"]."'</script>";
    }
else {
        echo "Foutief wachtwoord!!!";
    }
}

?>

<form action=<?php echo $_SERVER["PHP_SELF"]; ?> method=post>
<b>Naam:</b> <input type=text size=20 name=name maxlength=16><br>
<b>Wachtwoord:</b> <input type=password size=20 name=pass maxlength=16><br><br>
<input type=submit value=Inloggen>
</form>
</body>


/* //////////////// adminact.php //////////////// */
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
session_start();
error_reporting(E_ALL ^ E_NOTICE);
?>

<html>
<head>
<title>Admin actie</title>
<link rel=stylesheet type=text/css href="chat.css">
</head>
<body>
<?php
if (!isset($_SESSION["admin12345"])) {
    echo "U heeft geen toegang tot het adminscherm.";
    exit;
}


if ($_GET["p"] == "empty") {
    $handle = fopen("messages.html", "w");
    fclose($handle);
    echo "Wissen gelukt.<br><a href=\"?p\">Terug</a>";
}
else {
?>

<h2>Admin actie</h2>
Maak uw keuze uit de lijst:<br><br>
- <a href="?p=empty">Berichten wissen</a>
<?php
}
?>

<br><br><input type=button value=Sluit onClick="self.close();">
</body>
</html>


/* //////////////// chat.css //////////////// */
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
body {
    font-family: Verdana,Helvetica,Arial;
    text-align: center;
    font-size: 10pt;
    color: #CCD800;
    background: #990000;
}

h2 {
    margin-bottom: 0pt;
}

input, select {
    border: 1pt #000000 solid;
    border-right: 1pt #000000 solid thin;
    border-bottom: 1pt #000000 solid thin;
    background: #880000;
    color: #CCD800;
    font-size: 8pt;
}

.headermargin {
    margin-top: 5pt;
}

.smileytable {
    font-family: Verdana,Helvetica,Arial;
    text-align: center;
    font-size: 10pt;
    color: #CCD800;
}

a {
    color: #CCD800;
}

a:hover {
    text-decoration: none;
}


/* //////////////// chatcore.php //////////////// */

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
$inc
= include "config.php";
if(!$inc) die("Dit script is niet geinstalleerd");
session_start();
?>

<link rel=stylesheet type=text/css href=chat.css>
<?php
error_reporting(0);

if($_GET["p"] == "header") {
    echo "<body class=headermargin><h2>".$chatname." - Chat</h2>Welkom, ".$_GET["name"].".</body>";
    $date = date("G:i d-m-Y");
    $message = "[" . $date . "] <b>" . $_GET["name"] . " komt de chat binnen.</b><br>\n" . file_get_contents("messages.html");
    $handle = fopen("messages.html", "w");
    fputs($handle, $message);
    fclose($handle);
    $handle = fopen("users/".$_GET["name"].".usr", "w");
    fputs($handle, "gebruikerslog");
    fclose($handle);
}
else if($_GET["p"] == "messages") {
    echo "<meta http-equiv=\"Refresh\" content=\"3;URL=chatcore.php?p=messages\">";
    echo "<body style=\"text-align: left\">";
    include "messages.html";
    echo "</body>";
}
else if($_GET["p"] == "online") {
    echo "<meta http-equiv=\"Refresh\" content=\"30;URL=chatcore.php?p=online\">";

    $gebruikers = glob("users/*.usr");

    foreach($gebruikers as $naam) {
        $tijd = (time() - filemtime($naam))/60;
        if ($tijd > 2) {
            unlink($naam);
        }
    }


    $gebruikers = glob("users/*.usr");
    $aantal = count($gebruikers);

    if ($aantal >= 2) { $woord = array("zijn", "gebruikers"); }else{ $woord = array("is", "gebruiker"); }

    echo "<b>Er ".$woord[0]." ".$aantal." ".$woord[1]." online.</b><br><br>";

    foreach($gebruikers as $chatnaam) {
        $tijd = (time() - filemtime($naam))/60;
        $tijd = 2-$tijd;
        $chatnaam = str_replace(".usr", "", $chatnaam);
        $chatnaam = str_replace("users/", "", $chatnaam);
        echo $chatnaam."<br>";
    }
}
else if($_GET["p"] == "input") {
    if (!empty($_POST)) {
        $date = date("G:i d-m-Y");
        $bericht = $_POST["bericht"];

        include "chatfuncs.php";
        $bericht = cleanup($bericht);
        $bericht = smileys($bericht);
        $bericht = tokens($bericht);

        $message = "[" . $date . "] <b>" . $_GET["name"] . ":</b> " . $bericht . "<br>\n" . file_get_contents("messages.html");
        $handle = fopen("messages.html", "w");

        fputs($handle, $message);
        fclose($handle);
    }

?>

<form method=post name=form action=<?php echo $_SERVER["PHP_SELF"]; ?>?name=<?php echo $_GET["name"]; ?>&p=input>
<b>Bericht:</b> <input type=text name="bericht" size=60> <input type=submit value=Zeg!>
</form>
<script language="JavaScript">
<!--
document.form.bericht.focus()

function popUp(url) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=250,height=320,left=387,top=259');");
}
// -->
</script>
<a href="javascript:popUp('help.php?p=smileys');">Smileys</a> || <a href="javascript:popUp('help.php?p=tokens');">Tokens</a>
<?php if(isset($_SESSION["admin12345"]))
echo " || <a href=\"javascript:popUp('adminact.php');\">Admin acties</a>";
}

?>


/* //////////////// chatframe.php //////////////// */
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$inc
= include "config.php";
if(!$inc) die("Dit script is niet geinstalleerd");
?>

<head>
<title><?php echo $chatname; ?> - Chat</title>
<link rel=stylesheet type=text/css href=chat.css>
</head>
<frameset rows="10%, *, 20%">
    <frame src=chatcore.php?name=<?php echo $_GET["name"]; ?>&p=header scrolling=no noresize>

    <frameset cols="*, 20%">
        <frame src=chatcore.php?p=messages noresize>
        <frame src=chatcore.php?p=online noresize>
    </frameset>

    <frame src=chatcore.php?name=<?php echo $_GET["name"]; ?>&p=input scrolling=no noresize>
</frameset>


/* //////////////// chatfuncs.php //////////////// */
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
function cleanup($string="") {
    $string = strip_tags($string);
    $string = htmlspecialchars($string);
    return $string;
}

function
smileys($string="") {
    $smileys = array(":)", ";)", ":P", ":(", ":|", "8)", ":D", ":Y");
    $images = array("<img src=\"smileys/1.gif\">",
                    "<img src=\"smileys/2.gif\">",
                    "<img src=\"smileys/3.gif\">",
                    "<img src=\"smileys/4.gif\">",
                    "<img src=\"smileys/5.gif\">",
                    "<img src=\"smileys/6.gif\">",
                    "<img src=\"smileys/7.gif\">",
                    "<img src=\"smileys/8.gif\">");
    $string = str_replace($smileys, $images, $string);
    return $string;
}

function
tokens($string="") {
    $string = str_replace("!date!", date("d-m-Y"), $string);
    $string = str_replace("!time!", date("H:i"), $string);
    $string = str_replace("!name!", $_GET["name"], $string);
    return $string;
}

?>


/* //////////////// help.php //////////////// */
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<html>
<head>
<title>Chat help</title>
<link rel=stylesheet type=text/css href="chat.css">
</head>
<body>
<?php
if($_GET["p"] == "smileys") {
?>

Om het chatten leuker te maken, zijn er smileys om je emoties uit te beelden.<br><br>
<table class=smileytable>
    <tr width=100%>
        <td width=50%><b>Smiley</b></td><td width=50%><b>Code</b></td>
    </tr>
    <tr>
        <td><img src="smileys/1.gif"></td><td>:)</td>
    </tr>
    <tr>
        <td><img src="smileys/2.gif"></td><td>;)</td>
    </tr>
    <tr>
        <td><img src="smileys/3.gif"></td><td>:P</td>
    </tr>
    <tr>
        <td><img src="smileys/4.gif"></td><td>:(</td>
    </tr>
    <tr>
        <td><img src="smileys/5.gif"></td><td>:|</td>
    </tr>
    <tr>
        <td><img src="smileys/6.gif"></td><td>8)</td>
    </tr>
    <tr>
        <td><img src="smileys/7.gif"></td><td>:D</td>
    </tr>
    <tr>
        <td><img src="smileys/8.gif"></td><td>:Y</td>
    </tr>
</table>
<?php
}else if($_GET["p"] == "tokens") {
?>

Om specialen dingen weer te geven zijn er tokens.<br><br>
<table class=smileytable>
    <tr width=100%>
        <td width=50%><b>Token</b></td><td width=50%><b>Uitvoer</b></td>
    </tr>
    <tr>
        <td>!date!</td><td><?php echo date("d-m-Y"); ?></td>
    </tr>
    <tr>
        <td>!time!</td><td><?php echo date("H:i"); ?></td>
    </tr>
    <tr>
        <td>!name!</td><td>Je naam</td>
    </tr>
</table>
<?php
}
?>

<br><br><input type=button value=Sluit onClick="self.close();">
</body>
</html>


/* //////////////// index.php //////////////// */
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
<?php
$inc
= include "config.php";
if(!$inc) die("Dit script is niet geinstalleerd");
?>

<link rel=stylesheet type=text/css href=chat.css>
<body>
<h2><?php echo $chatname; ?> -- Chat</h2>
<form action=chatframe.php method=GET>
<b>Naam:</b> <input type=text size=20 name=name maxlength=16><br><br>
<input type=submit value=Inloggen>
</form>
</body>


/* //////////////// install.php //////////////// */
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<html>
<head>
<title>Chat Installatie</title>
<style>
<!--
body {
    background-color: #6699CC;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12pt;
    color: #000000;
    text-align: center;
}

a:link {
    color: #333333;
    text-decoration: none;
}


a:hover {
    text-decoration: underline;
}

.installtable {
    border: solid #333333;
    border-width: 1px;
    background: #FFF9D4;
}

.installerror {
    color: #FF0000;
    font-size: 9pt;
}

.installnotice {
    color: #669900;
    font-size: 9pt;
}

.copyright {
    border-top: 1pt #000000 solid;
    border-bottom: 1pt #000000 solid;
    border-right: 1pt #000000 solid;
    border-left: 1pt #000000 solid;
    background: #CCD800;
-->
</style>
</head>

<body>
<font size=5>Chat Installatie</font><br>Door Cas Ebbers<br><br>
<table width=80% border=0 cellspacing=0 cellpadding=3 class=installtable>
    <tr>
        <td align=center>
<?php
if(isset($_POST["submit"])) {
    echo "\t\tInstallatie gestart...<br><br>\n";

    $handle = @fopen("config.php", "w");
    $contents = "<?php\n";
    $contents .= "\$chatname = \"".$_POST["chatbox"]."\";\n";
    $contents .= "\$adminpass = \"".$_POST["adminpass"]."\";\n";
    $contents .= "?>";
    $write = @fputs($handle, $contents);
    @
fclose($handle);

    if($write) {
        echo "\t\t<span class=installnotice style=\"visibility: hidden\" id=line1>Informatie naar bestand geschreven.</span><br>\n";

        $handle = @fopen("messages.html", "w");
        $contents = "[".date("H:i d-m-Y")."] <b>De chat is geinstalleerd op deze server.</b><br>";
        $write = @fputs($handle, $contents);
        @
fclose($handle);

        if($write) {
            echo "\t\t<span class=installnotice style=\"visibility: hidden\" id=line2>Chatberichten bestand aangemaakt.</span><br>\n";

            if(@mkdir("users")) {
                echo "\t\t<span class=installnotice style=\"visibility: hidden\" id=line3>Map 'users' aangemaakt.</span><br>\n";
            }
else
                echo "\t\t<span class=installerror style=\"visibility: hidden\" id=line3>Kon map 'users' niet aanmaken.</span><br>\n";
        }
else
            echo "\t\t<span class=installerror style=\"visibility: hidden\" id=line2>Kon chatberichten bestand niet aanmaken.</span><br>\n";
    }
else
        echo "\t\t<span class=installerror style=\"visibility: hidden\" id=line1>Kon informatie niet naar bestand schrijven.</span><br>\n";
?>

<script language="JavaScript">
var line1 = document.getElementById("line1");
var line2 = document.getElementById("line2");
var line3 = document.getElementById("line3");

window.setTimeout("line1.style.visibility='visible'", 1000);
window.setTimeout("line2.style.visibility='visible'", 3000);
window.setTimeout("line3.style.visibility='visible'", 5000);

function blockError() {return true}
window.onerror = blockError;
</script>
<?php
} else {
?>

        <form method=post action="<?php echo $_SERVER["PHP_SELF"]; ?>">
        Chatboxnaam: <input type=text name=chatbox><br>
        Admin wachtwoord: <input type=password name=adminpass><br>
        <input type=submit name=submit value="Installeer">
        </form>
<?php
}
?>

        </td>
    </tr>
    <tr>
        <td align=center><font size=2 class=copyright>&copy; Cas Ebbers <?php echo date("Y"); ?></font></td>
    </tr>
</table>
</body>
</html>
Gewijzigd op 01/01/1970 01:00:00 door Michiel Pil
 
PHP hulp

PHP hulp

24/04/2024 19:09:21
 
PurpleMadness -

PurpleMadness -

05/04/2006 18:23:00
Quote Anchor link
en welke errors? =)
 

05/04/2006 18:24:00
Quote Anchor link
S=Sebazzz, G=Glazen bol
S: Glazen bol. Glazen bol, zegt alsublieft wat de genoemde errors zijn. Ik kom er niet uit.

G: Grote Heer, Ik Weet Het Ook Niet. Maar Ik Weet Wel Eén Ding.

S: Wat dan?

G: Je Bent Niet De Mooiste Van Het Land. Ik Heb Gezegd.

--------------
Even serieus:
Wat zijn je errors?
 
Michiel Pil

Michiel Pil

05/04/2006 18:24:00
Quote Anchor link
Een parse error in chatcore.php on line 6
 
Arjan Kapteijn

Arjan Kapteijn

05/04/2006 18:25:00
Quote Anchor link
Eehmmm.. ga naar de maker van dit script en vraag het hem? Kom anders terug met relevante code, errors en wat je al geprobeerd heb want hier ga ik niet eens aan beginnen...
 
PurpleMadness -

PurpleMadness -

05/04/2006 18:30:00
Quote Anchor link
error_reporting moest toch vóór output?
 
Michiel Pil

Michiel Pil

05/04/2006 18:40:00
Quote Anchor link
Bedankt het script werkt terug !!
 
Eric Cartman

Eric Cartman

05/04/2006 19:27:00
Quote Anchor link
Werkt die terug? Vreemd...
 
Willem Jan Z

Willem Jan Z

05/04/2006 19:32:00
Quote Anchor link
Er staat nogal duidelijk dat in lijn 6 in chatcore.php een fout zit.
Waarom post je dan 8 andere stukken script erbij :s

Ik zou zeggen RTFM, maar ik hou het netjes. En zeg: Lees de FAQ
Gewijzigd op 01/01/1970 01:00:00 door Willem Jan Z
 
Pieter van Linschoten

Pieter van Linschoten

05/04/2006 20:08:00
Quote Anchor link
Lees die faqing F.U.C.K!
 
Michiel Pil

Michiel Pil

06/04/2006 14:02:00
Quote Anchor link
Alles werkt ;)!!
Maar hoe zorg ik nu dat ze uitgelogt raken ?
 

06/04/2006 14:06:00
Quote Anchor link
Schakelaar achterop de computer, soms ook wel vooraan
 
Michiel Pil

Michiel Pil

06/04/2006 14:06:00
Quote Anchor link
? uitgelogt op de chat he ?
 

06/04/2006 14:10:00
Quote Anchor link
Niet alleen de faqing F.U.C.K. lezen maar ook tussen de regels door, of gewoon de post van arjan
 
Woopie100

Woopie100

06/04/2006 14:34:00
Quote Anchor link
wat dnek je van session_destroy(); :)
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.