home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
linuxmafia.com 2016
/
linuxmafia.com.tar
/
linuxmafia.com
/
pub
/
skeptic
/
bibliography
/
admin
/
categories.cgi
< prev
next >
Wrap
Text File
|
2009-08-26
|
3KB
|
121 lines
#!/usr/bin/perl
# $rcs = ' $Id: categories.cgi,v 1.2 1998/06/20 03:58:58 fitz Exp $ ' ;
unshift(@INC, "lib");
require 'bib.pl';
require 'web.pl';
require 'cgi-lib.pl';
&ReadParse; # Read the script input
print "Content-type: text/html\n";
# If they're submitting this form, write and exit
&write_files_and_exit() if %in;
&bib::load("CATEGORY", "KEYWORDS");
# Determine if we are running as an administrator
&error("Cannot run this CGI except from the admin subdir!")
unless $ENV{SCRIPT_NAME} =~ m!/admin/!;
# Get the categories and descriptions
@categories = &bib::get_categories();
&error($bib::error) unless defined @categories;
%categories = &bib::read_category_desc();
# Get the keywords
@keywords = &bib::get_keywords();
&error($bib::error) unless defined @keywords;
%keywords = &bib::read_keyword_desc();
# Get the keyword modifiers
@modifiers = &bib::get_modifiers();
&error($bib::error) unless defined @modifiers;
%modifiers = &bib::read_modifier_desc();
# Tables for the categories, keywords, and modifiers
foreach $category (@categories)
{
#$category =~ s/\W//g;
$t =
sprintf("<TR><TD>%s</TD><TD><INPUT SIZE=50 NAME=%s VALUE=\"%s\"></TD></TR>\n",
$category, "c_$category", &untaint($categories{$category}));
$categories{$category} ? ($categories .= $t) : ($categories = "$t$categories");
}
foreach $keyword (@keywords)
{
#$keyword =~ s/\W//g;
$t =
sprintf("<TR><TD>%s</TD><TD><INPUT SIZE=50 NAME=%s VALUE=\"%s\"></TD></TR>\n",
$keyword, "k_$keyword", &untaint($keywords{$keyword}));
$keywords{$keyword} ? ($keywords .= $t) : ($keywords = "$t$keywords");
}
foreach $modifier (@modifiers)
{
#$modifier =~ s/\W//g;
$t =
sprintf("<TR><TD>%s</TD><TD><INPUT SIZE=50 NAME=%s VALUE=\"%s\"></TD></TR>\n",
$modifier, "m_$modifier", &untaint($modifiers{$modifier}));
$modifiers{$modifier} ? ($modifiers .= $t) : ($modifiers = "$t$modifiers");
}
$data = &bib::template("categories.html",
"CATEGORIES", $categories,
"KEYWORDS", $keywords,
"MODIFIERS", $modifiers,);
$data = &bib::template("categories-form.html",
"DATA", $data);
print "\n", &bib::template("basic.html",
"TITLE", "Edit Keyword Descriptions",
"DATA", $data);
exit 0;
sub write_files_and_exit
{
my($k,$name,$c,%category_desc,%keyword_desc,%modifier_desc);
foreach $k (keys %in)
{
if ($k =~ /^c_(.*)/)
{
$name = $1;
$category_desc{$name} = $in{$k};
$c++;
next;
}
elsif ($k =~ /^k_(.*)/)
{
$name = $1;
$keyword_desc{$name} = $in{$k};
$c++;
next;
}
elsif ($k =~ /^m_(.*)/)
{
$name = $1;
$modifier_desc{$name} = $in{$k};
$c++;
next;
}
}
&error("Received no input!") unless $c;
&bib::write_category_desc(%category_desc) ||
&error("Cannot write category description file: $bib::error");
&bib::write_keyword_desc(%keyword_desc) ||
&error("Cannot write keyword description file: $bib::error");
&bib::write_modifier_desc(%modifier_desc) ||
&error("Cannot write modifier description file: $bib::error");
&success("Updated all description files.");
}