rare enter tekens
Weet iemand hoe ik dit kan verhelpen, ook geeft die // waneer je aanhalingstekens gebruikt.
http://www.daanooms.nl/gastenboek.php
Gewijzigd op 21/06/2005 18:07:00 door Daan
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?
$bericht = 'de tekst die in de db/ bestand staat';
$bericht = str_replace("{{","<br>",$bericht);
echo $bericht; // nu worden {{ omgezet naar <br>
?>
$bericht = 'de tekst die in de db/ bestand staat';
$bericht = str_replace("{{","<br>",$bericht);
echo $bericht; // nu worden {{ omgezet naar <br>
?>
Ja ok, maar dat lijkt me meer een gevolg aanpakken. Ik hoop dat er iemand is die de oorzaak weet van deze rare tekens en deze kan aanpakken.
wil je dan ff het script hiet posten anders kunnen wij nog niks
Code (php)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?
$amount=50;
if ($_GET['action']=='write') {
$file=fopen('gastenboek.txt','a');
$message=str_replace("\r",'',$message);
$message=str_replace("\n",'{{',$_GET['message']);
fwrite($file,$message."\n");
fclose($file);
header('location: gastenboek.php?action=read&start=0');
}
$start=(isset($_GET['start'])?$_GET['start']:0);
$gastenboek=Array();
$gastenboek=file('gastenboek.txt');
?>
<style>
#message{
width: 100%;
height: 100px;
font-family: Arial;
overflow: auto;
}
TD, textarea {
font-family:Arial;
font-size: 1em;
}
</style>
<HTML>
<HEAD>
<TITLE>Gastenboek</TITLE>
<!--
Gebruik de volgende script tag als je het SUR-script van CoR.nl wilt gebruiken
<SCRIPT language="JavaScript" src="sur.js" type="text/javascript"></SCRIPT>
Verwijder dan ook de twee slashes (//) in de onLoad van de BODY-tag
-->
<SCRIPT language="JavaScript">
function validate(form) {
if (form.name.value=="") {
alert("Vul je naam in");
return false;
} else if (form.message.value=="") {
alert("Vul je bericht in");
document.getElementById('message').focus();
return false;
}
}
</SCRIPT>
</HEAD>
<body onload="document.getElementById('message').focus()" topmargin="40" background="/images/backgrnd1.gif" leftmargin="20" topmargin="40">
<center>
<TABLE width="100%" cellspacing="0" cellpadding="0">
<tr><td align="center"><INPUT TYPE=button VALUE="Button"
onClick="location.href='index.htm'" style="font-family: Arial" title="Go to the main page">
</td></tr>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="25">
<TABLE width="748" style="border-style:solid; border-width:1; border-collapse: collapse" cellpadding="20" cellspacing="0" id="AutoNumber1" bordercolor="#000000" bgcolor="#FFFFFF">
<TR><TD class="conttd">
<FORM action="gastenboek.php" method="GET" onSubmit="return validate(this);">
<INPUT type="hidden" name="action" value="write">
<TEXTAREA name="message" id="message" cols="85" rows="5" style="border-collapse: collapse; border: 0px solid #000000;"></TEXTAREA></TD></TR>
<tr><td align="right"><INPUT type="submit" style="font-family: Arial" size="3" value="Verstuur" title="Klik hier om je bericht te plaatsten"></TD></TR>
</FORM>
</TD></TR>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="20">
<TABLE width="100" cellspacing="0" cellpadding="0">
<tr><td><img border="0" src="images/spacer.gif" width="1" height="20"></td></tr>
<tr>
<td style="border-style:solid; border-width:1; border-collapse: collapse" bordercolor="#000000" bgcolor="#FFFFFF">
<CENTER>
<?
if ($start>0) echo '<A href="gastenboek.php?start='.max(0,$start-$amount).'"style="text-decoration: none"><</A> ';
if ($start+$amount<sizeof($gastenboek)) echo ' <A href="gastenboek.php?start='.($start+$amount).'"style="text-decoration: none">></A>';
?>
</CENTER>
</TD>
</TR>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="20">
<TABLE width="748" cellspacing="0" cellpadding="20" style="border-style:solid; border-width:1; border-collapse: collapse" bordercolor="#000000" bgcolor="#FFFFFF">
<tr>
<td>
<TABLE BORDER= "0" cellspacing="0" cellpadding="0" style="font-family:Arial;" "border-style:none border-collapse: collapse" bgcolor="#FFFFFF">
<tr>
<td>
<?
$gastenboek=array_reverse($gastenboek);
for ($i=$start;$i<$start+$amount && $i<sizeof($gastenboek);$i++) {
list($name,$email,$date,$url,$message)=explode('|||',$gastenboek[$i]);
$message=str_replace('{{',"\n",$message);
echo '<TR><TD>'.($email!=""?'<A href="mailto:'.$email.'">'.$name.'</A>':$name).'</B></TD><TD align="right"></B> </FONT> '.$date.'</B></P></TD></TR>'."\n";
echo ($url!=""?'<TR><TD colspan="2"><A href="'.$url.'" target="_blank">'.$url.'</A></TD></TR>':'')."\n";
echo '<TR><TD colspan="2"><SPAN class="SUR">'.str_replace("\n",'<BR>' ,htmlspecialchars($message)).'</SPAN></TD></TR>'."\n";
echo '<TR><TD colspan="2"><HR></TD></TR>'."\n";
}
?>
</td>
</tr>
</TABLE>
</td>
</tr>
</TABLE>
<TABLE width="100" cellspacing="0" cellpadding="0">
<tr><td><img border="0" src="images/spacer.gif" width="1" height="20"></td></tr>
<tr>
<td style="border-style:solid; border-width:1; border-collapse: collapse" bordercolor="#000000" bgcolor="#FFFFFF">
<CENTER>
<?
if ($start>0) echo '<A href="gastenboek.php?start='.max(0,$start-$amount).'"style="text-decoration: none"><</A> ';
if ($start+$amount<sizeof($gastenboek)) echo ' <A href="gastenboek.php?start='.($start+$amount).'"style="text-decoration: none">></A>';
?>
</CENTER>
</TD>
</TR>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="40">
<TABLE width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><INPUT TYPE=button VALUE="Button"
onClick="location.href='index.htm'" style="font-family: Arial" title="Go to the main page">
</td>
</tr>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="25">
</center>
</BODY>
</HTML>
$amount=50;
if ($_GET['action']=='write') {
$file=fopen('gastenboek.txt','a');
$message=str_replace("\r",'',$message);
$message=str_replace("\n",'{{',$_GET['message']);
fwrite($file,$message."\n");
fclose($file);
header('location: gastenboek.php?action=read&start=0');
}
$start=(isset($_GET['start'])?$_GET['start']:0);
$gastenboek=Array();
$gastenboek=file('gastenboek.txt');
?>
<style>
#message{
width: 100%;
height: 100px;
font-family: Arial;
overflow: auto;
}
TD, textarea {
font-family:Arial;
font-size: 1em;
}
</style>
<HTML>
<HEAD>
<TITLE>Gastenboek</TITLE>
<!--
Gebruik de volgende script tag als je het SUR-script van CoR.nl wilt gebruiken
<SCRIPT language="JavaScript" src="sur.js" type="text/javascript"></SCRIPT>
Verwijder dan ook de twee slashes (//) in de onLoad van de BODY-tag
-->
<SCRIPT language="JavaScript">
function validate(form) {
if (form.name.value=="") {
alert("Vul je naam in");
return false;
} else if (form.message.value=="") {
alert("Vul je bericht in");
document.getElementById('message').focus();
return false;
}
}
</SCRIPT>
</HEAD>
<body onload="document.getElementById('message').focus()" topmargin="40" background="/images/backgrnd1.gif" leftmargin="20" topmargin="40">
<center>
<TABLE width="100%" cellspacing="0" cellpadding="0">
<tr><td align="center"><INPUT TYPE=button VALUE="Button"
onClick="location.href='index.htm'" style="font-family: Arial" title="Go to the main page">
</td></tr>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="25">
<TABLE width="748" style="border-style:solid; border-width:1; border-collapse: collapse" cellpadding="20" cellspacing="0" id="AutoNumber1" bordercolor="#000000" bgcolor="#FFFFFF">
<TR><TD class="conttd">
<FORM action="gastenboek.php" method="GET" onSubmit="return validate(this);">
<INPUT type="hidden" name="action" value="write">
<TEXTAREA name="message" id="message" cols="85" rows="5" style="border-collapse: collapse; border: 0px solid #000000;"></TEXTAREA></TD></TR>
<tr><td align="right"><INPUT type="submit" style="font-family: Arial" size="3" value="Verstuur" title="Klik hier om je bericht te plaatsten"></TD></TR>
</FORM>
</TD></TR>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="20">
<TABLE width="100" cellspacing="0" cellpadding="0">
<tr><td><img border="0" src="images/spacer.gif" width="1" height="20"></td></tr>
<tr>
<td style="border-style:solid; border-width:1; border-collapse: collapse" bordercolor="#000000" bgcolor="#FFFFFF">
<CENTER>
<?
if ($start>0) echo '<A href="gastenboek.php?start='.max(0,$start-$amount).'"style="text-decoration: none"><</A> ';
if ($start+$amount<sizeof($gastenboek)) echo ' <A href="gastenboek.php?start='.($start+$amount).'"style="text-decoration: none">></A>';
?>
</CENTER>
</TD>
</TR>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="20">
<TABLE width="748" cellspacing="0" cellpadding="20" style="border-style:solid; border-width:1; border-collapse: collapse" bordercolor="#000000" bgcolor="#FFFFFF">
<tr>
<td>
<TABLE BORDER= "0" cellspacing="0" cellpadding="0" style="font-family:Arial;" "border-style:none border-collapse: collapse" bgcolor="#FFFFFF">
<tr>
<td>
<?
$gastenboek=array_reverse($gastenboek);
for ($i=$start;$i<$start+$amount && $i<sizeof($gastenboek);$i++) {
list($name,$email,$date,$url,$message)=explode('|||',$gastenboek[$i]);
$message=str_replace('{{',"\n",$message);
echo '<TR><TD>'.($email!=""?'<A href="mailto:'.$email.'">'.$name.'</A>':$name).'</B></TD><TD align="right"></B> </FONT> '.$date.'</B></P></TD></TR>'."\n";
echo ($url!=""?'<TR><TD colspan="2"><A href="'.$url.'" target="_blank">'.$url.'</A></TD></TR>':'')."\n";
echo '<TR><TD colspan="2"><SPAN class="SUR">'.str_replace("\n",'<BR>' ,htmlspecialchars($message)).'</SPAN></TD></TR>'."\n";
echo '<TR><TD colspan="2"><HR></TD></TR>'."\n";
}
?>
</td>
</tr>
</TABLE>
</td>
</tr>
</TABLE>
<TABLE width="100" cellspacing="0" cellpadding="0">
<tr><td><img border="0" src="images/spacer.gif" width="1" height="20"></td></tr>
<tr>
<td style="border-style:solid; border-width:1; border-collapse: collapse" bordercolor="#000000" bgcolor="#FFFFFF">
<CENTER>
<?
if ($start>0) echo '<A href="gastenboek.php?start='.max(0,$start-$amount).'"style="text-decoration: none"><</A> ';
if ($start+$amount<sizeof($gastenboek)) echo ' <A href="gastenboek.php?start='.($start+$amount).'"style="text-decoration: none">></A>';
?>
</CENTER>
</TD>
</TR>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="40">
<TABLE width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><INPUT TYPE=button VALUE="Button"
onClick="location.href='index.htm'" style="font-family: Arial" title="Go to the main page">
</td>
</tr>
</TABLE>
<img border="0" src="images/spacer.gif" width="1" height="25">
</center>
</BODY>
</HTML>
dit is het probleem
wat je daar doet is : vervang alle \n (enter) voor {{
dus het klopt wel dat er alemaal {{ in je script staat en wat betreft "//" dat komt door htmlspecialchars
Code (php)
1
2
3
4
2
3
4
<?php
$message=str_replace("\r",'',$message);
$message=str_replace("\n",'{{',$_GET['message']);
?>
$message=str_replace("\r",'',$message);
$message=str_replace("\n",'{{',$_GET['message']);
?>
en vervang door:
Alle soorten enters worden nu vervangen door een html enter.
Gewijzigd op 21/06/2005 19:14:00 door Martijn B
Dat van die htmlspecialchars, probleem met aanhalingstekens (hij zet dan een / voor de "), kan dat verholpen worden?
Gewijzigd op 21/06/2005 21:02:00 door Daan
Die haalt de \ weg (niet de / :P), bij " en ' en etc..