#!/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 $CGI::HEADERS_ONCE = 1; # Kill redundant headers 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 }; if ($@) { print header('text/html; charset=windows-1251'); print start_html(-title=>"$ibtxt{'0025'}"); print "$ibtxt{'0026'} $@\n$ibtxt{'0027'}"; print end_html; exit; } $|++; # Unbuffer the output #################--- Begin the program ---################### $thisprog = "announcements.cgi"; $query = new CGI; $cookiepath = $query->url(-absolute=>1); $cookiepath =~ s/$thisprog//sg; for ('membername','password','announcementtitle','announcementpost','action','checked','number') { next unless defined $_; next if $_ eq 'SEND_MAIL'; $tp = $query->param($_); $tp = &cleaninput($tp); ${$_} = $tp; } $inmembername = $membername; $inpassword = $password; $inannouncementtitle = $announcementtitle; $inannouncementpost = $announcementpost; $IP="$ENV{'REMOTE_ADDR'} - $ENV{'HTTP_X_FORWARDED_FOR'} - $ENV{'HTTP_PROXY_CONNECTION'} - $ENV{'HTTP_VIA'}"; if (! $inmembername) { $inmembername = cookie("amembernamecookie"); } if (! $inpassword) { $inpassword = cookie("apasswordcookie"); } if ($inmembername eq "") { $inmembername = "$ibtxt{'0043'}"; } else { &getmemberstime("$inmembername"); } ### Print Header for the page. print header('text/html; charset=windows-1251'); &title; $output .= qq~
    $boardname
    $ibtxt{'0301'}

~; ### Startactions if ($action eq "delete") { if ($checked eq "yes") { # Validate user &getmember("$inmembername"); #$myposter=$inmembername; if (($membercode ne "ad")&&($membercode ne "mo")) { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0302'}."); } elsif ($inpassword ne $password) { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0303'}."); } # Get the announcement to delete $filetoopen = "$ikondir" . "data/news.cgi"; $filetoopen = &stripMETA($filetoopen); open(FILE, "$filetoopen") or die "$ibtxt{'0324'}"; @announcements = ; close(FILE); # Write it back minus the one to delete. $count = 0; $filetoopen = "$ikondir" . "data/news.cgi"; $filetoopen = &stripMETA($filetoopen); open(FILE, ">$filetoopen") or die "$ibtxt{'0324'}"; flock (FILE, 2); foreach $line (@announcements) { chomp $line; if ($count ne $number) { print FILE "$line\n"; } $count++; } close(FILE); &doend("$ibtxt{'0304'}"); exit; } # end checked delete else { &login("$thisprog?action=delete&number=$number&checked=yes"); } # end else } # end action elsif ($action eq "add") { # Present the form $output .= qq~
~; } # end action elsif ($action eq "addannouncement") { $currenttime = time; # Validate user &getmember("$inmembername"); $myposter=$inmembername; if ($membername eq "Guest") { print header('text/html; charset=windows-1251'); &error("Добавление объявления&Гости не могут добавлять объявления"); } if ($inpassword ne $password) { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0303'}."); } # Check for blanks. if ($inannouncementpost eq "") { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0311'}."); } if ($inannouncementtitle eq "") { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0312'}"); } # Get the announcement file $filetoopen = "$ikondir" . "data/news.cgi"; $filetoopen = &stripMETA($filetoopen); open(FILE, "$filetoopen"); @announcements = ; close(FILE); # Write it back with the new announcement at the top $newline = "$inannouncementtitle|$currenttime|$inannouncementpost|$myposter"; chomp $newline; $filetoopen = "$ikondir" . "data/news.cgi"; $filetoopen = &stripMETA($filetoopen); open(FILE, ">$filetoopen"); flock(FILE, 2); # print FILE "$newline\n"; # foreach $line (@announcements) { # chomp $line; # print FILE "$line\n"; # } # close(FILE); print FILE "$newline"; print FILE "\|$IP\n"; foreach $line (@announcements) { chomp $line; print FILE "$line\n"; } close(FILE); &doend("$ibtxt{'0313'}"); } # end add announcement elsif ($action eq "edit") { # Get the announcement file $filetoopen = "$ikondir" . "data/news.cgi"; $filetoopen = &stripMETA($filetoopen); open(FILE, "$filetoopen") or die "$ibtxt{'0324'}"; @announcements = ; close(FILE); # Get the announcement to edit $count = 0; foreach (@announcements) { if ($count eq $number) { ($announcementtitle, $notneeded, $announcementpost,$myposter) = split(/\|/,$_); } $count++; } # Clean the text area $announcementpost =~ s/\/\n\n/g; $announcementpost =~ s/\/\n/g; # Present the form $output .= qq~
~; } # end action elsif ($action eq "doedit") { $currenttime = time; # Make sure it's got all new lines converted # Validate user &getmember("$inmembername"); $myposter=$inmembername; if (($membercode ne "ad")&&($membercode ne "mo")) { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0303'}."); } elsif ($inpassword ne $password) { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0332'}."); } # Check for blanks. if ($inannouncementpost eq "") { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0311'}."); } if ($inannouncementtitle eq "") { print header('text/html; charset=windows-1251'); &error("$ibtxt{'0301'}&$ibtxt{'0312'}"); } # Get the announcement file $filetoopen = "$ikondir" . "data/news.cgi"; $filetoopen = &stripMETA($filetoopen); open(FILE, "$filetoopen") or die "$ibtxt{'0325'}"; @announcements = ; close(FILE); # Write it back with the new announcement at the top $count = 0; $newline = "$inannouncementtitle|$currenttime|$inannouncementpost|$myposter"; chomp $newline; $filetoopen = "$ikondir" . "data/news.cgi"; $filetoopen = &stripMETA($filetoopen); open(FILE, ">$filetoopen") or die "$ibtxt{'0325'}"; flock(FILE, 2); foreach $line (@announcements) { chomp $line; #print FILE "$newline"; #print FILE "\|$IP\n"; #print FILE "$line\n"; # $count++; # } #close(FILE); if ($count eq $number) { print FILE "$newline"; print FILE "\|$IP\n"; } else { print FILE "$line"; print FILE "\|$IP\n"; } $count++; } close(FILE); &doend("$ibtxt{'0315'}"); exit; } # end edit announcement else { # start last else ### start displaying the announcements. $filetoopen = "$ikondir" . "data/news.cgi"; $filetoopen = &stripMETA($filetoopen); open(FILE, "$filetoopen"); @announcements = ; close(FILE); $postcountcheck = 0; ###start pages $instart = $query -> param('start'); $pagestart = $query -> param('pagestart'); $nado=10; #количество выводимых сообщений на странице $numberofitems = @announcements; if ($numberofitems eq "0") { $dateposted = time; @announcements[0] = qq~$ibtxt{'0316'}|$dateposted|$ibtxt{'0317'} $ibtxt{'0318'}~; } else{ $kolvopages=$numberofitems; $numberofpages = $numberofitems / $nado; if ($kolvopages > $nado) { $showmore = "yes"; if ((!$instart) or ($instart < 0)) { $instart = 0; } if ($instart > 0) { $startarray = $instart; } else { $startarray = 0; } $endarray = $instart + $nado - 1; if ($endarray < ($numberofitems - 1)) { $more = "yes"; } if (($endarray > ($nado - 1)) and ($more ne "yes")) { $endarray = $numberofitems - 1; } } else { $showmore = "no"; $startarray = 0; $pages = ""; $endarray = $numberofitems - 1; } if ($showmore eq "yes") { if ($nado < $numberofitems) { ($integer,$decimal) = split(/\./,$numberofpages); if ($decimal > 0) { $numberofpages = $integer + 1; } $pagestart = 0; $counter = 0; while ($numberofpages > $counter) { $counter++; if ($instart ne $pagestart) { $pages .= qq~$counter ~; } else { $pages .= qq~ $counter ~; } $pagestart = $pagestart + $nado; } } $pages = qq~Страницы объявлений: $pages ~; } } $output .= qq~~; foreach $line (@announcements[$startarray .. $endarray]) { ($title, $dateposted, $post,$myposter) = split(/\|/, $line); $myposterview=$myposter; ###end pages $dateposted = $dateposted + ($timedifferencevalue*3600) + ($timezone*3600); $dateposted = &dateformat("$dateposted"); $post = &ikoncode("$post"); # $post = &doemoticons("$post"); $post =~ s/\:\)//g; $post =~ s/\;\)//g; $post =~ s/\:\(//g; $post =~ s/\:\o//g; # Allow HTML $post =~ s/<\;/\/g; $post =~ s/"\;/\"/g; if ($count eq "1") { $postbackcolor = "$postcolorone"; $postfontcolor = "$postfontcolorone"; $count++; } else { $postbackcolor = "$postcolortwo"; $postfontcolor = "$postfontcolortwo"; $count = 1; } $post = qq~

