Shoutbox sicher machen!

Dieses Thema im Forum "Webentwicklung" wurde erstellt von Nemesis Force, 26. Februar 2008 .

Schlagworte:
Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 26. Februar 2008
    Hallo,
    ich hätte da mal ne Frage. Wie kann ich meine Shoutbox sicher machen. Zur Zeit akzeptiert diese nämlich alle Zeichen, also HTML, CSS usw., wenn ich diese Zeichen sende, dann fliegt mir jedesmal die komplette Shoutbox um die Ohren. Ich hoffe mir kann jemand helfen. Hier mal der Code:

    PHP:
    <?
      
    $tablewidth  120 ;                 //Breite der Tabelle
      
    $showcomments  4 ;                 //Anzahl der anzuzeigenden Kommentare
      
    $file  "support/shouts.dat" ;         //Name der Shoutsdatei
      
    $timestamp  time ();
      
    $datum  date ( "d.m.Y" , $timestamp );
      
    $uhrzeit  date ( "H:i" , $timestamp );
      
      echo 
    "
          <form action='
    $PHP_SELF ?show= $show ' method='post'>
        <table width='
    $tablewidth ' border='0'>
        <tr>
          <td>
            <input type='text' value='Name' class='formular_home' name='input_name' size='35' maxlength='20' onclick='this.value=\"\";' /><br /><br />
            <input type='text' value='Kommentar' class='formular_home' name='input_comment' size='35' maxlength='150' onclick='this.value=\"\";' /><br /><br />
            <input type='submit' class='formular_button' style='font-weight:bold' value='senden' /><br /><br />
          </td>
          </tr>
        <tr>
          <td colspan='2'>"
    ;

      if(
    $input_name  !=  "Name"  &&  $input_name  !=  ""  &&  $input_comment  !=  "Kommentar"  &&  $input_comment  !=  "" ){
        
    $tmp  fopen ( $file "a" );
        
    fputs ( $tmp , " $input_name | $input_comment | $datum | $uhrzeit \n" );
        
    fclose ( $tmp );
      }
      
    $names  = array();
      
    $comments  = array();
      
    $dates  = array();
      
    $times  = array();
      
    $tmp  fopen ( $file , "r" );
      while(!
    feof ( $tmp )){
        
    $row  fgets ( $tmp , 999999 );
        list(
    $name , $comment , $date , $time ) =  split ( "\|" , $row );
        if(
    $name  !=  "" ){
          
    array_push ( $names , $name );
          
    array_push ( $comments , $comment );
          
    array_push ( $dates , $date );
          
    array_push ( $times , $time );
        }
      }
      
    fclose ( $tmp );
      
    $names  array_reverse ( $names );
      
    $comments  array_reverse ( $comments );
      
    $dates  array_reverse ( $dates );
      
    $times  array_reverse ( $times );

      if(
    $show  ==  "all" )
        
    $max  count ( $names );
      else
        
    $max  $showcomments ;

      for(
    $i = 0 $i < $max $i ++)
        echo 
    "<strong> $names [ $i ] </span> </strong>~  $dates [ $i ]  |  $times [ $i ] <br /> $comments [ $i ] <br />" ;

      echo 
    "
          </td>
        </tr>
    </table>
    </form>
      "
    ;
    ?>
     
  2. 26. Februar 2008
    AW: Shoutbox sicher machen!

    Wenn du nichtmal weist wie du eingaben filterst.
    Wo hast du dann das Script geklaut?


    nimm zur Ausgabe einfach $text = htmlspecialchars($text);
    dann sind alle Sonderzeichen umgewandelt und unschädlich gemacht worden.

    Oder habe ich nur deine Frage missverstanden? ?
     
  3. 27. Februar 2008
    AW: Shoutbox sicher machen!

    nimm gleich htmlentities() dann bekommst du auch valide Sonderzeichen.

    Mit css kannst du dann noch wordwrap setzen, sodass bei langen worten automatisch umgebrochen wird.

    Es reicht, wenn du htmlentities() bei allen Ausgaben benutzt, dann kannst du beim Speichern alles direkt wie es vom Formular kommt in deine db speichern.
     
  4. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.