#!/usr/local/bin/perl -w #Uncomment and modify the next line if you have experiencing path problems. #$odp_category_path = "/path/to/your/cgi-bin/odp"; use lib qw(/usr/home/pontivdi/usr/local/lib/perl5 /usr/home/pontivdi/usr/local/lib/site_perl /usr/home/pontivdi/usr/local/lib/site_perl/DBI /usr/home/pontivdi/usr/local/lib/perl5/5.00503); ###################### # Copyright © 2000 Portal Scripts. # All Rights Reserved. # # The original developer of this software module and his/her company, the subsequent # editors and their companies, have no liability for use of this # software module or modifications thereof in an implementation. # # Permission to use, copy, and modify this software and its documentation on # the server of the customer is hereby granted, provided that the above copyright # notice, this paragraph and the following two paragraphs appear in all # copies. # # This software program and documentation are copyrighted by Portal Scripts. # The software program and documentation are supplied "as is", without any # accompanying services. Portal Scripts does not # warrant that the operation of the program will be # uninterrupted or error-free. # # IN NO EVENT SHALL PORTAL SCRIPTS BE LIABLE TO ANY PARTY FOR # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING # LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION. # ###################### use strict; use vars qw(%CONFIG %MODULES %VARS %stop_list $cehc $erewop $netnoc $cehc_on $funky $odp_category_path); eval q{ require "stoplist.pm"; }; if($@ ne ''){ my $real_path; if($^O =~ m#win32#i){ if($ENV{'PATH_TRANSLATED'} ne ""){ $real_path = $ENV{'PATH_TRANSLATED'}; $real_path =~ s#\\#/#g; $real_path =~ s#[^/]*$##; chdir($real_path); } } else{ if($ENV{'SCRIPT_FILENAME'} ne ""){ $real_path = $ENV{'SCRIPT_FILENAME'}; $real_path =~ s#[^/]*$##; chdir($real_path); } } } unless($odp_category_path eq ""){ chdir($odp_category_path); } my ($current_cat, $currentcat, $searchoutput, $search_string); my $exit; eval q{use LWP::Simple;}; if($@ ne ''){ print "Content-type: text/html\n\n"; print qq! LWP::Simple perl library is not found in your installation.
This is a requirement to be able to run ODP++.

