/usr/share/gforge/cronjobs/get_news_notapproved.pl is in gforge-db-postgresql 5.1.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #!/usr/bin/perl -w
#
# get_news_notapproved.pl: script to get the news not yet approved
# by Vicente J. Ruiz Jurado (vjrj AT ourproject.org) Apr-2004
#
# depends: libgetopt-mixed-perl (Getopt::Long), libdbi-perl (DBI),
# libtext-autoformat-perl (Text::Autoformat)
# libmail-sendmail-perl (Mail::Sendmail)
#
use DBI;
use Text::Autoformat;
use Getopt::Long qw(:config require_order);
use Mail::Sendmail;
use strict;
require("/usr/share/gforge/lib/include.pl"); # Include all predefined functions
use vars qw/ $server_admin $sys_name $sys_default_domain /;
# DB
#-------------------------------------------------------------------------------
use vars qw/ $dbh / ; # Predeclaration of global vars
# Variables
#-------------------------------------------------------------------------------
my $numArgs = @ARGV;
my @args = @ARGV;
my $therearenews = 0;
sub usage();
my $debug;
my @results_array;
my $emailformatted;
# Options check
#-------------------------------------------------------------------------------
my $resultOptions = GetOptions(
"debug" => \$debug
);
unless (($debug && $resultOptions == 2) || ($resultOptions == 1)) {
usage();
exit(1);
}
# Start to get de News
#-------------------------------------------------------------------------------
if ($debug) {print STDERR "Getting the news not approved.\n"};
&db_connect;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $old_date = time()-60*60*24*30;
my $query = "SELECT group_name,summary,details
FROM news_bytes n, groups g
WHERE is_approved = 0
AND n.group_id=g.group_id
AND n.post_date > '$old_date'
AND g.is_public=1
AND g.status='A'
ORDER BY post_date";
my $sth = $dbh->prepare($query);
$sth->execute();
while (my @array = $sth->fetchrow_array ()) {
push @results_array, \@array ;
}
$sth->execute() or die "Problems with the query '$query' in DB";
$sth->finish() or die "Problems with the query '$query' in DB";
$dbh->commit or die $dbh->errstr;
foreach my $newsnotapprob (@results_array) {
$therearenews = 1;
my ($group_name, $summary, $details) = @{$newsnotapprob};
my $title = "$group_name: $summary\n";
$emailformatted .= autoformat $title, { all => 1, left=>0, right=>78 };
$emailformatted .= "----------------------------------------------------------------------\n";
$emailformatted .= autoformat $details, { all => 1, left=>8, right=>78 };
$emailformatted .= "\n\n";
}
if ($therearenews) {
if ($debug) {print STDERR "Sending the news not approved.\n"};
$emailformatted .= "Please visit: http://$sys_default_domain/news/admin/";
$emailformatted .= "\n\n";
my %mail = ( To => "$server_admin",
From => "noreply\@$sys_default_domain",
Subject => "$sys_name pending news",
Message => $emailformatted
);
$mail{'Content-type'} = 'text/plain; charset="UTF-8"';
sendmail(%mail) or die $Mail::Sendmail::error;
}
else {
if ($debug) {print STDERR "No news to approved.\n"};
}
if ($debug) {print STDERR "get_news_notapproved process finished ok\n"};
exit(0);
# Funcitions
#-------------------------------------------------------------------------------
sub usage() {
print STDERR "usage: get_news_notapproved.pl [--debug]\n";
}
|