| | > Wer sagt mir wo ich ein ordentliches Forum herbekomme? am besten programmiertst du dir selbst ein forum, per CGI! dazu brauchst du allerdings nen webhost, der CGI-scripts untersützt! Hier ein script:
Ich habe das Script angefügt. Allerdings musst du eine spezielle HTML-Seite für dein Forum verwenden. Den Quellcode für die Seite habe ich beigefügt. Auserdem musst du im gleichen Verzeichniss, in dem auch dieses Script liegt, eine Datei mit dem Namen config erstellen und die (mit dem Befehl chmod 777 config) beschreibbar machen. Das gleiche (chmod 777 index.html) gilt auch für die HTML-Datei.
Das CGI-Script: ------------------schnippel---------------- #!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use CGI::Cookie; $path="../gaestebuch/index.html";
#Hallo Biene: Editiere mich, so dass das auf die #HTML-Seite zeigt
$path_to_config="config"; $entry_id=0; @temp; $data_string; $gmt_time=time(); $time=localtime(); $name; $text; $answer_number; $html_code; $next_entry_is_yours=0; $entry_found=0;
#get hostname $ip = $ENV{'REMOTE_ADDR'}; $hostname= $ip; $data_string=$ENV{'QUERY_STRING'}; ($name,$text,$answer_number)=split(/&/,$data_string,3); foreach($name,$text,$answer_number){ ($tmp,$_)= split(/=/,$_); $_ =~ tr/+/ /; # wandle + in space $_ =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C",hex($1))/eg ; }
if($name eq ""){ $name = "Anonymer Feigling"; }
open(CONFIG,"<$path_to_config") || die ("error: unable to open $path_to_config"); $entry_id = <CONFIG>; close(CONFIG); $entry_id++; open(CONFIG,">$path_to_config"); print CONFIG $entry_id; close(CONFIG);
open(GUESTBOOK,"<$path")|| die ("error: unable to open $path for reading"); @temp=<GUESTBOOK>; close(GUESTBOOK);
if($answer_number eq ""){ # new topic $html_code=" <p><!cgi-label: id=$entry_id time=$gmt_time> <a name=\"id=$entry_id\"> <!$hostname> $name: <br> am $time<br> <blockquote> $text</blockquote><br> Posting-Nr.:$entry_id </a> <!end> <hr><p>\n "; foreach(@temp){ if(index($_,"<!LaBeL begin>") != -1){ $_ = "<!LaBeL begin>\n\n$html_code"; $entry_found=1; } } } else{ #answer to another posting $html_code=" <p><blockqote> <!cgi-label: id=$entry_id time=$gmt_time> <a name=\"id=$entry_id\"> <!$hostname> $name: <br> am $time als Antwort auf <a href=#id=$answer_number>Posting Nummer $answer_number</a> <blockquote> $text</blockquote><br> Posting-Nr.:$entry_id
<!end></blockquote> <hr><p> \n "; foreach(@temp){ # if(index($_,"<!cgi-label: id=$answer_number") != -1){ # $next_entry_is_yours=1; # } # if(index($_,"<!end>") != -1 && $next_entry_is_yours == 1){ # $_="<!end>\n\n$html_code"; # $entry_found=1; # $next_entry_is_yours=0; if(index($_,"<!LaBeL begin>") != -1){ $_ = "<!LaBeL begin>\n\n$html_code"; $entry_found=1; } } }
open(GUESTBOOK,">$path") || die("error: unable to open $path for writing"); print GUESTBOOK @temp; close(GUESTBOOK);
if($entry_found ==0 && $answer_number ne ""){ print("Content-type: text/html\n\n"); print("Error: Es konnte kein Posting mit der Nummer $answer_number gefunden werden<br>"); print("Dein Text war:<p>"); print("$text<br>"); }
else{ print("Location: $path\n\n"); }
|