#!/usr/bin/perl
#use K_CGI;
#use Mysql;
use strict;
# Version 4, begyndt udarbejdet 5. feb. 1998
# Brugerfladeændringer for at højne forståelsen
# OS navne også nede i skemaet.
# Tak til alle der har bidraget, og opfordring til at bidrage.
#
#Version 3, udarbejdet 16. nov 1997, tilrettet 4. dec. 1997
#Hastigheds optimering.
# Første version brugte en ukristelig mængde SELECT's og ingen JOIN's.
# Det var min første MySQL client og den skulle være klar hurtigt, så
# jeg tog ingen chancer.
# Denne version skulle også gerne få et meget pænere lay-out, folk er
# kommet med en del hentydninger, og første version er virkelig grim.
#
#Version 2, udarbejdet 24. oct 1997
#Tilføjer mindstebredde vha. gif-padding,
# og retter en bug - sub-areas kom i indtastningsrækkefølge
# så areas blev skilt ad når der indføjedes nye sub-areas.
# Løst ved at sortere på navn.
##########################################################################
#
# configuration start
#
my $HiRes = 0; # set to 0 and comment out the next line if HiRes isn't available
#use Time::HiRes qw( usleep ualarm gettimeofday tv_interval );
my $debug = 0;
my $qu;
my $tid1;
$tid1 = time;
#if($HiRes) { $tid1 = [gettimeofday]; }
my $host = "";
my $base = 'WS_Linux';
my @tables = ('os','navne');
my %colors = (
"table_bg" => "#ffffff",
"table_header" => "#00c0c0",
"page_bg" => "#FFFFFF",
"page_text" => "#000000"
);
my %name = %{&where()};
#
# configuration end
#
################################################################
# printed here and not at a later point for the benefit of the error-messages
#
print "Content-type: text/html\n\n";
print "\n";
print "
\n \n ", $name{'project'}, " - ", $name{'page'}, "\n \n";
print " \n";
print " \n";
print "\n";
print "\n\n";
#print "\n\n";
print "\n";
print "\n \n";
print " \n";
print " Feauturing: A comparison between Operating Systems.
\n";
print " We are currently collecting information on AIX and several others, they will be included as soon as we have enough information. ";
print " ";
print " | \n
\n";
print "
\n\n";
print "\n
\n\n";
print "\n\n | \n";
print " \n";
print " | \n
\n";
print "\n
\n\n";
# (7+7)*42 is max.length for the whole input
# ^\w+$ is a regexp that only alloves alphanumaric characters and _
#
# The K_CGI.pm gives us an error if the input data is longer than this,
# or if the fields has caracters not meet by the reg-exp
#
# No spaces and no "strange" characters are allowed by the regexp,
# so altering the sql-statements through carefully crafted input-strings
# is not possible.
#
eval {
my $r = Apache->request;
my %ENV = $r->cgi_env;
my @post_data = $r->content;
#my %user_data = K_CGI::mod_perl_cleanup_with_checks((7+7)*42, '^\w+$', @post_data);
my %user_data = $r->args;
if(scalar keys %user_data < 1) { &error("Input Error!"); }
# Figures out which information-areas and which os's
# the user told it to include
my (@os, @area);
foreach(keys %user_data) {
my $foo; #ain't exported so it's not an offense ;-)
if(($foo) = ($_ =~ m/os_(.+)/)) {
push @os, $foo;
}
if(($foo) = ($_ =~ m/area_(.+)/)) {
push @area, $foo;
}
}
unless((scalar @os > 0) && (scalar @area > 0)) { &error("Input Error!"); }
# DB_connect_error's are numbers not explanations, so that we don't give more
# than necessary information away. I know what they mean, and anyone with the sources
# can find out in a couple of minutes.
#
my ($tid, $dbh, $q4, $sth, $sth1, @rows);
$tid = time;
#if($HiRes) { $tid = [gettimeofday] if($debug > 0); }
unless($dbh = Mysql->connect($host)) { &error("DB_connect_error 0 : $!"); }
unless($dbh->selectdb($base)) { &error("DB_connect_error 1 : $!"); }
# a little statistics
my $qs = "INSERT INTO stats (referer) VALUES (\'$ENV{'HTTP_REFERER'}\')";
unless($sth = $dbh->query($qs)) { &error("DB_insert_error 2 : $!"); }
# leftmost column
$q4 = "DESCRIBE $tables[0]";
unless($sth = $dbh->query($q4)) { &error("DB_connect_error 2 : $!"); }
$qu++;
my (@r, @a);
while(@a = $sth->fetchrow) {
my($h,$sh) = ($a[0] =~ m/(.+)_(.+)/);
foreach(@area) {
if($_ eq $h) {
push @r, $a[0];
#break; next;
}
}
}
foreach(sort @r) {
push @rows, $_;
} undef @r; unshift @rows, 'name_os';
# for debugging
if($debug > 1) {
foreach(sort keys %user_data) {
print "[$_]\t[$user_data{$_}]\n";
}
}
print "\n";
# Arranges the selected information-areas for the selected OS's.
# The cryptic names are replaced with more verbose ones from
# another table.
#
&main_3(\@rows, \@os, $dbh);
$tid = time - $tid;
#if($HiRes) { $tid = tv_interval ( $tid, [gettimeofday]); }
print "
\n";
print "\n
\n\n";
my $q9 = "SELECT label FROM navne WHERE ident like \'meta_updated\'";
unless($sth1 = $dbh->query($q9)) { &error("DB_connect_error 4 : $!"); }
$qu++;
my $updated = $sth1->fetchrow;
print "\n";
print "\n";
print " \n Make a new Comparison there\'s 13 OS\'s to choose from | \n \n";
print "
| \n";
print "\n | \n";
print " \n";
print " The information in this chart are mostly from the OS and applications manufactors web-pages.\n";
print " The blank fields are areas where we haven\' yet found adequate verified information. ";
print " \n\n";
#print " | \n \n";
#print "\n \n";
print " We appriciate updates, corrections and general information for this chart, ";
print " especially if it is backed by URL\'s to \"official\" sites where it can be verified. ";
print " A big thank-you goes to all of you who have send us information. Your help have";
print " made this chart much better than we could have made it ourself \n";
print "\n\n";
#print " | \n | \n";
print " Comments, corrections etc. can be e-mailed to ";
print " Kristian Elof Sørensen";
print " at elof\@image.dk or entered below.\n";
print "\n \n";
#print " | \n | \n";
print " Last updated on $updated | \n";
print "\n";
print " \n \n";
print " \n\n<\/p>";
print "<\/td><\/tr>\n |
| \n";
#print "\n
\n\n";
print "| \n";
#print "\n
\n\n";
$tid1 = time - $tid1;
#if($HiRes) { $tid1 = tv_interval ( $tid1, [gettimeofday]); }
print "Inderst $tid\n Det hele $tid1\n \n" if($debug > 0);
print "Querys $qu\n \n" if($debug > 0);
print "\n " . Bazar->spyt_ud({"ID" => 'd10eeab13ed8bea664df8e9d1a8bc5e3'}) . "<\/p>\n";
print "<\/td><\/tr><\/table>";
print "<\/td><\/tr><\/table>";
print "\n\n\n\n";
}; &error($@) if($@);
return 1;
sub error {
# error messages are printed in fire-engine red
#
print "\n";
print "\n
\n";
print "\n \n\n ERROR!\n\n";
print "\n\n @_\n \n";
unless($_[0] =~ m/^DB_connect_error/) { # A friendly error-message if it can be a user-error
print "\n\n Maybe you did not select at least one OS and one area of interest?\n \n";
print "Try again<\/A> <\/p><\/center>\n";
}
print "\n \n\n";
print "\n\n |
|