#!/usr/bin/perl
use strict;

# use CGI;
use DBI;

# my ($page);
# Database connection.
my ($dsn)       = "DBI:mysql:database=eprintstats;host=127.0.0.1";
my ($user_name) = "eprintstatspub";
my ($password)  = "public";
my ( $connect, $query, %types, %unmapped, $stat, $row, $num_rows, $vtype );

# Miscellaneous variable.
my ( %cities, %IPs );
my ($num_entries) = -1;
my ($num_hits)    = 0;
my ( $ip, $count, $location );
my ( $lat, $long, $city, $key ) = ( 0, 0, '', '' );
$connect = DBI->connect( $dsn, $user_name, $password, { RaiseError => 1 } );
$types{'download'}    = $types{'abstract'}    = 0;
$unmapped{'download'} = $unmapped{'abstract'} = 0;
$query                =
"select ip, view_type, count(*) as count from view where id = 374975 group by ip";
$stat = $connect->prepare($query);
$stat->execute();
$num_rows = $stat->rows;
$row      = $stat->fetchrow_hashref();
$ip       = $row->{'ip'};                
$count    = $row->{'count'};
$vtype    = $row->{'view_type'};
print "$ip $vtype $count";
