From 21bbfd036b3dd4e9af7fba0e760e6ead68caaaa3 Mon Sep 17 00:00:00 2001 From: Banana Date: Fri, 30 Nov 2012 14:45:57 +0100 Subject: [PATCH] screenshot overview --- insipid.cgi | 5 +-- lib/Insipid/Main.pm | 4 +- lib/Insipid/Screenshots.pm | 89 ++++++++++++++++++++++++++++++++++++++ lib/Insipid/Stats.pm | 2 - lib/Insipid/Tags.pm | 2 - 5 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 lib/Insipid/Screenshots.pm diff --git a/insipid.cgi b/insipid.cgi index 6713da7..4bb6de3 100755 --- a/insipid.cgi +++ b/insipid.cgi @@ -18,7 +18,6 @@ # USA # -use Data::Dumper; use warnings; use strict; @@ -38,7 +37,7 @@ eval { }; if($@) { - my $errstr = $@; + my $errstr = $@; if($errstr =~ /Can\'t locate (.*) in/) { show_error("Couldn't find the module \"$1\".", "You may want to " . "search CPAN " . @@ -64,7 +63,7 @@ if($@) { if($@) { $errstr = $@; - show_error("Database error", "There was a problem " . + show_error("Database error", "There was a problem " . "creating the database tables required by Insipid:", $errstr); } diff --git a/lib/Insipid/Main.pm b/lib/Insipid/Main.pm index 66fb6e7..97c0739 100755 --- a/lib/Insipid/Main.pm +++ b/lib/Insipid/Main.pm @@ -40,6 +40,7 @@ use Insipid::Snapshots; use Insipid::Tags; use Insipid::Util; use Insipid::Stats; +use Insipid::Screenshots; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); @@ -545,7 +546,7 @@ BLET } # screenshot overview - if (param('op') eq 'screenshots') { + if (param('op') eq 'screenshots' && $usePhantomjs) { show_screenshots(); print "
"; exit; @@ -886,6 +887,7 @@ sub show_toolbar { print "import | "; print "export | "; print "snapshots | "; + print "screenshots | "; print "logout
"; print "add | "; print "bookmarklets | "; diff --git a/lib/Insipid/Screenshots.pm b/lib/Insipid/Screenshots.pm new file mode 100644 index 0000000..872ac03 --- /dev/null +++ b/lib/Insipid/Screenshots.pm @@ -0,0 +1,89 @@ +#!/usr/bin/perl +# +# Copyright (C) 2012 jumpin.banana +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +# + +package Insipid::Screenshots; + +use strict; +use warnings; + +use vars qw(@ISA @EXPORT @EXPORT_OK); +use CGI qw/:standard/; +use CGI::Carp qw(fatalsToBrowser); +use Insipid::Config; +use Insipid::Database; +use Insipid::Sessions; +use Insipid::Util; +require Exporter; + +use URI; +use URI::Escape; +use POSIX qw/strftime/; +use File::Basename; + +@ISA = qw(Exporter); + +@EXPORT = qw( +show_screenshots +); + +sub show_screenshots { + + if(defined(param('delete')) && defined(param('hash'))) { + my $_md5 = param('hash'); + if($_md5 ne '') { + unlink("./screenshots/$_md5.png"); + print "

Screenshot deleted.

"; + } + } + + my @files = <./screenshots/*.png>; + if(@files) { + print ''; + print ''; + foreach my $file (@files) { + # some file informations + my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, + $mtime, $ctime, $blksize, $blocks) = stat($file); + + my $md5Hash = basename($file, ".png"); + + # get the bookmark + my $sql = "select $tbl_bookmarks.url, $tbl_bookmarks.id from $tbl_bookmarks + where ($tbl_bookmarks.md5 = ?)"; + my $sth = $dbh->prepare($sql); + $sth->execute($md5Hash); + my @r = $sth->fetchrow_array; + + my $bookmark = $r[0]; + my $bookmarkID = $r[1]; + + print ''; + print ""; + print ""; + print "\n"; + print "\n"; + print ''; + } + print '
ScreenshotDateBookmarkOptions
Screenshotfile".scalar localtime($mtime)."$bookmarkdelete, refresh
'; + } + else { + print "

No screenshots available yet.

"; + } +} diff --git a/lib/Insipid/Stats.pm b/lib/Insipid/Stats.pm index 088e692..505193d 100644 --- a/lib/Insipid/Stats.pm +++ b/lib/Insipid/Stats.pm @@ -35,8 +35,6 @@ require Exporter; use URI; use URI::Escape; -use Data::Dumper; - @ISA = qw(Exporter); @EXPORT = qw( diff --git a/lib/Insipid/Tags.pm b/lib/Insipid/Tags.pm index 6d6c25d..46e681b 100755 --- a/lib/Insipid/Tags.pm +++ b/lib/Insipid/Tags.pm @@ -32,8 +32,6 @@ use Insipid::Sessions; use Insipid::Util; require Exporter; -use Data::Dumper; - @ISA = qw(Exporter); @EXPORT = qw( -- 2.39.5