spinchmeister
Mitglied
das Ganze besteht aus den Zeilen...und mein Problem ist: ich bin noch ziemlicher anfänger in php..das Ganze funktioniert soweit so gut..nur wenn man ein "Wort" wie z.B "fffffffffffffffffffffffffffff" eingibt...dann schreibt er das in einer Zeile und schmeisst das Ganze Design zusammen..wie kann ich das jetzt einbauen, dass er wörter trennt bzw. einfach in mehrere Zeilen schreibt!? Ich wäre echt ein glücklicher Mensch, wenn mir jemand das reinschreiben könnte..
<?php
$text_file = "db.txt";
$shoutbox_url = "xxx";
$referer_url = "xxx";
if( isset($_GET['action']) && $_GET['action'] == "add" )
{
if( $_POST['email'] == "Email" )
$_POST['email'] = "";
$new_line = $_POST['name']."|".$_POST['email']."|".date("Y/m/d H:i")."|".stripslashes(htmlspecialchars($_POST['message'])) . "\n";
if( ! $fp = fopen($text_file,"a") )
echo "Cannot open " . $text_file . "! Check the file rights.";
if( flock( $fp, LOCK_EX ) )
{
fwrite( $fp,$new_line );
flock( $fp, LOCK_UN );
} else {
echo "Couldn't lock the file " . $text_file . "!";
}
header("Location: " . $referer_url );
}
function show_shoutbox($height = 250,$width = 150,$per_page = 5, $border="border:1px #000000 solid;", $font_family="verdana",$font_size=11)
{
if( isset( $_GET['shoutbox_page'] ) )
$shoutbox_page = $_GET['shoutbox_page'];
if( empty( $_GET['shoutbox_page'] ) )
$shoutbox_page = 1;
$file = $GLOBALS['text_file'];
if( ! $fp = @fopen( $file, "r" ) )
{
echo "Text-Datenbank für die Shoutbox kann nicht geöffnet werden!";
exit;
}
$output_buffer = "";
$shouts = array();
if( filesize($file) )
{
$fp = fread( $fp, filesize( $file ) );
$shouts = explode("\n",$fp);
$total_shouts = count($shouts);
$total_pages = ceil($total_shouts/$per_page);
$shout_pointer = (($total_shouts - ($shoutbox_page * $per_page))+$per_page)-1;
if( $shoutbox_page > $total_pages )
$shoutbox_page = 1;
$output_buffer .= page_numbers( $total_pages , $shoutbox_page );
}
else
{
$shouts = 0;
$total_shouts = 0;
$shout_pointer = 0;
$output_buffer .= page_numbers( 1 , 1 );
}
for( $i = $shout_pointer ; $i > ($shout_pointer-$per_page); $i-- )
{
if( $i > -1 )
{
if( $shouts[$i] )
list( $name, $email, $date, $shout ) = explode("|",$shouts[$i]);
if( !empty( $name ) )
{
$email_start = "";
$email_end = "";
if( ! empty( $email ) )
{
$email_start = "<a href=\"mailto:" . $email . "\">";
$email_end = "</a>";
}
$output_buffer .= "<strong>" . $email_start . $name . $email_end . "</strong>\n<br />" . $shout . "<br /><br />";
}
}
}
?>
<table style="width:<?=$width;?>;">
<form method="post" action="<?=$GLOBALS['shoutbox_url'];?>?action=add">
<tr><td align="center" style="font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px;"></td></tr>
<tr>
<td background="shoutboxbg.jpg">
<div style="<?=$border;?> font-family:<?=$font_family;?>; color:#FFFFFF; font-size:<?=$font_size;?>px; height:<?=$height;?>; overflow:auto; padding:3px; width:100%;">
<?=$output_buffer;?>
</div>
</td>
</tr>
<tr>
<td>
<input type="text" name="name" value="Name" style="<?=$border;?> font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px; width:100%;" onfocus="this.select();"><br />
<input type="text" name="email" value="Email" style="<?=$border;?> font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px; width:100%;" onfocus="this.select();"><br />
<input type="text" name="message" value="Nachricht" style="<?=$border;?> font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px; width:100%;" onfocus="this.select();"><br />
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="Absenden" style="color: #FFFFFF; border: 1px solid #FFFFFF; background-color: #000000" font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px;"><br />
</td>
</tr>
</table>
<?php
}
function page_numbers($total_pages,$current = 1)
{
$url_bar = $_SERVER['PHP_SELF']. "?" . $_SERVER['QUERY_STRING'];
$url_bar = preg_replace( "/(&shoutbox_page=[1-9]+)/","", $url_bar );
$buffer = "<div align=\"center\">Seite: <select onchange=\"javascript: location.href='" . $url_bar . "&shoutbox_page='+this.value;\" style=\"font-family: verdana; font-size: 10px;\">\n";
for( $i = 1 ; $i <= $total_pages ; $i++ )
{
$selected = "";
if( $current == $i )
$selected = "selected=\"selected\"";
$buffer .= "<option value=\"".$i."\"" . $selected . ">".$i."</option>\n";
}
$buffer .= "</select></div><hr size=\"1\">\n";
return $buffer;
}
show_shoutbox();
?>
<?php
$text_file = "db.txt";
$shoutbox_url = "xxx";
$referer_url = "xxx";
if( isset($_GET['action']) && $_GET['action'] == "add" )
{
if( $_POST['email'] == "Email" )
$_POST['email'] = "";
$new_line = $_POST['name']."|".$_POST['email']."|".date("Y/m/d H:i")."|".stripslashes(htmlspecialchars($_POST['message'])) . "\n";
if( ! $fp = fopen($text_file,"a") )
echo "Cannot open " . $text_file . "! Check the file rights.";
if( flock( $fp, LOCK_EX ) )
{
fwrite( $fp,$new_line );
flock( $fp, LOCK_UN );
} else {
echo "Couldn't lock the file " . $text_file . "!";
}
header("Location: " . $referer_url );
}
function show_shoutbox($height = 250,$width = 150,$per_page = 5, $border="border:1px #000000 solid;", $font_family="verdana",$font_size=11)
{
if( isset( $_GET['shoutbox_page'] ) )
$shoutbox_page = $_GET['shoutbox_page'];
if( empty( $_GET['shoutbox_page'] ) )
$shoutbox_page = 1;
$file = $GLOBALS['text_file'];
if( ! $fp = @fopen( $file, "r" ) )
{
echo "Text-Datenbank für die Shoutbox kann nicht geöffnet werden!";
exit;
}
$output_buffer = "";
$shouts = array();
if( filesize($file) )
{
$fp = fread( $fp, filesize( $file ) );
$shouts = explode("\n",$fp);
$total_shouts = count($shouts);
$total_pages = ceil($total_shouts/$per_page);
$shout_pointer = (($total_shouts - ($shoutbox_page * $per_page))+$per_page)-1;
if( $shoutbox_page > $total_pages )
$shoutbox_page = 1;
$output_buffer .= page_numbers( $total_pages , $shoutbox_page );
}
else
{
$shouts = 0;
$total_shouts = 0;
$shout_pointer = 0;
$output_buffer .= page_numbers( 1 , 1 );
}
for( $i = $shout_pointer ; $i > ($shout_pointer-$per_page); $i-- )
{
if( $i > -1 )
{
if( $shouts[$i] )
list( $name, $email, $date, $shout ) = explode("|",$shouts[$i]);
if( !empty( $name ) )
{
$email_start = "";
$email_end = "";
if( ! empty( $email ) )
{
$email_start = "<a href=\"mailto:" . $email . "\">";
$email_end = "</a>";
}
$output_buffer .= "<strong>" . $email_start . $name . $email_end . "</strong>\n<br />" . $shout . "<br /><br />";
}
}
}
?>
<table style="width:<?=$width;?>;">
<form method="post" action="<?=$GLOBALS['shoutbox_url'];?>?action=add">
<tr><td align="center" style="font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px;"></td></tr>
<tr>
<td background="shoutboxbg.jpg">
<div style="<?=$border;?> font-family:<?=$font_family;?>; color:#FFFFFF; font-size:<?=$font_size;?>px; height:<?=$height;?>; overflow:auto; padding:3px; width:100%;">
<?=$output_buffer;?>
</div>
</td>
</tr>
<tr>
<td>
<input type="text" name="name" value="Name" style="<?=$border;?> font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px; width:100%;" onfocus="this.select();"><br />
<input type="text" name="email" value="Email" style="<?=$border;?> font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px; width:100%;" onfocus="this.select();"><br />
<input type="text" name="message" value="Nachricht" style="<?=$border;?> font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px; width:100%;" onfocus="this.select();"><br />
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="Absenden" style="color: #FFFFFF; border: 1px solid #FFFFFF; background-color: #000000" font-family:<?=$font_family;?>; font-size:<?=$font_size;?>px;"><br />
</td>
</tr>
</table>
<?php
}
function page_numbers($total_pages,$current = 1)
{
$url_bar = $_SERVER['PHP_SELF']. "?" . $_SERVER['QUERY_STRING'];
$url_bar = preg_replace( "/(&shoutbox_page=[1-9]+)/","", $url_bar );
$buffer = "<div align=\"center\">Seite: <select onchange=\"javascript: location.href='" . $url_bar . "&shoutbox_page='+this.value;\" style=\"font-family: verdana; font-size: 10px;\">\n";
for( $i = 1 ; $i <= $total_pages ; $i++ )
{
$selected = "";
if( $current == $i )
$selected = "selected=\"selected\"";
$buffer .= "<option value=\"".$i."\"" . $selected . ">".$i."</option>\n";
}
$buffer .= "</select></div><hr size=\"1\">\n";
return $buffer;
}
show_shoutbox();
?>