WebGUI 3.4.0 release

This commit is contained in:
JT Smith 2002-03-07 01:40:00 +00:00
parent 80f7752f32
commit a93b42789a
23 changed files with 3262 additions and 568 deletions

File diff suppressed because one or more lines are too long

View file

@ -15,5 +15,5 @@ Dutch Translation....................Joeri de Bruin
mod_rewrite Support..................Peter Beardsley / Appropriate Solutions, Inc.
Oracle testing.......................Richard Caelius
Image Manager concept................Frank Dillon
RSSLite..............................Scott Thomason

View file

@ -17,8 +17,7 @@ QnD INSTALL INSTRUCTIONS:
LWP
Tie::IxHash
DBI
XML::RSS
Mysql
Mysql (or some other DB driver)
Digest::MD5
Net::LDAP
Tie::CPHash

File diff suppressed because one or more lines are too long

View file

@ -25,3 +25,11 @@ alter table users change gender gender varchar(6) NOT NULL default 'neuter';

File diff suppressed because one or more lines are too long

338
lib/RSSLite.pm Normal file
View file

@ -0,0 +1,338 @@
package RSSLite;
##
## Copyright (c) 2000 Scott Thomason. All rights reserved.
## This program is free software; you can redistribute it
## and/or modify it under the same terms as Perl itself.
##
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
use Exporter;
@ISA = ('Exporter');
@EXPORT = qw/parseXML usableXML/;
@EXPORT_OK = qw/parseXML usableXML
isRSS isRDF isSN isWL
xml_content_string xml_content_array/;
$VERSION = '0.06';
use Carp;
use Data::Dumper;
sub parseXML {
my ($rr, $cr) = @_;
die "Parms to 'parse' must be refs to a hash and XML content!"
unless (ref($rr) and ref($cr));
return unless $$cr; ## Gotta have some content to parse
my $type = usableXML($cr)
or die "Content must be RSS/RDF/ScriptingNews/Weblog XML " .
"(or something pretty close)";
preprocess($cr);
if ($type == 1 or $type == 2) {
parseRSS($rr, $cr);
} elsif ($type == 3) {
parseSN($rr, $cr);
} elsif ($type == 4) {
parseWL($rr, $cr);
} else {
die "Screwed up XML type-checking somehow!";
}
postprocess($rr);
}
sub preprocess {
my $cr = shift;
##
## Help create "well-formed" XML so parser doesn't puke by
## 1. Making unix-style line endings
## 2. Using & for & (this screws up urls, but we fix it later)
## 3. Removing objectionable characters
##
$$cr =~ s|<(/*)rss\d+:(.*?)>|<$1$2>|g;
$$cr =~ s|<([^<> ]+)\s+(.+?)\s+/>|<$1 $2></$1>|g;
$$cr =~ s/\r\n?/\n/g;
$$cr =~ s/&(?!([a-zA-Z0-9]+|#\d+);)/&amp;/g;
$$cr =~ s/[^\s\d\w!@#\$%^&\*i\(\)\-\+=:;"'<>,\.\/\?]/ /g;
## Tidy up for debugging by starting open tags on new line
# $content =~ s|(?!\n)<(?!/)|\n<|gs;
}
sub postprocess {
my $rr = shift;
$rr->{'link'} =~ s/&amp;/&/gi;
if (defined($rr->{'items'})) {
my $i;
foreach $i (@{$rr->{'items'}}) {
$i->{'link'} = trim($i->{'link'});
# Put stuff into the right name if necessary
if (defined($i->{'url'}) and not $i->{'link'}) {
$i->{'link'} = $i->{'url'};
}
# Fix pre-process munging
$i->{'link'} =~ s/&amp;/&/gi;
# See if you can use misplaced url in title for empty links
if (not $i->{'link'}) {
if ($i->{'title'} =~ /^http:/) {
$i->{'link'} = $i->{'title'};
} elsif ($i->{'title'} =~ /"(http.*?)"/) {
$i->{'link'} = $1;
$i->{'title'} =~ s/<.*?>//;
} else {
next;
}
}
# Make sure you've got an http/ftp link
if ($i->{'link'} !~ m{^(http|ftp)://}i) {
## Rip link out of anchor tag
$i->{'link'} =~ m{a\s+href=("|&quot;)?(.*?)("|>|&quot;|&gt;)?}i;
if ($2) {
$i->{'link'} = $2;
} elsif ($i->{'link'} =~ m{[\.#/]}i and
$rr->{'link'} =~ m{^http://}) {
## Smells like a relative url
if (substr($i->{'link'}, 0, 1) ne '/') {
$i->{'link'} = '/' . $i->{'link'};
}
$i->{'link'} = $rr->{'link'} . $i->{'link'};
} else {
next;
}
}
$i->{'link'} =~ s/ //g;
}
}
}
sub parseRSS {
my ($rr, $cr) = @_;
my $channel = xml_content_string('channel', $cr);
$channel =~ s|<item.*?</item>||gis;
clean(\$channel);
my $ca;
my @channel_attrs = ($channel =~ m|(<.*?>.*?</.*?>)|gi);
foreach $ca (@channel_attrs) {
$ca =~ m|^<(.*?)>(.*?)</.*?>$|;
$rr->{$1} = trim($2);
}
$rr->{'items'} = ();
my $item;
foreach $item (xml_content_array('item', $cr)) {
clean(\$item);
my @item_attrs = ($item =~ m|(<.*?>.*?</.*?>)|gi);
my $ia;
my %ia;
foreach $ia (@item_attrs) {
$ia =~ m|^<(.*?)>(.*?)</.*?>$|;
$ia{$1} = trim($2);
}
push(@{$rr->{'items'}}, \%ia);
}
}
sub parseSN {
my ($rr, $cr) = @_;
my $channel = xml_content_string('header', $cr);
$channel =~ s|<item.*?</item>||gis;
clean(\$channel);
my $ca;
my @channel_attrs = ($channel =~ m|(<.*?>.*?</.*?>)|gi);
foreach $ca (@channel_attrs) {
$ca =~ m|^<(.*?)>(.*?)</.*?>$|;
$rr->{$1} = trim($2);
}
##
## Alias SN to RSS terms
##
if (exists $rr->{'channelDescription'}) {
$rr->{'description'} = $rr->{'channelDescription'};
}
if (exists $rr->{'channelTitle'}) {
$rr->{'title'} = $rr->{'channelTitle'};
}
if (exists $rr->{'channelLink'}) {
$rr->{'link'} = $rr->{'channelLink'};
}
$rr->{'items'} = ();
my $item;
foreach $item (xml_content_array('item', $cr)) {
clean(\$item);
my @item_attrs = ($item =~ m|(<.*?>.*?</.*?>)|gi);
my $ia;
my %ia;
foreach $ia (@item_attrs) {
$ia =~ m|^<(.*?)>(.*?)</.*?>$|;
$ia{$1} = trim($2);
}
# Links are nested, kill prev {'link'} and rebuild attrs inside it
undef $ia{'link'};
my @linkitems = xml_content_array('link', \$item)
or next;
my $linkitem = $linkitems[0]; ## Usually first one is most relevant
@item_attrs = ($linkitem =~ m|(<.*?>.*?</.*?>)|gi);
foreach $ia (@item_attrs) {
$ia =~ m|^<(.*?)>(.*?)</.*?>$|;
$ia{$1} = trim($2);
}
# Alias SN to RSS
if (exists $ia{'text'}) {
$ia{'description'} = $ia{'text'};
}
if (exists $ia{'linetext'}) {
$ia{'title'} = $ia{'linetext'};
}
if (exists $ia{'url'}) {
$ia{'link'} = $ia{'url'};
}
push(@{$rr->{'items'}}, \%ia);
}
}
sub parseWL {
my ($rr, $cr) = @_;
# my $channel = xml_content_string('header', $cr);
# $channel =~ s|<item.*?</item>||gis;
# clean(\$channel);
# my $ca;
# my @channel_attrs = ($channel =~ m|(<.*?>.*?</.*?>)|gi);
# foreach $ca (@channel_attrs) {
# $ca =~ m|^<(.*?)>(.*?)</.*?>$|;
# $rr->{$1} = trim($2);
# }
##
## Alias SN to RSS terms
##
# if (exists $rr->{'channelDescription'}) {
# $rr->{'description'} = $rr->{'channelDescription'};
# }
# if (exists $rr->{'channelTitle'}) {
# $rr->{'title'} = $rr->{'channelTitle'};
# }
# if (exists $rr->{'channelLink'}) {
# $rr->{'link'} = $rr->{'channelLink'};
# }
$rr->{'items'} = ();
my $item;
foreach $item (xml_content_array('link', $cr)) {
clean(\$item);
my @item_attrs = ($item =~ m|(<.*?>.*?</.*?>)|gi);
my $ia;
my %ia;
foreach $ia (@item_attrs) {
$ia =~ m|^<(.*?)>(.*?)</.*?>$|;
$ia{$1} = trim($2);
}
# Alias WL to RSS
if (exists $ia{'url'}) {
$ia{'link'} = $ia{'url'};
}
push(@{$rr->{'items'}}, \%ia);
}
}
sub usableXML {
my $cref = shift;
my $content = $$cref; ## Don't change caller's content just for usability check
preprocess(\$content);
return 1 if isRSS(\$content);
return 2 if isRDF(\$content);
return 3 if isSN(\$content);
return 4 if isWL(\$content);
return 0;
}
sub isRSS {
my $cref = shift;
return scalar($$cref =~ /<rss.*>.*<\/rss>/is);
}
sub isRDF {
my $cref = shift;
return scalar($$cref =~ /<rdf:RDF.*>.*<\/rdf:RDF>/is);
}
sub isSN {
my $cref = shift;
return scalar($$cref =~ /<scriptingnews.*>.*<\/scriptingnews>/is);
}
sub isWL {
my $cref = shift;
return scalar($$cref =~ /<weblog.*>.*<\/weblog>/is);
}
sub xml_content_string {
my $tag = shift;
my $cref = shift;
$$cref =~ /<${tag}.*?>(.*)<\/${tag}>/is;
return $1;
}
sub xml_content_array {
my $tag = shift;
my $cref = shift;
my $keeptags = shift;
$keeptags = 0 unless $keeptags;
my @result;
if ($keeptags) {
@result = ($$cref =~ /(<${tag}.*?>.*?<\/${tag}>)/gis);
} else {
@result = ($$cref =~ /<${tag}.*?>(.*?)<\/${tag}>/gis);
}
return @result;
}
sub clean {
my $cref = shift;
$$cref =~ s{(\n|<p>|</p>|<b>|</b>|<i>|</i>|<h\d>|</h\d>|<strong>|</strong>|<center>|</center>|<quote>|</quote>)}{ }gsi;
}
sub trim {
my $s = shift;
$s =~ s/^\s*(.*?)\s*$/$1/;
return $s;
}
1;

View file

@ -1,5 +1,5 @@
package WebGUI;
our $VERSION = "3.3.0";
our $VERSION = "3.4.0";
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2002 Plain Black Software.
@ -63,18 +63,16 @@ sub _displayAdminBar {
WebGUI::URL::page('op=listGroups')=>WebGUI::International::get(5),
WebGUI::URL::page('op=manageSettings')=>WebGUI::International::get(4),
WebGUI::URL::page('op=listUsers')=>WebGUI::International::get(7),
WebGUI::URL::gateway('page_not_found')=>WebGUI::International::get(8),
WebGUI::URL::gateway('trash')=>WebGUI::International::get(10),
WebGUI::URL::page('op=purgeTrash')=>WebGUI::International::get(11),
WebGUI::URL::page('op=listRoots')=>WebGUI::International::get(410),
WebGUI::URL::page('op=viewStatistics')=>WebGUI::International::get(144)
);
}
if (WebGUI::Privilege::isInGroup(4,$session{user}{userId})) {
%hash = (
'http://validator.w3.org/check?uri=http%3A%2F%2F'.$session{env}{SERVER_NAME}.
$session{page}{url}=>WebGUI::International::get(399),
WebGUI::URL::page()=>WebGUI::International::get(399),
WebGUI::URL::page('op=listImages')=>WebGUI::International::get(394),
WebGUI::URL::gateway('clipboard')=>WebGUI::International::get(9),
%hash
);
}
@ -187,7 +185,8 @@ sub page {
$contentHash{$widgetList[2]} .= '<hr><a href="'.WebGUI::URL::page('func=edit&wid='.$widgetList[0]).'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0 alt="Edit"></a><a href="'.WebGUI::URL::page('func=cut&wid='.$widgetList[0]).'"><img src="'.$session{setting}{lib}.'/cut.gif" border=0 alt="Cut"></a><a href="'.WebGUI::URL::page('func=copy&wid='.$widgetList[0]).'"><img src="'.$session{setting}{lib}.'/copy.gif" border=0 alt="Copy"></a><a href="'.WebGUI::URL::page('wid='.$widgetList[0].'&func=delete').'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0 alt="Delete"></a><a href="'.WebGUI::URL::page('func=moveUp&wid='.$widgetList[0]).'"><img src="'.$session{setting}{lib}.'/upArrow.gif" border=0 alt="Move Up"></a><a href="'.WebGUI::URL::page('func=moveDown&wid='.$widgetList[0]).'"><img src="'.$session{setting}{lib}.'/downArrow.gif" border=0 alt="Move Down"></a><a href="'.WebGUI::URL::page('func=jumpUp&wid='.$widgetList[0]).'"><img src="'.$session{setting}{lib}.'/jumpUp.gif" border=0 alt="Move to Top"></a><a href="'.WebGUI::URL::page('func=jumpDown&wid='.$widgetList[0]).'"><img src="'.$session{setting}{lib}.'/jumpDown.gif" border=0 alt="Move to Bottom"></a><br>';
}
$cmd = "WebGUI::Widget::".$widgetList[1]."::www_view";
$contentHash{$widgetList[2]} .= &$cmd($widgetList[0])."<p>\n\n";
$contentHash{$widgetList[2]} .= '<a name="'.$widgetList[0].'"></a>'.
&$cmd($widgetList[0])."<p>\n\n";
}
$sth->finish;
$cmd = "use WebGUI::Template::".$session{page}{template};

View file

@ -14,7 +14,7 @@ package WebGUI::Attachment;
=cut
use File::Copy cp;
use File::Copy qw(cp);
use File::Path;
use FileHandle;
use Image::Magick;
@ -284,7 +284,7 @@ sub getURL {
sub new {
my ($class, $filename, $node, $nodeSub) = @_;
my $node = WebGUI::Node->new($node, $nodeSub);
$node = WebGUI::Node->new($node, $nodeSub);
bless {_node => $node, _filename => $filename}, $class;
}

View file

@ -0,0 +1,33 @@
package WebGUI::Macro::FormParam;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2002 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Session;
#-------------------------------------------------------------------
sub _replacement {
my (@param);
@param = WebGUI::Macro::getParams($1);
return $session{form}{$param[0]};
}
#-------------------------------------------------------------------
sub process {
my ($output, $temp, @param);
$output = $_[0];
$output =~ s/\^FormParam\((.*?)\)\;/_replacement($1)/ge;
return $output;
}
1;

View file

@ -18,6 +18,7 @@ use WebGUI::Operation::Help;
use WebGUI::Operation::Image;
use WebGUI::Operation::Package;
use WebGUI::Operation::Page;
use WebGUI::Operation::Root;
use WebGUI::Operation::Search;
use WebGUI::Operation::Settings;
use WebGUI::Operation::Statistics;

View file

@ -103,22 +103,28 @@ sub www_createAccount {
$output .= WebGUI::Form::hidden("op","createAccountSave");
$output .= '<table>';
unless ($session{setting}{authMethod} eq "LDAP" && $session{setting}{usernameBinding} eq "yes") {
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(50).'</td><td>'.WebGUI::Form::text("username",20,30).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(50),WebGUI::Form::text("username",20,35));
}
if ($session{setting}{authMethod} eq "LDAP") {
$output .= WebGUI::Form::hidden("identifier1","ldap-password");
$output .= WebGUI::Form::hidden("identifier2","ldap-password");
$output .= '<tr><td class="formDescription">'.$session{setting}{ldapIdName}.'</td><td>'.WebGUI::Form::text("ldapId",20,100).'</td></tr>';
$output .= '<tr><td class="formDescription">'.$session{setting}{ldapPasswordName}.'</td><td>'.WebGUI::Form::password("ldapPassword",20,100).'</td></tr>';
$output .= tableFormRow($session{setting}{ldapIdName},WebGUI::Form::text("ldapId",20,100));
$output .= tableFormRow($session{setting}{ldapPasswordName},
WebGUI::Form::password("ldapPassword",20,100));
} else {
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(51).'</td><td>'.WebGUI::Form::password("identifier1",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(55).'</td><td>'.WebGUI::Form::password("identifier2",20,30).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(51),
WebGUI::Form::password("identifier1",20,35));
$output .= tableFormRow(WebGUI::International::get(55),
WebGUI::Form::password("identifier2",20,35));
}
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(56).'</td><td>'.WebGUI::Form::text("email",20,255).'<span class="formSubtext"><br>'.WebGUI::International::get(57).'</span></td></tr>';
$output .= tableFormRow(WebGUI::International::get(56),
WebGUI::Form::text("email",20,255).'<span class="formSubtext"><br>'.
WebGUI::International::get(57).'</span>');
%language = WebGUI::SQL->buildHash("select distinct(language) from international");
$array[0] = "English";
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(304).'</td><td>'.WebGUI::Form::selectList("language",\%language,\@array).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(304),
WebGUI::Form::selectList("language",\%language,\@array));
$output .= formSave();
$output .= '</table>';
$output .= '</form> ';
$output .= '<div class="accountOptions"><ul>';
@ -231,22 +237,28 @@ sub www_displayAccount {
$output .= '<table>';
if ($session{user}{authMethod} eq "LDAP" && $session{setting}{usernameBinding} eq "yes") {
$output .= WebGUI::Form::hidden("username",$session{user}{username});
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(50).'</td><td>'.$session{user}{username}.'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(50),$session{user}{username});
} else {
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(50).'</td><td>'.WebGUI::Form::text("username",20,30,$session{user}{username}).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(50),
WebGUI::Form::text("username",20,35,$session{user}{username}));
}
if ($session{user}{authMethod} eq "LDAP") {
$output .= WebGUI::Form::hidden("identifier1","password");
$output .= WebGUI::Form::hidden("identifier2","password");
} else {
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(51).'</td><td>'.WebGUI::Form::password("identifier1",20,30,"password").'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(55).'</td><td>'.WebGUI::Form::password("identifier2",20,30,"password").'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(51),
WebGUI::Form::password("identifier1",20,35,"password"));
$output .= tableFormRow(WebGUI::International::get(55),
WebGUI::Form::password("identifier2",20,35,"password"));
}
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(56).'</td><td>'.WebGUI::Form::text("email",20,255,$session{user}{email}).'<span class="formSubtext"><br>'.WebGUI::International::get(57).'</span></td></tr>';
$output .= tableFormRow(WebGUI::International::get(56),
WebGUI::Form::text("email",20,255,$session{user}{email}).
'<span class="formSubtext"><br>'.WebGUI::International::get(57).'</span>');
%hash = WebGUI::SQL->buildHash("select distinct(language) from international");
$array[0] = $session{user}{language};
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(304).'</td><td>'.WebGUI::Form::selectList("language",\%hash,\@array).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(304),
WebGUI::Form::selectList("language",\%hash,\@array));
$output .= formSave();
$output .= '</table>';
$output .= '</form> ';
$output .= _accountOptions();
@ -266,8 +278,10 @@ sub www_displayLogin {
$output .= formHeader();
$output .= WebGUI::Form::hidden("op","login");
$output .= '<table>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(50).'</td><td>'.WebGUI::Form::text("username",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(51).'</td><td>'.WebGUI::Form::password("identifier",20,30).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(50),
WebGUI::Form::text("username",20,35));
$output .= tableFormRow(WebGUI::International::get(51),
WebGUI::Form::password("identifier",20,35));
$output .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(52)).'</td></tr>';
$output .= '</table>';
$output .= '</form>';
@ -296,41 +310,65 @@ sub www_editProfile {
$output .= WebGUI::Form::hidden("uid",$session{user}{userId});
$output .= '<table>';
if ($session{setting}{profileName}) {
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(314).'</td><td>'.WebGUI::Form::text("firstName",20,50,$session{user}{firstName}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(315).'</td><td>'.WebGUI::Form::text("middleName",20,50,$session{user}{middleName}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(316).'</td><td>'.WebGUI::Form::text("lastName",20,50,$session{user}{lastName}).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(314),
WebGUI::Form::text("firstName",20,50,$session{user}{firstName}));
$output .= tableFormRow(WebGUI::International::get(315),
WebGUI::Form::text("middleName",20,50,$session{user}{middleName}));
$output .= tableFormRow(WebGUI::International::get(316),
WebGUI::Form::text("lastName",20,50,$session{user}{lastName}));
}
if ($session{setting}{profileExtraContact}) {
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(317).'</td><td>'.WebGUI::Form::text("icq",20,30,$session{user}{icq}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(318).'</td><td>'.WebGUI::Form::text("aim",20,30,$session{user}{aim}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(319).'</td><td>'.WebGUI::Form::text("msnIM",20,30,$session{user}{msnIM}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(320).'</td><td>'.WebGUI::Form::text("yahooIM",20,30,$session{user}{yahooIM}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(321).'</td><td>'.WebGUI::Form::text("cellPhone",20,30,$session{user}{cellPhone}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(322).'</td><td>'.WebGUI::Form::text("pager",20,30,$session{user}{pager}).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(317),
WebGUI::Form::text("icq",20,30,$session{user}{icq}));
$output .= tableFormRow(WebGUI::International::get(318),
WebGUI::Form::text("aim",20,30,$session{user}{aim}));
$output .= tableFormRow(WebGUI::International::get(319),
WebGUI::Form::text("msnIM",20,30,$session{user}{msnIM}));
$output .= tableFormRow(WebGUI::International::get(320),
WebGUI::Form::text("yahooIM",20,30,$session{user}{yahooIM}));
$output .= tableFormRow(WebGUI::International::get(321),
WebGUI::Form::text("cellPhone",20,30,$session{user}{cellPhone}));
$output .= tableFormRow(WebGUI::International::get(322),
WebGUI::Form::text("pager",20,30,$session{user}{pager}));
}
if ($session{setting}{profileHome}) {
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(323).'</td><td>'.WebGUI::Form::text("homeAddress",20,128,$session{user}{homeAddress}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(324).'</td><td>'.WebGUI::Form::text("homeCity",20,30,$session{user}{homeCity}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(325).'</td><td>'.WebGUI::Form::text("homeState",20,30,$session{user}{homeState}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(326).'</td><td>'.WebGUI::Form::text("homeZip",20,15,$session{user}{homeZip}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(327).'</td><td>'.WebGUI::Form::text("homeCountry",20,30,$session{user}{homeCountry}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(328).'</td><td>'.WebGUI::Form::text("homePhone",20,30,$session{user}{homePhone}).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(323),
WebGUI::Form::text("homeAddress",20,128,$session{user}{homeAddress}));
$output .= tableFormRow(WebGUI::International::get(324),
WebGUI::Form::text("homeCity",20,30,$session{user}{homeCity}));
$output .= tableFormRow(WebGUI::International::get(325),
WebGUI::Form::text("homeState",20,30,$session{user}{homeState}));
$output .= tableFormRow(WebGUI::International::get(326),
WebGUI::Form::text("homeZip",20,15,$session{user}{homeZip}));
$output .= tableFormRow(WebGUI::International::get(327),
WebGUI::Form::text("homeCountry",20,30,$session{user}{homeCountry}));
$output .= tableFormRow(WebGUI::International::get(328),
WebGUI::Form::text("homePhone",20,30,$session{user}{homePhone}));
}
if ($session{setting}{profileWork}) {
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(329).'</td><td>'.WebGUI::Form::text("workAddress",20,128,$session{user}{workAddress}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(330).'</td><td>'.WebGUI::Form::text("workCity",20,30,$session{user}{workCity}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(331).'</td><td>'.WebGUI::Form::text("workState",20,30,$session{user}{workState}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(332).'</td><td>'.WebGUI::Form::text("workZip",20,15,$session{user}{workZip}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(333).'</td><td>'.WebGUI::Form::text("workCountry",20,30,$session{user}{workCountry}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(334).'</td><td>'.WebGUI::Form::text("workPhone",20,30,$session{user}{workPhone}).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(329),
WebGUI::Form::text("workAddress",20,128,$session{user}{workAddress}));
$output .= tableFormRow(WebGUI::International::get(330),
WebGUI::Form::text("workCity",20,30,$session{user}{workCity}));
$output .= tableFormRow(WebGUI::International::get(331),
WebGUI::Form::text("workState",20,30,$session{user}{workState}));
$output .= tableFormRow(WebGUI::International::get(332),
WebGUI::Form::text("workZip",20,15,$session{user}{workZip}));
$output .= tableFormRow(WebGUI::International::get(333),
WebGUI::Form::text("workCountry",20,30,$session{user}{workCountry}));
$output .= tableFormRow(WebGUI::International::get(334),
WebGUI::Form::text("workPhone",20,30,$session{user}{workPhone}));
}
if ($session{setting}{profileMisc}) {
$array[0] = $session{user}{gender};
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(335).'</td><td>'.WebGUI::Form::selectList("gender",\%gender,\@array).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(336).'</td><td>'.WebGUI::Form::text("birthdate",20,30,$session{user}{birthdate}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(337).'</td><td>'.WebGUI::Form::text("homepage",20,2048,$session{user}{homepage}).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(335),
WebGUI::Form::selectList("gender",\%gender,\@array));
$output .= tableFormRow(WebGUI::International::get(336),
WebGUI::Form::text("birthdate",20,30,$session{user}{birthdate}));
$output .= tableFormRow(WebGUI::International::get(337),
WebGUI::Form::text("homepage",20,2048,$session{user}{homepage}));
}
$output .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
$output .= formSave();
$output .= '</table>';
$output .= '</form>';
$output .= _accountOptions();
@ -407,8 +445,7 @@ sub www_recoverPassword {
$output .= formHeader();
$output .= WebGUI::Form::hidden("op","recoverPasswordFinish");
$output .= '<table>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(56).
'</td><td>'.WebGUI::Form::text("email",20,255).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(56),WebGUI::Form::text("email",20,255));
$output .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(72)).'</td></tr>';
$output .= '</table>';
$output .= '</form>';

View file

@ -67,6 +67,7 @@ sub www_addPage {
$output .= '<h1>'.WebGUI::International::get(98).'</h1>';
$output .= formHeader();
$output .= WebGUI::Form::hidden("op","addPageSave");
$output .= WebGUI::Form::hidden("root","1");
$output .= '<table>';
$output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("title",20,128,$session{form}{title}));
%hash = sortHash(WebGUI::Template::getList());
@ -85,17 +86,22 @@ sub www_addPage {
#-------------------------------------------------------------------
sub www_addPageSave {
my ($urlizedTitle, $test, $nextSeq);
my ($urlizedTitle, $test, $nextSeq, $parentId);
if (WebGUI::Privilege::canEditPage()) {
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from page where parentId=$session{page}{pageId}");
if ($session{form}{title} eq "") {
$session{form}{title} = "no title";
}
if ($session{form}{root}) {
$parentId = 0;
} else {
$parentId = $session{page}{pageId};
}
$urlizedTitle = WebGUI::URL::urlize($session{form}{title});
while (($test) = WebGUI::SQL->quickArray("select urlizedTitle from page where urlizedTitle='$urlizedTitle'")) {
$urlizedTitle .= 2;
}
WebGUI::SQL->write("insert into page values (".getNextId("pageId").", $session{page}{pageId}, ".quote($session{form}{title}).", $session{page}{styleId}, $session{user}{userId}, $session{page}{ownerView}, $session{page}{ownerEdit}, $session{page}{groupId}, $session{page}{groupView}, $session{page}{groupEdit}, $session{page}{worldView}, $session{page}{worldEdit}, '$nextSeq', ".quote($session{form}{metaTags}).", '$urlizedTitle', '$session{form}{defaultMetaTags}', '$session{form}{template}')");
WebGUI::SQL->write("insert into page values (".getNextId("pageId").", $parentId, ".quote($session{form}{title}).", $session{page}{styleId}, $session{user}{userId}, $session{page}{ownerView}, $session{page}{ownerEdit}, $session{page}{groupId}, $session{page}{groupView}, $session{page}{groupEdit}, $session{page}{worldView}, $session{page}{worldEdit}, '$nextSeq', ".quote($session{form}{metaTags}).", '$urlizedTitle', '$session{form}{defaultMetaTags}', '$session{form}{template}')");
return "";
} else {
return WebGUI::Privilege::insufficient();

View file

@ -0,0 +1,67 @@
package WebGUI::Operation::Root;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2002 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Exporter;
use strict;
use Tie::CPHash;
use WebGUI::Form;
use WebGUI::International;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::Shortcut;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_listRoots);
#-------------------------------------------------------------------
sub www_listRoots {
my ($output, $p, $sth, %data, @row, $i);
if (WebGUI::Privilege::isInGroup(3)) {
$output = helpLink(28);
$output .= '<h1>'.WebGUI::International::get(408).'</h1>';
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=addPage&root=1').
'">'.WebGUI::International::get(409).'</a></div>';
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
$sth = WebGUI::SQL->read("select * from page where title<>'Reserved' and parentId=0 order by title");
while (%data = $sth->hash) {
$row[$i] = '<tr><td valign="top" class="tableData">'.
'<a href="'.WebGUI::URL::gateway($data{urlizedTitle}.'?op=deletePage').'">'.
'<img src="'.$session{setting}{lib}.'/delete.gif" border=0></a>'.
'<a href="'.WebGUI::URL::gateway($data{urlizedTitle}.'?op=cutPage').'">'.
'<img src="'.$session{setting}{lib}.'/cut.gif" border=0></a>'.
'<a href="'.WebGUI::URL::gateway($data{urlizedTitle}.'?op=editPage').'">'.
'<img src="'.$session{setting}{lib}.'/edit.gif" border=0></a>'.
'<a href="'.WebGUI::URL::gateway($data{urlizedTitle}).'">'.
'<img src="'.$session{setting}{lib}.'/view.gif" border=0></a>'.
'</td>';
$row[$i] .= '<td valign="top" class="tableData">'.$data{title}.'</td>';
$row[$i] .= '<td valign="top" class="tableData">'.$data{urlizedTitle}.'</td></tr>';
$i++;
}
$sth->finish;
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listRoots'),\@row);
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
$output .= $p->getPage($session{form}{pn});
$output .= '</table>';
$output .= $p->getBarTraditional($session{form}{pn});
return $output;
} else {
return WebGUI::Privilege::adminOnly();
}
}
1;

View file

@ -43,7 +43,7 @@ sub www_viewStatistics {
$output .= '<h1>'.WebGUI::International::get(144).'</h1>';
$output .= '<table>';
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(145).'</td><td class="tableData">'.$WebGUI::VERSION.' ('.WebGUI::International::get(349).': '.$version.')</td></tr>';
($data) = WebGUI::SQL->quickArray("select count(*) from session");
($data) = WebGUI::SQL->quickArray("select count(*) from userSession");
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(146).'</td><td class="tableData">'.$data.'</td></tr>';
($data) = WebGUI::SQL->quickArray("select count(*)+1 from page where parentId>25");
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(147).'</td><td class="tableData">'.$data.'</td></tr>';

View file

@ -41,8 +41,8 @@ sub www_addUser {
$output .= formHeader();
$output .= WebGUI::Form::hidden("op","addUserSave");
$output .= '<table>';
$output .= tableFormRow(WebGUI::International::get(50),WebGUI::Form::text("username",20,30,$session{form}{username}));
$output .= tableFormRow(WebGUI::International::get(51),WebGUI::Form::password("identifier",20,30,$session{form}{username}));
$output .= tableFormRow(WebGUI::International::get(50),WebGUI::Form::text("username",20,35,$session{form}{username}));
$output .= tableFormRow(WebGUI::International::get(51),WebGUI::Form::password("identifier",20,35,$session{form}{username}));
%hash = ('WebGUI'=>'WebGUI', 'LDAP'=>'LDAP');
$array[0] = $session{setting}{authMethod};
$output .= tableFormRow(WebGUI::International::get(164),WebGUI::Form::selectList("authMethod",\%hash, \@array));
@ -203,8 +203,8 @@ sub www_editUser {
$output .= WebGUI::Form::hidden("uid",$session{form}{uid});
$output .= '<table>';
$output .= tableFormRow(WebGUI::International::get(378),$session{form}{uid});
$output .= tableFormRow(WebGUI::International::get(50),WebGUI::Form::text("username",20,30,$user{username}));
$output .= tableFormRow(WebGUI::International::get(51),WebGUI::Form::password("identifier",20,30,"password"));
$output .= tableFormRow(WebGUI::International::get(50),WebGUI::Form::text("username",20,35,$user{username}));
$output .= tableFormRow(WebGUI::International::get(51),WebGUI::Form::password("identifier",20,35,"password"));
%data = ('WebGUI'=>'WebGUI', 'LDAP'=>'LDAP');
$array[0] = $user{authMethod};
$output .= tableFormRow(WebGUI::International::get(164),WebGUI::Form::selectList("authMethod",\%data,\@array));

View file

@ -384,9 +384,10 @@ sub rows {
=cut
sub unconditionalRead {
my ($sth);
$sth = $_[2]->prepare($_[1]);
$sth->execute;
my ($sth,$dbh);
$dbh = $_[2] || $WebGUI::Session::session{dbh};
$sth = $dbh->prepare($_[1]) or WebGUI::ErrorHandler::warn("Unconditional read failed: ".$_[1]." : ".DBI->errstr);
$sth->execute or WebGUI::ErrorHandler::warn("Unconditional read failed: ".$_[1]." : ".DBI->errstr);
bless ({_sth => $sth}, $_[0]);
}

View file

@ -34,7 +34,7 @@ sub isIn {
}
foreach $e (@a, @b) { $union{$e}++ && $isect{$e}++ }
@isect = keys %isect;
if (defined @isect) {
if (@isect) {
undef @isect;
return 1;
} else {

View file

@ -398,7 +398,7 @@ sub www_view {
$row[$i] = _calendarLayout($_[0],$nextDate);
($first,$last) = WebGUI::DateTime::monthStartEnd($nextDate);
if ($session{form}{pn} eq "" && $first <= time() && $last >= time()) {
$session{form}{pn} = $i;
$session{form}{pn} = $i+1;
}
$i++;
$nextDate = addToDate($nextDate,0,1,0);

View file

@ -82,7 +82,7 @@ sub www_addSave {
$widgetId = create($session{page}{pageId},$session{form}{widget},$session{form}{title},$session{form}{displayTitle},$session{form}{description},$session{form}{processMacros},$session{form}{templatePosition});
$attachment = WebGUI::Attachment->new("",$widgetId);
$attachment->save("attachment");
WebGUI::SQL->write("insert into Item values ($widgetId, ".quote($session{form}{description}).", ".quote($session{form}{linkURL}).", ".quote($attachment).")");
WebGUI::SQL->write("insert into Item values ($widgetId, ".quote($session{form}{description}).", ".quote($session{form}{linkURL}).", ".quote($attachment->getFilename).")");
return "";
} else {
return WebGUI::Privilege::insufficient();

View file

@ -35,7 +35,9 @@ sub duplicate {
$data{description},$data{processMacros},$data{templatePosition});
WebGUI::SQL->write("insert into SQLReport values($newWidgetId, ".quote($data{template}).", ".
quote($data{dbQuery}).", ".quote($data{DSN}).", ".quote($data{username}).", ".
quote($data{identifier}).", '$data{convertCarriageReturns}', '$data{paginateAfter}')");
quote($data{identifier}).", ".quote($data{convertCarriageReturns}).", ".
quote($data{paginateAfter}).", ".quote($data{preprocessMacros}).", ".
quote($data{debugMode}).")");
}
#-------------------------------------------------------------------
@ -70,10 +72,14 @@ sub www_add {
WebGUI::Form::selectList("templatePosition",\%hash));
$output .= tableFormRow(WebGUI::International::get(85),
WebGUI::Form::textArea("description",'','','',1));
$output .= tableFormRow(WebGUI::International::get(15,$namespace),
WebGUI::Form::checkbox("preprocessMacros",1));
$output .= tableFormRow(WebGUI::International::get(16,$namespace),
WebGUI::Form::checkbox("debugMode",1));
$output .= tableFormRow(WebGUI::International::get(4,$namespace),
WebGUI::Form::textArea("dbQuery",''));
$output .= tableFormRow(WebGUI::International::get(3,$namespace),
WebGUI::Form::textArea("template",'','','',1));
$output .= tableFormRow(WebGUI::International::get(4,$namespace),
WebGUI::Form::textArea("dbQuery",''));
$output .= tableFormRow(WebGUI::International::get(5,$namespace),
WebGUI::Form::text("DSN",20,255,$session{config}{dsn}));
$output .= tableFormRow(WebGUI::International::get(6,$namespace),
@ -102,10 +108,16 @@ sub www_addSave {
$session{form}{description},$session{form}{processMacros},
$session{form}{templatePosition});
WebGUI::SQL->write("insert into SQLReport values($widgetId, ".
quote($session{form}{template}).", ".quote($session{form}{dbQuery}).", ".
quote($session{form}{DSN}).", ".quote($session{form}{username}).", ".
quote($session{form}{identifier}).
", '$session{form}{convertCarriageReturns}', '$session{form}{paginateAfter}')");
quote($session{form}{template}).", ".
quote($session{form}{dbQuery}).", ".
quote($session{form}{DSN}).", ".
quote($session{form}{username}).", ".
quote($session{form}{identifier}).", ".
quote($session{form}{convertCarriageReturns}).", ".
quote($session{form}{paginateAfter}).", ".
quote($session{form}{preprocessMacros}).", ".
quote($session{form}{debugMode}).
")");
return "";
} else {
return WebGUI::Privilege::insufficient();
@ -147,10 +159,14 @@ sub www_edit {
WebGUI::Form::selectList("templatePosition",\%hash,\@array));
$output .= tableFormRow(WebGUI::International::get(85),
WebGUI::Form::textArea("description",$data{description},50,10,1));
$output .= tableFormRow(WebGUI::International::get(15,$namespace),
WebGUI::Form::checkbox("preprocessMacros",1,$data{preprocessMacros}));
$output .= tableFormRow(WebGUI::International::get(16,$namespace),
WebGUI::Form::checkbox("debugMode",1,$data{debugMode}));
$output .= tableFormRow(WebGUI::International::get(4,$namespace),
WebGUI::Form::textArea("dbQuery",$data{dbQuery},50,10));
$output .= tableFormRow(WebGUI::International::get(3,$namespace),
WebGUI::Form::textArea("template",$data{template},50,10,1));
$output .= tableFormRow(WebGUI::International::get(4,$namespace),
WebGUI::Form::textArea("dbQuery",$data{dbQuery},50,10));
$output .= tableFormRow(WebGUI::International::get(5,$namespace),
WebGUI::Form::text("DSN",20,255,$data{DSN}));
$output .= tableFormRow(WebGUI::International::get(6,$namespace),
@ -176,10 +192,14 @@ sub www_editSave {
update();
WebGUI::SQL->write("update SQLReport set template=".quote($session{form}{template}).
", dbQuery=".quote($session{form}{dbQuery}).
", convertCarriageReturns='$session{form}{convertCarriageReturns}', DSN=".
quote($session{form}{DSN}).", username=".quote($session{form}{username}).
", convertCarriageReturns=".quote($session{form}{convertCarriageReturns}).
", DSN=".quote($session{form}{DSN}).
", username=".quote($session{form}{username}).
", identifier=".quote($session{form}{identifier}).
", paginateAfter='$session{form}{paginateAfter}' where widgetId=$session{form}{wid}");
", paginateAfter=".quote($session{form}{paginateAfter}).
", preprocessMacros=".quote($session{form}{preprocessMacros}).
", debugMode=".quote($session{form}{debugMode}).
" where widgetId=$session{form}{wid}");
return "";
} else {
return WebGUI::Privilege::insufficient();
@ -192,27 +212,34 @@ sub www_view {
@template, $temp, $col);
tie %data, 'Tie::CPHash';
%data = getProperties($namespace,$_[0]);
if (defined %data) {
if (%data) {
if ($data{preprocessMacros}) {
$data{dbQuery} = WebGUI::Macro::process($data{dbQuery});
}
if ($data{displayTitle} == 1) {
$output = "<h1>".$data{title}."</h1>";
}
$output .= WebGUI::International::get(17,$namespace)." ".$data{dbQuery}."<p>" if ($data{debugMode});
if ($data{description} ne "") {
$output .= $data{description}.'<p>';
}
if ($data{DSN} =~ /\DBI\:\w+\:\w+/) {
$dbh = DBI->connect($data{DSN},$data{username},$data{identifier});
} else {
$output .= WebGUI::International::get(9,$namespace).'<p>';
$output .= WebGUI::International::get(9,$namespace).'<p>' if ($data{debugMode});
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] The DSN specified is of an improper format.");
}
if (defined $dbh) {
if ($data{dbQuery} =~ /select/i) {
$sth = WebGUI::SQL->unconditionalRead($data{dbQuery},$dbh);
} else {
$output .= WebGUI::International::get(10,$namespace).'<p>';
$output .= WebGUI::International::get(10,$namespace).'<p>' if ($data{debugMode});
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] The SQL query is improperly formatted.");
}
if ($sth->rows > 0) {
unless ($sth->array) {
$output .= WebGUI::International::get(11,$namespace).'<p>' if ($data{debugMode});
WebGUI::ErrorHandler::warn("There was a problem with the query.");
} else {
if ($data{template} ne "") {
@template = split(/\^\-\;/,$data{template});
} else {
@ -239,18 +266,20 @@ sub www_view {
$row[$i] = $temp;
$i++;
}
if ($sth->rows < 1) {
$output .= $template[2];
$output .= WebGUI::International::get(18,$namespace).'<p>';
} else {
$p = WebGUI::Paginator->new(WebGUI::URL::page(),\@row,$data{paginateAfter});
$output .= $p->getPage($session{form}{pn});
$output .= $template[2];
$output .= $p->getBar($session{form}{pn});
}
$sth->finish;
$p = WebGUI::Paginator->new(WebGUI::URL::page(),\@row,$data{paginateAfter});
$output .= $p->getPage($session{form}{pn});
$output .= $template[2];
$output .= $p->getBar($session{form}{pn});
} else {
$output .= WebGUI::International::get(11,$namespace).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] There was a problem with the query.");
}
$dbh->disconnect();
} else {
$output .= WebGUI::International::get(12,$namespace).'<p>';
$output .= WebGUI::International::get(12,$namespace).'<p>' if ($data{debugMode});
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] Could not connect to remote database.");
}
}

View file

@ -18,7 +18,7 @@ use LWP::UserAgent;
use strict;
use Data::Config;
use WebGUI::SQL;
use XML::RSS;
use RSSLite;
my $config = new Data::Config './etc/WebGUI.conf';
our $dbh = DBI->connect($config->param('dsn'), $config->param('dbuser'), $config->param('dbpass'));
@ -30,74 +30,48 @@ $dbh->disconnect();
#-------------------------------------------------------------------
sub deleteExpiredSessions {
WebGUI::SQL->write("delete from session where expires<".time(),$dbh);
WebGUI::SQL->write("delete from userSession where expires<".time(),$dbh);
}
#-------------------------------------------------------------------
sub getRSS {
my ($rss, $userAgent, $request, $response);
my ($userAgent, $request, $response, $content, %result);
$userAgent = new LWP::UserAgent;
$request = new HTTP::Request (GET => $_[0]);
$response = $userAgent->request($request);
$rss = new XML::RSS;
$rss->parse($response->content);
return $rss;
$content = $response->content;
parseXML(\%result, \$content);
return %result;
}
#-------------------------------------------------------------------
sub generateHTML {
my ($rss, $image, $content, $copyright, $title, $link, $description, $name, $url, $item, $html, $width, $height);
$rss = $_[0];
#-- image
$url = $rss->{'image'}->{'url'};
if ($url) {
$link = $rss->{'image'}->{'link'} || "";
$title = $rss->{'image'}->{'title'} || "";
$width = $rss->{'image'}->{'width'} || "";
$height = $rss->{'image'}->{'height'} || "";
$width = 'width="'.$width.'"' if ($width);
$height = 'height="'.$height.'"' if ($height);
$image = '<img src="'.$url.'" alt="'.$title.'" border=0 $width $height>';
$image = '<a target="_NEWSITEM" href="'.$link.'">'.$image.'</a>' if ($link);
my (%rss, $html, $item);
%rss = @_;
$html = $rss{title};
$html = '<a href="'.$rss{link}.'" target="_blank">'.$html.'</a>' if ($rss{link});
$html = '<h1>'.$html.'</h1>';
$html .= $rss{description}.'<p>' if ($rss{description});
foreach $item (@{$rss{items}}) {
$html .= '<li>';
if ($item->{link}) {
$html .= '<a href="'.$item->{link}.'" target="_blank">'.$item->{title}.'</a>';
} else {
$html .= $item->{title};
}
$html .= ' - '.$item->{description} if ($item->{description});
$html .= '<br>';
}
#-- items
$html = ($image) ? '<div align="center">'.$image.'</div>' : "";
foreach $item (@{$rss->{'items'}}) {
next unless defined($item->{'title'}) && defined($item->{'link'});
$title = $item->{'title'} if (defined ($item->{'title'}));
$description = $item->{'description'} if (defined ($item->{'description'}));
$url = $item->{'link'} if (defined ($item->{'link'}));
$html .= "<li><a target='_NEWSITEM' href='$url'>$title</a><br>\n";
}
#-- form
$title = $rss->{'textinput'}->{'title'};
if ($title) {
$link = $rss->{'textinput'}->{'link'};
$description = $rss->{'textinput'}->{'description'};
$name = $rss->{'textinput'}->{'name'};
$html .= '<p><form method="get" action="'.$link.'">';
$html .= $description.'<br>';
$html .= '<input type="text" name="'.$name.'"><br>';
$html .= '<input type="submit" value="'.$title.'"></form>';
}
$copyright = $rss->{'channel'}->{'copyright'};
#-- copyright
if ($copyright) {
$html .= "<p><sub>$copyright</sub></p>";
}
#-- title
$title = $rss->{'channel'}->{'title'};
$title =~ s/^\s*//;
return ($html);
}
#-------------------------------------------------------------------
sub updateSyndicatedContent {
my ($sth, @data, $rss, $html);
my ($sth, @data, %rss, $html);
$sth = WebGUI::SQL->read("select widget.widgetId, SyndicatedContent.rssURL, SyndicatedContent.content from widget,SyndicatedContent where widget.WidgetId=SyndicatedContent.widgetId and widget.pageId<>3",$dbh);
while (@data = $sth->array) {
$rss = getRSS($data[1]);
$html = generateHTML($rss);
%rss = getRSS($data[1]);
$html = generateHTML(%rss);
if ($html ne "") {
WebGUI::SQL->write("update SyndicatedContent set content=".$dbh->quote($html).", lastFetched=".time()." where widgetId=$data[0]",$dbh);
} elsif (substr($data[2],6) ne "Unable" && substr($data[2],7) ne "Not yet") {

View file

@ -154,18 +154,6 @@ if (eval { require Net::SMTP }) {
}
}
print "XML::RSS module..........................";
if (eval { require XML::RSS }) {
print "OK\n";
} else {
if ($ARGV[0] eq "--install-modules") {
print "Installing...\n";
CPAN::Shell->install("XML::RSS");
} else {
print "Please install.\n";
}
}
print "Net::LDAP module.........................";
if (eval { require Net::LDAP }) {
print "OK\n";