#!/usr/bin/perl use Fcntl ':flock'; use CGI qw(:standard); require "ikon.lib"; require "data/progs.cgi"; require "data/boardinfo.cgi"; print header(); #4 поменяй на номер форума rebuildLIST2(5); sub rebuildLIST2 { my ($forum) = @_; opendir (DIR, "$ikondir" . "forum$forum"); my @entry = grep(/pl/, readdir(DIR)); closedir (DIR); open (TMP, "$ikondir" . "forum$forum/list.cgi"); flock(TMP,LOCK_SH); my @listf = <TMP>; foreach (@listf){ chomp $_; my ($topicids) = split (/\|/,$_); $liststruct{$topicids} = [split (/\|/,$_)]; } flock(TMP,LOCK_UN); close (TMP); undef @listf; my @dat; foreach my $lol (@entry){ my $rr; my ($id) = split(/\./, $lol); open (TMP, "$ikondir" . "forum$forum/$id.pl"); flock(TMP,LOCK_SH); my ($topicid, $topictitle, $topicdescription, $threadstate, $threadposts, $threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate) = split (/\|/,<TMP>); flock(TMP,LOCK_UN); close (TMP); open (TMP, "$ikondir" . "forum$forum/$id.thd"); flock(TMP,LOCK_SH); my @thds = <TMP>; my ($startedby, $topictitle, undef, undef, undef, $startedpostdate) = split(/\|/,$thds[0]); flock(TMP,LOCK_UN); close (TMP); next if (length(join('', @thds)) < 5 || $topictitle eq ""); $topicid = $topicid ne "" ? $topicid : $id; $threadstate = $threadstate ne "" ? $threadstate : "open"; $threadposts = $threadposts ne "" ? $threadposts : $#thds; $threadviews = $threadviews ne "" ? $threadviews : $#thds; my ($lastposter, undef, undef, undef, undef, $lastpostdate) = split(/\|/,$thds[$#thds]); $topicdescription =~ s/(::::)(.*?)\b//; open (FILE, ">$ikondir" . "forum$forum/$id.pl"); flock(FILE,LOCK_EX); print FILE "$topicid|$topictitle|$topicdescription|$threadstate|$threadposts|$threadviews|$startedby|$startedpostdate|$lastposter|$lastpostdate"; flock(FILE,LOCK_UN); close (FILE); push (@dat, "$lastpostdate|$topicid|$topictitle|$topicdescription|$threadstate|$threadposts|$threadviews|$startedby|$startedpostdate|$lastposter"); } my @sortdat = reverse(sort(@dat)); open (LIST, ">$ikondir" . "forum$forum/list.cgi"); flock(FILE,LOCK_EX); foreach (@sortdat) { chomp $_; next if(! $_); my ($lastpostdate, $topicid, $topictitle, $topicdescription, $threadstate, $threadposts, $threadviews, $startedby, $startedpostdate, $lastposter) = split (/\|/,$_); print LIST "$topicid|$topictitle|$topicdescription|$threadstate|$threadposts|$threadviews|$startedby|$startedpostdate|$lastposter|$lastpostdate\n" if ($topictitle); } flock(FILE,LOCK_UN); close (LIST); } |