Commit info for scoop/lib/Scoop:
Modified Files:
Cron.pm Utility.pm
Log Message:
Committing cron fixes, even though they don't solve the problem reported
in bug 15, they do tidy up some of the cron stuff. --hulver
Index: Cron.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Cron.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -r1.24 -r1.25
97a98,106
> # We want to run the crons as the anonymous user
> my $user_data = $S->user_data(-1);
> my $old_uid;
> if ($S->{UID} != -1) {
> $old_uid = $S->{UID};
> $S->{UID} = -1;
> $S->_refresh_group_perms();
> }
>
115a125,130
> # Back to old uid permissions now we've run everything
> if (defined $old_uid) {
> $S->{UID} = $old_uid;
> $S->_refresh_group_perms();
> }
>
370a386
>
371a388
>
491a509
> #my $rss = XML::RSS->new(encoding => $S->{UI}->{VARS}->{charset});
496c514
< title => $S->{UI}->{VARS}->{sitename},
---
> title => $S->strip_invalid($S->{UI}->{VARS}->{sitename}),
502,504c520,522
< creator => $S->{UI}->{VARS}->{rdf_creator} || $S->{UI}->{VARS}->{sitename},
< publisher => $S->{UI}->{VARS}->{rdf_publisher} || $S->{UI}->{VARS}->{sitename},
< rights => $S->{UI}->{VARS}->{rdf_copyright},
---
> creator => $S->strip_invalid($S->{UI}->{VARS}->{rdf_creator} || $S->{UI}->{VARS}->{sitename}),
> publisher => $S->strip_invalid($S->{UI}->{VARS}->{rdf_publisher} || $S->{UI}->{VARS}->{sitename}),
> rights => $S->strip_invalid($S->{UI}->{VARS}->{rdf_copyright}),
510,511c528,529
< title => $S->{UI}->{VARS}->{sitename},
< url => $S->{UI}->{VARS}->{rdf_image},
---
> title => $S->strip_invalid($S->{UI}->{VARS}->{sitename}),
> url => $S->strip_invalid($S->{UI}->{VARS}->{rdf_image}),
516c534
< title => "Search $S->{UI}->{VARS}->{sitename}",
---
> title => $S->strip_invalid("Search $S->{UI}->{VARS}->{sitename}"),
521,525c539,541
< # really should use getstories or something here, but right now it's easier
< # to just directly fetch it (easier to port, that is)
< my $excl_sect_sql = ' AND ' . $S->get_disallowed_sect_sql('norm_read_stories', 'Anonymous');
< $excl_sect_sql = '' if( $excl_sect_sql eq ' AND ' );
< my $days_to_show = $S->{UI}->{VARS}->{rdf_days_to_show};
---
> my $story_params;
> $story_params->{-type} = 'section';
> $story_params->{-section} = '__all__';
527,537c543,550
< my $ad_section = $S->{UI}->{VARS}->{ad_story_section} || 'advertisements';
< $ad_section = $S->dbh->quote($ad_section);
< my $excluded_sections = $S->excluded_from_all_stories();
< my $where = "TO_DAYS(NOW()) - TO_DAYS(time) <= $days_to_show AND displaystatus >= 0 AND section != 'Diary' AND section != $ad_section $excluded_sections $excl_sect_sql";
< my ($rv, $sth) = $S->db_select({
< WHAT => 'title, dept, sid, introtext',
< FROM => 'stories',
< WHERE => $where,
< ORDER_BY => 'time DESC',
< LIMIT => $max_stories
< });
---
> if ($max_stories) {
> $story_params->{-maxstories} = $max_stories;
> }
> my $days_to_show = $S->{UI}->{VARS}->{rdf_days_to_show};
> if ($days_to_show) {
> $story_params->{-maxdays} = $days_to_show;
> }
> my $stories = $S->getstories($story_params);
539c552
< while (my $story = $sth->fetchrow_hashref) {
---
> foreach my $story (@{$stories}) {
563c576
< title => $story->{title},
---
> title => $S->strip_invalid($story->{title}),
565c578
< description => $story->{introtext}
---
> description => $S->strip_invalid($story->{introtext})
568,569d580
<
< $sth->finish;
Index: Utility.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Utility.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -r1.32 -r1.33
660a661,670
> sub strip_invalid {
> my $S = shift;
> my $string = shift;
>
> $string =~ s/([\x00-\x1F])/"&#".ord($1).";"/eg;
> $string =~ s/([\x80-\x9F])/"&#".ord($1).";"/eg;
>
> return $string;
> }
>