#!/usr/bin/perl

#use utf8;
use strict;
use CGI;
use Text::CSV_XS;
use Digest::SHA qw(
    sha1_base64
    sha1_hex
);

use Opals::Context;

use Opals::User qw(
    user_currentUser
);


my $dbh = Opals::Context->dbh();
END { $dbh->disconnect(); }

my $cgi          = CGI->new;
my $input        = $cgi->Vars();
my ($errCode, $cookie, $user) = user_currentUser($dbh, $cgi);

if($errCode==0){
    my $uid     = $user->{'uid'}||0;
    my $bid     = $input->{'bid'}||0;
    my $rid     = $input->{'rid'};
    my $type    = $input->{'type'} || 'read';
    if($rid && $rid>0){
        $dbh->do("insert into opl_ebReadingStats 
                  set onDate=curDate(),onTime=curTime(),
                      uid=$uid, bid=$bid,rid=$rid,type='$type'");
    }
  
}
print $cgi->header(
        -type    => 'text/html',
        -expires => 'now',
        -cookie  => ($cookie)?$cookie:'',
        -charset => 'utf-8',
    ),"";

#------------------------------------------------------------------------------
sub registeReadingStats{
    my($dbh)=@_;
}
