# # Changes: # 1.1 corrected problem with cookies # database parameters $host = "myhost"; $database = "mydatabase"; $uid = "myuser"; $pwd = "mypasswd"; # table name for wboard articles $wboard = "wboard"; # table name for link table (relations between articles) $wlink = "wlink"; # table name for section table to allow multiple forums $wsections = "wsections"; $header = "header.html"; $footer = "footer.html"; $bigfont = ""; # how long will an article be displayed on the first page $maxdays = 31; # zeigt rekursiv einen Thread an Function subshow ($root, $level) { global $dbh,$sid; global $wboard, $wlink, $wsections; if($level>15) { return; } $query = "select id,subject,name,DATE_FORMAT(stamp,'M, d Y - H:i:s') as zeit from $wboard as b,$wlink as l where l.id1='$root' and l.id2=b.id and b.section='$sid'"; $r = mysql_query($query, $dbh); $num = mysql_numrows($r); for($i=0; $i<$num; $i++) { $ro = mysql_fetch_array($r); printf("
  • %s - %s  %s\n", $sid, $ro['id'], $ro['subject'], $ro['name'], $ro['zeit'] ); printf(""); } } # action 1 Function show_section($stime) { global $dbh, $maxdays, $sid; global $wboard, $wlink, $wsections; # aktuelle Uhrzeit ermitteln $time = Time(); # ermittle aktuelles Datum $y = Date("Y", $time); $m = Date("m", $time); $d = Date("d", $time); $time = MkTime(0, 0, 0, $m, $d, $y) + 86400; if($stime==0) { $stime = $time - $maxdays*86400; $query = "select id,subject,name,DATE_FORMAT(stamp,'M, d Y - H:i:s') as zeit from $wboard where top=1 and section='$sid' and stamp>FROM_UNIXTIME($stime) order by stamp desc"; } else { $query = "select id,subject,name,DATE_FORMAT(stamp,'M, d Y - H:i:s') as zeit from $wboard where top=1 and section='$sid' and stamp"; echo ""; echo ""; echo "Willkommen im Diskussionsforum. Du kannst Dir die Einträge ansehen oder mit dem Button rechts einen neuen Eintrag vornehmen."; echo ""; echo ""; echo "
    "; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
    "; printf("
      "); $num = mysql_numrows($result); for($i=0; $i<$num; $i++) { $row = mysql_fetch_array($result); printf("
    • %s - %s  %s\n", $sid, $row['id'], $row['subject'], $row['name'], $row['zeit'] ); printf("
        "); subshow($row['id'], 0); printf("
      "); printf("

      "); } printf("

    "); printf("
    "); printf("ältere Beiträge"); } # action 2 function show_entry() { global $dbh, $maxdays, $id, $sid; global $wboard, $wlink, $wsections; $q = "select * from $wsections where id='$sid'"; $r = mysql_query($q, $dbh); $rr = mysql_fetch_array($r); $delete = $rr['del']; $query = "select * from $wboard where id='$id'"; $result = mysql_query($query, $dbh); echo ""; $row = mysql_fetch_array($result); $subject=$row['subject']; $author=$row['name']; $email=$row['email']; $link=$row['link']; $title=$row['title']; $message=$row['message']; $pwd = $row['passwd']; if($pwd != "") { $par = 1; } else { $par = 0; } echo ""; echo ""; echo ""; if($email != "") { echo "\n"; } else { echo "\n"; } if($delete == "1" && $par == 1) { echo ""; } if($link != "" && $title != "") echo ""; else if($link != "") echo ""; echo "
    Subject$subject"; echo ""; echo ""; echo ""; #echo ""; #echo ""; #echo ""; #echo ""; #echo ""; #echo ""; echo ""; echo "
    Autor$author
    Autor$author
    "; echo ""; echo ""; echo ""; echo ""; echo "
    "; } else { echo "
    Link$title
    Link$link
    "; echo "
    "; echo "

    Follow-Ups

    "; echo "
      "; subshow($id, 0); echo "
    "; echo "
    "; echo "$message"; } # action 3 Function show_form() { global $dbh, $parent, $sid; global $wboard, $wlink, $wsections; global $subject,$name,$email,$kommentar,$link,$title; $q = "select * from $wsections where id='$sid'"; $r = mysql_query($q, $dbh); $rr = mysql_fetch_array($r); $delete = $rr['del']; if($parent!=0) { # Sonderbehandlung fuer Antworten # zuerst mal die Daten des Parent holen $query = "select subject,message from $wboard where id='$parent'"; $result = mysql_query($query, $dbh); $row = mysql_fetch_array($result); $subject = $row['subject']; $kommentar = $row['message']; if(ereg("^Re:", $subject, $regs) == 0) { $subject = "Re: " . $subject; } $subject = htmlspecialchars($subject); $kommentar = ": " . ereg_replace("
    ", "\n: ", $kommentar); # fuer alte Eintraege... $kommentar = ereg_replace("

    ", "\n: ", $kommentar); } echo "

    "; echo ""; echo ""; echo ""; echo '
    '; echo ""; echo ''; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if($delete == "1" && $parent == "0") { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo ""; echo ''; echo ''; echo '"; echo ""; echo "
    Neuer Diskussionsbeitrag
    Subject
    Name
    E-Mail
    Nachricht
    Link (URL)
    Titel für Link
    Passwortwiederholen
    '; echo '
    '; echo "
    "; echo "
    "; } # action 4 Function new_entry() { global $dbh, $sid, $parent; global $wboard, $wlink, $wsections; global $subject,$name,$email,$kommentar,$link,$title,$pwd1,$pwd2; $errmsg = array( "", "Du mußt einen Namen eingeben!", "Du mußt ein Subject eingeben!", "Du mußt ein Passwort eingeben!", "Die beiden Passwoerter stimmen nicht ueberein!" ); $q = "select * from $wsections where id='$sid'"; $r = mysql_query($q, $dbh); $rr = mysql_fetch_array($r); $delete = $rr['del']; $errno = 0; if($name == "") { $errno = 1; } if($subject == "") { $errno = 2; } if($delete == "1" && $parent == "0") { if($pwd1 == "") { $errno = 3; } if($pwd1 != $pwd2) { $errno = 4; } } else { $pwd1 = $pwd2 = ""; } if($errno>0) { echo "Fehler: $errmsg[$errno]"; echo "

    "; echo "

    "; echo "
    "; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
    "; echo "
    "; return; } $kommentar = ereg_replace("\n", "
    ", $kommentar); $kommentar = ereg_replace("'", "''", $kommentar); if($parent=="0") { $query = "insert into $wboard values ('', '$name','$email','$subject','$kommentar','$link','$title','$sid',now(),'1','$pwd1')"; } else { $query = "insert into $wboard values ('', '$name','$email','$subject','$kommentar','$link','$title','$sid',now(),'0','$pwd1')"; } $result = mysql_query($query, $dbh); $myid = mysql_insert_id(); # Einfuegen in wlink $query = "insert into $wlink values ('$parent', '$myid')"; $result = mysql_query($query, $dbh); echo "Eintrag erfolgreich eingefügt :-)"; echo "

    "; echo "zurück zum Diskussionsforum"; } # action 0 Function show_sections() { global $dbh, $bigfont; global $wboard, $wlink, $wsections; $query = "select * from $wsections"; $result = mysql_query($query, $dbh); echo "

    Probleme mit den Cookies des Forums

    "; echo "Es gab ein Problem mit den Cookies des Forums. Und zwar konnte man, wenn man einmal einen Wert eingegeben hatte z.B. bei dem Link, diese nicht mehr löschen."; echo "

    Dieser Fehler ist jetzt behoben. Allerdings muß man, damit es funktioniert, in seinem Browser zuerst alle Cookies des Diskussionsforums löschen. Bei Netscape werden diese in einer Datei cookies gespeichert, beim Internet Explorer kann man sie unter c:\windows\cookies finden und wie normale Dateien löschen."; echo "


    "; echo "Willkommen im Diskussionsforum.
    "; echo "Hier könnt Ihr Fragen rund ums Bürgernetz stellen,"; echo "aber auch Kauf- und Verkaufgesuche aufgeben.\n"; echo "Wir bitten allerdings darum, daß hier keine kommerzielle"; echo "Werbung betrieben wird."; echo "

    "; echo "Für weitere Diskussionen bitten wir, folgende lokale"; echo "Newgruppen zu verwenden:

    "; echo "dlg.test - zum Testen Eures News-Readers
    "; echo "dlg.markt - für Kauf- und Verkaufgesuche
    "; echo "dlg.talk - Einfach so zum Unterhalten...
    "; echo "dlg.announce - für Ankündigungen unserer Seite und auch von Mitgliedern
    "; echo "dlg.computer - Alle Themen rund um den Computer
    "; echo "

    "; echo "


    "; echo ""; $num = mysql_numrows($result); for($i=0; $i<$num; $i++) { $row = mysql_fetch_array($result); printf("\n", $row['id'], $row['name']); printf(""); } echo "
    $bigfont%s
    "); echo ""; echo ""; echo ""; echo "
    "; printf("
    "; } # action 5 Function show_searchmask() { global $dbh, $parent, $sid; global $wboard, $wlink, $wsections; global $searchtext; echo "
    "; echo ""; echo ""; echo '
    '; echo ""; echo ''; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ''; echo ''; echo '"; echo ""; echo "
    Suchen
    Suchbegriff
    '; echo '
    '; echo "
    "; echo "
    "; } # action 6 Function show_results() { global $dbh, $parent, $sid; global $wboard, $wlink, $wsections; global $searchtext; if($searchtext=="") { show_searchform(); return; } $query = "select id,subject,name,DATE_FORMAT(stamp,'M, d Y - H:i:s') as zeit from $wboard as b where b.message like '%$searchtext%'"; $r = mysql_query($query, $dbh); $num = mysql_numrows($r); for($i=0; $i<$num; $i++) { $ro = mysql_fetch_array($r); printf("
  • %s - %s  %s\n", $sid, $ro['id'], $ro['subject'], $ro['name'], $ro['zeit'] ); } } # action 7 Function show_delform() { global $dbh, $parent; global $wboard, $wlink, $wsections; global $id, $sid; echo "
    "; echo ""; echo ""; echo ""; echo '
    '; echo ""; echo ''; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ''; echo ''; echo '"; echo ""; echo "
    Löschen
    Passwort
    '; echo '
    '; echo "
    "; echo "
    "; } Function dodel($pid, $sid) { global $dbh; global $wboard, $wlink; $query = "select id2 from $wlink where id1='$pid'"; $r = mysql_query($query, $dbh); $num = mysql_numrows($r); if($num>0) { $ro = mysql_fetch_array($r); $id2 = $ro['id2']; if($id2 != "0") { dodel($id2, $sid); } } $query = "delete from $wboard where id='$pid' and section='$sid'"; $r = mysql_query($query, $dbh); } # action 8 Function delete() { global $dbh, $parent; global $wboard, $wlink, $wsections; global $id, $sid, $pwd1; $query = "select id from $wboard where section='$sid' and id='$id' and passwd='$pwd1'"; $r = mysql_query($query, $dbh); $num = mysql_numrows($r); if($num > 0) { $ro = mysql_fetch_array($r); $id = $ro['id']; # Ok, loeschen... dodel($id, $sid); echo "Eintrag und alle Antworten dazu gelöscht..."; } else { echo "Fehler, falsches Passwort :-("; } } #################### # Hauptprogramm # #################### if($action == "3") { if($c_name != "") $name = $c_name; if($c_email != "") $email = $c_email; if($c_link != "") $link = $c_link; if($c_title != "") $title = $c_title; } if($action == "4") { if($name != "") setcookie("c_name", $name, time()+86400*365); else setcookie("c_name"); if($email != "") setcookie("c_email", $email, time()+86400*365); else setcookie("c_email"); if($title != "") setcookie("c_title", $title, time()+86400*365); else setcookie("c_title"); if($link != "") setcookie("c_link", $link, time()+86400*365); else setcookie("c_link"); } # mit Datenbank verbinden $dbh = mysql_connect($host, $uid, $pwd); mysql_select_db($database, $dbh); # Seitenkopf einbinden include($header); # Verzweigung anhand von action switch($action) { case 1: show_section($stime); break; case 2: show_entry(); break; case 3: show_form(); break; case 4: new_entry(); break; case 5: show_searchmask(); break; case 6: show_results(); break; case 7: show_delform(); break; case 8: delete(); break; default: show_sections(); } include($footer); ?>