#!/usr/bin/perl
#############################################################
# Ikonboard v2.1
# Copyright 2001 Ikonboard.com - All Rights Reserved
# Ikonboard is a trademark of Ikonboard.com
#
# Software Distributed by: Ikonboard.com
# Visit us online at http://www.ikonboard.com
# Email us on boards@ikonboard.com
#
# All files written by Matthew Mecham
#############################################################
use CGI::Carp "fatalsToBrowser"; # Output errors to browser
use CGI qw(:standard); # Saves loads of work
$CGI::POST_MAX=1024 * 150; # limit post data
$CGI::DISABLE_UPLOADS = 1; # Disable uploads
eval {
($0 =~ m,(.*)/[^/]+,) and unshift (@INC, "$1");
($0 =~ m,(.*)\\[^\\]+,) and unshift (@INC, "$1");
require "ikon.lib"; # Require ikonboard ()
require "data/progs.cgi"; # Require prog names
require "data/boardinfo.cgi";# Require board info
require "data/styles.cgi"; # Require styles info
require "ikonmail.lib"; # Require email func ()
};
if ($@) {
print header(); print start_html(-title=>"Ikonboard Error!");
print "Could not find these files: $@\nIf you are running NT you may need to enter the full path in each require statement in each script";
print end_html; exit;
}
$|++; # Unbuffer the output
#################--- Begin the program ---###################
$thisprog = "post.cgi";
$query = new CGI;
&checkVALIDITY;
$cookiepath = $query->url(-absolute=>1);
$cookiepath =~ s/$thisprog//sg;
for ('forum','topic','membername','password','action','postno','inshowsignature',
'notify','inshowemoticons','previewfirst','intopictitle','intopicdescription',
'inpost') {
next unless defined $_;
next if $_ eq 'SEND_MAIL';
$tp = $query->param($_);
$tp = &cleaninput("$tp");
${$_} = $tp;
}
$inforum = $forum;
$intopic = $topic;
$inmembername = $membername;
$inpassword = $password;
$inpostno = $postno;
$innotify = $notify;
$currenttime = time;
$postipaddress = $ENV{'REMOTE_ADDR'};
if ($inshowemoticons ne "yes") { $inshowemoticons eq "no"; }
if ($innotify ne "yes") { $innotify eq "no"; }
if (! $inmembername) { $inmembername = cookie("amembernamecookie"); }
if (! $inpassword) { $inpassword = cookie("apasswordcookie"); }
if ($inmembername eq "") {
$inmembername = "Guest";
}
else {
&getmemberstime("$inmembername");
}
if ($action eq "addnew" or $action eq "addreply") {
$namecookie = cookie(-name => "amembernamecookie",
-value => "$inmembername",
-path => "$cookiepath",
-expires => "+30d");
$passcookie = cookie(-name => "apasswordcookie",
-value => "$inpassword",
-path => "$cookiepath",
-expires => "+30d");
print header(-charset=>'windows-1256', -cookie =>[$cookie, $tempcookie]);
}
else {
print header(-charset=>'windows-1256');
}
if (($inforum) && ($inforum !~ /^[0-9]+$/)) { &error("General&Please do not modify the URL's generated."); }
if (($intopic ) && ($intopic !~ /^[0-9]+$/)) { &error("General&Please do not modify the URL's generated."); }
if (($inpostno) && ($inpostno !~ /^[0-9]+$/)) { &error("General&Please do not modify the URL's generated."); }
$helpurl = &helpfiles("Making_a_post");
$helpurl = qq~$helpurl~;
my %Mode = (
'new' => \&newthread,
'reply' => \&reply,
'replyquote' => \&replyquote
);
if($Mode{$action}) {
$Mode{$action}->();
}
elsif ($action eq "addnew" && $previewfirst eq "no") { &addnewthread; }
elsif ($action eq "addnew" && $previewfirst eq "yes") { &newthread; }
elsif ($action eq "addreply" && $previewfirst eq "no") { &addreply; }
elsif ($action eq "addreply" && $previewfirst eq "yes") { &reply; }
else { &error("General&Please only access this script in the correct manner"); }
&output(
-Title => "$boardname - Posting in $forumname",
-ToPrint => $output,
-Version => $versionnumber
);
############ New Thread side
sub newthread {
### Lets sort out the flood control
&getmember("$inmembername");
if (($floodcontrol eq "on") && ($membercode ne "ad") && ($membercode ne "mo")) {
$currenttime = time;
($lastpost, $posturl, $posttopic) = split(/\%\%\%/,$lastpostdate);
$lastpost = ($lastpost + $floodcontrollimit);
if ($lastpost > $currenttime) {
&error("اضافة موضوع جديد&Flood control has been enabled on this board, you must wait for $floodcontrollimit seconds before making another post");
}
}
&getforum("$inforum");
if ($allowedentry{$inforum} eq "yes") { $allowed = "yes"; }
if (($privateforum eq "yes") && ($allowed ne "yes")) {
&error("Posting&Sorry, you are not allowed to post in this forum");
}
# Emoticons routine
if ($emoticons eq "on") {
$emoticonslink = qq~Emoticons are enabled~;
$emoticonsbutton =qq~ ~;
}
# Add member to who's online
&whosonline("$inmembername|اضافة موضوع جديد $forumname|none") if ($privateforum ne "yes");
# Set up are we previewing/emailing/start thread allowance
if ($previewfirst eq "yes") {
&preview;
$inpost =~ s/\
/\n\n/g;
$inpost =~ s/\ /\n/g;
}
else {
&mischeader("اضافة موضوع جديد");
}
if ($emailfunctions eq "on") {
if ($innotify eq "yes") {
$requestnotify = qq~هل تريد اشعارك بالردود على موضوعك عن طريق البريد الالكتروني؟ ~;
}
else {
$requestnotify = qq~هل تريد اشعارك بالردود على موضوعك عن طريق البريد الالكتروني؟ ~;
}
}
if ($startnewthreads eq "no") {
$startthreads = "لايحق لغير الاداريين البدء بمواضيع جديدة للنقاش";
}
else {
$startthreads = "يحق لكل الاعضاء البدء بمواضيع جديدة";
}
# Output the form
$output .= qq~
~;
rebuildLIST(-Forum=>"$inforum");
} # end else
} # end addnewthread
###########################################
############## reply side #################
sub reply {
### Lets sort out the flood control
&getmember("$inmembername");
if (($floodcontrol eq "on") && ($membercode ne "ad") && ($membercode ne "mo")) {
$currenttime = time;
($lastpost, $posturl, $posttopic) = split(/\%\%\%/,$lastpostdate);
$lastpost = ($lastpost + $floodcontrollimit);
if ($lastpost > $currenttime) {
&error("Posting a reply&Flood control has been enabled on this board, you must wait for $floodcontrollimit seconds before making another post");
}
}
&getforum("$inforum");
if ($allowedentry{$inforum} eq "yes") { $allowed = "yes"; }
if (($privateforum eq "yes") && ($allowed ne "yes")) {
&error("Posting&Sorry, you are not allowed to post in this forum");
}
if ($threadstate eq "closed" or $threadstate eq 'moved') { &error("Posting a reply&Sorry, this thread has been locked"); }
if ($emoticons eq "on") {
$emoticonslink = qq~Emoticons are enabled~;
}
if ($emailfunctions eq "on") {
if ($innotify eq "yes") {
$requestnotify = qq~هل تريد اشعارك بالردود على الموضوع عن طريفق البريد الالكتروني؟ ~;
}
else {
$requestnotify = qq~هل تريد اشعارك بالردود على الموضوع عن طريفق البريد الالكتروني؟ ~;
}
}
if ($previewfirst eq "yes") {
&preview;
$inpost =~ s/\
/\n\n/g;
$inpost =~ s/\ /\n/g;
}
else {
&mischeader("Post reply to")
}
#Show Smileys
$addbr = 0;
$emoticonsurl = qq~$imagesurl/emoticons~;
$dirtoopen = "$imagesdir" . "emoticons"; opendir (DIR, "$dirtoopen") or die "this is not the correct path to the emoticons (You are using $dirtoopen )"; @dirdata = readdir(DIR); closedir (DIR);
@emoticondata = grep(/gif/,@dirdata);
$smileys .= qq~
$requestnotify
$emoticonsbutton
هل تريد المعاينة قبل الارسال؟ نعم كلا
~;
# Lets display the thread review
$filetoopen = "$ikondir" . "forum$inforum/$intopic.thd";
$filetoopen = &stripMETA($filetoopen);
open(FILE, "$filetoopen");
flock(FILE, 2);
@threads = ;
close(FILE);
@sortedthreads = reverse(@threads);
&threadreview;
} # end add reply routine
##### Reply with quote
sub replyquote {
### Lets sort out the flood control
&getmember("$inmembername");
if (($floodcontrol eq "on") && ($membercode ne "ad") && ($membercode ne "mo")) {
$currenttime = time;
($lastpost, $posturl, $posttopic) = split(/\%\%\%/,$lastpostdate);
$lastpost = ($lastpost + $floodcontrollimit);
if ($lastpost > $currenttime) {
&error("Posting a reply&Flood control has been enabled on this board, you must wait for $floodcontrollimit seconds before making another post");
}
}
&getforum("$inforum");
if ($allowedentry{$inforum} eq "yes") { $allowed = "yes"; }
if ($threadstate eq "closed") { &error("Posting a reply&Sorry, this thread has been locked"); }
if (($privateforum eq "yes") && ($allowed ne "yes")) {
&error("Posting&Sorry, you are not allowed to post in this forum");
}
# Get the post to edit
$filetoopen = "$ikondir" . "forum$inforum/$intopic.thd";
$filetoopen = &stripMETA($filetoopen);
open(FILE, $filetoopen);
flock(FILE, 1);
@threads = ;
close(FILE);
$posttoget = $inpostno;
$posttoget--;
($membername, $topictitle, $postipaddress, $showemoticons, $showsignature ,$postdate, $post) = split(/\|/, @threads[$posttoget]);
$post =~ s/\