⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookmarks.pm

📁 Insipid 是一款基于Web书签仓库。很方面的记录下各种输入输出信息。
💻 PM
字号:
#!/usr/bin/perl -w## Copyright (C) 2005 Luke Reeves## 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::Bookmarks;use strict;use vars qw(@ISA @EXPORT @EXPORT_OK);use Insipid::Config;use Insipid::Database;use Insipid::Util;use DBI qw/:sql_types/;;use Date::Format;use Date::Parse;use CGI qw/:standard/;use CGI::Carp qw(fatalsToBrowser);require Exporter;@ISA = qw(Exporter);@EXPORT = qw(export_bookmarks);sub export_bookmarks {	my ($writer) = (@_);	my ($sql, $sth, $last_id);	$writer->startTag("posts");	$sql = "select 		  bookmarks.id, bookmarks.title, bookmarks.date, 		  bookmarks.access_level, bookmarks.url, tags.name		from bookmarks		left join bookmark_tags on		  (bookmarks.id = bookmark_tags.bookmark_id)		left join tags on		  (bookmark_tags.tag_id = tags.id)";  	$sth = $dbh->prepare($sql);	$sth->execute();	my ($url, $title);	my $tags = "";	my %last;	$last_id = -1;	my $current = 0;	my $max = $sth->rows;	# There HAS to be a better way to do this horrible looping for tags.	while(my $hr = $sth->fetchrow_hashref) {		$current++;		# For the first bookmark		if($last_id eq -1) {		  $last_id = $hr->{'id'};		  $last{title} = $hr->{'title'};		  $last{url} = $hr->{'url'};		  $last{tags} = "";		  $last{timestamp} = $hr->{'date'};		  $last{access_level} = $hr->{'access_level'};		} 				#if(($hr->{'id'} ne $last_id) || ($current eq $max)) {		if($hr->{'id'} ne $last_id) {		  # the id changed, so show the last mark.		  my $url = sanitize_html($last{'url'});		  my $title = sanitize_html($last{'title'});		  $title =~ s/"/"/gi;		  if(defined($last{tags})) {		  	if($last{tags} eq "") {		  		$last{tags} = "system:unfiled"; 		  	}		  } else {		  	$last{tags} = "system:unfiled";		  }		  		  if($last{url} ne "") {		 	my $tstr = time2str("%Y-%m-%dT%TZ", $last{timestamp}, "GMT");			$writer->emptyTag('post',				'access_level' => $last{access_level},				'href' => $url,				'description' => $title,				'tag' => $last{tags},				'time' => $tstr);		  }		  # Swap the new one in.		  $last_id = $hr->{'id'};		  $last{title} = $hr->{'title'};		  $last{url} = $hr->{'url'};		  $last{tags} = $hr->{'name'};		  $last{timestamp} = $hr->{'date'};		  $last{access_level} = $hr->{'access_level'};		} else {		  # Add tag to the current bookmark		  if($hr->{'name'}) {			  $last{tags} = "$last{tags} $hr->{'name'}";		  }		}	}		if($last{'url'}) {		$url = sanitize_html($last{'url'});		$title = sanitize_html($last{'title'});		$title =~ s/"/"/gi;		if(defined($last{tags})) {			if($last{tags} eq "") {				$last{tags} = "system:unfiled"; 			}		} else {			$last{tags} = "system:unfiled";		}		  		if($last{url} ne "") {			my $tstr = time2str("%Y-%m-%dT%TZ", $last{timestamp}, "GMT");			$writer->emptyTag('post',				'access_level' => $last{access_level},				'href' => $url,				'description' => $title,				'tag' => $last{tags},				'time' => $tstr);		}	}	$writer->endTag("posts");}1;__END__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -