From: Banana Date: Thu, 16 Feb 2012 07:38:18 +0000 (+0100) Subject: some stats about the bookmarks X-Git-Tag: 2.1-alpha-2019-0-29~97 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=2c53fe379c9fccde622b58b6109b3be1d2102630;p=insipid.git some stats about the bookmarks --- 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;