Tadashi Okoshi
slash****@users*****
2005年 10月 25日 (火) 04:20:45 JST
Index: affelio_farm/admin/skelton/affelio/apps/diary/AF_app.cfg
diff -u affelio_farm/admin/skelton/affelio/apps/diary/AF_app.cfg:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/AF_app.cfg:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/AF_app.cfg:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/AF_app.cfg Tue Oct 25 04:20:45 2005
@@ -1,13 +0,0 @@
-[this_installation]
-title=ç§ã®æ¥è¨
-
-[application]
-app_name=diary
-app_version=1.1
-app_desc=Affelioæ¥è¨
-app_author=Affelio project
-guest_index=list_diary.cgi
-owner_index=owner.cgi
-action_types=write_diary, write_comment
-action_types_desc=æ¥è¨æ¸ãè¾¼ã¿, ã³ã¡ã³ãæ¸ãè¾¼ã¿
-
Index: affelio_farm/admin/skelton/affelio/apps/diary/CHANGES
diff -u affelio_farm/admin/skelton/affelio/apps/diary/CHANGES:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/CHANGES:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/CHANGES:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/CHANGES Tue Oct 25 04:20:45 2005
@@ -1,4 +0,0 @@
-1.0.0 (July 12, 2005)
- Change: Diary.pm
- Allow to use anchor tag in diary
- Add explanation for allowed tag
Index: affelio_farm/admin/skelton/affelio/apps/diary/Diary.pm
diff -u affelio_farm/admin/skelton/affelio/apps/diary/Diary.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/Diary.pm:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/Diary.pm:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/Diary.pm Tue Oct 25 04:20:45 2005
@@ -1,973 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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 Diary;
-
-use strict;
-
-use lib '../../extlib';
-use lib '../../lib';
-
-use lib '.';
-use Diary::L10N;
-
-use DBI;
-use Jcode;
-use LWP::UserAgent;
-use HTTP::Request::Common qw(POST);
-use AffelioApp;
-use HTML::Template;
-
-##############################################
-# Constructor for diary
-##############################################
-
-sub new {
- my ($proto, $afap) = @_;
- unless ($afap) { die("Diary::new: Error: missing username\n"); }
-
- my $self = {};
- $self->{afap} = $afap;
- $self->{uname} = $afap->{af}->{site__username};
- $self->{datadir} = $afap->get_userdata_dir();
- $self->{dbh} = $afap->get_userdata_dbh;
- $self->{entry_table} = "diary_$afap->{install_name}_entries";
- $self->{comment_table} = "diary_$afap->{install_name}_comments";
- $self->{tb_table} = "diary_$afap->{install_name}_tb";
- $self->{max_entries} = 365;
- $self->{recent_entries_no} = 10;
- $self->{header_title} = 'Affelio Diary';
- $self->{header_show} = 0;
-
- ###########################
- #Locale init
- ###########################
- $self->{lh} = Diary::L10N->get_handle(($afap->get_site_info("locale"),$afap->get_site_info("locale")));
- ###########################
-
- my $DBConfig = Config::Tiny->new();
- $DBConfig = Config::Tiny->read("$self->{afap}->{af}->{site__user_dir}/db.cfg");
- $self->{dbtype} = $DBConfig->{db}->{type};
-
- my @rets;
- if ($self->{dbtype} eq 'mysql') {
- @rets = getall($self, "SHOW TABLES like '$self->{entry_table}'");
- }
- else { # SQLite
- @rets = getall($self, "SELECT * FROM sqlite_master WHERE type = 'table' AND name = '$self->{entry_table}'");
- }
-
- # entries
- my $pkey_modifier = $self->{dbtype} eq 'mysql' ? " AUTO_INCREMENT PRIMARY KEY " : " PRIMARY KEY ";
- create_table($self, $self->{entry_table},
- "CREATE TABLE $self->{entry_table} (
- id INTEGER $pkey_modifier ,
- title TEXT,
- contents TEXT,
- year INTEGER,
- month INTEGER,
- day INTEGER,
- timestamp INTEGER
- )");
-
- # comments
- create_table($self, $self->{comment_table},
- "CREATE TABLE $self->{comment_table} (
- id INTEGER,
- user TEXT,
- comment TEXT,
- timestamp INTEGER
- )");
-
- # trackbacks
- create_table($self, $self->{tb_table},
- "CREATE TABLE $self->{tb_table} (
- id INTEGER,
- title TEXT,
- url TEXT,
- excerpt TEXT,
- blog_name TEXT,
- timestamp INTEGER
- )");
-
- bless $self, $proto;
- return $self;
-}
-
-
-##############################################
-# Destructor
-##############################################
-
-sub DESTROY {
- my $self = shift;
- $self->{dbh}->disconnect;
-}
-
-
-##############################################
-# addEntry
-##############################################
-
-sub addEntry {
- my $self = shift;
- my $title = $self->escape(shift);
- my $contents = $self->escape(shift);
- my $time = shift;
-
- unless ($time) { $time = time; }
-
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($time);
- $year += 1900; $mon += 1;
-
- # prevent double submit
- my @same = $self->getall("SELECT id FROM $self->{entry_table} WHERE title = '$title' AND contents = '$contents'");
- if($#same >= 0) { return; }
-
- # log rotation
- if($self->getColumn("SELECT count(*) FROM $self->{entry_table}") >= $self->{max_entries}) {
- my $erase = $self->getColumn("SELECT MIN(timestamp) FROM $self->{entry_table}");
- my $erase_id = $self->getColumn("SELECT id FROM $self->{entry_table} WHERE timestamp = '$erase'");
- $self->removeEntry($erase_id);
- }
-
- $self->{dbh}->do("INSERT INTO $self->{entry_table} VALUES (NULL, '$title', '$contents', $year, $mon, $mday, $time)");
-
- # send trackback ping by using urls in entry
- my $id = $self->getColumn("SELECT MAX(id) FROM $self->{entry_table}");
-# $self->send_trackback_ping($id, $title, $contents);
-}
-
-
-##############################################
-# updateEntry
-##############################################
-
-sub updateEntry {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- my $title = $self->escape(shift);
- my $contents = $self->escape(shift);
- $self->{dbh}->do("UPDATE $self->{entry_table} SET title = '$title', contents = '$contents' WHERE id = $id");
-}
-
-
-##############################################
-# removeEntry
-##############################################
-
-sub removeEntry {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- $self->{dbh}->do("DELETE FROM $self->{entry_table} WHERE id = $id");
- $self->{dbh}->do("DELETE FROM $self->{comment_table} WHERE id = $id");
- $self->{dbh}->do("DELETE FROM $self->{tb_table} WHERE id = $id");
- if (-f $self->{datadir}."$id.stor") {
- unlink $self->{datadir}."$id.stor";
- }
- $self->removeUploadedImage($id);
-}
-
-
-##############################################
-# getEntry
-##############################################
-
-sub getEntry {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- my @ret = $self->getall("SELECT * FROM $self->{entry_table} WHERE id = $id");
- return $ret[0];
-}
-
-##############################################
-# existsEntry
-##############################################
-
-sub existsEntry {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- return $self->getColumn("SELECT COUNT(*) FROM $self->{entry_table} WHERE id = $id") > 0;
-}
-
-##############################################
-# getEntries
-#############################################
-
-sub getEntries {
- my $self = shift;
- my $year = $self->escape(shift, 'int');
- my $month = $self->escape(shift, 'int');
- my $day = $self->escape(shift, 'int');
-
- my $query = "SELECT * FROM $self->{entry_table} WHERE year = $year AND month = $month";
-
- if ($day) {
- $query .= " AND day = $day";
- }
-
- $query .= " ORDER BY timestamp DESC";
-
- return $self->getall($query);
-}
-
-
-##############################################
-# getNewestEntries
-##############################################
-
-sub getNewestEntries {
- my ($self, $num) = @_;
- unless ($num) { $num = 5; }
- return $self->getall("SELECT * FROM $self->{entry_table} ORDER BY timestamp DESC LIMIT $num");
-}
-
-
-##############################################
-# addComment
-##############################################
-
-sub addComment {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- my $user = shift;
- my $comment = $self->escape_comment(shift);
- my $time = time;
-
- my @same = $self->getall("SELECT id FROM $self->{comment_table} WHERE user = '$user' AND comment = '$comment'");
- if($#same >= 0) { return; }
-
- $self->{dbh}->do("INSERT INTO $self->{comment_table} VALUES ($id, '$user', '$comment', $time)");
-}
-
-
-##############################################
-# getComments
-##############################################
-
-sub getComments {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- return $self->getall("SELECT * FROM $self->{comment_table} WHERE id = $id ORDER BY timestamp");
-}
-
-##############################################
-# getVisitorInfo
-##############################################
-
-sub getVisitorInfo {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
-
- my $uname = $self->getColumn("SELECT user FROM $self->{comment_table} WHERE id = $id");
- if ($uname) {
- if ($uname =~ /([^<]*)<br \/>(.*)/) {
- return ($1, $2);
- }
- else {
- return ($uname);
- }
- }
- return ("");
-}
-
-##############################################
-# getCommentsNo
-##############################################
-
-sub getCommentsNo {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- return $self->getColumn("SELECT count(*) FROM $self->{comment_table} WHERE id = $id");
-}
-
-sub getColumn {
- my ($self, $query) = @_;
- my $sth = $self->{dbh}->prepare($query);
- $sth->execute;
- my $num;
- $sth->bind_columns(undef, \$num);
- $sth->fetch;
- $sth->finish;
- if($num) {
- return $num;
- }
- else {
- return 0;
- }
-}
-
-##############################################
-# get_HTML_header
-##############################################
-
-sub get_HTML_header {
- my $self = shift;
-
- return "" if ($self->{header_show} == 1) ;
-
- # conetnt type
- my $header =
- "Content-type: text/html; charset=UTF-8\n".
- "Pragma: no-cache\n\n";
-
- # affelio header
- $header .= $self->{afap}->get_HTML_header($self->{header_title});
-
- my $tmpl = HTML::Template->new(filename => "./templates/menu.tmpl");
-
- # calender
- my $calender;
- if($self->{afap}->{cgi}->param('year') and $self->{afap}->{cgi}->param('month')) {
- $calender = $self->getCalender($self->{afap}->{cgi}->param('year'), $self->{afap}->{cgi}->param('month'));
- }
- elsif($self->{afap}->{cgi}->param('id')) {
- my $id =
- my @date = $self->getall("SELECT year, month FROM $self->{entry_table} WHERE id = ".$self->{afap}->{cgi}->param('id'));
- $calender = $self->getCalender($date[0]->{year}, $date[0]->{month});
- }
- else {
- $calender = $self->getCalender;
- }
-
- # archives
- my @archives = $self->getall("SELECT DISTINCT year, month FROM $self->{entry_table} LIMIT 10");
- if ($#archives >= 0) {
- shift @archives unless $archives[0]->{year};
- $tmpl->param(ARCHIVES => \@archives);
- }
-
- # recent entries
- my @entries = $self->getall("SELECT id, title FROM $self->{entry_table} ORDER BY timestamp DESC LIMIT 10");
- if ($#entries >= 0) {
- $tmpl->param(RECENT_ENTRIES => \@entries);
- }
-
- # recent comments
- my @comments = $self->getall("SELECT $self->{comment_table}.id, title, user FROM $self->{entry_table}, $self->{comment_table} WHERE $self->{entry_table}.id = $self->{comment_table}.id ORDER BY $self->{comment_table}.timestamp DESC LIMIT 10");
- if ($#comments >= 0) {
- $tmpl->param(RECENT_COMMENTS => \@comments);
- }
-
- # recent trackbacks
- my @trackbacks = $self->getall("SELECT id, blog_name, title FROM $self->{tb_table} ORDER BY timestamp DESC LIMIT 10");
- if ($#trackbacks >= 0) {
- $tmpl->param(RECENT_TRACKBACKS => \@trackbacks);
- }
-
- $tmpl->param(CALENDER => $self->translate_templateL10N($calender), );
-
- if ($self->{afap}->check_access('write_diary')) {
- $tmpl->param(EDITABLE => 1);
- unless (eval { require XML::Parser; }) {
- $tmpl->param(NO_PARSER => 1);
- }
- }
- $header .= $tmpl->output;
-
- $self->{header_show} = 1;
-
- return $header;
-}
-
-
-##############################################
-# get_HTML_footer
-##############################################
-
-sub get_HTML_footer {
- my $self = shift;
- my $tmpl = HTML::Template->new(filename => "./templates/footer.tmpl");
- return $tmpl->output().$self->{afap}->get_HTML_footer;
-}
-
-##############################################
-# redirection
-##############################################
-
-sub getRedirection {
- my ($self, $file) = @_;
- my $webroot = $self->{afap}->get_site_info('web_root');
- return
- "Content-type: text/html; charset=UTF-8\n".
- "Location: $webroot/apps/$self->{afap}->{install_name}/$file"."\n\n";
-}
-
-##############################################
-# checkAccess
-##############################################
-
-sub checkAccess {
- my ($self, $page_name) = @_;
- unless ($self->{afap}->check_access($page_name)) {
- $self->accessErrorExit("You have no permittion on this page");
- }
-}
-
-##############################################
-# errorExit
-##############################################
-
-sub errorExit {
- my $self = shift;
- my $msg = $self->escape(shift);
-
- my $tmpl = new HTML::Template(filename => './templates/error.tmpl');
- $tmpl->param(MESSAGE => $msg);
-
- unless ($self->{header_show}) {
- print "Content-type: text/html; charset=UTF-8\n\n";
- print $self->translate_templateL10N($self->{afap}->get_HTML_header($self->{header_title}));
- }
- print $self->translate_templateL10N($tmpl->output);
- print $self->translate_templateL10N($self->{afap}->get_HTML_footer);
- exit;
-}
-
-##############################################
-# accessErrorExit
-##############################################
-
-sub accessErrorExit {
- my $self = shift;
- my $msg = $self->escape(shift);
- my $affelio_id = $self->{afap}->get_visitor_info("afid");
- my $visitor_type=$self->{afap}->get_visitor_info("type");
-
- $visitor_type="pb" if ($visitor_type eq "");
-
- my $tmpl = new HTML::Template(filename => "./templates/access_error.tmpl");
- $tmpl->param(
- AFID => $affelio_id,
- VIS_TYPE=> $visitor_type,
- MESSAGE => $msg,
- );
-
- unless ($self->{header_show}) {
- print "Content-type: text/html; charset=UTF-8\n\n";
- print $self->translate_templateL10N($self->{afap}->get_HTML_header($self->{header_title}));
- }
- print $self->translate_templateL10N($tmpl->output);
- print $self->translate_templateL10N($self->{afap}->get_HTML_footer);
- exit;
-}
-
-##############################################
-# getCalender
-##############################################
-
-sub getCalender {
- my $self = shift;
- my $year = $self->escape(shift, 'int');
- my $mon = $self->escape(shift, 'int');
-
- unless ($mon) { my $d; ($d, $d, $d, $d, $mon, $year) = localtime(time); $year += 1900; $mon += 1; }
- my @weeks = $self->weekly_days($year, $mon);
-
- my $tmpl = HTML::Template->new(filename => "./templates/calender.tmpl");
-
- my $last_mon = $mon - 1;
- my $next_mon = $mon + 1;
- my $lastyear = $year;
- my $nextyear = $year;
- if ($mon == 1) {
- $last_mon = 12;
- $lastyear = $year - 1;
- }
- elsif ($mon == 12) {
- $next_mon = 1;
- $nextyear = $year + 1;
- }
-
- $tmpl->param(
- YEAR => $year, MONTH => $mon,
- LAST_MON => $last_mon, NEXT_MON => $next_mon,
- LASTYEAR => $lastyear, NEXTYEAR => $nextyear,
- );
-
- my @days = $self->getall("SELECT day FROM $self->{entry_table} WHERE year = $year AND month = $mon");
- my @daytable = (0 .. 31);
- $daytable[0] = '';
- foreach(@days) {
- $daytable[$_->{day}] = "<a href=\"list_diary.cgi?year=$year&month=$mon&day=$_->{day}\"><b>$_->{day}</b></a>";
- }
-
- my @weeks_param;
- foreach(@weeks) {
- if($_->[0] == '' and $_->[6] == '') { next; }
- push @weeks_param,
- {
- SUN => $daytable[$_->[0]],
- MON => $daytable[$_->[1]],
- TUE => $daytable[$_->[2]],
- WED => $daytable[$_->[3]],
- THU => $daytable[$_->[4]],
- FRI => $daytable[$_->[5]],
- SAT => $daytable[$_->[6]],
- };
- }
-
- $tmpl->param(WEEKS => \@weeks_param);
-
- return $tmpl->output;
-}
-
-
-##############################################
-# addTrackback
-##############################################
-
-sub addTrackback {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- my $title = $self->escape(shift);
- my $url = $self->escape(shift);
- my $excerpt = $self->escape(shift);
- my $blog_name = $self->escape(shift);
- my $timestamp = $self->escape(shift, 'int');
- $self->{dbh}->do("INSERT INTO $self->{tb_table} VALUES($id, '$title', '$url', '$excerpt', '$blog_name', $timestamp)");
-}
-
-##############################################
-# getTrackbacks
-##############################################
-
-sub getTrackbacks {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- my @ret = $self->getall("SELECT * FROM $self->{tb_table} WHERE id = $id");
-
- foreach (@ret) {
- $_->{excerpt} = Jcode::convert($_->{excerpt}, 'utf8');
- }
- reset (@ret);
-
- return @ret;
-}
-
-##############################################
-# getTrackbacksNo
-##############################################
-
-sub getTrackbacksNo {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
- return $self->getColumn("SELECT COUNT(*) FROM $self->{tb_table} WHERE id = $id");
-}
-
-##############################################
-# sendTrackbackPing
-##############################################
-
-sub sendTrackbackPing {
- my ($self, $url, $title, $contents, $id) = @_;
-
- $id = $self->getColumn("SELECT MAX(id) FROM $self->{entry_table}") unless ($id);
-
- my %form = (
- title => $title,
- excerpt => "",#Jcode::convert($contents, 'utf8', 'auto'),
- url => $self->{afap}->get_site_info('web_root')."/apps/$self->{afap}->{install_name}/show_diary.cgi?id=$id",
- blog_name => $self->{afap}->get_owner_info('nickname')."'s Affelio Diary",
- );
- my $req = POST($url, [%form]);
- my $ua = new LWP::UserAgent;
- my $res = $ua->request($req);
- my $str = $res->as_string;
- if ($str =~ /<error>[^1]*1[^<]*<\/error>/) {
- $self->errorExit('Failed to send trackback ping');
- }
-}
-
-##############################################
-# setRDFURL
-##############################################
-
-sub setRDFURL {
- my ($self, $url) = @_;
- local (*OUT);
-
- open(OUT, "> $self->{datadir}url");
- print OUT $url;
- close(OUT);
-}
-
-##############################################
-# getRDFURL
-##############################################
-
-sub getRDFURL {
- my $self = shift;
- if (-f "$self->{datadir}url") {
- local (*IN);
- open (IN, "$self->{datadir}url");
- my $rssfile = <IN>;
- $rssfile =~ s/[\r\n]//g;
- close(IN);
- return $rssfile;
- }
- return undef;
-}
-
-##############################################
-# unsetRDF
-##############################################
-
-sub unsetRDFURL {
- my $self = shift;
- unlink("$self->{datadir}url") if (-f "$self->{datadir}url");
-}
-
-##############################################
-# getRSS
-##############################################
-
-sub getRSS {
- my ($self, $count) = @_;
- unless ($count) { $count = 5; }
-
- my $tmpl = new HTML::Template(filename => './templates/rss.tmpl');
-
- my @entries = $self->getNewestEntries($count);
- my @item_list;
- my @items;
- my $web_root = $self->{afap}->get_site_info('web_root');
- my $uname = $self->{afap}->get_owner_info('nickname');
-
- foreach (@entries) {
- my $link = "$web_root/apps/$self->{afap}->{install_name}/show_diary.cgi?id=$_->{id}";
- push @item_list, { LINK => $link, };
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
- push @items, {
- TITLE => $_->{title},
- LINK => $link,
- DESCRIPTION => $_->{contents},
- DATE => sprintf("%4d-%02d-%02dT%02d:%02d+09:00", $year, $mon, $mday, $hour, $min),
- CREATOR => $uname,
- TPING => $web_root."apps/$self->{afap}->{install_name}/tb.cgi/$_->{id}",
- };
- }
-
- $tmpl->param(
- LINK => $web_root,
- NICKNAME => $uname,
- ITEM_LIST => \@item_list,
- ITEMS => \@items,
- );
-
- return $tmpl->output;
-}
-
-##############################################
-# getURLDescription
-##############################################
-
-sub getURLDescription {
- my $self = shift;
- my $id = $self->escape(shift, 'int');
-
- my ($entry) = $self->getall("SELECT * FROM $self->{entry_table} WHERE id = $id");
- my $tmpl = new HTML::Template(filename => "./templates/tpingrdf.tmpl");
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($entry->{timestamp});
- $year += 1900; $mon += 1;
-
- $tmpl->param(
- TITLE => $entry->{title},
- TURL => "$self->{afap}->{af}->{site__web_root}/apps/$self->{afap}->{install_name}/tb/tb.cgi/$id",
- IDENT => "$self->{afap}->{af}->{site__web_root}/apps/$self->{afap}->{install_name}/show_diary.cgi?id=$id",
- DESCRIPTION => $entry->{contents},
- CREATOR => $self->{afap}->{af}->{user__nickname},
- DATE => sprintf("%4d-%02d-%02dT%02d:%02d+09:00", $year, $mon, $mday, $hour, $min),
- );
-
- return $tmpl->output;
-}
-
-##############################################
-# saveUploadedImage
-##############################################
-
-sub saveUploadedImage {
- use File::Basename;
- my ($self, $filename, $id) = @_;
-
- if ($filename !~ /^[a-zA-Z0-9\.\-\_]{1,32}$/) {
- $self->errorExit("You can only use ascii character in your file name");
- }
-
- $id = $self->getColumn("SELECT MAX(id) FROM $self->{entry_table}") unless ($id);
-
- my $afap = $self->{afap};
-
- my $file;
- my $buf;
- my $filesize = 0;
- while (my $bytesread = read($filename, $buf, 1024)) {
- $file .= $buf;
- $self->errorExit('Uploaded file was too big') if (++$filesize >= 300);
- }
-
- my $imgdir = "$self->{datadir}img/";
- unless (-d $imgdir) {
- mkdir $imgdir;
- }
- my $basedir = $imgdir."$id/";
- unless (-d $basedir) {
- mkdir $basedir;
- }
-
- fileparse_set_fstype('MSDOS');
- my $distfile = $basedir.basename($filename);
-
- unless (basename($filename) =~ /^[a-zA-Z0-9\.\-\_]{1,28}\.(jpg|jpeg|png|gif|bmp)$/i) {
- $self->errorExit('Uploaded file had invalid MIME type');
- }
-
- local (*OUT);
- open(OUT, "> $distfile") or $self->errorExit('Failed to open file');
- binmode OUT;
- print OUT $file;
- close(OUT);
-}
-
-##############################################
-# removeUploadedImage
-##############################################
-
-sub removeUploadedImage {
- my ($self, $id) = @_;
-
- $id = $self->getColumn("SELECT MAX(id) FROM $self->{entry_table}") unless ($id);
-
- my $imgdir = "$self->{datadir}img/$id/";
- if (-d $imgdir) {
- local (*DIR);
- opendir(DIR, $imgdir);
- while (my $file = readdir(DIR)) {
- unlink ($imgdir.$file) if (-f $imgdir.$file);
- }
- closedir(DIR);
- rmdir $imgdir;
- }
-}
-
-##############################################
-# getUploadedImages
-##############################################
-
-sub getUploadedImages {
- my ($self, $id, $width, $height) = @_;
-
- $width = "&w=$width" if ($width);
- $height = "&h=$height" if ($height);
-
- my $imgdir = "$self->{datadir}img/$id/";
- my $ret;
-
- local (*DIR);
- opendir(DIR, $imgdir);
- while (my $file = readdir(DIR)) {
- if (-f $imgdir.$file) {
- $ret .= "<a href=\"show_image.cgi?id=$id&filename=$file\" target=\"_blank\">".
- "<img src=\"show_image.cgi?id=$id&filename=$file$width$height\" border=\"0\" />".
- "</a><br />";
- }
- }
- closedir(DIR);
-
- return $ret ? "<p>$ret</p>" : "";
-}
-
-##############################################
-# Internal functions
-##############################################
-
-sub create_table {
- my ($self, $table_name, $sql) = @_;
-
- my @rets;
- if ($self->{dbtype} eq 'mysql') {
- @rets = getall($self, "SHOW TABLES like '$table_name'");
- }
- else { # SQLite
- @rets = getall($self, "SELECT * FROM sqlite_master WHERE type = 'table' AND name = '$table_name'");
- }
-
- if ($#rets < 0) {
- $self->{dbh}->do($sql);
- }
-}
-
-sub send_trackback_ping {
- my ($self, $id, $title, $contents) = @_;
- my @urls = $contents =~ /(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/g;
-
- foreach(@urls) {
- my $url = $self->discover_tb($_);
- if($url) {
- my %form = (
- title => $title,
- excerpt => $contents,
- url => "$self->{afap}->{af}->{site__web_root}/apps/$self->{afap}->{install_name}/show_diary.cgi?id=$id",
- blog_name => "$self->{afap}->{af}->{user__nickname}'s affelio diary",
- );
- my $req = POST($url, [%form]);
- my $ua = new LWP::UserAgent;
- my $res = $ua->request($req);
- my $str = $res->as_string;
- }
- }
-}
-
-sub escape {
- my ($self, $str, $type) = @_;
-
- if ($type eq 'int') {
- return int($str);
- }
- else {
- $str =~ s/[\t\a]//g;
- $str =~ s/&/&/g;
- $str =~ s/["']/"/g;
- $str =~ s/</</g;
- $str =~ s/>/>/g;
- $str =~ s/<(\/?)(a|p|i|b|big|strong|small|em|u|blockquote)>/<$1$2>/ig;
- $str =~ s/<a +href=(")?(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+) *(")? *>/<a href="$2">/ig;
- $str =~ s/""/"/g;
- $str =~ s/(\r\n|\r|\n)/<br \/>/g;
-
- while ($str =~ /(<(a|p|i|b|big|strong|small|em|u|blockquote)\b(?:(?!<\/\2>).)*(?:<\2>|$))/sigx) {
- $self->errorExit("Error: You may mistype a tag or forget to close it.");
- }
- }
-
- return $str;
-}
-
-sub escape_comment {
- my ($self, $str) = @_;
-
- $str =~ s/[\t\a]//g;
- $str =~ s/&/&/g;
- $str =~ s/['"]/"/g;
- $str =~ s/</</g;
- $str =~ s/>/>/g;
- $str =~ s/(\r\n|\r|\n)/<br \/>/g;
-
- return $str;
-}
-
-sub getall {
- my ($self, $query) = @_;
-
- my $sth = $self->{dbh}->prepare($query);
- $sth->execute;
-
- my @ret;
- while(my $row = $sth->fetchrow_hashref) {
- push @ret, $row;
- }
- $sth->finish;
-
- return @ret;
-}
-
-sub weekly_days {
- my ($self, $year, $mon) = @_;
- my @weeks;
- my @mday = (31,31,28,31,30,31,30,31,31,30,31,30,31);
- if (($year % 4 == 0) and ($year % 100) or ($year % 400 == 0)) { $mday[2] = 29 };
-
- my $lastday = $mday[$mon];
- @mday = (1 .. $mday[$mon]);
- if($mon < 3){ $mon += 12; $year--; }
- my $first_day = ($year+int($year/4)-int($year/100)+int($year/400)+int((13*$mon+8)/5)+1)% 7;
-
- my $day = 1;
- for my $week (0 .. 7) {
- my @days;
- for(my $i = 0; $i < 7; $i++) {
- push @days,
- (($week == 0 and $i < $first_day) or ($day > $lastday)) ?
- '' : $day++;
- }
- $weeks[$week] = \@days;
- }
-
- return @weeks;
-}
-
-# Refer to: http://lowlife.jp/yasusii/stories/8.html
-sub discover_tb {
- my ($self, $url) = @_;
- my $ua = LWP::UserAgent->new;
- $ua->agent('TrackBack/1.0');
- $ua->parse_head(0);
- $ua->timeout(15);
- my $req = HTTP::Request->new(GET => $url);
- my $res = $ua->request($req);
- return unless $res->is_success;
- my $c = $res->content;
- (my $url_no_anchor = $url) =~ s/#.*$//;
- my $item;
- while ($c =~ m!(<rdf:RDF.*?</rdf:RDF>)!sg) {
- my $rdf = $1;
- my($perm_url) = $rdf =~ m!dc:identifier="([^"]+)"!;
- next unless $perm_url eq $url || $perm_url eq $url_no_anchor;
- if ($rdf =~ m!trackback:ping="([^"]+)"!) {
- return $1;
- } elsif ($rdf =~ m!about="([^"]+)"!) {
- return $1;
- }
- }
-}
-
-############################################################################
-#L10N added by slash
-############################################################################
-sub translate_templateL10N{
- my $af=shift;
- my $mesg = shift;
-
- my $tag_body ="";
- my $text_value="";
- my $param_value="";
-
- while( $mesg =~ /<AF_M ([^>]+)>/ ){
- $tag_body = $1;
-
- $tag_body =~ /text(\s*)=(\s*)["']([^"']*)["'](\s*)param(\s*)=(\s*)["']([^"']*)["']/;
- $text_value=$3;
- $param_value=$7;
- if($text_value eq ""){
- $tag_body =~ /text(\s*)=(\s*)["']([^"']*)["']/;
- $text_value=$3;
- }
-
- my $sbst = $af->{lh}->maketext($text_value, $param_value);
-
-# debug_print("Diary::translate tag_body = [$tag_body]\n");
-# debug_print("Diary::translate \t text=[$text_value]\n");
-# debug_print("Diary::translate \t param=[$param_value]\n");
-# debug_print("Diary::translate \t sbst=[$sbst]\n");
-
- $mesg =~ s/\Q<AF_M $tag_body>\E/$sbst/g;
- }
- return($mesg);
-}
-############################################################################
-
-
-1;
Index: affelio_farm/admin/skelton/affelio/apps/diary/edit_diary.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/edit_diary.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/edit_diary.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/edit_diary.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/edit_diary.cgi Tue Oct 25 04:20:45 2005
@@ -1,97 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require 'init.pl';
-use Error qw(:try);
-
-$diary->checkAccess('write_diary');
-
-my $id = $afap->{cgi}->param('id') or $diary->errorExit('An article number was not specified');
-
-$diary->errorExit("The specified article does not exist") unless $diary->existsEntry($id);
-
-my $tmpl;
-
-# submitted
-if($afap->{cgi}->param('edit')) {
- try {
- # send trackback ping
- if ($afap->{cgi}->param('tping_url')) {
- $diary->sendTrackbackPing($afap->{cgi}->param('tping_url'), $afap->{cgi}->param('title'), $afap->{cgi}->param('contents'), $id);
- }
-
- $diary->updateEntry($id, $afap->{cgi}->param('title'), $afap->{cgi}->param('contents'));
-
- my $filename_1 = $afap->{cgi}->param('filename_1');
- my $filename_2 = $afap->{cgi}->param('filename_2');
-
- if ($afap->{cgi}->param('delete_images') or $filename_1 or $filename_2) {
- $diary->removeUploadedImage($id);
- }
- if ($filename_1) {
- $diary->saveUploadedImage($filename_1, $id);
- }
- if ($filename_2) {
- $diary->saveUploadedImage($filename_2, $id);
- }
- }
- catch Error with {
- my $e = shift;
- error($q, "Error: \n".$e);
- };
-
- print $diary->getRedirection("show_diary.cgi?id=$id");
- exit;
-}
-
-# deleted
-elsif($afap->{cgi}->param('delete')) {
- try {
- $diary->removeEntry($id);
- }
- catch Error with {
- my $e = shift;
- error($q, "Error: \n".$e);
- };
-
- print $diary->getRedirection("list_diary.cgi");
- exit;
-}
-
-# confirm
-elsif($afap->{cgi}->param("delete_confirm")) {
- $tmpl = HTML::Template->new(filename => "./templates/edit_diary_delete_confirm.tmpl");
- my $entry = $diary->getEntry($id);
- $tmpl->param(ID => $entry->{id});
-}
-
-# edit
-else {
- $tmpl = HTML::Template->new(filename => "./templates/edit_diary_edit.tmpl");
- my $entry = $diary->getEntry($id);
- $entry->{contents} =~ s/<br[^>]*>/\n/g;
- $tmpl->param(
- ID => $entry->{id},
- TITLE => $entry->{title},
- CONTENTS => $entry->{contents},
- DATETIME => "$entry->{year}/$entry->{month}/$entry->{day}",
- );
-}
-
-print $diary->translate_templateL10N($diary->get_HTML_header);
-print $diary->translate_templateL10N($tmpl->output);
-print $diary->get_HTML_footer;
Index: affelio_farm/admin/skelton/affelio/apps/diary/external_blog.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/external_blog.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/external_blog.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/external_blog.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/external_blog.cgi Tue Oct 25 04:20:45 2005
@@ -1,136 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require 'init.pl';
-
-use Error qw(:try);
-
-my $urlfile = $diary->{datadir}.'url';
-
-my $writable = 0;
-if($afap->check_access("write_diary")){
- $writable = 1;
-}
-
-eval { require XML::Parser; } or $diary->errorExit("XML::Parser is not available");
-
-# print header
-my $header =
- "Content-type: text/html; charset=UTF-8\n".
- "Pragma: no-cache\n\n".
- $afap->get_HTML_header($diary->{header_titile});
-
-# set url
-if ($afap->{cgi}->param('set_url')) {
- $diary->setRDFURL($afap->{cgi}->param('url'));
-}
-# unset url
-elsif ($afap->{cgi}->param('remove_urlfile')) {
- $diary->unsetRDFURL;
- print $diary->getRedirection('list_diary.cgi');
- exit;
-}
-
-# load rss file and get url of rdf
-my $rssfile = $diary->getRDFURL;
-
-# if file was not found, show configuration file
-unless ($rssfile) {
- $diary->checkAccess('write_diary');
- my $tmpl = new HTML::Template(filename => "./templates/external_blog_conf.tmpl");
- print $header;
- print $diary->translate_templateL10N($tmpl->output);
- print $diary->get_HTML_footer;
- exit;
-}
-
-# send request
-my $req = new HTTP::Request(GET => $rssfile);
-my $ua = new LWP::UserAgent;
-my $res = $ua->request($req);
-my $str;
-if ($res->is_success) {
- $str = $res->content;
- $str =~ s/&/&/g; # escape '&'
-}
-else {
- unlink($urlfile) if (-f $urlfile);
- print $diary->errorExit("Failed to get RDF File");
-}
-
-# parse and output
-use lib 'extlib';
-use XML::RSS;
-
-my $rss = new XML::RSS;
-unless (eval { $rss->parse($str); }) {
- $diary->unsetRDFURL;
- $diary->errorExit("Failed to parse RDF File");
-}
-
-my @entries;
-my @entry_list;
-my $i = 0;
-foreach (@{ $rss->{items} }) {
- push @entries, {
- TITLE => $_->{'title'},
- LINK => $_->{'link'},
- CONTENTS=> &escape_html($_->{'description'}),
- DATE => $_->{dc}->{'date'},
- };
- push @entry_list, {
- TITLE => $_->{'title'},
- LINK => $_->{'link'},
- };
- last if (++$i >= 10);
-}
-
-my $tmpl = new HTML::Template(filename => "./templates/external_blog.tmpl");
-$tmpl->param(
- WRITABLE => $writable,
- RSS_URL => $rssfile,
- TITLE_MAIN => $rss->channel('title'),
- LINK_MAIN => $rss->channel('link'),
- ENTRIES => \@entries,
- ENTRY_LIST => \@entry_list,
-);
-
-print $header;
-print $diary->translate_templateL10N($tmpl->output);
-print $diary->get_HTML_footer;
-
-sub escape_html {
- my $html = shift;
-
- if ($html =~ /</) {
- $html =~ s/<(.*)>//g;
- $html =~ s/&/&/g;
- $html =~ s/&(quot|apos);/"/g;
- }
-
- $html =~ s/&/&/g;
- $html =~ s/['"]/"/g;
- $html =~ s/<[^>]*>//g;
- $html =~ s/</</g;
- $html =~ s/>/>/g;
-
- # allow <br>,<p>,<a>,<i>,<b>,<strong>,<em>,<u>,<font>
-# $html =~ s/<(\/?)(br|p|a|i|b|strong|em|u|font)[^&]*>/<$1$2$3>/gi;
-# $html =~ s/<a +href="([^&]*)"([^&]*)>/<a href="$1" $2>/gi;
-
- return $html;
-}
Index: affelio_farm/admin/skelton/affelio/apps/diary/get_rss.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/get_rss.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/get_rss.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/get_rss.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/get_rss.cgi Tue Oct 25 04:20:45 2005
@@ -1,23 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require 'init.pl';
-
-print "Content-type: application/xml; charset=UTF-8\n";
-print "Pragma: no-cache", "\n\n";
-
-print $diary->getRSS;
Index: affelio_farm/admin/skelton/affelio/apps/diary/init.pl
diff -u affelio_farm/admin/skelton/affelio/apps/diary/init.pl:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/init.pl:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/init.pl:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/init.pl Tue Oct 25 04:20:45 2005
@@ -1,46 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-use strict;
-
-use lib("../../extlib");
-use HTML::Template;
-use CGI;
-use Cwd;
-#
-use lib("../../lib");
-use AffelioApp;
-use Affelio::misc::CGIError;
-#
-use Diary;
-
-our $cgi = new CGI();
-
-our $afap = new AffelioApp(ConfigDir => Cwd::getcwd(),
- cgi => $cgi);
-
-if(our $mymode eq "owner"){
- $afap->set_owner_mode();
-}
-
-our $diary = new Diary($afap);
-
-unless ($afap->check_access("DF_access")) {
- $diary->accessErrorExit('Access Denied. You don\'t have permission to this application.');
-}
-
-##########################################################################
-1;
Index: affelio_farm/admin/skelton/affelio/apps/diary/list_diary.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/list_diary.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/list_diary.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/list_diary.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/list_diary.cgi Tue Oct 25 04:20:45 2005
@@ -1,78 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require('init.pl');
-
-if (-f "$diary->{datadir}url") {
- print $diary->getRedirection('external_blog.cgi');
- exit;
-}
-
-print $diary->translate_templateL10N($diary->get_HTML_header);
-
-my $user = $afap->{cgi}->param("user");
-my $edit = 0;
-
-if($afap->check_access("write_diary")) {
- $user = $afap->get_owner_info("nickname");
- $edit = 1;
-}
-
-my $tmpl = HTML::Template->new(filename => "./templates/list_diary.tmpl");
-#$tmpl->param(NICKNAME => $afap->get_owner_info("nickname"));
-
-my @entries_param;
-my $year = $afap->{cgi}->param("year");
-my $month = $afap->{cgi}->param("month");
-my $day = $afap->{cgi}->param("day");
-my @entries;
-
-if($year and $month){
- @entries = $diary->getEntries($year, $month, $day);
- if($day and $#entries == 0) {
- my ($tid) = @entries;
- print $diary->getURLDescription($tid->{id});
- }
-}
-else {
- @entries = $diary->getNewestEntries;
-}
-
-my $i = 0;
-foreach(@entries) {
- my ($sec, $min, $hour) = localtime($_->{timestamp});
- push @entries_param,
- {
- MONTH => $_->{month},
- DAY => $_->{day},
- #TIME => sprintf("%02d:%02d", $hour, $min),
- TITLE => $_->{title},
- CONTENTS=> $_->{contents},
- COMMENT_NO => $diary->getCommentsNo($_->{id}),
- TRACKBACKS => $diary->getTrackbacksNo($_->{id}),
- ID => $_->{id},
- IMAGES => $diary->getUploadedImages($_->{id}, 300, 300),
- EDITABLE=> $edit
- };
-}
-$tmpl->param(ENTRIES => \@entries_param, EDITABLE => $edit);
-
-$tmpl->param(install_title => $afap->get_app_info("install_title"));
-
-print $diary->translate_templateL10N($tmpl->output);
-
-print $diary->get_HTML_footer;
Index: affelio_farm/admin/skelton/affelio/apps/diary/no_output.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/no_output.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/no_output.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/no_output.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/no_output.cgi Tue Oct 25 04:20:45 2005
@@ -1,26 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require './common/header.pl';
-
-print "<table>\n<tr><th colspan=\"2\">Debug info</th></tr>\n";
-while(my ($key, $value) = each %{$afap->{cgi}->{'.fieldnames'}}) {
- print "<tr><td>$key</td><td>$value</td></tr>\n";
-}
-print "</table>\n";
-
-require './common/footer.pl';
Index: affelio_farm/admin/skelton/affelio/apps/diary/owner.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/owner.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/owner.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/owner.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/owner.cgi Tue Oct 25 04:20:45 2005
@@ -1,56 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-our $mymode="owner";
-
-require 'init.pl';
-
-$diary->checkAccess("write_diary");
-
-if ($afap->{cgi}->param('save_state')) {
- my $type = $afap->{cgi}->param('type');
- if ($type eq 'import') {
- if ($afap->{cgi}->param('url')) {
- $diary->setRDFURL($afap->{cgi}->param('url'));
- print $diary->getRedirection('external_blog.cgi'); exit;
- }
- }
- else { # normal diary
- $diary->unsetRDFURL;
- print $diary->getRedirection('list_diary.cgi'); exit;
- }
-}
-
-my $tmpl = new HTML::Template(filename => './templates/owner.tmpl');
-my $url = $diary->getRDFURL;
-if ($url) {
- $tmpl->param(
- URL => $url,
- SELECT_IMPORT => 'checked'
- );
-}
-else {
- $tmpl->param(SELECT_DIARY => 'checked');
-}
-
-eval { require XML::Parser; } or $tmpl->param(NO_PARSER => 1);
-
-$tmpl->param(access_control_URL => $afap->get_URL("access_control"));
-
-print $diary->get_HTML_header;
-print $diary->translate_templateL10N($tmpl->output);
-print $diary->get_HTML_footer;
Index: affelio_farm/admin/skelton/affelio/apps/diary/show_diary.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/show_diary.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/show_diary.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/show_diary.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/show_diary.cgi Tue Oct 25 04:20:45 2005
@@ -1,67 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require 'init.pl';
-print $diary->get_HTML_header;
-
-my $id = $afap->{cgi}->param('id') or $diary->errorExit("An article number was not specified");
-
-$diary->errorExit("The specified article does not exist") unless $diary->existsEntry($id);
-
-my $entry = $diary->getEntry($id);
-
-my $tmpl = HTML::Template->new(filename => "./templates/show_diary.tmpl");
-
-# Diary
-$tmpl->param(
- ID => $entry->{id},
- MONTH => $entry->{month},
- DAY => $entry->{day},
- TITLE => $entry->{title},
- CONTENTS=> $entry->{contents},
- IMAGES => $diary->getUploadedImages($entry->{id}, 300, 300),
-);
-
-# Comment
-if($diary->getCommentsNo($id) > 0) {
- $tmpl->param(HAS_COMMENTS => 1);
- my @comments_param;
- my @comments = $diary->getComments($id);
- foreach(@comments) {
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
- $mon += 1;
-
- push @comments_param,
- {
- UNAME => $_->{user},
- COMMENT_TIME => "$monæ$mdayæ¥$hour:$min",
- COMMENT => $_->{comment}
- };
- }
- $tmpl->param(COMMENTS => \@comments_param);
-}
-
-if($afap->check_access("write_comment")){
- $tmpl->param("comment_write" => "true");
-}
-
-# Notify Trackback Ping URL
-print $diary->getURLDescription($id);
-
-print $diary->translate_templateL10N($tmpl->output);
-
-print $diary->get_HTML_footer;
Index: affelio_farm/admin/skelton/affelio/apps/diary/show_image.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/show_image.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/show_image.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/show_image.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/show_image.cgi Tue Oct 25 04:20:45 2005
@@ -1,56 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require 'init.pl';
-
-use Error qw(:try);
-
-my $id = $afap->{cgi}->param('id') or die;
-my $filename = $afap->{cgi}->param('filename') or die;
-
-my $type = $filename;
-$type =~ s/[^.]+\.(.*)/$1/i;
-$type =~ s/jpg/jpeg/i;
-my $filepath = "$diary->{datadir}img/$id/".$filename;
-
-my $width = $afap->{cgi}->param('w');
-my $height = $afap->{cgi}->param('h');
-
-binmode STDOUT;
-print "Content-type: image/$type\n\n";
-if ($width and $height and (eval 'use Image::Magick; 1;')) {
- try {
- my $image = new Image::Magick;
- $image->Read(filename => $filepath);
- my ($w, $h) = $image->Get('columns', 'rows');
- if ($w > $width or $h > $height) {
- $image->Resize(geometry => $width.'x'.$height);
- $image->Set(quality => 75);
- }
- $image->Write(file => \*STDOUT);
- }
- catch Error with {
- my $e = shift;
- error($q, "Error: \n". $e);
- };
-}
-else {
- open(IMG, "$filepath") or die;
- binmode IMG;
- print while (<IMG>);
- close(IMG);
-}
Index: affelio_farm/admin/skelton/affelio/apps/diary/show_trackback.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/show_trackback.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/show_trackback.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/show_trackback.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/show_trackback.cgi Tue Oct 25 04:20:45 2005
@@ -1,42 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require 'init.pl';
-
-my $id = $afap->{cgi}->param('id') or $diary->errorExit('An article number was not specified');
-
-my $tmpl = HTML::Template->new(filename => "./templates/show_trackback.tmpl");
-
-my @ts = $diary->getTrackbacks($id);
-my @trackbacks;
-foreach (@ts) {
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
- $year += 1900; $mon += 1;
- push @trackbacks, {
- TITLE => $diary->escape($_->{title}),
- BLOG_NAME => $diary->escape($_->{blog_name}),
- URL => $_->{url},
- EXCERPT => $diary->escape($_->{excerpt}),
- DATE => "$year-$mon-$mday",
- };
-}
-$tmpl->param(PING_URL => $afap->get_site_info("web_root") . "/apps/$diary->{afap}->{install_name}/tb.cgi/$id", TRACKBACKS => \@trackbacks);
-
-print $diary->get_HTML_header;
-print $diary->getURLDescription($id);
-print $diary->translate_templateL10N($tmpl->output);
-print $diary->get_HTML_footer;
Index: affelio_farm/admin/skelton/affelio/apps/diary/style.css
diff -u affelio_farm/admin/skelton/affelio/apps/diary/style.css:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/style.css:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/style.css:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/style.css Tue Oct 25 04:20:45 2005
@@ -1,93 +0,0 @@
-div#diary_2ColLeft {
- float: left;
- width: 20%;
- font-size: small;
-/* border-right: 1px solid #D7D7D7; */
- padding: 1.0em 1.0em 1.0em 0.5em;
- padding: 5px 5px 5px 5px;
-}
-
-div#diary_2ColRight {
- float: right;
- width: 70%;
- padding: 5px 10px 5px 10px;
-}
-
-div#date {
- font-size: 8pt;
- text-align: right;
-}
-
-div#diary_etc h2 {
- font-weight: bold;
-}
-
-div#diary_etc h3 {
- color: #663333;
- font-weight: bold;
-}
-
-div#diary_etc table {
- width: 450px;
- table-layout: fixed;
-}
-
-div#diary_etc th {
- color: #6699FF;
- border-top: 0px;
- border-left: 0px;
- border-right: 0px;
- border-bottom: 1px dashed #989898;
- text-align: left;
-}
-
-table#calender {
- border-spacing: 0px;
- border-collapse: collapse;
- empty-cells: show;
- font-size: x-small;
- text-align: center;
- border-bottom: 1px solid #989898;
- width: 120px;
- height: 120px;
-}
-
-table#calender th {
- border-top: 0px;
- border-left: 0px;
- border-right: 0px;
- border-bottom: 1px solid #989898;
- font-size: 7pt;
-}
-
-table#calender td {
- font-size: 8pt;
- border: 0px;
-}
-
-table#diary {
- border-spacing: 0px;
- border-collapse: collapse;
-}
-
-table#diary th {
- color: #333333;
- text-align: left;
- font-size: 12pt;
-}
-
-table#diary h3 {
- color: #663333;
- font-weight: bold;
- font-size: large;
-}
-
-table#diary td {
- font-size: 12pt;
- padding-bottom: 1.5em;
-}
-
-table#diary p {
- padding-left: 1.0em;
-}
-
Index: affelio_farm/admin/skelton/affelio/apps/diary/tb.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/tb.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/tb.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/tb.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/tb.cgi Tue Oct 25 04:20:45 2005
@@ -1,498 +0,0 @@
-#!/usr/bin/perl -w
-# Copyright 2002 Benjamin Trott.
-# This code is released under the Artistic License.
-use strict;
-
-#-------------
-use lib("../../extlib");
-use HTML::Template;
-use CGI qw( :standard );
-use Cwd;
-use Jcode;
-#
-use lib("../../lib");
-use AffelioApp;
-#
-use Diary;
-
-my $cgi = new CGI();
-
-my $afap = new AffelioApp(ConfigDir => Cwd::getcwd(),
- cgi => $cgi);
-
-my $diary = new Diary($afap);
-my $datadir = $afap->get_userdata_dir;
-#-------------
-
-my $DataDir = $datadir;
-my $RSSDir = $DataDir;
-my $GenerateRSS = 0;
-my $Header = "./resource/header.txt";
-my $Footer = "./resource/footer.txt";
-my $Password = "";
-
-use vars qw( $VERSION );
-$VERSION = '1.02';
-
-#use CGI qw( :standard );
-use File::Spec::Functions;
-
-my $mode = param('__mode');
-unless ($mode) {
- my $tb_id = munge_tb_id(get_tb_id());
- respond_exit("No TrackBack ID (tb_id)") unless $tb_id;
- my $i = { map { $_ => scalar param($_) } qw(title excerpt url blog_name) };
- $i->{title} ||= $i->{url};
- $i->{timestamp} = time;
-#-------------
- $i->{title} = Jcode::convert($i->{title}, 'euc');
- $i->{excerpt} = Jcode::convert($i->{excerpt}, 'euc');
- $i->{blog_name} = Jcode::convert($i->{blog_name}, 'euc');
-#-------------
- respond_exit("No URL (url)") unless $i->{url};
- my $data = load_data($tb_id);
- unshift @$data, $i;
- store_data($tb_id, $data);
- if ($GenerateRSS && open(FH, ">" . catfile($RSSDir, $tb_id . '.xml'))) {
- print FH generate_rss($tb_id, $data, 15);
- close FH;
- }
-#-------------
- $diary->addTrackback($tb_id, $i->{title}, $i->{url}, $i->{excerpt}, $i->{blog_name}, $i->{timestamp});
-#-------------
- respond_exit();
-} elsif ($mode eq 'list') {
- my $tb_id = munge_tb_id(get_tb_id());
- die("No TrackBack ID (tb_id)") unless $tb_id;
- my $me = url();
- print header(), from_file($Header), <<URL;
-<div class="url">TrackBack URL for this entry:
-<div class="ping-url">$me/$tb_id</div>
-</div>
-URL
- my $data = load_data($tb_id);
- my $tmpl = <<TMPL;
-<a target="new" href="%s">%s</a><br />
-<div class="head">» %s</div>
-<div class="excerpt">"%s"</div>
-<div class="footer">Tracked: %s %s</div>
-TMPL
- my $i = 0;
- require POSIX;
- my $logged_in = is_logged_in();
- for my $item (@$data) {
- my $ts = POSIX::strftime("%B %d, %Y %I:%M %p",
- localtime $item->{timestamp});
- printf $tmpl,
- $item->{url}, $item->{title},
- $item->{blog_name} || "[No blog name]",
- $item->{excerpt} || "[No excerpt]",
- $ts,
- $logged_in ? qq(<a class="delete" href="$me?__mode=delete&tb_id=$tb_id&index=$i">[DELETE]</a>) : '';
- $i++;
- }
- unless ($logged_in) {
- print <<HTML;
-<div align="right">[Is this your site? <a href="$me?__mode=login">Log in</a> to delete pings.]</div>
-HTML
- } else {
- print <<HTML;
-<div align="right">[<a href="$me?__mode=logout">Log out</a>]</div>
-HTML
- }
- print from_file($Footer);
-} elsif ($mode eq 'delete') {
- die "You are not authorized" unless is_logged_in();
- my $tb_id = munge_tb_id(get_tb_id());
- die("No TrackBack ID (tb_id)") unless $tb_id;
- my $data = load_data($tb_id);
- my $index = param('index') || 0;
- splice @$data, $index, 1;
- store_data($tb_id, $data);
- print redirect(url() . "?__mode=list&tb_id=$tb_id");
-} elsif ($mode eq 'rss') {
- my $tb_id = munge_tb_id(get_tb_id());
- respond_exit("No TrackBack ID (tb_id)") unless $tb_id;
- my $data = load_data($tb_id);
- respond_exit(undef, generate_rss($tb_id, $data));
-} elsif ($mode eq 'send_ping') {
- require LWP::UserAgent;
- my $ua = LWP::UserAgent->new;
- $ua->agent("TrackBack/$VERSION");
- my @qs = map $_ . '=' . encode_url(param($_) || ''),
- qw( title url excerpt blog_name );
- my $ping = param('ping_url') or ping_form_exit("No ping URL");
- my $req;
- if ($ping =~ /\?/) {
- $req = HTTP::Request->new(GET => $ping . '&' . join('&', @qs));
- } else {
- $req = HTTP::Request->new(POST => $ping);
- $req->content_type('application/x-www-form-urlencoded');
- $req->content(join('&', @qs));
- }
- my $res = $ua->request($req);
- ping_form_exit("HTTP error: " . $res->status_line) unless $res->is_success;
- my($e, $msg) = $res->content =~ m!<error>(\d+).*<message>(.+?)</message>!s;
- $e ? ping_form_exit("Error: $msg") : ping_form_exit("Ping successfuly sent");
-} elsif ($mode eq 'send_form') {
- ping_form_exit();
-} elsif ($mode eq 'login') {
- print header(), login_form();
-} elsif ($mode eq 'do_login') {
- my $key = param('key');
- unless ($key eq $Password) {
- print header(), login_form("Invalid login");
- exit;
- }
- require CGI::Cookie;
- my @alpha = ('a'..'z', 'A'..'Z', 0..9);
- my $salt = join '', map $alpha[rand @alpha], 1..2;
- my $cookie = CGI::Cookie->new(-name => 'key',
- -value => crypt($key, $salt));
- print header(-cookie => $cookie), from_file($Header),
- "Logged in", from_file($Footer);
-} elsif ($mode eq 'logout') {
- require CGI::Cookie;
- my $cookie = CGI::Cookie->new(-name => 'key', -value => '',
- -expire => '-1y');
- print header(-cookie => $cookie), login_form("Logged out");
-}
-
-sub get_tb_id {
- my $tb_id = param('tb_id');
- unless ($tb_id) {
- if (my $pi = path_info()) {
- ($tb_id = $pi) =~ s!^/!!;
- }
- }
- $tb_id;
-}
-
-sub munge_tb_id {
- my($id) = @_;
- return '' unless $id;
- $id =~ tr/a-zA-Z0-9/_/cs;
- $id;
-}
-
-sub is_logged_in {
- require CGI::Cookie;
- my %cookies = CGI::Cookie->fetch;
- return unless $cookies{key};
- my $key = $cookies{key}->value || return;
- $key eq crypt $Password, substr $key, 0, 2;
-}
-
-sub load_data {
- my($tb_id) = @_;
- my $tb_file = catfile($DataDir, $tb_id . '.stor');
- require Storable;
- scalar eval { Storable::retrieve($tb_file) } || [];
-}
-
-sub store_data {
- my($tb_id, $data) = @_;
- my $tb_file = catfile($DataDir, $tb_id . '.stor');
- require Storable;
- Storable::store($data, $tb_file);
-}
-
-sub generate_rss {
- my($tb_id, $data, $limit) = @_;
- my $rss = qq(<rss version="0.91"><channel><title>TB: $tb_id</title>\n);
- my $max = $limit ? $limit - 1 : $#$data;
- for my $i (@{$data}[0..$max]) {
- $rss .= sprintf "<item>%s%s%s</item>\n", xml('title', $i->{title}),
- xml('link', $i->{url}), xml('description', $i->{excerpt}) if $i;
- }
- $rss . qq(</channel></rss>);
-}
-
-sub respond_exit {
- print "Content-Type: text/xml\n\n";
- print qq(<?xml version="1.0" encoding="iso-8859-1"?>\n<response>\n);
- if ($_[0]) {
- printf qq(<error>1</error>\n%s\n), xml('message', $_[0]);
- } else {
- print qq(<error>0</error>\n) . ($_[1] ? $_[1] : '');
- }
- print "</response>\n";
- exit;
-}
-
-sub ping_form_exit {
- print header(), from_file($Header);
- print "@_" if @_;
- print <<HTML;
-<h2>Send a TrackBack ping</h2>
-<form method="post"><input type="hidden" name="__mode" value="send_ping" />
-<table border="0" cellspacing="3" cellpadding="0">
-<tr><td>TrackBack Ping URL:</td><td><input name="ping_url" size="60" /></td></tr>
-<tr><td> </td></tr>
-<tr><td>Title:</td><td><input name="title" size="35" /></td></tr>
-<tr><td>Blog name:</td><td><input name="blog_name" size="35" /></td></tr>
-<tr><td>Excerpt:</td><td><input name="excerpt" size="60" /></td></tr>
-<tr><td>Permalink URL:</td><td><input name="url" size="60" /></td></tr>
-</table>
-<input type="submit" value="Send">
-</form>
-HTML
- print from_file($Footer);
- exit;
-}
-
-sub login_form {
- my $str = from_file($Header);
- $str .= "<p>@_</p>" if @_;
- $str .= <<HTML . from_file($Footer);
-<form method="post">
-<input type="hidden" name="__mode" value="do_login" />
-Password: <input name="key" type="password" />
-<input type="submit" value="Log in" />
-</form>
-HTML
- $str;
-}
-my(%Map, $RE);
-BEGIN {
- %Map = ('&' => '&', '"' => '"', '<' => '<', '>' => '>');
- $RE = join '|', keys %Map;
-}
-sub xml {
- (my $s = defined $_[1] ? $_[1] : '') =~ s!($RE)!$Map{$1}!g;
- "<$_[0]>$s</$_[0]>\n";
-}
-
-sub encode_url {
- (my $str = $_[0]) =~ s!([^a-zA-Z0-9_.-])!uc sprintf "%%%02x", ord($1)!eg;
- $str;
-}
-
-sub from_file {
- my($file) = @_;
- local *FH;
- open FH, $file;
- my $c;
- { local $/; $c = <FH> }
- close FH;
- $c;
-}
-
-__END__
-
-=head1 NAME
-
-tb-standalone - Standalone TrackBack
-
-=head1 DESCRIPTION
-
-The standalone TrackBack tool serves two purposes: 1) it allows non-Movable
-Type users to use TrackBack with the tool of their choice, provided they meet
-the installation requirements; 2) it serves as a reference point to aid
-developers in implementing TrackBack in their own systems. This tool is a
-single CGI script that accepts TrackBack pings through HTTP requests, stores
-the pings locally in the filesystem, and can return a list of pings either
-in RSS or in a browser-viewable format. It can also be used to send pings
-to other sites.
-
-It is released under the Artistic License. The terms of the Artistic License
-are described at I<http://www.perl.com/language/misc/Artistic.html>.
-
-=head1 REQUIREMENTS
-
-You'll need a webserver capable of running CGI scripts (this means, for
-example, that this won't work with BlogSpot-hosted blogs). You'll also need
-perl, and the following Perl modules:
-
-=over 4
-
-=item * File::Spec
-
-=item * Storable
-
-=item * CGI
-
-=item * CGI::Cookie
-
-=item * LWP
-
-=back
-
-The first four are core modules as of perl 5.6.0, I believe, and LWP is
-installed on most hosts. Furthermore LWP is only required if you wish to
-B<send> TrackBack pings.
-
-=head1 INSTALLATION
-
-Installation of the standalone TrackBack tool is very simple. It's just one
-CGI script, F<tb.cgi>, along with two text files that define the header and
-footer HTML for the public list of TrackBack pings.
-
-=over 4
-
-=item 1. Configure tb.cgi
-
-You'll need to edit the script to change the I<$DataDir>, I<$RSSDir>,
-and I<$Password> settings.
-
-B<BE SURE TO CHANGE THE I<$Password> BEFORE INSTALLING THE TOOL.>
-
-I<$DataDir> is the path to the directory where the TrackBack data
-files will be stored; I<$RSSDir> is the path to the directory where the static
-RSS files will be generated; I<$Password> is your secret password that will
-allow you to delete TrackBack pings, when logged in.
-
-After setting I<$DataDir> and I<$RSSDir>, you'll need to create both of these
-directories and make them writeable by the user running the CGI scripts. In
-most cases, this means that you must set the permissions on these directories
-to 777.
-
-=item 2. Upload Files
-
-After editing the settings, upload F<tb.cgi>, F<header.txt>, and F<footer.txt>
-in ASCII mode to your webserver into a directory where you can run CGI
-scripts. Set the permissions on F<tb.cgi> to 755.
-
-=back
-
-=head1 USAGE
-
-=head2 Sending Pings
-
-To send pings from the tool, go to the following URL:
-
- http://yourserver.com/cgi-bin/tb.cgi?__mode=send_form
-
-where I<http://yourserver.com/cgi-bin/tb.cgi> is the URL where you
-installed F<tb.cgi>. Fill out the fields in the form, then press I<Send>.
-
-=head2 Receiving Pings
-
-To use the tool in your existing pages, you'll need to do two things:
-
-=over 4
-
-=item 1. Link to TrackBack listing
-
-First, you'll need to add a link to each of your weblog entries with a
-link to the list of TrackBack pings for that entry. You can do this by
-adding the following HTML to your template:
-
- <a href="http://yourserver.com/cgi-bin/tb.cgi?__mode=list&tb_id=[TrackBack ID]" onclick="window.open(this.href, 'trackback', 'width=480,height=480,scrollbars=yes,status=yes'); return false">TrackBack</a>
-
-You'll need to change C<http://yourserver.com/cgi-bin/tb.cgi> to the proper
-URL for I<tb.cgi> on your server. And, depending on the weblogging tool that
-you use, you'll need to change C<[TrackBack ID]> to a unique post ID. See
-the L<conversion table below|Conversion Table> to determine the proper tag to
-use for the tool that you use, to generate a unique post ID.
-
-=item 2. Add RDF
-
-TrackBack uses RDF embedded within your web page to auto-discover
-TrackBack-enabled entries on your pages. It also uses this information when
-building a threaded list of a cross-weblog "discussion". For these purposes,
-it is useful to embed the RDF into your page.
-
-Add the following to your weblog template so that it is displayed for each
-of the entries on your page:
-
- <!--
- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
- <rdf:Description
- rdf:about="[Entry Permalink]"
- dc:title="[Entry Title]"
- dc:identifier="[Entry Permalink]" />
- trackback:ping="http://yourserver.com/cgi-bin/tb.cgi/[TrackBack ID]"
- </rdf:RDF>
- -->
-
-As above, the tags that you should use for C<[TrackBack ID]>,
-C<[Entry Title]>, and C<[Entry Permalink]> all depend on the weblogging tool
-that you are using. See the L<conversion table below|Conversion Table>.
-
-=back
-
-=head2 Conversion Table
-
-=over 4
-
-=item * Blogger
-
-TrackBack ID = C<E<lt>$BlogItemNumber$E<gt>>
-
-Entry Title = C<E<lt>PostSubjectE<gt>E<lt>$BlogItemSubject$E<gt>E<lt>/PostSubjectE<gt>>
-
-Entry Permalink = C<E<lt>$BlogItemArchiveFileName$E<gt>#E<lt>$BlogItemNumber$E<gt>>
-
-=item * GreyMatter
-
-TrackBack ID = C<{{entrynumber}}>
-
-Entry Title = C<{{entrysubject}}>
-
-Entry Permalink = C<{{pagelink}}>
-
-=item * b2
-
-TrackBack ID = C<E<lt>?php the_ID() ?E<gt>>
-
-Entry Title = C<E<lt>?php the_title() ?E<gt>>
-
-Entry Permalink = C<E<lt>?php permalink_link() ?E<gt>>
-
-=item * pMachine
-
-TrackBack ID = C<%%id%%>
-
-Entry Title = C<%%title%%>
-
-Entry Permalink = C<%%comment_permalink%%>
-
-=item * Bloxsom
-
-TrackBack ID = C<$fn>
-
-Entry Title = C<$title>
-
-Entry Permalink = C<$url/$yr/$mo/$da#$fn>
-
-Thanks to Rael for this list of conversions.
-
-=back
-
-=head1 POSSIBLE USES
-
-=over 4
-
-=item 1. Content repository
-
-Like Movable Type's TrackBack implementation, this standalone script can
-be used to power a distributed content repository. The value of the I<tb_id>
-parameter does not necessarily have to be an integer, because all it is used
-for is a filename (B<note> that this is not true of most other TrackBack
-implementations). For example, if you run a site about cats, and want to have
-a way for users to ping your site with entries they write about their own
-cats, you could set up a TrackBack URL like
-F<http://www.foo.com/bar/tb.cgi?tb_id=cats>, then give that URL out on your
-site. End users could then associate this URL with a I<Cats> category in
-their own blog, and ping you whenever they wrote about cats.
-
-=item 2. Building block
-
-You can use this simple implementation as a building block, or a guide, for
-implementing TrackBack in your own system. It illustrates the core
-functionality of the TrackBack framework, onto which you could add bells
-and whistles (IP banning, password-protected TrackBacks, etc).
-
-=item 3. Centralized tool
-
-This TrackBack tool requires that the end user have the ability to run CGI
-scripts on their server. For many users (eg BlogSpot users), this is not
-an option. For such users, a centralized system (based on this tool, perhaps)
-would be ideal.
-
-=back
-
-=cut
Index: affelio_farm/admin/skelton/affelio/apps/diary/write_comment.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/write_comment.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/write_comment.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/write_comment.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/write_comment.cgi Tue Oct 25 04:20:45 2005
@@ -1,68 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-require 'init.pl';
-
-use Error qw(:try);
-
-$diary->checkAccess('write_comment');
-
-my $id = $afap->{cgi}->param('id') or $diary->errorExit('An article number was not specified');
-
-$diary->errorExit("The specified article does not exist") unless $diary->existsEntry($id);
-
-my $user = $afap->get_visitor_info("nickname");
-
-# Confirm
-if($afap->{cgi}->param('comment_confirm')) {
- my $tmpl = HTML::Template->new(filename => "./templates/write_comment_confirm.tmpl");
- $tmpl->param(COMMENT_SHOW => $diary->escape_comment($afap->{cgi}->param('comment')), COMMENT => $afap->{cgi}->param('comment'), ID => $id);
- $tmpl->param(REQUIRE_NAME => 1) unless ($user);
- print $diary->get_HTML_header;
- print $diary->translate_templateL10N($diary->translate_templateL10N($tmpl->output));
- print $diary->get_HTML_footer;
-}
-
-# Commit
-elsif($afap->{cgi}->param('comment_commit')) {
-
- if(!$user){
- $user = $diary->escape_comment($afap->{cgi}->param('visitor_name'));
- }else{
- $url = $afap->get_visitor_info('afid');
- if ($url =~ /<a href="([^"]*)"/) {
- $url = $1;
- }
- $url = $afap->get_site_info('web_root').'/outgoing.cgi?dest_url='.$url;
- $user = "<a href=\"$url\">".$afap->get_visitor_info("nickname")."</a>";
- }
-
- try {
- $diary->addComment($id, $user, $afap->{cgi}->param('comment'));
- }
- catch Error with {
- my $e = shift;
- error($q, "Error: \n".$e);
- };
-
- print $diary->getRedirection("show_diary.cgi?id=$id");
- exit;
-}
-
-else {
- $diary->errorExit('Invalid Access');
-}
Index: affelio_farm/admin/skelton/affelio/apps/diary/write_diary.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/diary/write_diary.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/diary/write_diary.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/diary/write_diary.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/diary/write_diary.cgi Tue Oct 25 04:20:45 2005
@@ -1,82 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-
-our $mymode="owner";
-
-require 'init.pl';
-
-# Error handling causes "Internal Server Error" ...
-# use Error qw(:try);
-
-$diary->checkAccess('write_diary');
-
-my $title = $afap->{cgi}->param('title');
-my $contents = $afap->{cgi}->param('contents');
-
-my $tmpl;
-if($afap->{cgi}->param('submit')) {
-# try {
- # add entry
- $diary->addEntry($title, $contents);
-
- # send trackback ping
- if ($afap->{cgi}->param('tping_url')) {
- $diary->sendTrackbackPing($afap->{cgi}->param('tping_url'), $title, $contents);
- }
-
- # update images
- $diary->removeUploadedImage;
- if ($afap->{cgi}->param('filename_1')) {
- $diary->saveUploadedImage($afap->{cgi}->param('filename_1'));
- }
- if ($afap->{cgi}->param('filename_2')) {
- $diary->saveUploadedImage($afap->{cgi}->param('filename_2'));
- }
-
-# }
-# catch Error with {
-# my $e = shift;
-# error($q, "Error: \n".$e);
-# };
-
- print $diary->getRedirection('list_diary.cgi');
- exit;
-}
-else {
- print $diary->get_HTML_header;
- if($afap->{cgi}->param('confirm')) {
- $tmpl = new HTML::Template(filename => "./templates/write_diary_confirm.tmpl");
- $tmpl->param(
- TITLE_SHOW => $diary->escape($title),
- CONTENTS_SHOW => $diary->escape($contents),
- );
- }
- else { # edit
- $tmpl = new HTML::Template(filename => "./templates/write_diary_edit.tmpl");
- }
-}
-
-if ($contents) {
- $tmpl->param(
- TITLE => $title,
- CONTENTS => $contents,
- );
-}
-
-print $diary->translate_templateL10N($tmpl->output);
-
-print $diary->get_HTML_footer;