!; $exit = 1; } eval q{use URI::Escape;}; if($@ ne ''){ print "Content-type: text/html\n\n"; print qq! URI::Escape perl library is not found in your installation.
This is a requirement to be able to run ODP++.

!; $exit = 1; } exit if($exit == 1); eval q{ require "dirextract.pm"; require "searchextract.pm"; require "editorextract.pm"; require "tools.pm"; require "html_util.pm"; require "access_logs.pm"; require "stoplist.pm"; }; if($@ ne ''){ print "Content-type: text/html\n\n"; print qq! Error in "require" statements:
$@

!; exit; } my %cookies = &get_cookie; my $adult_status = $cookies{'adult'}; if($ENV{'QUERY_STRING'} =~ m#appr_okay#){ set_cookie("adult", "on"); } my ($cgi_url, $script_name) = &get_url; unless(-e "$script_name.name"){ opendir(CURRENT, "."); unlink( grep{m#\.name$#}readdir(CURRENT) ); closedir(CURRENT); open(FILE, ">$script_name.name"); flock(FILE, 2); print FILE "\n"; flock(FILE, 8); close(FILE); } %CONFIG = &read_config; $CONFIG{'CGI_URL'} = $cgi_url; $CONFIG{'SCRIPT_NAME'} = $script_name; if($CONFIG{'MAX_LOGS'} > 1000){ $CONFIG{'MAX_LOGS'} = 1000; } my $base = $ENV{'QUERY_STRING'}; if($base =~ m#^search=#i){ if($base =~ m#fo=#){ $base = "http://search.dmoz.org/cgi-bin/osearch?" . $base; } else{ $base = "http://search.dmoz.org/cgi-bin/search?" . $base; if($CONFIG{'MAIN_SUB_CATEGORY'} ne "" and lc($CONFIG{'LIMIT_SEARCH_RESULTS'}) eq "yes"){ unless($base =~ m#all=no#){ my $main_sub_cat = $CONFIG{'MAIN_SUB_CATEGORY'}; $main_sub_cat =~ tr/ /_/; $main_sub_cat = uri_escape($main_sub_cat); if($base =~ s#cat=[^\&]*#cat=$main_sub_cat#){ unless($base =~ s#all=yes#all=no# ){ $base =~ s#\&$##; $base .= "\&all=no"; } } else{ if($base =~ s#all=yes#all=no# ){ $base =~ s#\&$##; $base .= "\&cat=$main_sub_cat"; } else { $base =~ s#\&$##; $base .= "\&all=no\&cat=$main_sub_cat"; } } } } } } elsif($base !~ m#^http://search#i) { $current_cat = $base; $current_cat =~ s#^/##; $current_cat =~ s#/$##; $base = "http://dmoz.org" . $base; } open(DATA, "conf.dat" ); binmode(DATA); my @conf_data = ; close(DATA); my $conf_data = pack('C*', @conf_data); eval qq{$conf_data}; #################### # Main page is drawn here #################### unless($cehc eq "change_ok"){ print "Content-type: text/html\n\n"; print "fatal Error 807
"; print qq!Please contact ODP++ support to fix this problem!; exit; } if($base =~ m#^http://(www\.)?dmoz\.org/?$#i || $base eq "" ){ $VARS{'PAGE_TYPE'} = "main"; undef $/; open(FILE, "data/main.txt"); flock(FILE, 2); my $maincontent = ; flock(FILE, 8); close(FILE); $/ = "\n"; $maincontent =~ s#\[link cat="/?([^"]*?)/?"\]([^\[]*)\[/link\]#$2#igs; # inserting SSI here. $maincontent =~ s#\[include\s+url="([^"]*)"\]#get_content($1)#egsi; $maincontent =~ s#\[include\s+path="([^"]*)"\]#transfer_content($1)#egsi; $maincontent =~ s#\[execute\s+path="([^"]*)"\]#execute_cgi($1)#egsi; $maincontent =~ s#\[advanced\s+url="([^"]*)"\s+start=!([^!]*)!\s+end=!([^!]*)!\]#adv_get_content($1, $2, $3)#egsi; $netnoc = $maincontent; &$funky; # Finally the output print "Content-type: text/html\n\n"; unless($cehc_on eq "anok"){ print "fatal Error 808
"; print qq!Please contact ODP++ support to fix this problem!; exit; } print $netnoc; } #################### # Editor pages are drawn here #################### elsif($base =~ m#^http://dmoz.org/profiles/#i){ my $editor_html = editorextract($base); undef $/; open(FILE, "data/default.txt"); flock(FILE, 2); $VARS{'TEMPLATE'} = ; flock(FILE, 8); close(FILE); $/ = "\n"; $VARS{'TEMPLATE'} =~ s#\[module\]\s*MAIN\s*\[/module\]#$editor_html#gsi; $netnoc = $VARS{'TEMPLATE'}; &$funky; # Finally the output print "Content-type: text/html\n\n"; unless($cehc_on eq "anok"){ print "fatal Error 808
"; print qq!Please contact ODP++ support to fix this problem!; exit; } print $netnoc; } #################### # Category pages are drawn here #################### elsif($base =~ m#http://(www\.)?dmoz\.org#i){ $VARS{'PAGE_TYPE'}= "cat"; $VARS{'RAW_CURRENT_CAT'} = $current_cat; $VARS{'CURRENT_CAT'} = uri_unescape($current_cat); $VARS{'CURRENT_CAT'} =~ s#_# #g; $VARS{'CURRENT_CAT'} =~ m#^([^/]*)/?#; $CONFIG{'CAT_TEMPLATE_FILE'} = "cat.txt"; my $start_cat = $1; if(-f "data/$start_cat.txt"){ $CONFIG{'CAT_TEMPLATE_FILE'} = "$start_cat.txt"; } if(lc($CONFIG{'ENABLE_ADULT_FILTER'}) eq "yes" and $VARS{'CURRENT_CAT'} =~ m#^Adult# and $adult_status ne "on"){ if($VARS{'RAW_CURRENT_CAT'} =~ s#appr_okay$##){ $VARS{'RAW_CURRENT_CAT'} =~ s#appr okay$##; $base =~ s#appr_okay/$##; } else{ undef $/; open(FILE, "data/adultfilter.txt"); flock(FILE, 2); my $adult_template = ; flock(FILE, 8); close(FILE); $/ = "\n"; $adult_template =~ s#\[CONTINUE\](.*?)\[/CONTINUE\]#$1#isg; print "Content-type: text/html\n\n"; print $adult_template; exit; } } my $temp_cat; if(lc($CONFIG{'ENABLE_CACHING'}) eq "yes"){ unless(-d "cache"){ mkdir("cache", 0755); } $temp_cat = $VARS{'RAW_CURRENT_CAT'}; $temp_cat =~ s#/#_#g; if(-e "cache/$temp_cat.txt"){ undef $/; open(FILE, "cache/$temp_cat.txt"); flock(FILE, 2); my $cache_source = ; flock(FILE, 8); close(FILE); $/ = "\n"; print "Content-type: text/html\n\n"; print $cache_source; if(lc($CONFIG{'ENABLE_LOGGING'}) eq "yes"){ &access_logs; } exit; } } my ($html_source, $form, $main, $alphabar, $cat0, $cat1, $cat2, $related, $listings, $newsgroup, $outsearch, $editors) = dirextract($base); $VARS{'HTML_SOURCE'} = $html_source; unless($CONFIG{'MAIN_SUB_CATEGORY'} eq ""){ $CONFIG{'MAIN_SUB_CATEGORY'} =~ tr/ /_/; my $temp_check = $CONFIG{'MAIN_SUB_CATEGORY'}; $temp_check =~ s#/?([^/]*)$##; my $last = $1; $last =~ tr/_/ /; $temp_check = uri_escape($temp_check); my @main_subs = grep{length} split('/', $CONFIG{'MAIN_SUB_CATEGORY'}); for my $sub (@main_subs){ $sub = uri_escape($sub); } my $full = join("/", @main_subs); my $top_sub = uri_unescape($main_subs[-1]); my $top_temp_check; eval q{ $top_temp_check = uri_unescape($main_subs[-2]); }; if($@ ne ''){ print "Content-type: text/html\n\n"; print qq! Error... You can't use the first level categories as MAIN_SUB_CATEGORY:
Please go to the admin, and correct this.
$@

!; exit; } $top_sub =~ tr/_/ /; $top_temp_check =~ tr/_/ /; my $subs = ""; if( $main =~ m#$top_sub:#is or ($main =~ m#$top_temp_check:#is and $main =~ m#$last #is) ){ for my $sub (@main_subs){ $subs .= "/" . $sub; my $sub_text = uri_unescape($sub); $sub_text =~ tr/_/ /; $main =~ s#$sub_text:##is; } } } open(FILE, "top_cats.conf"); flock(FILE, 2); my $junk = ; my @top_cats = ; flock(FILE, 8); close(FILE); chomp(@top_cats); @top_cats = grep{length} @top_cats; for my $top_cat (@top_cats) { $top_cat =~ s#^\s+|\s+$##; $top_cat =~ tr/ /_/; my $temp_check = $top_cat; $temp_check =~ s#/?([^/]*)$##; my $last = $1; $last =~ tr/_/ /; $temp_check = uri_escape($temp_check); my @main_subs = grep{length} split('/', $top_cat); for my $sub (@main_subs){ $sub = uri_escape($sub); } my $full = join("/", @main_subs); my $top_sub = uri_unescape($main_subs[-1]); my $top_temp_check = uri_unescape($main_subs[-2]) if (scalar(@main_subs)>1); $top_sub =~ tr/_/ /; $top_temp_check =~ tr/_/ /; my $subs = ""; if( $main =~ m#$top_sub:#is or ($main =~ m#$top_temp_check:#is and $main =~ m#$last #is) ){ pop @main_subs; for my $sub (@main_subs){ $subs .= "/" . $sub; my $sub_text = uri_unescape($sub); $sub_text =~ tr/_/ /; $main =~ s#$sub_text:##is; } } } $MODULES{'FORM'} = $form; $MODULES{'MAINCAT'} = $main; $MODULES{'ALPHABAR'} = $alphabar; $MODULES{'CATS'} = $cat0 . $cat1 . $cat2; $MODULES{'CAT0'} = $cat0; $MODULES{'CAT1'} = $cat1; $MODULES{'CAT2'} = $cat2; $MODULES{'RELATED'} = $related; $MODULES{'LISTINGS'} = $listings; $MODULES{'NEWSGROUP'} = $newsgroup; $MODULES{'OUTSEARCH'} = $outsearch; $MODULES{'EDITORS'} = $editors; ############ #------------------------------------- ############ $MODULES{'LISTINGS'} =~ s#; my @category_filters = ; flock(FILE, 8); close(FILE); chomp(@category_filters); @category_filters = grep{length} @category_filters; for my $category_filter (@category_filters){ $category_filter =~ tr/ /_/; $category_filter = uri_escape($category_filter); } ############ #------------------------------------- ############ my @reg_listings_temp = $MODULES{'LISTINGS'} =~ m#((.*?))(.*?)(|

  • |

    )#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! Cool !; } $list->[3] =~ s#(\ )?(\-)?##gis; $list->[2] =~ s###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###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###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###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###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\.\.\. \]
    )##is){ $MODULES{'SEARCH_CATS_MORE'} = $1; } if($searchoutput =~ s#(\n)##is){ $MODULES{'SEARCH_LINKS'} = $1; } if($searchoutput =~ s#(
    \ .*?
    )##is){ $MODULES{'NEXT'} = $1; } if($searchoutput =~ s#(
    )##is){ $MODULES{'SEARCH_FORM'} = $1; } if($searchoutput =~ s#(.*?
    )##is){ $MODULES{'OUTSEARCH'} = $1; } my $temp_google_rep = $VARS{'RAW_SEARCH_STRING'}; $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=$VARS{'RAW_SEARCH_STRING'}\&safe=on\&sa=Go#is; $MODULES{'OUTSEARCH'} .= qq!!; print "Content-type: text/html\n\n"; if( ($MODULES{'SEARCH_CATS'} eq "" and $MODULES{'SEARCH_LINKS'} eq "") or $base =~ m#osearch\?#i){ undef $/; open(FILE, "data/default.txt"); flock(FILE, 2); $VARS{'TEMPLATE'} = ; flock(FILE, 8); close(FILE); $/ = "\n"; $MODULES{'SEARCH'} =~ s#http://www\.google\.com/search\?num=10\&query=$temp_google_rep#http://service.bfast.com/bfast/click?siteid=31291691\&bfpage=safesearch\&bfmid=27253343\&q=$VARS{'RAW_SEARCH_STRING'}\&safe=on\&sa=Go#is; $MODULES{'SEARCH'} .= qq!!; $VARS{'TEMPLATE'} =~ s#\[module\]\s*MAIN\s*\[/module\]#$MODULES{'SEARCH'}#gsi; $netnoc = $VARS{'TEMPLATE'}; &$funky; 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_LOGGING'}) eq "yes"){ &access_logs; } exit; } undef $/; open(FILE, "data/search.txt"); flock(FILE, 2); $VARS{'TEMPLATE'} = ; flock(FILE, 8); close(FILE); $/ = "\n"; # autoexec plugins here opendir(EX, "autoexec"); my @search_execs = grep{m#\.pm$#}readdir(EX); closedir(EX); no strict "refs"; my $exit_ex; for my $ex (@search_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 @search_customs = grep{m#\.pm$#}readdir(CUSTOM); closedir(CUSTOM); my $exit_custom; for my $custom (@search_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; # replace MODULES $VARS{'TEMPLATE'} =~ s#\[module\]\s*([^\[]*?)\s*\[/module\]#$MODULES{$1}#gs; $VARS{'TEMPLATE'} =~ s#\[exists module="([^"]*)"\]([^\[]*)\[/exists\]#eval {my $a = $2;$a if($MODULES{$1})}#egsi; $VARS{'TEMPLATE'} =~ s#\[selective search="([^"]*)"\]([^\[]*)\[/selective\]#eval {my $a = $2;$a if($VARS{'SEARCH_STRING'} =~ /\Q$1/i)}#egsi; $VARS{'TEMPLATE'} =~ s#\[SEARCH_TERMS\]#$VARS{'SEARCH_STRING'}#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; } # post processing if(lc($CONFIG{'ENABLE_LOGGING'}) eq "yes"){ &access_logs; }