]> 91.132.146.200 Git - insipid.git/commitdiff
some stats about the bookmarks
authorBanana <banana@starscream.de>
Thu, 16 Feb 2012 07:38:18 +0000 (08:38 +0100)
committerBanana <banana@starscream.de>
Thu, 16 Feb 2012 07:38:18 +0000 (08:38 +0100)
lib/Insipid/Main.pm
lib/Insipid/Stats.pm

index 2a6189de412a479750eb8cbc01090ca00c839b77..583f349fa61d1465c5a5c49a1d8eaab9548fd1a7 100755 (executable)
@@ -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 "<ul><li><a href=\"$ad\">Add to Insipid</a></li></ul>";
-                print "</body></html>";
+                #print "</body></html>";
+                               print "</td></tr></table><br /></body></html>";
                 exit;
             }
 
             # Configuration and management pages
             if (param('op') eq 'tags') {
                 tag_operations();
-                print '</body></html>';
+                #print '</body></html>';
+                               print "</td></tr></table><br /></body></html>";
                 exit;
             }
 
                        # show the options
             if (param('op') eq 'options') {
                 show_options();
-                print '</body></html>';
+                #print '</body></html>';
+                               print "</td></tr></table><br /></body></html>";
                 exit;
             }
 
                        # management
                        if (param('op') eq 'stats') {
                 show_stats();
-                print '</body></html>';
+                #print '</body></html>';
+                               print "</td></tr></table><br /></body></html>";
                 exit;
             }
         }
index 5170cb1765095a74cd864472f5376cc8787ffbdb..0da2bcccad682f035fb8fc0e763f8ccd05585e3b 100644 (file)
@@ -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']."<br />";
+                       my $uri = URI->new($row['url']);
+                       #print $uri->host."<br />";
+                       if($domains{$uri->host}) {
+                               $domains{$uri->host}++;
+                       }
+                       else {
+                               $domains{$uri->host} = 1;
+                       }
+               }
+
+               if(%domains) {
+
+
 
+                       print "<table cellpadding='2' cellspacing='0'>";
+                       print "<tr><th>Domain</th><th>Count</th></tr>";
+                       #for(sort keys %domains) {
+                       foreach (reverse sort { $domains{$a} <=> $domains{$b} } keys %domains ) {
+                               print "<tr><td>$_</td><td>$domains{$_}</td></tr>";
+                       }
+                       print "</table>";
+               }
+       }
 }
 
 1;