#!/usr/bin/perl require "vars.cgi"; $apass="2chmona"; ########################################################################## ## ## ## SmartFAQ v2.0 ## ## ------------- ## ## by Jimmy (wordx@hotmail.com) ## ## http://www.smartCGIs.com ## ## ## ## This is a free script, if anyone sold it to you please contact me. ## ## Please DO NOT remove any of the copyrights or links to our site, ## ## they keep this CGI free for everyone. Thanks! ## ## ## ## (c) copyright 2000 SmartCGIs.com ## ########################################################################## print "Content-type: text/html;charset=EUC-JP\n\n"; $buffer = $ENV{'QUERY_STRING'}; @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name,$value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/~!/ ~!/g; #$value =~ s/[\<\>\"\'\%\;\)\(\&\+\`]//g; $value =~ s/ EOF print "


Script provided by SmartCGIs.com
\n"; } sub newsubject { $time = time; &Jcode::convert(\$newsubject,$prog_kcode); open(DATA,">>subject.faq"); print DATA "$time|$newsubject\n"; close(DATA); if (not(-e "subject")) { mkdir("subject", 0777) || &error("Can't create directory 'subject' ($!)"); } mkdir("subject/$time", 0777) || &error("Can't create directory 'subject/$time' ($!)"); print <New Subject Created Done. A new subject has been entered.
Go Back EOF print "


Script provided by SmartCGIs.com
\n"; exit; } sub subject { open(DATA,"subject.faq"); @subj = ; close(DATA); foreach (@subj) { chomp($_); ($id, $sub) = split(/\|/,$_); if($id eq $subject) { print <SmartFAQ Subject: $sub

セクション: $sub

Location: $cgiurl/smartfaq.cgi?subject=$subject

質問:

回答:


EOF opendir (DIR, "subject/$id"); @files = grep { /.qa$/ } readdir(DIR); close (DIR); foreach $file(@files) { $fid = $file; $fid =~ s/.qa//g; open(DATA,"subject/$id/$file"); @content = ; close(DATA); $content = join('',@content); ($q, $a) = split(/\|/,$content); print "$q
$a
\n"; print "
"; #print "Edit - Delete

\n"; } print "

Back to main\n"; print "


Script provided by SmartCGIs.com
\n"; exit; } } exit; } sub error { my $error = shift; print <Error Error: $error EOF print "


Script provided by SmartCGIs.com
\n"; exit; } sub question { if($answer eq "") { print <No Answer Provided You did not provide an answer to your question. Please go back and enter one. EOF print "


Script provided by SmartCGIs.com
\n"; exit; } $time = time; &Jcode::convert(\$question,$prog_kcode); &Jcode::convert(\$answer,$prog_kcode); @a = split(/\n/,$answer); open(DATA,">subject/$id/$time.qa"); print DATA "$question|\n"; foreach (@a) { print DATA "$_
\n"; } close(DATA); print <Entry Added Done. The question has been added to the FAQ.
Go back EOF print "


Script provided by SmartCGIs.com
\n"; exit; } sub edit { open(DATA,"subject/$id/$edit.qa"); @content = ; close(DATA); $content = join('',@content); ($q, $a) = split(/\|/,$content); print <Edit Entry

Question:

Answer:

EOF print "


Script provided by SmartCGIs.com
\n"; exit; } sub edit2 { if($answer eq "") { print <No Answer Provided You did not provide an answer to your question. Please go back and enter one. EOF print "


Script provided by SmartCGIs.com
\n"; exit; } &Jcode::convert(\$editquestion,$prog_kcode); &Jcode::convert(\$answer,$prog_kcode); open(DATA,">subject/$id/$fid.qa"); print DATA "$editquestion|$answer"; close(DATA); print <Entry Added Done. The question has been edited.
Go back EOF print "


Script provided by SmartCGIs.com
\n"; exit; } sub delete { unlink("subject/$id/$delete.qa"); print <Entry Deleted Done. The question has been deleted.
Go back EOF print "


Script provided by SmartCGIs.com
\n"; exit; } sub editsub { open(DATA,"subject.faq"); @subjects = ; close(DATA); foreach (@subjects) { chomp($_); ($num, $sub) = split(/\|/,$_); if($num eq $id) { &Jcode::convert(\$editsub,$prog_kcode); push(@newlist,"$num|$editsub\n"); } else { push(@newlist,"$_\n"); } } open(DATA,">subject.faq"); print DATA @newlist; close(DATA); print <Subject Edited Done. The subject has been changed.
Go back EOF print "


Script provided by SmartCGIs.com
\n"; exit; } sub deletesub { print <Are you sure?
Are you sure you want to delete this FAQ subject and all its Q&A entries?
EOF print "


Script provided by SmartCGIs.com
\n"; exit; } sub deletesub2 { opendir (DIR, "subject/$deletesub2"); @files = grep { /.qa$/ } readdir(DIR); close (DIR); foreach $file(@files) { unlink("subject/$deletesub2/$file"); } rmdir("subject/$deletesub2"); open(DATA,"subject.faq"); @subjects = ; close(DATA); foreach (@subjects) { ($num, $sub) = split(/\|/,$_); if($num ne $deletesub2) { push(@newlist,$_); } } open(DATA,">subject.faq"); print DATA @newlist; close(DATA); print <Subject Deleted Done. The subject and all its entries have been deleted.
Go back EOF print "


Script provided by SmartCGIs.com
\n"; exit; }