--- loncom/lonsql 2004/06/08 22:09:44 1.62 +++ loncom/lonsql 2004/08/20 16:42:41 1.64 @@ -3,7 +3,7 @@ # The LearningOnline Network # lonsql - LON TCP-MySQL-Server Daemon for handling database requests. # -# $Id: lonsql,v 1.62 2004/06/08 22:09:44 raeburn Exp $ +# $Id: lonsql,v 1.64 2004/08/20 16:42:41 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -206,6 +206,23 @@ my $run =0; # running count my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf'); my %perlvar=%{$perlvarref}; # +# Write the /home/www/.my.cnf file +my $conf_file = '/home/www/.my.cnf'; +if (! -e $conf_file) { + if (open MYCNF, ">$conf_file") { + print MYCNF <<"ENDMYCNF"; +[client] +user=www +password=$perlvar{'lonSqlAccess'} +ENDMYCNF + close MYCNF; + } else { + warn "Unable to write $conf_file, continuing"; + } +} + + +# # Make sure that database can be accessed # my $dbh; @@ -424,6 +441,20 @@ sub make_new_child { if ($locresult) { $result .= &escape(join(':',map{$_.'='.$replies{$_}} keys %replies)); } + } elsif ($query eq 'prepare activity log') { + my ($cid,$domain) = map {&unescape($_);} ($arg1,$arg2); + &logthis('preparing activity log tables for '.$cid); + my $command = + qq{$perlvar{'lonDaemons'}/parse_activity_log.pl -course=$cid -domain=$domain}; + system($command); + &logthis($command); + my $returnvalue = $?>>8; + if ($returnvalue) { + $result = 'error: parse_activity_log.pl returned '. + $returnvalue; + } else { + $result = 'success'; + } } else { # Do an sql query $result = &do_sql_query($query,$arg1,$arg2); @@ -478,6 +509,7 @@ sub process_file { sub do_sql_query { my ($query,$custom,$customshow) = @_; + &logthis('doing query '.$query); $custom = &unescape($custom); $customshow = &unescape($customshow); #