Geen plaintext e.d. op de berichtenbalk

Gestart doorRemcoboy29 reacties40 weergaven

30 berichten · pagina 1 van 2

Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoe doe ik dit : Geen plaintext e.d. op de berichtenbalk op de source van budget-scripts ?
0
Berichten
1.712
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
met htmlentities();
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kan je dit in me script bouwen ??
0
Berichten
1.712
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als het goed is heb je ergens een query die het bericht in de berichtenbalk-tabel in je MySQL zet of niet?

In ieder geval ziet die query er ongeveer zo uit:
mysql_query("INSERT INTO berichtenbalk (naam, bericht) VALUES (".$_POST[naam].", ".$_POST[email]."") or die(mysql_error());


Dat moet worden:
mysql_query("INSERT INTO berichtenbalk (naam, bericht) VALUES (".htmlentities($_POST[naam]).", ".htmlentities($_POST[email])."") or die(mysql_error());


Ik weet uiteraard niet precies wat de query is, maar het zal zoiets moeten worden.
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb dit :

if( isset($_POST["plaats"])) {
if($_POST["naam"] != "" && $_POST["bericht"] != "")
{
mysql_query("INSERT INTO berichten (id,bbid,afzender,bericht,ip) values (,".$_GET["id"].",".$_POST["naam"].",".$_POST["bericht"].",".$_SERVER[REMOTE_ADDR].")") or die(mysql_error());
echo"Bericht is succesvol geplaatst";
}else{

Trouwens er mogen ook geen urllink in kunnen..
0
Berichten
1.712
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"plaats"[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]""[/COLOR] [COLOR= #007700]&&[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"bericht"[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO berichten (id,bbid,afzender,bericht,ip) values (,"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"id"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"bericht"[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Bericht is succesvol geplaatst"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]


Dan werkt ie denk ik wink
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ok,
ty!

Kan je het ook zo doen dat er in plaats van naam en text dikgedrukt is alleen de naam ??
0
Berichten
1.712
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Alleen de naam dikgedrukt bedoel je?
Dat zit sowieso in een ander deel van je script, bij waar de berichtenbalk wordt weergegeven zegmaar.
0
Berichten
5.209
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Schopje richting webwereld.
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
htmlentities() moet je pas doen als je het uit de database haalt he. biggrinAnders kun je het nooit aanpassen zegmaar, omdat je niet weet wat je oorspronkelijke data was.
0
Remi

Lid

Berichten
1.270
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Doe maar
htmlentities($string, ENT_QUOTES);
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
htmlentities() moet je pas doen als je het uit de database haalt he. biggrin
Anders kun je het nooit aanpassen zegmaar, omdat je niet weet wat je oorspronkelijke data was.

Het werkt wel...

Alleen nog html eruit..
Pascal schreef:
Alleen de naam dikgedrukt bedoel je?
Dat zit sowieso in een ander deel van je script, bij waar de berichtenbalk wordt weergegeven zegmaar.

Deze heb ik voor je

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>Bericht plaatsen</title>
<link href="opmaak.css" rel="stylesheet" type="text/css">
<script language=JavaScript>

function Smile(code) {
window.opener.document.form.bericht.value = code;
}
function Invoegen(veld,waarde,positie) {
        veld = document.getElementById(veld);
  if (document.selection) {
    veld.focus();
    Selectie = document.selection.createRange();
    Selectie.text = waarde;
  }
  else if (veld.selectionStart || veld.selectionStart == 0) {
    var begin = veld.value.substring(0,veld.selectionStart);
    var einde = veld.value.substring(veld.selectionEnd,veld.value.length);;
    veld.value = begin + waarde + einde;
    veld.focus();
    veld.selectionStart = veld.selectionEnd = (begin.length + waarde.length - positie);
  }
  else {
    veld.value += waarde;
  }
}
</script>
</head>

<body>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]db/config.php[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM berichtenbalk WHERE id="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$resultaat[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$aantal[/COLOR]    [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resultaat[/COLOR][COLOR= #007700]);[/COLOR]
    
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Error #404"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
[COLOR= #0000BB]<?Php
    $sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM ban WHERE ip = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" AND bbid="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700]) >=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
    {[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM ban WHERE ip="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" AND bbid="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$obj[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$reden[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]reden[COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bent geband om de volgende reden :<BR> $reden<BR>Daarom kan je geen bericht plaatsen."[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
    }
}[/COLOR]
?>

[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM berichtenbalk WHERE id="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$obj[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$reclame[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]reclame[COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$reclame[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$reclame[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<center><a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$siteurl[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" target="_blank" >Ook een gratis berichtenbalk ?</a></center>[/COLOR][COLOR= #007700];
} 
}[/COLOR]
?>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"plaats"[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]""[/COLOR] [COLOR= #007700]&&[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"bericht"[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO berichten (id,bbid,afzender,bericht,ip) values (,"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"id"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"bericht"[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Bericht is succesvol geplaatst"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Je hebt iets niet ingevult"[/COLOR][COLOR= #007700];
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
<form method="post" id="form">
Naam :<BR>
<input type="text" name="naam"><BR>
Bericht :<BR>
<textarea cols="30" name="bericht" id="bericht">
</textarea><BR>
<a href=javascript:// onClick="Invoegen(bericht, :),0)"><img src="images/icon1.gif" border="0"></a>&nbsp;<a href=javascript:// onClick="Invoegen(bericht, :D,0)"><img src="images/icon2.gif" border="0"></a>&nbsp;<a href=javascript:// onClick="Invoegen(bericht, (h),0)"><img src="images/icon4.gif" border="0"></a><BR>
<input type="submit" name="plaats" value="Plaats bericht">
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}
}[/COLOR]
?>
<BR>
<BR>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$reclame[/COLOR][COLOR= #007700];[/COLOR] 
?>
      
</body>

</html>
0
Berichten
1.712
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dat is enkel de plaats-bericht pagina? Daar moet je niet zoeken.

@htmlentities bij het uit database halen: ik doe altijd als ik het erin stop, tot nog toe nooit problemen mee gehad eigenlijk emo?
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kan nogsteeds html..

Welke pagina dan ?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Pascal schreef:
Dat is enkel de plaats-bericht pagina? Daar moet je niet zoeken.
@htmlentities bij het uit database halen: ik doe altijd als ik het erin stop, tot nog toe nooit problemen mee gehad eigenlijk emo?
Komt nog wel dan. yummie
Stel dat je een bewerk-optie wil maken, dan kan dat niet omdat je niet weet wat het oorspronkelijke bericht was. Opzich geen ramp omdat je het wel terug kunt redeneren (omgekeerde functie van htmlentities() gebruiken), maar t is "netter" en handiger om het achteraf te doen. yummie
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren