|)#gis;
my @reg_listings = ();
for (1..(scalar(@reg_listings_temp)/5) ){
push(@reg_listings, [shift(@reg_listings_temp), shift(@reg_listings_temp), shift(@reg_listings_temp), shift(@reg_listings_temp), shift(@reg_listings_temp)]);
}
undef $/;
open(FILE, "data/listinglist.txt");
flock(FILE, 2);
my $listing_template = ;
flock(FILE, 8);
close(FILE);
$/ = "\n";
for my $list (@reg_listings){
my $temp = $listing_template;
if($list->[3] =~ s#
]*?>##gis){
$list->[0] .= qq!
!;
}
$list->[3] =~ s#(\ )?(\-)?##gis;
$list->[2] =~ s#?b>##isg;
$list->[1] =~ s#^http://##i;
my $short_url;
if(length($list->[1]) > 50){
$short_url = substr($list->[1], 0, 50) . "....";
}
else{
$short_url = $list->[1];
}
$temp =~ s#\[LISTING\]#$list->[0]#sg;
$temp =~ s#\[URL\]#$list->[1]#sg;
$temp =~ s#\[SHORT_URL\]#$short_url#sg;
$temp =~ s#\[TITLE\]#$list->[2]#sg;
$temp =~ s#\[DESCRIPTION\]#$list->[3]#sg;
$list = [$temp, $list->[0] ,$list->[1] , $list->[2], $list->[3]];
}
$MODULES{'LISTINGS_CUSTOM'} = join( "\n", map{$_->[0]} @reg_listings );
############
#-------------------------------------
############
my @related_cats_temp = $MODULES{'RELATED'} =~ m#(.*?).*?\((.*?)\)#gis;
my @related_cats = ();
for (1..(scalar(@related_cats_temp)/3) ){
push(@related_cats, [shift(@related_cats_temp), shift(@related_cats_temp), shift(@related_cats_temp)]);
}
for my $category_filter (@category_filters){
@related_cats = grep{$_->[0] !~ m#$category_filter#} @related_cats;
}
@related_cats = map{[$_->[0] , $_->[2]]}@related_cats;
undef $/;
open(FILE, "data/relatedlist.txt");
flock(FILE, 2);
my $relatedlist_template = ;
flock(FILE, 8);
close(FILE);
$/ = "\n";
for my $list (@related_cats){
my $temp = $relatedlist_template;
$list->[0] =~ s#?b>##gis;
$temp =~ s#\[CATEGORY\]#$list->[0]#sg;
$temp =~ s#\[COUNT\]#$list->[1]#sg;
$list = [$temp, $list->[0] ,$list->[1]];
}
$MODULES{'RELATED_CUSTOM'} = join( "\n", map{$_->[0]} @related_cats );
############
#-------------------------------------
############
my @cats_list0_temp = $MODULES{'CAT0'} =~ m#((.*?)\@?)\s*\ \;\((.*?)\)#gis;
my @cats_list1_temp = $MODULES{'CAT1'} =~ m#((.*?)\@?)\s*\ \;\((.*?)\)#gis;
my @cats_list2_temp = $MODULES{'CAT2'} =~ m#((.*?)\@?)\s*\ \;\((.*?)\)#gis;
my @cats_list0 = ();
my @cats_list1 = ();
my @cats_list2 = ();
for (1..(scalar(@cats_list0_temp)/4) ){
push(@cats_list0, [shift(@cats_list0_temp), shift(@cats_list0_temp), shift(@cats_list0_temp), shift(@cats_list0_temp)]);
}
for (1..(scalar(@cats_list1_temp)/4) ){
push(@cats_list1, [shift(@cats_list1_temp), shift(@cats_list1_temp), shift(@cats_list1_temp), shift(@cats_list1_temp)]);
}
for (1..(scalar(@cats_list2_temp)/4) ){
push(@cats_list2, [shift(@cats_list2_temp), shift(@cats_list2_temp), shift(@cats_list2_temp), shift(@cats_list2_temp)]);
}
for my $category_filter (@category_filters){
@cats_list0 = grep{$_->[1] !~ m#$category_filter#} @cats_list0;
@cats_list1 = grep{$_->[1] !~ m#$category_filter#} @cats_list1;
@cats_list2 = grep{$_->[1] !~ m#$category_filter#} @cats_list2;
}
@cats_list0 = map{[$_->[0], $_->[2], $_->[3]]}@cats_list0;
@cats_list1 = map{[$_->[0], $_->[2], $_->[3]]}@cats_list1;
@cats_list2 = map{[$_->[0], $_->[2], $_->[3]]}@cats_list2;
undef $/;
open(FILE, "data/catlist.txt");
flock(FILE, 2);
my $catlist = ;
flock(FILE, 8);
close(FILE);
$/ = "\n";
for my $cat0 (@cats_list0){
my $temp = $catlist;
$cat0->[0] =~ s#?b>##gis;
$temp =~ s#\[CATEGORY\]#$cat0->[0]#sg;
$temp =~ s#\[COUNT\]#$cat0->[2]#sg;
$cat0 = [$temp, $cat0->[0] ,$cat0->[1] , $cat0->[2]];
}
for my $cat1 (@cats_list1){
my $temp = $catlist;
$cat1->[0] =~ s#?b>##gis;
$temp =~ s#\[CATEGORY\]#$cat1->[0]#sg;
$temp =~ s#\[COUNT\]#$cat1->[2]#sg;
$cat1 = [$temp, $cat1->[0] ,$cat1->[1] , $cat1->[2]];
}
for my $cat2 (@cats_list2){
my $temp = $catlist;
$cat2->[0] =~ s#?b>##gis;
$temp =~ s#\[CATEGORY\]#$cat2->[0]#sg;
$temp =~ s#\[COUNT\]#$cat2->[2]#sg;
$cat2 = [$temp, $cat2->[0] ,$cat2->[1] , $cat2->[2]];
}
my @cats_all = sort {$a->[2] cmp $b->[2]} (@cats_list0, @cats_list1, @cats_list2);
$MODULES{'CATS_ALL_COLUMN'} = join("\n", map{$_->[0]}@cats_all);
$MODULES{'CATS_ALL_COLUMN_REFINED'} = join("\n", grep{$_ !~ m#\@#s}map{$_->[0]}@cats_all);
my $sep1 = scalar(@cats_list0) ? "
\n" :"";
my $sep2 = scalar(@cats_list1) ? "
\n" :"";
$MODULES{'CATS_CUSTOM_COLUMN'} = join("\n", map{$_->[0]}@cats_list0) .
$sep1 .join("\n", map{$_->[0]}@cats_list1) .
$sep2 . join("\n", map{$_->[0]}@cats_list2);
$MODULES{'CATS_CUSTOM_COLUMN_REFINED'} = join("\n", grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list0) .
$sep1 . join("\n", grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list1) .
$sep2 . join("\n", grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list2);
my ($col_len, @cats_all_1 , @cats_all_2);
@cats_all_1 = ();
@cats_all_2 = ();
my ($ref_len, $refined_col_len, @refined_cats_all_1 , @refined_cats_all_2);
@refined_cats_all_1 = ();
@refined_cats_all_2 = ();
if(scalar(@cats_list0) > 0){
$col_len = int(scalar(@cats_list0)/2-0.3);
@cats_all_1 = map{$_->[0]}@cats_list0[0..$col_len];
@cats_all_2 = map{$_->[0]}@cats_list0[($col_len+1)..$#cats_list0];
$ref_len = scalar(grep{$_->[0] !~ m#\@#s}@cats_list0);
$refined_col_len = int($ref_len/2-0.3);
@refined_cats_all_1 = (grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list0)[0..$refined_col_len];
@refined_cats_all_2 = (grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list0)[($refined_col_len+1)..($ref_len-1)];
for (@cats_all_1){
$_ .= "" ;
}
for (@cats_all_2){
$_ .= "" ;
}
for (@refined_cats_all_1){
$_ .= "" ;
}
for (@refined_cats_all_2){
$_ .= "" ;
}
$MODULES{'CATS_CUSTOM'} .= q!| ! .
join("\n", @cats_all_1) .
qq! | ! .
join("\n", @cats_all_2) .
" |
";
$MODULES{'CATS_CUSTOM_REFINED'} .= q!| ! .
join("\n", @refined_cats_all_1) .
qq! | ! .
join("\n", @refined_cats_all_2) .
" |
";
}
@cats_all_1 = ();
@cats_all_2 = ();
@refined_cats_all_1 = ();
@refined_cats_all_2 = ();
if(scalar(@cats_list1) > 0){
$col_len = int(scalar(@cats_list1)/2-0.3);
@cats_all_1 = map{$_->[0]}@cats_list1[0..$col_len];
@cats_all_2 = map{$_->[0]}@cats_list1[($col_len+1)..$#cats_list1];
$ref_len = scalar(grep{$_->[0] !~ m#\@#s}@cats_list1);
$refined_col_len = int($ref_len/2-0.3);
@refined_cats_all_1 = (grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list1)[0..$refined_col_len];
@refined_cats_all_2 = (grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list1)[($refined_col_len+1)..($ref_len-1)];
for (@cats_all_1){
$_ .= "" ;
}
for (@cats_all_2){
$_ .= "" ;
}
for (@refined_cats_all_1){
$_ .= "" ;
}
for (@refined_cats_all_2){
$_ .= "" ;
}
$MODULES{'CATS_CUSTOM'} .= q!| ! .
join("\n", @cats_all_1) .
qq! | ! .
join("\n", @cats_all_2) .
" |
";
$MODULES{'CATS_CUSTOM_REFINED'} .= q!| ! .
join("\n", @refined_cats_all_1) .
qq! | ! .
join("\n", @refined_cats_all_2) .
" |
";
}
@cats_all_1 = ();
@cats_all_2 = ();
@refined_cats_all_1 = ();
@refined_cats_all_2 = ();
if(scalar(@cats_list2) > 0){
$col_len = int(scalar(@cats_list2)/2-0.3);
@cats_all_1 = map{$_->[0]}@cats_list2[0..$col_len];
@cats_all_2 = map{$_->[0]}@cats_list2[($col_len+1)..$#cats_list2];
$ref_len = scalar(grep{$_->[0] !~ m#\@#s}@cats_list2);
$refined_col_len = int($ref_len/2-0.3);
@refined_cats_all_1 = (grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list2)[0..$refined_col_len];
@refined_cats_all_2 = (grep{$_ !~ m#\@#s}map{$_->[0]}@cats_list2)[($refined_col_len+1)..($ref_len-1)];
for (@cats_all_1){
$_ .= "" ;
}
for (@cats_all_2){
$_ .= "" ;
}
for (@refined_cats_all_1){
$_ .= "" ;
}
for (@refined_cats_all_2){
$_ .= "" ;
}
$MODULES{'CATS_CUSTOM'} .= q!| ! .
join("\n", @cats_all_1) .
qq! | ! .
join("\n", @cats_all_2) .
" |
";
$MODULES{'CATS_CUSTOM_REFINED'} .= q!| ! .
join("\n", @refined_cats_all_1) .
qq! | ! .
join("\n", @refined_cats_all_2) .
" |
";
}
@cats_all_1 = ();
@cats_all_2 = ();
@refined_cats_all_1 = ();
@refined_cats_all_2 = ();
if(scalar(@cats_all) > 0){
$col_len = int(scalar(@cats_all)/2-0.3);
@cats_all_1 = map{$_->[0]}@cats_all[0..$col_len];
@cats_all_2 = map{$_->[0]}@cats_all[($col_len+1)..$#cats_all];
$ref_len = scalar(grep{$_->[0] !~ m#\@#s}@cats_all);
$refined_col_len = int($ref_len/2-0.3);
@refined_cats_all_1 = (grep{$_ !~ m#\@#s}map{$_->[0]}@cats_all)[0..$refined_col_len];
@refined_cats_all_2 = (grep{$_ !~ m#\@#s}map{$_->[0]}@cats_all)[($refined_col_len+1)..($ref_len-1)];
for (@cats_all_1){
$_ .= "" ;
}
for (@cats_all_2){
$_ .= "" ;
}
for (@refined_cats_all_1){
$_ .= "" ;
}
for (@refined_cats_all_2){
$_ .= "" ;
}
$MODULES{'CATS_ALL'} = q!| ! .
join("\n", @cats_all_1) .
qq! | ! .
join("\n", @cats_all_2) .
" |
";
$MODULES{'CATS_ALL_REFINED'} = q!| ! .
join("\n", @refined_cats_all_1) .
qq! | ! .
join("\n", @refined_cats_all_2) .
" |
";
}
# print "$_
\n" for (@cats_all );
$base =~ m#http://(www\.)?dmoz\.org(.*?)$#i;
$currentcat = $2;
undef $/;
my $copright;
if(-e "data/copyright.txt"){
open(FILE, "data/copyright.txt");
flock(FILE, 2);
$copright = ;
flock(FILE, 8);
close(FILE);
$copright =~ s#\[CURRENTCAT\]#$currentcat#igs;
$copright =~ s#CURRENTCAT#$currentcat#igs;
$MODULES{'COPRIGHT'} = $copright;
$MODULES{'COPYRIGHT'} = $copright;
}
else{
open(FILE, "data/copright.txt");
flock(FILE, 2);
$copright = ;
flock(FILE, 8);
close(FILE);
$copright =~ s#\[CURRENTCAT\]#$currentcat#igs;
$copright =~ s#CURRENTCAT#$currentcat#igs;
$MODULES{'COPRIGHT'} = $copright;
$MODULES{'COPYRIGHT'} = $copright;
}
open(FILE, "data/$CONFIG{'CAT_TEMPLATE_FILE'}");
flock(FILE, 2);
$VARS{'TEMPLATE'} = ;
flock(FILE, 8);
close(FILE);
$/ = "\n";
print "Content-type: text/html\n\n";
# autoexec plugins here
opendir(EX, "autoexec");
my @execs = grep{m#\.pm$#} readdir(EX);
closedir(EX);
no strict "refs";
my $exit_ex;
for my $ex (@execs){
eval q{
require "autoexec/$ex";
$ex =~ s#\.pm##;
&$ex;
};
if($@ ne ''){
print qq!
Error in autoexec plugin $ex:
$@
!;
$exit_ex = 1;
}
}
exit if($exit_ex == 1);
use strict "refs";
# custom plugins
opendir(CUSTOM, "custom");
my @customs = grep{m#\.pm$#}readdir(CUSTOM);
closedir(CUSTOM);
my $exit_custom;
for my $custom (@customs){
eval q{
require "custom/$custom";
};
if($@ ne ''){
print qq!
Error in custom plugin $custom:
$@
!;
$exit_custom = 1;
}
}
exit if($exit_custom == 1);
$VARS{'TEMPLATE'} =~ s#\[custom\]\s*([^\[]*?)\s*\[/custom\]#my $aaa=$1; if($aaa =~ m/\(/){eval($aaa)}else{eval("\&$aaa")}#egsi;
$VARS{'CURRENT_CAT'} =~ m#([^/]*)$#;
my $last_part_cat = $1;
my $temp_google_rep = $last_part_cat;
$temp_google_rep = quotemeta($temp_google_rep );
$MODULES{'OUTSEARCH'} =~ s#http://www\.google\.com/search\?num=10\&query=$temp_google_rep#http://service.bfast.com/bfast/click?siteid=32558989\&bfpage=safesearch\&bfmid=27253343\&q=$last_part_cat\&safe=on\&sa=Go#is;
$MODULES{'OUTSEARCH'} .= qq!
!;
# Replace the MODULES
$VARS{'TEMPLATE'} =~ s#\[module\]\s*([^\[]*?)\s*\[/module\]#$MODULES{$1}#gsi;
$VARS{'TEMPLATE'} =~ s#\[exists module="([^"]*)"\]([^\[]*)\[/exists\]#eval {my $a = $2;$a if($MODULES{$1})}#egsi;
$VARS{'TEMPLATE'} =~ s#\[selective cat="([^"]*)"\]([^\[]*)\[/selective\]#eval {my $a = $2;$a if($VARS{'CURRENT_CAT'} eq $1)}#egsi;
$VARS{'TEMPLATE'} =~ s#\[selective_tree cat="([^"]*)"\]([^\[]*)\[/selective_tree\]#eval {my $a = $2;$a if($VARS{'CURRENT_CAT'} =~ m!$1!i)}#egsi;
$VARS{'TEMPLATE'} =~ s#\[non_selective_tree cat="([^"]*)"\]([^\[]*)\[/non_selective_tree\]#eval {my $a = $2;$a if($VARS{'CURRENT_CAT'} !~ m!$1!i)}#egsi;
$VARS{'TEMPLATE'} =~ s#\[CURRENT_CATEGORY\]#$last_part_cat#egsi;
# inserting SSI here.
$VARS{'TEMPLATE'} =~ s#\[include\s+url="([^"]*)"\]#get_content($1)#egsi;
$VARS{'TEMPLATE'} =~ s#\[include\s+path="([^"]*)"\]#transfer_content($1)#egsi;
$VARS{'TEMPLATE'} =~ s#\[execute\s+path="([^"]*)"\]#execute_cgi($1)#egsi;
$VARS{'TEMPLATE'} =~ s#\[advanced\s+url="([^"]*)"\s+start=!([^!]*)!\s+end=!([^!]*)!\]#adv_get_content($1, $2, $3)#egsi;
$netnoc = $VARS{'TEMPLATE'};
&$funky;
# Finally the output
unless($cehc_on eq "anok"){
print "fatal Error 808
";
print qq!Please contact ODP++ support
to fix this problem!;
exit;
}
print $netnoc;
if(lc($CONFIG{'ENABLE_CACHING'}) eq "yes"){
open(FILE, ">cache/$temp_cat.txt");
flock(FILE, 2);
print FILE $VARS{'TEMPLATE'};
flock(FILE, 8);
close(FILE);
opendir(CACHE, "cache");
my @caches = grep{m#\.txt$#}readdir(CACHE);
closedir(CACHE);
chdir("cache");
@caches = map{[$_, -M $_]} @caches;
if(lc($CONFIG{'USE_TIME_LIMITED_CACHE'}) eq "yes"){
my @expired_caches = map{$_->[0]} grep{ $_->[1] > $CONFIG{'CACHE_DAY_LIMIT'} } @caches;
unlink( @expired_caches );
}
if(scalar(@caches) > $CONFIG{'MAX_CACHES'}){
@caches = map{$_->[0]} sort{$a->[1] <=> $b->[1]} @caches;
unlink(@caches[$CONFIG{'MAX_CACHES'}..$#caches]);
}
chdir("..");
}
}
########################
# Search results are drawn here
########################
elsif($base =~ m#http://search\.dmoz\.org#i){
$VARS{'PAGE_TYPE'} = "search";
if($base =~ m#search=([^\&]*)(\&|$)#i){
$search_string = $1;
}
$VARS{'RAW_SEARCH_STRING'} = $search_string;
$search_string =~ s#\+# #g;
$VARS{'SEARCH_STRING'} = uri_unescape($search_string);
open(FILE, "bad_terms.conf");
flock(FILE, 2);
my $junk = ;
my @search_filters = ;
flock(FILE, 8);
close(FILE);
chomp(@search_filters);
for my $search_filter (@search_filters){
$search_filter = lc(quotemeta($search_filter));
if(lc($VARS{'SEARCH_STRING'}) =~ m#\b$search_filter\b#){
undef $/;
open(FILE, "data/searchfilter.txt");
flock(FILE, 2);
my $search_filter_template = ;
flock(FILE, 8);
close(FILE);
$/ = "\n";
print "Content-type: text/html\n\n";
print $search_filter_template;
exit;
}
}
$searchoutput = searchextract($base);
$MODULES{'SEARCH'}=$searchoutput;
if(lc($CONFIG{'USE_GOOGLE_REDIRECTION'}) eq "yes"){
if($MODULES{'SEARCH'} =~ m#No Open Directory Project results found#s){
# print "Location: http://service.bfast.com/bfast/click?siteid=31291691\&bfpage=safesearch\&bfmid=27253343\&q=$VARS{'RAW_SEARCH_STRING'}\&safe=on\&sa=Go\n\n";
undef $/;
open(FILE, "data/googleredirect.txt");
flock(FILE, 2);
my $google_redirect_template = ;
flock(FILE, 8);
close(FILE);
$/ = "\n";
print "Content-type: text/html\n\n";
print qq!
$google_redirect_template
!;
exit;
}
}
if($searchoutput =~ s#(\n)##is){
$MODULES{'SEARCH_CATS'} = $1;
}
if($searchoutput =~ s#(\[.*?more\.\.\.