#!/usr/bin/perl 

BEGIN {
    if (!$ENV{'PERL5LIB'} || !$ENV{'OPALS_CONF'}) {
        exit 1;
    }
}

use strict;
use Time::HiRes qw( time );
use CGI;
use DBI;
use Time::HiRes qw( 
      clock_gettime 
      CLOCK_REALTIME 
      );
use POSIX qw(
    ceil
    floor
);

use Opals::Context;
use JSON;
my $dbh     = Opals::Context->dbh();
$dbh->do("update opl_preference set val='{\"pageVisit\":1}' where var='hitCounter' && val=0;");
my ($hitCounter)=$dbh->selectrow_array("select val from opl_preference where var='hitCounter'");
my $counterObj=decode_json($hitCounter);
my $count=$counterObj->{'pageVisit'};
$hitCounter={pageVisit=>$count};
$dbh->do("update opl_preference set val=? where var='hitCounter'",undef,to_json($hitCounter));

exit 0;


