version 1.34, 2003/06/19 20:24:57
|
version 1.36, 2003/07/30 16:49:27
|
Line 76 use POSIX qw(strftime mktime);
|
Line 76 use POSIX qw(strftime mktime);
|
|
|
my @metalist; |
my @metalist; |
|
|
|
$simplestatus=''; |
|
|
|
sub writesimple { |
|
open(SMP,'>/home/httpd/html/lon-status/mysql.txt'); |
|
print SMP $simplestatus."\n"; |
|
close(SMP); |
|
} |
|
|
# ----------------------------------------------------- Un-Escape Special Chars |
# ----------------------------------------------------- Un-Escape Special Chars |
|
|
Line 104 sub dynamicmeta {
|
Line 111 sub dynamicmeta {
|
my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//); |
my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//); |
my $prodir=&propath($adomain,$aauthor); |
my $prodir=&propath($adomain,$aauthor); |
if ((tie(%evaldata,'GDBM_File', |
if ((tie(%evaldata,'GDBM_File', |
$prodir.'/nohist_resevaldata.db',&GDBM_READER(),0640)) && |
$prodir.'/nohist_resevaldata.db',&GDBM_READER(),0640)) && |
(tie(%newevaldata,'GDBM_File', |
(tie(%newevaldata,'GDBM_File', |
$prodir.'/nohist_new_resevaldata.db',&GDBM_WRCREAT(),0640))) { |
$prodir.'/nohist_new_resevaldata.db',&GDBM_WRCREAT(),0640))) { |
my %sum=(); |
my %sum=(); |
my %cnt=(); |
my %cnt=(); |
my %listitems=('count' => 'add', |
my %listitems=('count' => 'add', |
'course' => 'add', |
'course' => 'add', |
'avetries' => 'avg', |
'avetries' => 'avg', |
'stdno' => 'add', |
'stdno' => 'add', |
'difficulty' => 'avg', |
'difficulty' => 'avg', |
'clear' => 'avg', |
'clear' => 'avg', |
'technical' => 'avg', |
'technical' => 'avg', |
'helpful' => 'avg', |
'helpful' => 'avg', |
'correct' => 'avg', |
'correct' => 'avg', |
'depth' => 'avg', |
'depth' => 'avg', |
'comments' => 'app', |
'comments' => 'app', |
'usage' => 'cnt' |
'usage' => 'cnt' |
); |
); |
my $regexp=$url; |
my $regexp=$url; |
$regexp=~s/(\W)/\\$1/g; |
$regexp=~s/(\W)/\\$1/g; |
$regexp='___'.$regexp.'___([a-z]+)$'; |
$regexp='___'.$regexp.'___([a-z]+)$'; |
study($regexp); |
foreach (keys %evaldata) { |
while (my ($key,$value) = each(%evaldata)) { |
my $key=&unescape($_); |
$key=&unescape($key); |
if ($key=~/$regexp/) { |
next if ($key !~ /$regexp/); |
my $ctype=$1; |
my $ctype=$1; |
|
if (defined($cnt{$ctype})) { |
if (defined($cnt{$ctype})) { |
$cnt{$ctype}++; |
$cnt{$ctype}++; |
} else { |
} else { |
$cnt{$ctype}=1; |
$cnt{$ctype}=1; |
} |
} |
unless ($listitems{$ctype} eq 'app') { |
unless ($listitems{$ctype} eq 'app') { |
if (defined($sum{$ctype})) { |
if (defined($sum{$ctype})) { |
$sum{$ctype}+=$value; |
$sum{$ctype}+=$evaldata{$_}; |
} else { |
} else { |
$sum{$ctype}=$value; |
$sum{$ctype}=$evaldata{$_}; |
} |
} |
} else { |
|
if (defined($sum{$ctype})) { |
|
if ($value) { |
|
$sum{$ctype}.='<hr>'.$value; |
|
} |
|
} else { |
|
$sum{$ctype}=''.$value; |
|
} |
|
} |
|
if ($ctype ne 'count') { |
|
$newevaldata{$_}=$value; |
|
} |
|
} |
|
while (my($key,$value) = each(%cnt)) { |
|
if ($listitems{$key} eq 'avg') { |
|
$returnhash{$key}=int(($sum{$key}/$value)*100.0+0.5)/100.0; |
|
} elsif ($listitems{$key} eq 'cnt') { |
|
$returnhash{$key}=$value; |
|
} else { |
} else { |
$returnhash{$key}=$sum{$key}; |
if (defined($sum{$ctype})) { |
} |
if ($evaldata{$_}) { |
} |
$sum{$ctype}.='<hr>'.$evaldata{$_}; |
if ($returnhash{'count'}) { |
} |
my $newkey=$$.'_'.time.'_searchcat___'.&escape($url).'___count'; |
} else { |
$newevaldata{$newkey}=$returnhash{'count'}; |
$sum{$ctype}=''.$evaldata{$_}; |
} |
} |
untie(%evaldata); |
} |
untie(%newevaldata); |
if ($ctype ne 'count') { |
} |
$newevaldata{$_}=$evaldata{$_}; |
return %returnhash; |
} |
|
} |
|
} |
|
foreach (keys %cnt) { |
|
if ($listitems{$_} eq 'avg') { |
|
$returnhash{$_}=int(($sum{$_}/$cnt{$_})*100.0+0.5)/100.0; |
|
} elsif ($listitems{$_} eq 'cnt') { |
|
$returnhash{$_}=$cnt{$_}; |
|
} else { |
|
$returnhash{$_}=$sum{$_}; |
|
} |
|
} |
|
if ($returnhash{'count'}) { |
|
my $newkey=$$.'_'.time.'_searchcat___'.&escape($url).'___count'; |
|
$newevaldata{$newkey}=$returnhash{'count'}; |
|
} |
|
untie(%evaldata); |
|
untie(%newevaldata); |
|
} |
|
return %returnhash; |
} |
} |
|
|
# ----------------- Code to enable 'find' subroutine listing of the .meta files |
# ----------------- Code to enable 'find' subroutine listing of the .meta files |
require "find.pl"; |
require "find.pl"; |
sub wanted { |
sub wanted { |
Line 207 if ($wwwid!=$<) {
|
Line 214 if ($wwwid!=$<) {
|
|
|
open(LOG,'>'.$perlvar{'lonDaemons'}.'/logs/searchcat.log'); |
open(LOG,'>'.$perlvar{'lonDaemons'}.'/logs/searchcat.log'); |
print LOG '==== Searchcat Run '.localtime()."====\n\n"; |
print LOG '==== Searchcat Run '.localtime()."====\n\n"; |
|
$simplestatus='time='.time.'&'; |
my $dbh; |
my $dbh; |
# ------------------------------------- Make sure that database can be accessed |
# ------------------------------------- Make sure that database can be accessed |
{ |
{ |
Line 214 my $dbh;
|
Line 222 my $dbh;
|
$dbh = DBI->connect("DBI:mysql:loncapa","www",$perlvar{'lonSqlAccess'},{ RaiseError =>0,PrintError=>0}) |
$dbh = DBI->connect("DBI:mysql:loncapa","www",$perlvar{'lonSqlAccess'},{ RaiseError =>0,PrintError=>0}) |
) { |
) { |
print LOG "Cannot connect to database!\n"; |
print LOG "Cannot connect to database!\n"; |
|
$simplestatus.='mysql=defunct'; |
|
&writesimple(); |
exit; |
exit; |
} |
} |
|
|
my $make_metadata_table = "CREATE TABLE IF NOT EXISTS metadata (". |
my $make_metadata_table = "CREATE TABLE IF NOT EXISTS metadata (". |
"title TEXT, author TEXT, subject TEXT, url TEXT, keywords TEXT, ". |
"title TEXT, author TEXT, subject TEXT, url TEXT, keywords TEXT, ". |
"version TEXT, notes TEXT, abstract TEXT, mime TEXT, language TEXT, ". |
"version TEXT, notes TEXT, abstract TEXT, mime TEXT, language TEXT, ". |
Line 312 foreach my $user (@homeusers) {
|
Line 323 foreach my $user (@homeusers) {
|
$dbh->disconnect; |
$dbh->disconnect; |
print LOG "\n==== Searchcat completed ".localtime()." ====\n"; |
print LOG "\n==== Searchcat completed ".localtime()." ====\n"; |
close(LOG); |
close(LOG); |
|
&writesimple(); |
exit 0; |
exit 0; |
|
|
|
|