Haaaaaaallo!!!
Ach ja wo wir gerade bei den faq beachtungen sind...
<?php
// Show Entryform
function show_entry_form($file_index){
echo "<form action=".$file_index."&cmd=add method=post>\n";
echo "<table>\n";
echo "<tr><td>".translate("Name").":</td><td><input type=text name=name size=40></td></tr>\n";
echo "<tr><td>".translate("Email").":</td><td><input type=text name=email size=40></td></tr>\n";
echo "<tr><td>".translate("Web").":</td><td><input type=text name=web size=40></td></tr>\n";
echo "<tr><td colspan=2>".translate("Write a new entry").":<p><textarea cols=40 rows=7 name=text></textarea></td></tr>\n";
echo "<tr><td></td><td><input type=submit value=".translate("Save")."><input type=reset value=".translate("Delete")."></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "<hr>\n";
// read entries
read_data();
}
// save ebtry
function add_entry($data_file, $name, $email, $web, $text, $file_index){
// global $file_index, $data_file, $name, $email, $web, $text;
if ( $name and $text ) {
// check inputs
if ((strlen($web)>0) and (!(eregi("^http://",$web)))) {
$p_web = "http://$web"; }
$p_text = ereg_replace("\n","<br>",$text);
$date = date("d.m.Y-G:i");
$data = "$date|$name|$email|$p_web|$p_text\n";
// save inputs to file
$o_data_file=fopen($data_file, "a");
fputs($o_data_file, $data);
fclose($o_data_file);
// update guestbook
show_the_entry($file_index, $name, $email, $text, $date, "show");
}
else
{
echo "<h2>".translate("Please check you inputs.")."</h2>";
}
return false;
}
// show the made entry
function show_the_entry($file_index, $name, $email, $text, $date){
echo "<table border=1>\n";
echo "<tr bgcolor=red><td>".translate("Entry")." ".translate("by")."<a href=mailto:$email> $name</a> , $date</td></tr>\n";
echo "<tr><td>$text</td></tr>\n";
echo "</table>\n";
echo "<a href=$file_index>".translate("Back")."</a>\n";
}
//show entries
function read_data(){
global $file_index, $data_file, $name, $email, $web, $text;
$r_data_file=fopen($data_file, "r");
echo "<table><table>";
while (!feof($r_data_file)){
$string=chop(fgets($r_data_file, 1000));
if ( $string == "" ) {
continue;
}
else
{
$entry=split("|", $string);
echo "<tr><td><table width=500 border=1><tr><td bgcolor=red>".translate("Entry")." ".translate("by")."<a href=mailto:".$entry[2]."> ".$entry[1]."</a> ; <a href=".$entry[3].">".$entry[3]."</a>; ".$entry[0]."</td></tr><tr><td>".$entry[4]."</td></tr></table></td></tr>\n";
}
}
fclose($r_data_file);
echo "</table>\n";
}
/* loading language file */
function get_translations($lang) {
$lngfile="lang/".$lang.".txt";
if (file_exists($lngfile)) {
$lines = file($lngfile);
while (list(,$line) = each($lines)) {
list($key,$val)= explode("=",$line);
$phrases[$key] = $val;
}
return $phrases;
} else {
return false;
}
}
/* translate a string */
function translate($str,$vals="") {
global $phrases;
if ($phrases) {
$p_str = $phrases[$str];
if ($p_str == "") {
$p_str = $str;
}
} else {
$p_str = $str;
}
if (gettype($vals)=="array") {
$p_str = sprintf($p_str,$vals[0],$vals[1],$vals[2],$vals[3],$vals[4],$vals[5],$vals[6]);
}
return (trim($p_str));
}
// include the guestbook
function include_ckgb(){
global $file_index, $name, $email, $web, $text, $date, $cmd, $data_file, $file_path;
if ( $cmd == "add" ){
add_entry($data_file, $name, $email, $web, $text, $file_index);
} else if ( $cmd == "show" ){
show_the_entry($file_index);
}
else
{
show_entry_form($file_index);
}
}
// Start Guestbook //
// --------------- //
// if $lang not set, than that the language file
$defaultlng = "de";
// check if set $lang
if ( $lang ){
$phrases = get_translations($lang);
}
else
{
$phrases = get_translations($defaultlng);
}
// name of the guestbookfile
$file_index="index.php3?lang=".$lang;
// path and name of the data file
$data_file="data/ckgb.txt";
// include the guestbook in the index file
include_ckgb();
?>
warum geht der auch net??
http://www.hosting.metroprime.de/getthefloh/index.php3
Gruss
Flo
Grüß Goth,
ein schöneres Beispiel hätte jetzt gar nicht kommen können.
Also ganz freundlich: lies bitte </faq/#Q-09a>, danke.
jaja, is ja schon gut ... *grinsel*
Gruß
Stefan D.