#!/usr/local/bin/perl5.6.1 -w #...................................................................# # Sanitarium WebLoG: web publish system.............................# # Author: Green Kakadu (WebScript.Ru Network) ......................# # Email: gnezdo@webscript.ru .......................................# # WWW: http://webscript.ru .........................................# # Copyright 2002 WebScript.Ru Network ( http://webscript.ru ).......# # All Rights Reserved. .............................................# #...................................................................# # Welcome to where time stands still # no one leaves and no one will # Moon is full, never seems to change # just labeled mentally deranged # Dream the same thing every night # I see our freedom in my sight # No locked doors, No windows barred # No things to make my brain seem scarred #................... Metallica, "Welcome Home (Sanitarium)" #...................................................................# # File name: admin.cgi ....................# #...................................................................# use strict; use CGI::Carp qw(fatalsToBrowser); use vars '$time_view','$script_admin', '$ext', '$img_url', '$tmpl_dir', '$data', '$public_dir', '$use_emoticons', '$public_url', '$use_flock', '$dir', '%msg', '%in', '$builder', '$index_url', '$index_page', '$entry_per_page', '$static_pages', '$view_cgi_url', '$site_title', '$how_news', '$use_search', '$not_found', '$foto_url', '$premoderate', '$send_new_comments', '$admin_mail', '$SEND_MAIL', '$comadmin_cgi_url', '$comment_url', '$mail_cgi_url', '$coms_per_page', '$foto_dir', '$img_dir', '$GMT', '$upload_url', '$autolink', '$qhtml', '$fozzy', '$txt_news'; #....Load Libraries eval { require "cfg.cfg"; require "Sanitarium_WL.pm"; require "lang.pl"; }; #....If not Libraries if ($@){ print "Content-type: text/html\n\n"; print "ERROR including libraries: $@"; exit; } #flock() options: $Sanitarium_WL::USE_FLOCK=$use_flock; $Sanitarium_WL::USE_FLOCK||=0; #....RUN main subrouting eval { &main }; #....If Errors if ($@){ &WLerr("Error: $@"); } exit; sub main { #-------------------------------------------------------------- $script_admin||=$ENV{'SCRIPT_NAME'}; if ($ENV{'REQUEST_METHOD'}){%in=&parse_form;} #......CATEGORY if ($in{'new_cat'}) {&create_category;} elsif ($in{'save_mod_category'}) {&save_category;} elsif ($in{'save_category'}) {&save_category;} elsif ($in{'delete_category'}) {&delete_category;} elsif ($in{'view_category'}) {&view_category;} elsif ($in{'modify_category'}) {&create_category;} #......ARTICLES elsif ($in{'new_article'}) {&add_article;} elsif ($in{'save_mod_article'}) {&save_article;} elsif ($in{'save_article'}) {&save_article;} elsif ($in{'delete_article'}) {&delete_article;} elsif ($in{'modify'}) {&mod_article;} elsif ($in{'search_id'}) {&mod_by_id;} elsif ($in{'search_view'}) {&mod_by_id;} elsif ($in{'mod_art_options'}) {&mod_article_options;} elsif ($in{'save_new_options'}) {&mod_article_options;} elsif ($in{'index_article'}&&$use_search) {&indexing_article} elsif ($in{'delete_from_index'}&&$use_search) {&delete_article_from_index;} elsif ($in{'delete_from_index_y'}&&$use_search) {&delete_article_from_index;} #.....ARTICLE'S PAGES elsif ($in{'modify_article'}) {&add_article(1);} elsif ($in{'delete_page'}) {&delete_page;} elsif ($in{'add_page'}) {&add_article(666);} #.....TEMPLATE EDITOR elsif ($in{'new_template'}) {&template_edit;} elsif ($in{'modify_template'}) {&select_template;} elsif ($in{'mod_templ_but'}) {&save_template;} elsif ($in{'new_templ_but'}) {&save_template(1);} elsif ($in{'view_template'}) {&view_template;} #....AUTHORS elsif ($in{'add_author'}) {&add_author;} elsif ($in{'modify_author'}) {&add_author;} elsif ($in{'save_mod_author'}) {&save_author;} elsif ($in{'save_new_author'}) {&save_author;} elsif ($in{'view_author'}) {&author_info;} elsif ($in{'save_new_author'}) {&save_author;} elsif ($in{'delete_author'}) {&delete_author;} #....BUILDER elsif ($in{'rebuild_all'}) {&rebuild_all;} elsif ($in{'rebuild_cat'}) {&rebuild_category;} elsif ($in{'article_rebuild'}) {&article_rebuild;} #....MISC elsif ($in{'list_files'}) {&print_file_list;} elsif ($in{'delete_files'}) {&delete_files;} elsif ($in{'delete_this'}) {&delete_files;} #.....START else {&start_page;} } #.......#ADMIN ROUTINGS ####################### #......#CATEGORY sub create_category { #---------------------------------------------------------------------- my ($obj, $value, $name, %category); if ($in{'cat_id'}){ #CREATE OBJECT $obj = new Sanitarium_WL ("$data/categories", 'categories'); %category = $obj->get_data($in{'cat_id'}); #DESTROY $obj=0; $value='Modify!'; $name='save_mod_category';#don't change it value } else { $value='Create!'; $name='save_category';#don't change it value %category=0; } #Print Page &head; print qq~
~; #Print input fields: #&table('Category DirName', &input_form('cat_dir', 70, 100, $in{'cat_dir'})); &table($msg{'cat_name'}.':', &input_form('cat_name', 70, 100, $category{'cat_name'})); &table($msg{'cat_desc'}.':', &textarea('cat_description', 50, 5, $category{'cat_description'})); &table($msg{'cat_keywords'}.':', &textarea('cat_keywords', 50, 5, $category{'cat_keywords'})); &table($msg{'template'}.':', &drop_list('template',$category{'template'}, &template_list)); print qq~
~; &foot; } sub save_category { #--------------------------------------------------------------------- my ($obj, $key, $html, %index); #my $option=shift;#Modify or create new? #Check %in unless ($in{'cat_name'}){&msg('You must input Category Name!');} unless ($in{'cat_description'}){&msg('You must input Category Description!');} unless ($in{'template'}){&msg('You must select Category Template')} #CREATE Object $obj = new Sanitarium_WL ("$data/categories", 'categories'); #if modify, than modify it! #Fields: categories =>['cat_name', 'cat_description', 'cat_keywords', 'template'] if ($in{'cat_id'}){ $obj->modify_data($in{'cat_id'}, $in{'cat_name'}, $in{'cat_description'}, $in{'cat_keywords'}, $in{'template'}); } #Else Create new! else { $key=$obj->write_data('1cat', $in{'cat_name'}, $in{'cat_description'}, $in{'cat_keywords'}, $in{'template'}); } $obj=0; $key||=$in{'cat_id'}; #Check category dir if (!(-e "$data/$key")){ mkdir("$data/$key", 0777) or &WLerr("Can't mkdir $data/$key , reason: $!"); chmod(0777, "$data/$key") or &WLerr("Can't chmod $data/$key , reason: $!"); } if (!(-e "$public_dir/$key")){ mkdir("$public_dir/$key", 0777) or &WLerr("Can't mkdir $public_dir/$key , reason: $!"); chmod(0777, "$public_dir/$key") or &WLerr("Can't chmod $public_dir/$key , reason: $!"); } #Create Category DB $obj= new Sanitarium_WL("$data/$key", 'index'); $obj->create_db(); $obj=0; $html=&category_info($key, $in{'cat_name'}, $in{'cat_description'}, $in{'cat_keywords'}, $in{'template'}); &head; &table($msg{'info'}.':', $html); &foot; } sub delete_category { #--------------------------------------------------------------------- my ($obj, $html, @del_keys, %category); $obj= new Sanitarium_WL ("$data/categories", 'categories'); %category=$obj->get_data($in{'cat_id'}); unless ($in{'del_cat'}){ #Build category Info $html=&category_info($in{'cat_id'}, $in{'cat_name'}, $in{'cat_description'}, $in{'cat_keywords'}, $in{'template'}); $html .= qq~ $msg{'want_del'}

$msg{'yes_del_cat'} ~; &head; &table($msg{'att'}, $html); &foot; } else { $obj->delete_data($in{'cat_id'});#Delete Category... bay-bay, babe! $obj=0; #Now Delete categories'articles from index $obj= new Sanitarium_WL ("$data/$in{'cat_id'}", 'index'); @del_keys=$obj->get_keys(); $obj=0; #Delete articles from index DB: $obj= new Sanitarium_WL ("$data/index", 'index'); $obj->mass_delete(@del_keys); $obj=0; ####################################### #DELETING FROM INDEX ALL Articles! if ($use_search){ foreach my $key(@del_keys){ &delete_from_index_all($key); } } ###################################### #Delete Categories DB: unlink ("$data/$in{'cat_id'}.dat")||die("Can not delete file $data/$in{'cat_id'}.dat, reason: $!"); #Delete category database :0 What you think about archiving??? unlink ("$data/$in{'cat_id'}.lock") if (-e "$data/$in{'cat_id'}.lock"); opendir (CATDEL, "$data/$in{'cat_id'}")||die("Can not open dir: $data/$in{'cat_id'}, reason: $!"); #delete all files from forum directory while (my $file=readdir(CATDEL)){ if (defined $file){ unlink("$data/$in{'cat_id'}/$file")||die("Can not delete file: $data/$in{'cat_id'}/$file, reason: $!"); if ($file=~/\.dat/){ $file=~s/\.dat/.txt/; unlink("$data/comments/$file") if (-e "$data/comments/$file"); } } } closedir(CATDEL)||die("Can not close directory: $data/$in{'cat_id'}, reason: $!"); #delete cat dir: rmdir("$data/$in{'cat_id'}")||die("Can not delete dir: $data/$in{'cat_id'}, reason: $!"); #Delete Categories HTML opendir (CATDEL, "$public_dir/$in{'cat_id'}")||die("Can not open dir: $public_dir/$in{'cat_id'}, reason: $!"); #delete all files from cat directory while (my $file=readdir(CATDEL)){ if (defined $file){ unlink("$public_dir/$in{'cat_id'}/$file")||die("Can not delete file: $public_dir/$in{'cat_id'}/$file, reason: $!");} } closedir(CATDEL)||die("Can not close directory: $public_dir/$in{'cat_id'}, reason: $!"); #delete forum dir: rmdir("$public_dir/$in{'cat_dir'}")||die("Can not delete dir: $public_dir/$in{'cat_id'}, reason: $!"); #Update Cache Info: #&rebuild_caches; #Build category Info: $html=&category_info($in{'cat_id'}, $in{'cat_name'}, $in{'cat_description'}, $in{'cat_keywords'}, $in{'template'}); $html .=$msg{'cat_del_end'}; &head; &table($msg{'cat_del'}, $html); &foot; } } sub view_category { #--------------------------------------------------------------------- my ($obj, $html, @keys, %category, %cat); #my %authors=&authors_list; $obj= new Sanitarium_WL("$data/categories", 'categories'); %category= $obj->get_nn_recs('all'); if ($in{'cat_id'}){ push(@keys, $in{'cat_id'}); %cat=$obj->unpack_to_hash($category{$in{'cat_id'}}); } else { @keys = sort {$a <=> $b} keys %category; } &head; #'categories' =>['cat_dir', 'cat_name', 'cat_description', 'cat_keywords', 'template'], unless ($in{'page'}){ foreach my $key (@keys){ %cat=$obj->unpack_to_hash($category{$key}) unless($in{'cat_id'}); $html =&category_info($key, $cat{'cat_name'}, $cat{'cat_description'}, $cat{'cat_keywords'}, $cat{'template'}); $html .= qq~
:$msg{'modify'} :$msg{'view'} :$msg{'rebuild'} :$msg{'delete'} ~; &table("$msg{'cat'} - $cat{'cat_name'}", $html); } } #Articles in Category if ($in{'cat_id'}){ #articles per page: my $mes_per_page=15; $obj= new Sanitarium_WL("$data/$in{'cat_id'}", 'index'); my $num_recs=$obj->get_num_recs(); #Number pages my $how_pages = int ($num_recs/$mes_per_page); ++$how_pages if ($how_pages*$mes_per_page != $num_recs); #Build page index $in{'page'}||=0; my $pages; for (my $i =1; $i<=$how_pages; $i++){ my $num=($i-1); #....HTML if ($num != $in{'page'}){$pages .= qq~ $i|~;} else {$pages .= qq~ $i~;} } $pages||= qq~ 1 ~; # my %data=$obj->get_nn_recs($mes_per_page, $in{'page'});#15 topiks per page my @articles= sort {$b<=>$a} keys %data; my %art_data; #Build List of Articles: print qq~