$post

~; $adminadd = qq~~; $admindelete = qq~~; $adminedit = qq~~; $output .= qq~

~; &getmember("$inmembername"); $myposter=$inmembername; if (($membercode ne "ad")&&($membercode ne "mo")&&($membername ne "Guest")){ $output .= qq~ ~; } if (($membercode eq "ad")||($membercode eq "mo")){ $output .= qq~ ~; } $output .= qq~ ~; $postcountcheck++; } # end foreach } # end last else $output .= qq~
$ibtxt{'0305'}
$ibtxt{'0306'}
$ibtxt{'0307'}
$ibtxt{'0308'}
$ibtxt{'0331'}
$ibtxt{'0309'}

$ibtxt{'0310'}

 
$ibtxt{'0314'}
$ibtxt{'0306'}
$ibtxt{'0307'}
$ibtxt{'0308'}
$ibtxt{'0331'}
$ibtxt{'0309'}.

$ibtxt{'0310'}.

 
$pages
» $title «
$adminadd
$admindelete   $adminedit   $adminadd
$post
$ibtxt{'0319'}: $dateposted $myposterview
~; &output( -Title => "$boardname - $ibtxt{'0301'}", -ToPrint => $output, -Version => $versionnumber ); ############################################################## ### Sub route (login) sub login { local($url) = @_; ($postto, $therest) = split(/\?/,$url); @pairs = split(/\&/,$therest); foreach (@pairs) { ($name, $value)=split(/\=/,$_); $hiddenvars .= qq~\n~; } $output .= qq~

$hiddenvars $ibtxt{'0320'} $ibtxt{'0306'} $ibtxt{'0307'} ~; } # end routine sub doend { my $action_taken = shift; $relocurl = "$boardurl/$thisprog"; $output .= qq~ $ibtxt{'0301'} $ibtxt{'0321'} ~; &output( -Title => "$boardname - $ibtxt{'0301'}", -ToPrint => $output, -Version => $versionnumber ); }