#!/usr/bin/perl # Name of style to use if none is set in the url. my $VNStyle = 'Default News Style'; # Name of template to use if none is set in the url (without .tmpl extension). my $VNTMPL = 'viewnews'; # END OF SETTINGS (unless you encounter problems - then fill out the next section) # EXTRA SERVER INFORMATION # Coranto tries to determine its path and URL automatically. This works in 90% # of cases, but some servers aren't cooperative and don't allow this information # to be found automatically. Though it won't hurt, there's no need to fill this out # unless you encounter problems. $abspath = ''; # Set the above to the absolute path to Coranto's directory, without a trailing slash. # Example: # $abspath = '/data/b/8/b83f8f15-55ec-4415-bd9b-6c1fe0353277/countrynews.nu/public_html/cgi-bin/corantonews'; $scripturl = ''; # Set the above to the URL to coranto.cgi. # Example: # $scripturl = 'http://www.countrynews.nu/corantonews/coranto.cgi'; # END EXTRA SERVER INFORMATION #### # START (Unless you know Perl, don't change anything after this point.) #### $crcgiBuild = 40; $crcgiVer = '1.25.2'; $crcgiRC = 1; eval { &main; }; CRdie("Untrapped Error: $@") if $@; sub main { # Try and be compatible with Microsoft IIS. unshift @INC, $1 if $0 =~ m!(.*)(\\|\/)!; # If extra server information was specified, use it. push @INC, $abspath if $abspath; NeedFile('cruser.pl'); NeedFile('crcore.pl'); NeedFile('crlib.pl'); print &header; &NeedCFG; $CurrentTime = time; # Put the script's URL into $scripturl. # Don't if it was already set as a server problem workaround. $scripturl = &GetScriptURL unless $scripturl; # Get form input &ReadForm; # Read in settings &ReadConfigInfo; $CConfig{'neverSave'} = 1; if ($CConfig{'CorantoSQL_built'} eq 'yes') { eval { require DBI; DBI->import; }; CRdie("DBI could not be found. Therefore, you cannot use Coranto SQL (please disable it and try again).") if $@; $CConfig{'CorantoSQL_path'} = $CConfig{'htmlfile_path'} unless $CConfig{'CorantoSQL_path'}; NeedFile("$CConfig{'CorantoSQL_path'}/crsql_sqlstuff.pl"); } if ($CConfig{'AddonsLoaded'}) { NeedFile('craddon.pl'); &LoadAddons; } package main; &ReadProfileInfo; # Initialize the date-retrieval subroutines. InitGTD($CConfig{'DateFormat'}, 'GetTheDate'); InitGTD($CConfig{'InternalDateFormat'}, 'GetTheDate_Internal'); # HOOK: ViewNews_If if($Addons{'ViewNews_If'}){for my $w (@{$Addons{'ViewNews_If'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} # compatibility $in{'id'} = $1 if $ENV{'QUERY_STRING'} =~ /newsid(\w+)$/; ViewNews( (exists $in{'id'} ? 1 : 2), ($in{'id'} or $in{'cat'}), ($in{'style'} or $VNStyle), ($in{'tmpl'} or $VNTMPL) ) if exists $in{'id'} or exists $in{'cat'}; CRdie('No parameters given.'); } sub ViewNews { my ($mode, $id, $style, $tmpl) = @_; CRdie("The ID contains an invalid character. Please check the link and try again!") if $mode == 1 and $id =~ /[^0-9a-zA-Z]/; # HOOK: ViewNews_0 if($Addons{'ViewNews_0'}){for my $w (@{$Addons{'ViewNews_0'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} my ($newshtml, $newsnum, $title); if ($style =~ /Default News Style$/i) { $style = 'Default'; } elsif ($style =~ /Default Headline Style$/i) { $style = 'DefaultHeadline'; } else { $style =~ s/ /_/g; $style = lc $style; $style =~ s/[^a-z0-9_]//g; } # HOOK: ViewNews_1 if($Addons{'ViewNews_1'}){for my $w (@{$Addons{'ViewNews_1'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} if ($CConfig{'CorantoSQL_built'} eq 'yes') { my $dbh = &CorantoSQL_connectdb; my $sth = $dbh->prepare(qq~SELECT * FROM $CConfig{'CorantoSQL_tblname'} WHERE Category='$id' OR newsid='$id'~); $sth->execute; $newsnum = 1; NCLOOP: while ($corantosql_ref = $sth->fetchrow_hashref) { &GetSQLFields; next NCLOOP if $mode == 1 and $newsid ne $id or $mode == 2 and $Category ne $id; $FileName = 'viewnews'; $ProfileName = 'viewnews'; $Date = GetTheDate($newstime); $title = $mode == 1 ? $Subject : $Category; &ReadUserInfo; &InitUserFieldVars; # HOOK: ViewNews_2 if($Addons{'ViewNews_2'}){for my $w (@{$Addons{'ViewNews_2'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} $newshtml .= &{"NewsStyle_$style"}; # HOOK: ViewNews_3 if($Addons{'ViewNews_3'}){for my $w (@{$Addons{'ViewNews_3'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} $newsnum++; } $sth->finish; $dbh->disconnect; } else { my $ndfh = CRopen("$CConfig{'htmlfile_path'}/newsdat.txt"); $newsnum = 1; NCLOOP: while (<$ndfh>) { chomp; SplitDataFile($_); next NCLOOP if $mode == 1 and $newsid ne $id or $mode == 2 and $Category ne $id; $FileName = 'viewnews'; $ProfileName = 'viewnews'; $Date = GetTheDate($newstime); $title = $mode == 1 ? $Subject : $Category; &ReadUserInfo; &InitUserFieldVars; # HOOK: ViewNews_2 if($Addons{'ViewNews_2'}){for my $w (@{$Addons{'ViewNews_2'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} $newshtml .= &{"NewsStyle_$style"}; # HOOK: ViewNews_3 if($Addons{'ViewNews_3'}){for my $w (@{$Addons{'ViewNews_3'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} $newsnum++; # BUG FIXED IN 1.03 last NCLOOP if $mode == 1 and $newsid eq $id; } close $ndfh; } # HOOK: ViewNews_4 if($Addons{'ViewNews_4'}){for my $w (@{$Addons{'ViewNews_4'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} CRdie('Could not find that news entry or category.') if $newsnum == 1; GenPage(\$newshtml, $title, $tmpl); exit; } # Gets our full URL. Needed for error messages. sub GetScriptURL { my $url = ($ENV{'HTTPS'} ? 'https://' : 'http://') . ($ENV{'HTTP_HOST'} ? $ENV{'HTTP_HOST'} : $ENV{'SERVER_NAME'}) . ($ENV{'SERVER_PORT'} != 80 && $ENV{'HTTP_HOST'} !~ /:/ ? ":$ENV{'SERVER_PORT'}" : '') . $ENV{'SCRIPT_NAME'}; return $url; } sub CRdie { print "Content-type: text/html\n\n" unless $HeaderPrinted; print "