~; foreach my $article(@articles){ %art_data= $obj->unpack_to_hash($data{$article}); # if ($art_data{'author'}=~/\d+auth/){ # $art_data{'author'}=$authors{$art_data{'author'}}; # } print qq~ [ id:$article ] $art_data{'title'}
$msg{'Date'}: $art_data{'date'} $msg{'page'}: $art_data{'pages'}
:$msg{'modify'}: :$msg{'delete'}: :$msg{'rebuild'}: :$msg{'view_coms'}:

~; } $obj=0; print qq~

\ $msg{'Pages'}: $pages
~; # } #End Articles &foot; } sub category_info { #------------------------------------------------------------- return qq~ $msg{'info'}:
  • $msg{'Category ID'}: $_[0]
  • $msg{'cat_path'}: $public_url/$_[0]
  • $msg{'cat_name'}: $_[1]
  • $msg{'cat_desc'}: $_[2]
  • $msg{'cat_keywords'}: $_[3]
  • $msg{'template'}: $_[4]
    ~; } sub category_list { #---------------------------------------------------------- my ($obj, @keys, @list, %category); $obj = new Sanitarium_WL("$data/categories", 'categories'); %category = $obj->get_nn_recs('all'); #categories=>['cat_dir', 'cat_name', 'cat_description', 'cat_keywords', 'template'], @keys= keys %category; foreach my $cat(@keys){ my %cat=$obj->unpack_to_hash($category{$cat}); push(@list,$cat,$cat{'cat_name'}); } $obj=0; return @list; } #......#ARTICLES ################ sub add_article { #-------------------------------------------------------------- my ($obj, $html,$value, $name, $id, $modify_old, $page, @keys, %art_dump, %article, %first); $modify_old=shift; $modify_old||=0; #$in{'page'}||=shift; #$in{'cat_id'}||=shift #$in{'entry'}||=shift; $page=$in{'page'}||1; if ($in{'cat_id'}&&$in{'id'}){ #CREATE OBJECT $obj = new Sanitarium_WL ("$data/$in{'cat_id'}/$in{'id'}", 'article'); %art_dump = $obj->get_nn_recs('all'); @keys= sort {$a <=> $b} keys %art_dump; %article=$obj->unpack_to_hash($art_dump{$keys[$page-1]}) if $in{'page'}; %first=$obj->unpack_to_hash($art_dump{$keys[0]}); $first{'id'}=$in{'id'}; undef %art_dump; #DESTROY $obj=0; $value='Modify Page!'; $name='save_mod_article';#don't change this value #IMG EMOTICONS TO SYMBOLS: if ($use_emoticons){ $article{'preview'}=&emoticons_to_symbol($article{'preview'}) if $article{'preview'}; $article{'content'}=&emoticons_to_symbol($article{'content'}) if $article{'content'}; $first{'preview'}=&emoticons_to_symbol($first{'preview'}); } #HTML to form: if ($article{'related'}=~//){$article{'related'}=$1;} elsif ($first{'related'}=~//){$first{'related'}=$1;} $article{'preview'}=&text_to_form($article{'preview'}) if $article{'preview'}; $article{'content'}=&text_to_form($article{'content'}) if $article{'content'}; $first{'preview'}=&text_to_form($first{'preview'}) if $first{'preview'}; } else { $value='Post!'; $name='save_article';#don't change this value $obj= new Sanitarium_WL("$data/id", 'none'); $id=$obj->get_id(); $obj=0; } #if ($modify_old eq 'next'){undef $modify_old;} #Print Page $id||=$in{'id'}; &head; print qq~
    ~; #About Page Number if (($modify_old)&&($modify_old != 666)&&($use_search)){ &table($msg{'indexing_title'}, qq~ $msg{'index_y'}
    $msg{'index_y_n'} ~); } if ($modify_old == 666){&table("Add Page", $msg{'add_page'});} else {&table("$msg{'page'} $page", $msg{'input_page'}." $page");} print qq~~ if $modify_old; #If modify, but not first page: if ($first{'pages'}||($modify_old == 666)){ #Not modify: cat_id, pages, num, id, author, date: print qq~ ~; if ($first{'author'}=~/,,,/){ #Coding unregistered authors data for hidden input field $first{'author'}=~s/"/|34;/g; $first{'author'}=~s/'/|44;/g; $first{'author'}=~s//|62;/g; } print qq~~; } #if modify first page, than not change id! elsif ($first{'id'}){print qq~ ~;} #IF CREATE FIRST PAGE: if (!$in{'id'}){ #........AUTHOR $html =&js_drop_list('authorid','author',$first{'author'},&authors_list); $html .= "
    $msg{'select_author'}"; &table($msg{'Author'}.':', $html); #........SELECT CATEGORY &table($msg{'select_cat'}.':', &drop_list('cat_id',$first{'cat_id'}, &category_list)); #........PAGES &table($msg{'how_pages'}.':', &input_form('pages', 2, 2, 1)); } else { $html= qq~$msg{'how_pages'}: $first{'pages'}~; &table($msg{'how_pages'}.':', $html); } #Print input fields: if ($modify_old == 666){ $article{'content'}=''; &table($msg{'new_page_num'}.':', &drop_list('add_page', ($first{'pages'}+1), &pages_list($first{'pages'}+1))); } #FOR ALL: &table($msg{'Title'}.':', &input_form('title', 70, 150, ($article{'title'}||$first{'title'}))); &table($msg{'Preview'}.'/Meta Description:', &textarea('preview', 60, 5, ($article{'preview'}||$first{'preview'}))); &table($msg{'keywords'}.':', &textarea('keywords', 60, 5, ($article{'keywords'}||$first{'keywords'}))); $html=''; if ($qhtml||$fozzy){ $html=qq~
    B I P BR img A CODE li :) 8) :(
    ~; } $html .=&textarea('content', 70, 40, $article{'content'}); if ($fozzy){$html .=$msg{'fozzy_html'};} &table($msg{'content'}.':', $html); $html=''; &table($msg{'related'}.':', (&input_form('related', 70, 70, ($article{'related'}||$first{'related'}))).$msg{'about_related'}); print qq~
    ~; &foot; #end sub } sub save_article { #-------------------------------------------------------------- my ($obj, $id, @check, @err); #article =>['cat_id', 'title', 'date', 'author', 'preview', 'content', 'keywords', 'num', 'pages'],); @check=('cat_id', 'title', 'content', 'num', 'pages'); foreach my $check(@check){ if (!$in{$check}){push(@err, $check);} } if (@err){&msg("$msg{'not_defined'} @err!
    $msg{'back'}");} unless($in{'date'}){$in{'date'}=&get_time();} #IF MODIFY: if ($in{'indexing'}&&$use_search){&delete_page_from_index($in{'cat_id'}, $in{'id'}, $in{'num'});} #IF ADD PAGE to old article if ($in{'add_page'}) { &delete_from_index_all if $use_search; $in{'num'}=$in{'add_page'};#update some %in data $in{'pages'}++; $obj= new Sanitarium_WL("$data/$in{'cat_id'}/$in{'id'}", 'article'); $obj->add_page($in{'id'}, $in{'add_page'});#rebuild article DB $obj=0; foreach my $db_index ($in{'cat_id'}, 'index'){ $obj=new Sanitarium_WL("$data/$db_index", 'index'); $obj->modify_fields($in{'id'}, 'pages', 'pages++');#Update number of pages in indexes $obj=0; } #END IF PAGE } #RELATED if ($in{'related'}){ $in{'related'} =~ s/[^\d,]//g; my @related=split(/,/,$in{'related'}); $in{'related'}= qq~~; &load_cfg; $in{'related'} .= $builder->related_links($in{'cat_id'},@related); $builder=0; } #AUTHOR unless($in{'author'}||$in{'radiom'}){&msg("$msg{'not_defined'} - author!
    $msg{'back'}");} if ($in{'radiom'}){ if ($in{'radiom'} eq 'my'){ unless($in{'authorid'}){&msg("$msg{'not_defined'} - author!
    $msg{'back'}");} $in{'author'}=$in{'authorid'}; } else {$in{'author'}=join(",,,", $in{'authname'},$in{'authmail'},$in{'authsignature'},$in{'authfoto'},$in{'authwww'});} } elsif ($in{'author'}=~/,,,/){ #Encoding unregistered authors data from hidden field to normal html view $in{'author'}=~s/\|34;/"/g; $in{'author'}=~s/\|44;/'/g; $in{'author'}=~s/\|60;//g; } #CONTENT my $content=&parse_article($in{'content'}); $in{'content'}=0;#DESTROY! #PREVIEW $in{'preview'}||= substr($content, 0, 180);#180 simbols in preview by default! my $preview=&parse_article($in{'preview'}); $in{'preview'}=0;#DESTROY! $id=$in{'id'}; #NOW WRITE INTO ARTICLE DB #'article'=>['cat_id', 'title', 'date', 'author', 'preview', 'content', 'keywords', 'num', 'pages', 'related'] $obj= new Sanitarium_WL("$data/$in{'cat_id'}/$id", 'article'); $obj->add_entry($in{'num'}, $in{'cat_id'}, $in{'title'}, $in{'date'}, $in{'author'}, $preview, $content, $in{'keywords'}, $in{'num'}, $in{'pages'}, $in{'related'}); $in{'id'}=$id; #IF MODIFY ARTICLE if ($in{'modify_old'}&&($in{'num'}!=1)){&mod_article;} #IF END - UPDATE INDEX! elsif (($in{'num'} == $in{'pages'})||($in{'modify_old'})){ if ($in{'modify_old'}){ &indexing_page($in{'cat_id'}, $in{'id'}, $in{'num'}) if (($in{'modify_old'}!=666)&&($use_search)&&$in{'indexing'}); &end_article_input; }#If Modify First Article Page else {&end_article_input;}#If add new article } #IF NEXT PAGE else { $in{'page'}=($in{'num'}+1); &add_article; #('next', ($in{'num'}+1), $in{'cat_id'}, $id) } #end sub } sub mod_by_id { #------------------------------------------------------------- my $html; if ($in{'id'}){ my $obj=new Sanitarium_WL("$data/index", 'index'); my %art=$obj->check_and_get($in{'id'}); $obj=0; if ($art{'cat_id'}){ %in=%art; &mod_article($in{'id'}); exit; } else {$html = qq~ID:$in{'id'} $msg{'not_id'}

    ~;} } &head; #Search by ID $html .= qq~

    $msg{'by_id'}
    ~; $html .=&input_form('id', 10, 10, ''); $html .= qq~
    ~; &table("Input ID", $html); #Search by Category $html = qq~
    ~; $html .=$msg{'by_cat'}; $html .= &drop_list('cat_id','', &category_list); $html .= qq~
    ~; &table('Select Category', $html); &foot; #end sub } sub mod_article { #------------------------------------------------------------- my ($obj, $modify, $html, @keys, %art_dump, %article, %authors); my $id=shift; my $cat_id=shift; $id||=$in{'id'}; $cat_id||=$in{'cat_id'}; &head; $obj= new Sanitarium_WL("$data/$cat_id/$id", 'article'); %art_dump = $obj->get_nn_recs('all'); #Now Print short article info my %art=$obj->unpack_to_hash($art_dump{1});#Get info from first page $art{'author'}=&get_author_name($art{'author'}); $html= qq~
  • $msg{'Article_ID'}: $id
  • $msg{'Title'}: $art{'title'}
  • $msg{'Date'}: $art{'date'}
  • $msg{'Author'}: $art{'author'}
  • $msg{'how_pages'}: $art{'pages'}
  • $msg{'Preview'}: $art{'preview'} ~; &table($msg{'info'}, $html); @keys= sort {$a <=> $b} keys %art_dump; #Article Options $html = qq~
  • $msg{'a_pub'} $msg{'a_pub_desc'}
  • $msg{'a_mod'} $msg{'a_mod_desc'}
  • $msg{'add_page'} $msg{'add_page_desc'}
  • $msg{'view_art_coms'} ~; if ($use_search){ $html .= qq~
  • $msg{'index_article'} $msg{'index_article_desc'}
  • $msg{'a_delete_index'} $msg{'a_delete_index_desc'} ~; } $html .= qq~
  • $msg{'a_delete'} $msg{'a_delete_desc'} ~; &table($msg{'a_t_opt'}.':', $html); $html= qq~
      ~; #Build Article Index foreach my $key(@keys){ %article = $obj->unpack_to_hash($art_dump{$key}); $html .= qq~
    1. [ $msg{'page'}:$article{'num'} ] $article{'title'}
      :$msg{'view'} :$msg{'modify'} :$msg{'delete'}

      ~; } undef %art_dump; $html .= qq~
    ~; &table("$msg{'Pages'}:", $html); &foot; #end sub } sub mod_article_options { #------------------------------------------------------- my ($obj, $html, $author, %art); if (!$in{'save_new_options'}){ $obj= new Sanitarium_WL("$data/$in{'cat_id'}", 'index'); %art=$obj->get_data($in{'id'}); $obj=0; $author=$art{'author'}; $art{'author'}=&get_author_name($art{'author'}); &head; $html= qq~
  • $msg{'Article_ID'}: $in{'id'}
  • $msg{'Title'}: $art{'title'}
  • $msg{'Date'}: $art{'date'}
  • $msg{'Author'}: $art{'author'}
  • $msg{'how_pages'}: $art{'pages'} ~; &table($msg{'info'}, $html); print qq~
    ~; &table($msg{'select_cat'}.':', &drop_list('new_cat_id',$in{'cat_id'}, &category_list)); $html =&js_drop_list('author_id','author',$author,&authors_list); $html .=$msg{'select_author'}; &table($msg{'Author'}.':', $html); &table($msg{'status'}.':', &drop_list('status',$art{'status'}, 'ok', $msg{'open'}, 'close', $msg{'close'})); print qq~
    ~; &foot; } else { #AUTHORS if ($in{'radiom'} eq 'my'){$in{'author'}=$in{'authorid'};} else {$in{'author'}=join(",,,", $in{'authname'},$in{'authmail'},$in{'authsignature'},$in{'authfoto'},$in{'authwww'});} #IF NEW CATEGORY if ($in{'cat_id'} ne $in{'new_cat_id'}){ rename("$data/$in{'cat_id'}/$in{'id'}.dat", "$data/$in{'new_cat_id'}/$in{'id'}.dat")||&WLerr("Can't rename $data/$in{'cat_id'}/$in{'id'}.dat to $data/$in{'new_cat_id'}/$in{'id'}.dat REASON: $!"); unlink("$data/$in{'cat_id'}/$in{'id'}.lock") if (-e "$data/$in{'cat_id'}/$in{'id'}.lock"); foreach my $pg ([1..$in{'pages'}]){ if (-e "$public_dir/$in{'cat_id'}/$in{'id'}"."_"."$pg.$ext"){ rename("$public_dir/$in{'cat_id'}/$in{'id'}"."_"."$pg.$ext", "$public_dir/$in{'new_cat_id'}/$in{'id'}"."_"."$pg.$ext")||&WLerr("Can't rename $data/$in{'cat_id'}/$in{'id'} to $data/$in{'new_cat_id'}/$in{'id'} REASON: $!"); } } $obj= new Sanitarium_WL("$data/$in{'cat_id'}", 'index'); my %article=$obj->get_data($in{'id'}); $obj->delete_data($in{'id'}); $obj=0; $obj= new Sanitarium_WL("$data/$in{'new_cat_id'}", 'index'); $obj->write_data($in{'id'}, $article{'title'}, $article{'preview'}, $article{'new_cat_id'}, $in{'author'}, $in{'id'}, $article{'date'}, $article{'pages'}, $in{'status'}); $obj=0; &rebuild_category($in{'cat_id'}); } else { $obj= new Sanitarium_WL("$data/$in{'cat_id'}", 'index'); $obj->modify_fields($in{'id'}, 'author', $in{'author'}, 'status', $in{'status'}); $obj=0; } $obj= new Sanitarium_WL("$data/$in{'new_cat_id'}/$in{'id'}", 'article'); $obj->modify_all_recs('cat_id', $in{'new_cat_id'}, 'author', $in{'author'}); $obj=0; $obj= new Sanitarium_WL("$data/index", 'index'); $obj->modify_fields($in{'id'}, 'cat_id',$in{'new_cat_id'}, 'author', $in{'author'}, 'status', $in{'status'}); $obj=0; &rebuild_category($in{'cat_id'}); &index_print('index'); $in{'cat_id'}=$in{'new_cat_id'}; &article_rebuild; &mod_article($in{'id'},$in{'new_cat_id'}); } #end sub } sub end_article_input { #------------------------------------------------------- #'article' =>['cat_id', 'title', 'date', 'author', 'preview', 'content', 'keywords', 'num', 'pages', 'related'],); my ($obj, $modify, %article); my $id=$in{'id'}; $modify=$in{'modify_old'}||shift; $obj= new Sanitarium_WL("$data/$in{'cat_id'}/$id", 'article'); %article=$obj->get_data(1); undef $article{'content'};#now its not need undef $article{'keywords'}; undef $article{'related'}; $article{'status'}=($in{'status'}||'ok'); $obj=0; #UPDATE CATEGORY INDEX #'index' =>['title', 'preview', 'cat_id', 'author', 'id', 'date', 'pages', 'status'], my @db_index=($article{'cat_id'}, 'index'); foreach my $db_index (@db_index){ $obj= new Sanitarium_WL("$data/$db_index", 'index'); #IF MODIFY if ($modify){ $obj->modify_data($id, $article{'title'}, $article{'preview'}, $article{'cat_id'}, $article{'author'}, $id, $article{'date'}, $article{'pages'}, $article{'status'}); } #IF NEW else {$obj->write_data($id, $article{'title'}, $article{'preview'}, $article{'cat_id'}, $article{'author'}, $id, $article{'date'}, $article{'pages'}, $article{'status'}); } $obj=0; } %in=%article; &mod_article($id); #end sub } sub delete_article_from_index { #------------------------------------------------------------- unless ($use_search){return 0;} my ($obj, @ids); my $option=shift; if (!$in{'delete_from_index_y'}){ &head; my $html= qq~ $msg{'a_q_del_index'}
    $msg{'a_delete_index'} ~; &table('Are you sure?', $html); &foot; } else { &delete_from_index_all; &head; my $html= $msg{'a_del_index'}; &table($msg{'a_t_del'}, $html); &foot; } } sub delete_article { #-------------------------------------------------------------- my ($obj, @ids); if (!$in{'del_art_now'}){ &head; my $html= qq~ $msg{'a_q_del'}
    Yes, delete this article! ~; &table('Are you sure?', $html); &foot; } else { if (-e "$data/$in{'cat_id'}/$in{'id'}"){ $obj= new Sanitarium_WL ("$data/$in{'cat_id'}/$in{'id'}"); @ids=$obj->get_keys(); $obj=0; &delete_from_index_all if $use_search;#DELETE FROM SEARCH INDEX #DELETE .DAT File with article's db unlink("$data/$in{'cat_id'}/$in{'id'}.dat")||&WLerr("Can not delete $data/$in{'cat_id'}/$in{'id'}.dat, reason: $!"); #..delete lock file unlink("$data/$in{'cat_id'}/$in{'id'}.lock") if (-e "$data/$in{'cat_id'}/$in{'id'}.lock"); #..delete comments unlink("$data/comments/$in{'id'}.txt") if (-e "$data/comments/$in{'id'}.txt"); } foreach my $db_index ($in{'cat_id'}, 'index'){ $obj=new Sanitarium_WL("$data/$db_index", 'index'); $obj->delete_data($in{'id'}); $obj=0; } #Delete *.$ext pages (ex., *.html) $obj= new Sanitarium_WL ("$data/categories", 'categories'); my %category=$obj->get_data($in{'cat_id'}); $obj=0; foreach my $id_page(@ids){ if (-e "$public_dir/$category{'cat_dir'}/$id_page.$ext"){ unlink("$public_dir/$category{'cat_dir'}/$id_page.$ext")||&WLerr("Can't delete $public_dir/$category{'cat_dir'}/$id_page.$ext , reason: $!"); } } &head; my $html= $msg{'a_del'}; &table($msg{'a_t_del'}, $html); &foot; } #end sub } sub delete_page { #---------------------------------------------------------- my ($obj, $html, $author, %page_info); $obj = new Sanitarium_WL("$data/$in{'cat_id'}/$in{'id'}", 'article'); if (!$in{'del_this_page'}){ %page_info = $obj->get_data($in{'page'}); $author=&get_author_name($page_info{'author'}); undef $page_info{'content'};#clean memory undef $page_info{'keywords'};#clean memory undef $page_info{'related'};#clean memory $html = qq~ $msg{'dalete_it'}
  • $msg{'Page_Num'}: $page_info{'num'}
  • $msg{'Title'}: $page_info{'title'}
  • $msg{'Article_ID'}: $in{'id'}
  • $msg{'Author'}: $author
  • $msg{'Category ID'}: $page_info{'cat_id'}
  • $msg{'Date'}: $page_info{'date'}
  • $msg{'Preview'}: $page_info{'preview'}

    $msg{'yes_del'} ~; &head; &table($msg{'you_sure'}, $html); &foot; } else { &delete_from_index_all if $use_search; $obj->delete_page($in{'id'}, $in{'page'}); $obj=0; foreach my $db_index ($in{'cat_id'}, 'index'){ $obj=new Sanitarium_WL($data."/".$db_index, 'index'); $obj->modify_fields($in{'id'}, 'pages', 'pages--');#Update number of pages in indexes $obj=0; } #GET CATEGORY INFO: $obj= new Sanitarium_WL ("$data/categories", 'categories'); my %category=$obj->get_data($in{'cat_id'}); $obj=0; #Delete *.$ext version of page if (-e "$public_dir/$category{'cat_dir'}/".$in{'id'}."_".$in{'page'}.$ext){ unlink ("$public_dir/$category{'cat_dir'}/".$in{'id'}."_".$in{'page'}.$ext)||&WLerr("Can't delete $public_dir/$category{'cat_dir'}/$in{'id'}_$in{'page'}.$ext , reason: $!"); } &end_article_input(1); } #end sub } sub pages_list { #--------------------------------------------------------- my %nums=(); %nums=map{$_=>$_}(1..$_[0]); #foreach my $num(1..$_[0]){ # $nums{$num}=$num; #} return %nums; } #........#MISC ############## sub WLopen { #-------------------------------------------------------------- my ($filename, $my_flock); $filename = shift; $my_flock = shift; $filename =~ s/[^\w\\\/><\.\-:]//g; $my_flock =~s/(\d)+/$1/g; $my_flock =~s/[^128]/1/g; open ('TEXT', $filename)||&WLerr("Could not open $filename, reason:$!"); if ($use_flock){flock(TEXT,$my_flock);} } sub get_time { #------------------------------------------------------------- my $time=shift; $time||=time(); if ($GMT){$time +=$GMT*3600;} my(@MON)= split(/,/, $msg{'MON'}); my(@WDAY) = split(/,/, $msg{'WDAY'}); my($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime($time); $year += 1900; if ($time_view == 1){ return sprintf("%02d/%02d/%04d",$mday,($mon+1),$year);}# dd/mm/yyyy elsif ($time_view == 2){ return sprintf("%02d %s %04d", $mday,$MON[$mon],$year);}# dd MON yyyy elsif ($time_view == 3){return sprintf("%s, %02d %s. %04d",$WDAY[$wday],$mday,$MON[$mon],$year);}#WEEKDAY DAY MON yyyy elsif ($time_view == 4){return sprintf("%s, %02d %s %04d %02d:%02d:%02d",$WDAY[$wday],$mday,$MON[$mon],$year,$hour,$min,$sec);}#WDAY DAY MON yyyy hour:min:sec elsif ($time_view == 5){return sprintf("%02d.%02d.%04d",$mday,($mon+1),$year);}#dd.mm.yyyy elsif ($time_view == 6){return sprintf("%02d.%02d.%04d",($mon+1),$mday,$year);}#mm.dd.yyyy else {return sprintf("%02d/%02d/%04d",($mon+1),$mday,$year);}#mm/dd/yyyy } #........#HTML ############## sub head { #-------------------------------------------------------------- &print_header; &head_html; print qq~
    » $msg{'2'}
  • $msg{'3'}
  • $msg{'4'}

    » $msg{'6'}

  • $msg{'7'}
  • $msg{'4'}

    » $msg{'14'}

  • $msg{'menu_upload'}
  • $msg{'view_file'}
  • $msg{'file_delete'}

    » $msg{'author_menu'}

  • $msg{'author_menu_1'}
  • $msg{'author_menu_2'}

    » $msg{'8'}

  • $msg{'9'}
  • $msg{'4'}
  • $msg{'10'}

    » $msg{'666'}

  • $msg{'666_1'}
  • $msg{'666_2'}
  • $msg{'666_3'}

    ~; if ($premoderate){ print qq~ » $msg{'com_menu'}

  • $msg{'com_edit'}

    ~; } print qq~ » $msg{'13'}

  • $msg{'11'}
  • $msg{'12'}

  • ~; } sub head_html { #-------------------------------------------------------------- print qq~ Sanitarium WebLoG - Admin Tools $msg{'charset'} ~; print &css_style; print qq~ ~; } sub css_style { #-------------------------------------------------------------- return qq~ ~; } sub foot { #-------------------------------------------------------------- print qq~
    2002 © WebScript.Ru Network All Rights Reserved
    ~; } sub table { #-------------------------------------------------------------- my ($title, @content); $title=shift; @content=@_; print qq~
    \ || $title
    @content

    ~; } sub input_form { #-------------------------------------------------------------- #my ($iname, $size, $max, $val)=@_; my $val=$_[3]; if ($val){$val=&for_form($val);} else {$val='';} return qq~
    ~; } sub textarea { #-------------------------------------------------------------- my ($fname, $cols, $rows, $val)=@_; if ($val){$val=&for_form($val);} else {$val='';} return qq~
    ~; } sub drop_list { #------------------------------------------------------------- my ($name, $mylist, $selected, %list ); $name=shift; $selected=shift; $selected||=''; %list=@_; #@list=@_; #$list[0]||return 0; #my $lst=$#list; $mylist= qq~~; return $mylist; } sub js_drop_list { #------------------------------------------------------------- my ($name, $mylist, $event, $selected, $a_name, $a_mail, $a_signatures, $a_foto, $a_www, %list ); $name=shift; $event=shift; $selected=shift; my ($checked1, $checked2); $selected||=''; if ($selected=~/,,,/){ $checked2='checked'; $checked1=''; } else { $checked1='checked'; $checked2=''; } %list=@_; $mylist= qq~ $msg{'select_author'}
    $msg{'reg_auth'}


    $msg{'unreg_auth'}
    $msg{'author_name'}:

    $msg{'mail'}:

    $msg{'foto'}:

    $msg{'www'}:

    $msg{'signatures'}:
    ~; return $mylist; } sub file_list { #--------------------------------------------------- my ($file, @file); my $for_dir=shift; opendir(FILE, $for_dir)||&WLerr("Can't open $foto_dir, reason: $!"); (undef,undef,@file)=readdir(FILE); close FILE; return sort {$a cmp $b} @file; } sub print_file_list { #---------------------------------------------------- my @fotos= &file_list($foto_dir); my @img=&file_list($img_dir); my $html = qq~
    » $msg{'upload_img'}
    ~; foreach my $file(@img){ next unless (-f "$img_dir/$file"); $html .= qq~
  • $file\n~; } unless(@img){$html .= '

    ..no files!';} $html .= qq~

  • » $msg{'upload_author'}
    ~; foreach my $file(@fotos){ next unless (-f "$foto_dir/$file"); $html .= qq~
  • $file\n~; } unless(@fotos){$html .= '

    ..no files!';} $html .= qq~

  • ~; &head; &table($msg{'view_file'}, $html); print ""; } sub delete_files { #--------------------------------------------------- my (@fotos, @img, $html); if (! $in{'delete_this'}){ @fotos= &file_list($foto_dir); @img=&file_list($img_dir); $html = qq~

    » $msg{'upload_img'}
    ~; foreach my $file(@img){ $html .= qq~$file
    \n~; } unless(@img){$html .= '

    ..no files!';} $html .= qq~

    » $msg{'upload_author'}
    ~; foreach my $file(@fotos){ $html .= qq~$file
    \n~; } unless(@fotos){$html .= '

    ..no files!';} $html .= qq~

    ~; &head; &table($msg{'file_delete'}, $html); print qq~   
    ~; } else { if ($in{'img'}){ @img=split(/,/,$in{'img'}); $html = qq~ Img Dir: $img_dir
    ~; foreach my $file(@img){ if (-e "$img_dir/$file"){ unlink "$img_dir/$file"; $html .= "
  • $file deleted!" unless (-e "$img_dir/$file"); } else { $html .= qq~
  • $file $msg{'not_deleted'}~;} } } if ($in{'foto'}){ @fotos=split(/,/,$in{'foto'}); $html .= qq~
    Foto Dir: $foto_dir
    ~; foreach my $file(@fotos){ if (-e "$foto_dir/$file"){ unlink "$foto_dir/$file"; $html .= "
  • $file deleted!" unless (-e "$foto_dir/$file"); } else { $html .= qq~
  • $file $msg{'not_deleted'}~;} } } &head; &table($msg{'files_deleted'}, $html); print ""; } #end sub } #.........#TEMPLATES #################### sub template_list { #---------------------------------------------------- my ($my_tmp, $my_file, @my_tmps); $my_tmp=shift; $my_tmp||=''; opendir(TMP,$tmpl_dir)||die("Can't open $tmpl_dir, reason:$!"); while (defined($my_file=readdir(TMP))){ if ($my_file=~/tmp-.*\.txt/){ $my_file =~ s/\.txt//g; if ($my_file eq $my_tmp){unshift(@my_tmps,$my_tmp, $my_tmp);} else {push(@my_tmps,$my_file,$my_file );} } } closedir(TMP); return @my_tmps; } #.........#ERRORS ################# sub msg { #---------------------------------------------------------- &head; &table($msg{'att'}, @_); &foot; exit; } #.........#PARSE_TEXT ##################### sub parse_article { #--------------------------------------------------------- my $text=shift; #For works like
    $text=~s/(|<(p|P|br|BR|pre|PRE)>)/$1\n/g;
    if ($text=~/MY CODE/){
    	my $lin;
    	my $code_here;
    	my @entry=split(/\n/,$text);
    	foreach  $lin(@entry) {
    		if($lin =~ /MY CODE/) {
    		 	$code_here = 1; 
    			next; 
    		}
    	
    		next unless ($code_here);
    		if($lin =~ /END CODE/) { 
    			$code_here = 0;
    			next;
    		}
    		$lin =~ s/
    //g; $lin =~ s/\&/\&/g; #$lin =~ s/ / /g if $code_here; $lin =~ s//\>/g; $lin =~ s/"/\"/g; $lin .="
    \n"; } $text=join("\n", @entry); $text=~s/(?:
    \s+)+/
    \n/g; } $text=~s/[\n\r]{2,}/\n/g; #AutoLink if ($autolink){ $text=~s/([\s|\(]|
    |

    |\A)(http:\/\/|ftp:\/\/|mailto:|https:\/\/)([^\s'"<>]+)/$1$3<\/a>/g; } #IF USE EMOTICONS: if ($use_emoticons){ $text=~ s/\s\Q:)\E\s/ \:) /g; $text =~ s/\s\Q:-)\E\s/ \:-) /g; $text =~ s/\s\Q:-(\E\s/ \:-( /g; $text =~ s/\s\Q:(\E\s/ \:( /g; $text =~ s/\s\Q8)\E\s/ \8) /g; } return $text; #end sub } sub text_to_form { #-------------------------------------- my $text=shift; #$text =~ s/&([\w\d#]+;)/\&$1/g; $text=~s/(|<(p|P|br|BR|pre|PRE)>)/$1\n/g; $text =~ s/ /&nbsp; /g; $text =~ s//>/g; $text =~ s/"/"/g; if ($text=~/MY CODE/){ my $lin; my $code_here; my @entry=split(/\n/,$text); foreach $lin(@entry) { if($lin =~ /MY CODE/) { $code_here = 1; next; } next unless ($code_here); if($lin =~ /END CODE/) { $code_here = 0; next; } $lin =~ s/
    /\n/g; } $text=join("\n", @entry); $text=~s/(
    [\s\n]+)+/$1/g; } $text=~s/\n\n+/\n/g; return $text; } sub for_form { #--------------------------------------------- my $text=shift; $text =~ s/ /&nbsp;/g; $text =~ s//>/g; $text =~ s/"/"/g; return $text; } sub emoticons_to_symbol { #--------------------------------------------- my $text=shift; $text=~ s/\s\s/ $1 /g; return $text; #end sub } #.........#TEMPLATE EDITOR ########################## sub select_template { #---------------------------------------------------- my $my_html = qq~

    ~; $my_html .=&drop_list('template','',&template_list); $my_html .=qq~
    $msg{'tmp_index'}
    $msg{'tmp_article'}
    $msg{'tmp_mail'}
    $msg{'tmp_comment'}

    Click here and view templates ~; &head; &table('Select Template', $my_html); &foot; } sub template_edit { #--------------------------------------------------- my ($template, $file, $my_html, %rec); my %tmplist=('index' =>['index', 'preview', 'menu_row', 'drop_list', 'news'], 'article'=>['article', 'related','foto'], 'mail' =>['mail', 'mailform', 'print'], 'comment'=>['view_comments', 'comment']); #Modify template or create new? $template=$in{'template'} if $in{'template'}; #Name templates files #@tmp=('index', 'article'); #@tmp2=('preview', 'menu_row', 'related', 'drop_list', 'print', 'mail', 'news'); #Load Template Data if ($template){ foreach $file (@{$tmplist{$in{'tmplist'}}}){ if (-e "$tmpl_dir/$template/$file.txt"){ &WLopen("<$tmpl_dir/$template/$file.txt",1); foreach my $line(){$rec{$file} .=$line;} close TEXT; $rec{$file}=~s/&/&/g; $rec{$file}=~s//>/g; $my_html =$msg{'49'}.' '.$template.' '.$msg{'50'}; } } } else { $|++; &head; print qq~ ~; $my_html = qq~ $msg{'62'}
    ~; &table('Template Name', $my_html); $my_html = qq~ ~; &table($msg{'temp_desc'}, $my_html); print qq~ ~; &foot; exit; } $my_html .=$msg{'51'}; &head; print qq~
    ~; #About Templates &table('Template Builder', $my_html); #Template Name $my_html = qq~ $template ~; &table('Template Name', $my_html); #Now build textarea input field for each template my $rows=15; foreach my $line(@{$tmplist{$in{'tmplist'}}}){ $rows=40 if $line=~/(index|article|mailform|view_comments|mail)/; $my_html = qq~ ~; &table($line, $my_html); $rows=15; } if ($in{'tmplist'} eq 'index'){ #Template description &WLopen("<$tmpl_dir/$template.txt",1); foreach my $line (){$rec{'desc'} .=$line;} close TEXT; $my_html = qq~ ~; &table($msg{'temp_desc'}, $my_html); } #Buttons print qq~ ~; &foot; } sub save_template { #---------------------------------------------------- my ($option, $line, @input); my %tmplist=('index' =>['index', 'preview', 'menu_row', 'drop_list', 'news'], 'article'=>['article', 'related','foto'], 'mail' =>['mail', 'mailform', 'print'], 'comment'=>['view_comments', 'comment']); #New Template (=1) or Modify Old Template? $option=shift; if ($option){ @input=('template','desc'); #Check users input data foreach $line(@input){ if (!$in{$line}){&msg("$msg{'30'}: $line!")} } $in{'template'} =~ s/[\&;\`'\|\"*\?\~\^\(\)\[\]\{\}\$\n\r]/san/g; if(-e "$tmpl_dir/$in{'template'}"){&WLerr("Template with name $in{'template'} alredy exists, rename your ner template!");} unless(mkdir("$tmpl_dir/$in{'template'}", 0777)){&WLerr("Can't mkdir $in{'template'}, reason: $!");} unless(chmod (0777, "$tmpl_dir/$in{'template'}")){&WLerr("Can't chmod $tmpl_dir/$in{'template'}, reason: $!");} #Print Template Description &WLopen( ">$tmpl_dir/$in{'template'}.txt", 2); print TEXT $in{'desc'}; close TEXT; &select_template; } else { #Print Template files foreach $line (@{$tmplist{$in{'tmplist'}}}){ &WLopen( ">$tmpl_dir/$in{'template'}/$line.txt", 2); print TEXT $in{$line}; close TEXT; } if ($in{'desc'}){ #Print Template Description &WLopen( ">$tmpl_dir/$in{'template'}.txt", 2); print TEXT $in{'desc'}; close TEXT; } &head; &table('Template Saved', "$msg{'67'} $in{'template'}"); &foot; } } sub view_template { #-------------------------------------------------------------- my ($file, $temp_info, @templates); opendir(TMP,"$tmpl_dir")||die("Can't open $tmpl_dir, reason:$!"); while ($file=readdir(TMP)){if ($file=~/tmp-.*?\.txt/){push(@templates,$file);}} closedir(TMP); $file=""; foreach $file(@templates){ open ('TEMPLATE', "<$tmpl_dir/$file"); $file =~ s/\.txt//g; $temp_info = qq~ $file: $_~; while (