#!/usr/local/bin/perl
###########################################################################
# #
# This script inspired by News ver 1.1b Written by Julian Figueroa #
# 1997 - 1998 #
# #
###########################################################################
# COPYRIGHT NOTICE #
# Copyright 1998-1999 Richard Tirtadji All Rights Reserved. #
# #
# News_updater may be used and modified free of charge by anyone so long #
# as this copyright notice and the comments above remain intact. By #
# using this code you agree to indemnify Richard from any #
# liability that might arise from it's use. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try #
# and make money off of the program. #
# #
# Obtain permission before redistributing this software over the Internet #
# or in any other medium. In all cases copyright and header must remain #
# intact. #
###########################################################################
# #
# KKK KKK RRRRRRR #
# KKK KKK RRRRRRRR Programmer : Richard Tirtadji #
# KKK KKK RRR RRR Date : 01/04/99 #
# KKKKK RRR RRR Version : 1.01 #
# KKKKK RRRRRRR Title : newsupdater.cgi #
# KKK KKK RRR RRR #
# KKK KKK RRR RRR #
# KKK KKK RRR RRR #
# #
# Mail:webmaster@kingrichard.hypermart.net #
# http://kingrichard.hypermart.net #
# King Richard Scripts #
###########################################################################
# Version 1.01 #
# * Top Story is now replace with Announcement #
# * Headline is work like it should #
# * Headline type is now set by the WebMaster #
# * Headline have now have time stamp #
# * Autolink is now using on|off button #
# * Major Bugs fix #
# * Check for subject and data before submission #
# * Enhance the editing and reseting files #
# #
# Version 1.01 #
# * Automatic archives #
# * Password Protection #
# * Build in form #
# * Editing function #
# * Color customize #
# #
# #
# #
###########################################################################
###########################################################################
# Variable #
###########################################################################
# Your cgi directory without the "/" at the end
$cgidir = "/data1/hypermart.net/kingrichard/cgi-bin/freenews";
$datadir = "$cgidir/data";
# Your server local standard time
$standard_time = "CST";
# Your home url
$home_url = "http://kingrichard.hypermart.net";
# Your members Author and E-mail list
@email_data = ('King Richard|webmaster@kingrichard.hypermart.net','John Doe|jdoe@somewhere.com');
# WebMaster name
$webmaster_name = "King Richard";
# WebMaster E-mail
$webmaster_mail = "webmaster\@kingrichard.hypermart.net";
# Current Headline link to the main news page (SSI) do not delete the "\#"
$HEADLINE_FILE_LINK = "$home_url/news.html\#";
# Top Headline link to the top news page (SSI) do not delete the "\#"
$HEADLINE_TOP_LINK = "$home_url/news.html\#";
# HTML setup (self explainatory) f=face c=color s=size
$back_ground = "black";
$font_f_header = "arial";
$font_c_header = "blue";
$font_s_header = "2";
$font_f_text = "arial";
$font_c_text = "white";
$font_s_text = "-1";
$font_f_time = "arial";
$font_c_time = "red";
$font_s_time = "3";
# referers site to avoid people submitting news other place
@referers = ('http://kingrichard.hypermart.net');
# How many days do you want the news to be listed (default is four days)
$NUMBER_OF_ARCHIVES = 3;
# Would like to use Headline type or just normal type
$headline_on = "1"; # On="1" Off="0"
# No changes necessary below this line
###########################################################################
require "jmf-lib.pl";
$AUTOLINK_FILE = "$datadir/autolink.txt";
$v1="1";
$v2="0";
$v3="1";
$host = $ENV{'HTTP_REFERER'};
$cgiurl = $ENV{'SCRIPT_NAME'};
print "Content-type: text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# $value =~ s/<([^>]|\n)*>//g;
if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
else { $INPUT{$name} = $value; }
}
if ($INPUT{'login'}) { &login; }
elsif ($INPUT{'news'}) { &referer_check; }
elsif ($INPUT{'editing'}) { &referer_check; }
elsif ($INPUT{'fixed_page'}) { &referer_check; }
elsif ($INPUT{'deleting'}) { &referer_check; }
elsif ($INPUT{'newpass'}) { &newpass; }
else { &printoptions; }
exit;
sub referer_check {
foreach $referer (@referers) {
if ($host =~ /^$referer/i) { &start; }
else { &error("Please use the proper form"); }
}
}
sub start {
&checkpassword;
if ($INPUT{'news'}) {
&checkcomplete;
}
&Get_Date;
&Top;
$STATUS = &DIRECTORY_CHECK($datadir);
print "
\n";
print "
Posting Successfull. Should you see any error please edit the files manually. You could also edit it later using the News Manager
\n\n";
}
sub AUTO_LINK {
@AUTOLINK_DATA = &FILE_READ(AUTOLINK, $AUTOLINK_FILE);
$AUTOLINK_TEMP = join(/\n/, @AUTOLINK_DATA);
@AUTOLINK_INFO = split(/::/,$AUTOLINK_TEMP);
$COUNT = 0;
$STORY_DATA = join(/\n/, $INPUT{'story'});
while ($COUNT < @AUTOLINK_INFO) {
$PATTERN = $AUTOLINK_INFO[$COUNT + 1];
$MATCH = $AUTOLINK_INFO[$COUNT];
$MATCH =~ s/_//g;
$REPLACE = "$MATCH";
$STORY_DATA =~ s/$AUTOLINK_INFO[$COUNT]/$REPLACE/g;
$COUNT = $COUNT + 2;
}
$INPUT{'story'} = $STORY_DATA;
close(AUTOLINK_FILE);
}
sub checkcomplete {
unless ($INPUT{'subject'}) { &error("You must enter a title before the news can be posted"); }
unless ($INPUT{'story'}) { &error("You forgot to enter a story?"); }
if ($INPUT{'source'}) {
unless ($INPUT{'name_source'}) { &error("You selected a source but forget to enter a site name"); }
unless ($INPUT{'url_source'}=~/\http:/) { &error("You selected a source but forget to enter an url site"); }
}
}
sub printoptions {
open (PASSWORD, "$cgidir/password.txt");
$password = ;
close (PASSWORD);
chop ($password) if ($password =~ /\n$/);
if (!$password) {
&InitializePassword;
}
&Top;
&Mainmenu;
&Bottom;
exit;
}
sub InitializePassword {
&Top;
print "
";
print "
Before you can do anything else, ";
print "you'll need to set your administrative password. ";
print "This will allow you to use the administrative functions, ";
print "";
print "Please enter your desired password below. ";
print "(Enter it twice.)\n";
print "
\n";
print "
\n";
&Bottom;
exit;
}
sub newpass {
unless ($INPUT{'password'} eq $INPUT{'passad2'}) {
&error("Your administrative password was not set, as the two entries were different!");
exit;
}
&Top;
$newpassword = crypt($INPUT{'passad2'}, aa);
open (PASSWORD, ">$cgidir/password.txt") || &error("Can not write to $cgidir/password.txt");
print PASSWORD "$newpassword";
close (PASSWORD);
print" Admin Password has set Login Now! ";
&Bottom;
exit;
}
sub checkpassword {
$log = $INPUT{'password'};
open (PASSWORD, "$cgidir/password.txt");
$password = ;
close (PASSWORD);
chop ($password) if ($password =~ /\n$/);
if ($INPUT{'password'}) {
$new = crypt($INPUT{'password'}, aa);
}
else {
&error("You must enter a password");
}
unless (($password eq $new) || ($new eq $pair)) {
&error ("The password you entered is incorrect!");
}
}
sub Mainmenu {
print <
Enter Password:
Your Version
Latest Version
.
.
EOF
}
sub login {
&checkpassword;
&Top;
&scr_top;
print <
To update news, type in the subject, select your nickname and type in the news and press submit. If you have problem regarding this script, contact $webmaster_name.
HTML Tags
Settings
Type :
Autolink :
Preview/Submit
News Manager
Reset files :
Edit files :
EOF
&Bottom;
exit;
}
sub scr_top {
open (SCR, "$cgidir/scripts.txt");
if ($use_flock) {
flock SCR, 2;
}
@scr = ;
close (SCR);
foreach $line (@scr) {
print "$line";
}
}
sub Top {
print "News Updater - King Richard Scripts\n";
print "\n";
print "
\n";
print "
News Administrative
\n";
}
sub Bottom {
print "
\n";
print "News Updater Scripts version $v1.$v2$v3 can be download FREE at King Richard Scripts\n";
print "