From 2c53fe379c9fccde622b58b6109b3be1d2102630 Mon Sep 17 00:00:00 2001 From: Banana Date: Thu, 16 Feb 2012 08:38:18 +0100 Subject: [PATCH] some stats about the bookmarks --- lib/Insipid/Main.pm | 12 ++++++++---- lib/Insipid/Stats.pm | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/lib/Insipid/Main.pm b/lib/Insipid/Main.pm index 2a6189d..583f349 100755 --- a/lib/Insipid/Main.pm +++ b/lib/Insipid/Main.pm @@ -453,28 +453,32 @@ DESC javascript:location.href='$site_url/insipid.cgi?op=add_bookmark&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&redirect=true' BLET print ""; - print ""; + #print ""; + print "
"; exit; } # Configuration and management pages if (param('op') eq 'tags') { tag_operations(); - print ''; + #print ''; + print "
"; exit; } # show the options if (param('op') eq 'options') { show_options(); - print ''; + #print ''; + print "
"; exit; } # management if (param('op') eq 'stats') { show_stats(); - print ''; + #print ''; + print "
"; exit; } } diff --git a/lib/Insipid/Stats.pm b/lib/Insipid/Stats.pm index 5170cb1..0da2bcc 100644 --- a/lib/Insipid/Stats.pm +++ b/lib/Insipid/Stats.pm @@ -32,6 +32,8 @@ use Insipid::Sessions; use Insipid::Util; require Exporter; +use URI; + use Data::Dumper; @ISA = qw(Exporter); @@ -41,7 +43,49 @@ show_stats ); sub show_stats { + &findSimilarities; +} + +sub findSimilarities { + my $url = shift; + + my ($sql, $sth, @row); + my %domains = (); + + if($url) { + + } + + $sql = "SELECT `url` FROM `$tbl_bookmarks` ORDER BY `url`"; + $sth = $dbh->prepare($sql); + $sth->execute; + + if($sth->rows ne 0) { + while(@row = $sth->fetchrow_array()) { + #print $row['url']."
"; + my $uri = URI->new($row['url']); + #print $uri->host."
"; + if($domains{$uri->host}) { + $domains{$uri->host}++; + } + else { + $domains{$uri->host} = 1; + } + } + + if(%domains) { + + + print ""; + print ""; + #for(sort keys %domains) { + foreach (reverse sort { $domains{$a} <=> $domains{$b} } keys %domains ) { + print ""; + } + print "
DomainCount
$_$domains{$_}
"; + } + } } 1; -- 2.39.5