#!/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 "\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"; print "
\n"; if ($STATUS == 0){ print "DATA DIRECTORY: Exists
\n"; } @CURRENT_DATE = &FILE_READ(CURRENT_DATE, "$datadir/CURRENT_DATE.TXT"); @TOP_STORY = &FILE_READ(TOP_STORY, "$datadir/TOP_STORY.TXT"); @CURRENT_NEWS = &FILE_READ(CURRENT_NEWS, "$datadir/CURRENT_NEWS.TXT"); if ($headline_on) { @HEADLINE_FILE = &FILE_READ(HEADLINE_FILE, "$datadir/HEADLINE_FILE.TXT"); @HEADLINE_TOP = &FILE_READ(HEADLINE_TOP, "$datadir/HEADLINE_TOP.TXT"); } @ARCHIVED_NEWS = &FILE_READ(ARCHIVE, "$datadir/$special.TXT"); print "DATA FILES: Exist and Read
\n"; $COUNT = 1; while($COUNT <= $NUMBER_OF_ARCHIVES) { if ($headline_on) { @TEMP_HEADARC = &FILE_READ(HEADARC, "$datadir/HEADLINE_ARC_$COUNT.TXT"); $TEMP2_HEADARC = join (/\n/,@TEMP_HEADARC); $HEADARC[$COUNT] = $TEMP2_HEADARC; } @TEMP_ARCHIVES = &FILE_READ(TEMPFILE, "$datadir/ARCHIVE_$COUNT.TXT"); $TEMP2_ARCHIVE = join (/\n/,@TEMP_ARCHIVES); $ARCHIVES[$COUNT] = $TEMP2_ARCHIVE; $COUNT++; close(TEMPFILE); if ($headline_on) { close(HEADARC); } } print "ARCHIVES: $NUMBER_OF_ARCHIVES Exist
\n"; if ($INPUT{'news'}) { &new_news; } elsif ($INPUT{'editing'}) { &editing; } elsif ($INPUT{'fixed_page'}) { &fixed_page; } elsif ($INPUT{'deleting'}) { &deleting; } print "
\n"; print "
\n"; &Bottom; exit; } sub editing { @FILE_DATA = &FILE_READ(FILE_TO_READ, "$datadir/$INPUT{'file_location'}"); print "\n"; print "Files Edited :\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; } sub deleting { open (THIS, ">$datadir/$INPUT{'file_location'}"); close(THIS); print "EXIT STATUS: Headline File Successfully Cleared
\n"; } sub fixed_page { open (THIS, ">$datadir/$INPUT{'file_location'}"); print THIS "$INPUT{'FIXED_TEXT'}"; close(THIS); print "EXIT STATUS: File Successfully Altered
\n"; } sub new_news { open(DATES, "$datadir/CURRENT_DATE.TXT"); @DATES = ; close (DATES); $TESTS = "@DATES"; $TEST = " $hari $tanggal
\n"; if ("$TESTS" eq "$TEST") { &NEXT;} else { &AUTOARCHIVE_NEWS; &NEXT; } } sub AUTOARCHIVE_NEWS { open(CURRENT_TEST, ">$datadir/CURRENT_NEWS.TXT"); open(BACKUP, ">$datadir/$special.TXT"); open(CURRENT_DATE, ">$datadir/CURRENT_DATE.TXT"); print CURRENT_DATE " $hari $tanggal
\n"; close (CURRENT_DATE); if ($NUMBER_OF_ARCHIVES == 0) { print BACKUP "\t@CURRENT_DATE\n"; print BACKUP "\t@CURRENT_NEWS\n"; print BACKUP "@ARCHIVED_NEWS\n\n"; } else { if ($headline_on) { open(HEADLINE1, ">$datadir/HEADLINE_ARC_1.TXT"); print HEADLINE1 "@CURRENT_DATE\n"; print HEADLINE1 "@HEADLINE_FILE\n"; close(HEADLINE1); } open(BACK, ">$datadir/ARCHIVE_1.TXT"); print BACK "@CURRENT_DATE\n"; print BACK "@CURRENT_NEWS\n"; close(BACK); $COUNT = 2; while($COUNT <= $NUMBER_OF_ARCHIVES) { if ($headline_on) { open(HEADLINE2, ">$datadir/HEADLINE_ARC_$COUNT.TXT"); } open(BACKUP3, ">$datadir/ARCHIVE_$COUNT.TXT"); $TOPRINT = $COUNT-1; print BACKUP3 "$ARCHIVES[$TOPRINT]"; if ($headline_on) { print HEADLINE2 "$HEADARC[$TOPRINT]"; } $COUNT++; if ($headline_on) { close(HEADLINE2); } close(BACKUP3); } print BACKUP "$ARCHIVES[$NUMBER_OF_ARCHIVES]\n\n"; print BACKUP "@ARCHIVED_NEWS\n\n"; } close (BACKUP); close (CURRENT_TEST); } sub NEXT { &UPDATE_NEWS; print "EXIT STATUS: News Successfully Updated
\n"; print "
EDIT THE FILES :

\n"; } sub UPDATE_NEWS { ### CHECK FORM DATA TO SEE IF AUTO LINK IS ENABLED if ($INPUT{'autolink'} == 1) { &AUTO_LINK; print "AUTOLINK: Enabled
\n"; } ### OPEN COUNT FILE FOR TARGETING if (open (HEADCOUNT, "$datadir/HEADCOUNT.TXT")) { $HEADCOUNT = ; $HEADCOUNT++; close(HEADCOUNT); open (HEADCOUNT, ">$datadir/HEADCOUNT.TXT"); print HEADCOUNT "$HEADCOUNT"; } else { open (HEADCOUNT, ">$datadir/HEADCOUNT.TXT"); print HEADCOUNT "1"; $HEADCOUNT = 1; } if ($headline_on) { if ($INPUT{'document'} == 1) { open (HEADLINE_TOP2, ">$datadir/HEADLINE_TOP.TXT"); print HEADLINE_TOP2 "$jam - $INPUT{'subject'}
\n"; print HEADLINE_TOP2 (@HEADLINE_TOP); close (HEADLINE_TOP2); print "TOP HEADLINE: Story Made Into Top Headline
\n"; } else { #CHECK/READ DELAY FILE open (HEADLINE, ">$datadir/HEADLINE_FILE.TXT"); print HEADLINE "$jam - $INPUT{'subject'}
\n"; print HEADLINE (@HEADLINE_FILE); close (HEADLINE); print "CURRENT HEADLINE: Story Made Into Current Headline
\n"; } close(HEADCOUNT); print "CURRENT TARGET: $HEADCOUNT
\n"; } ### WRITE NEWS TO TOPSTORY.TXT if ($INPUT{'document'} == 1) { #if (!(-z "$datadir/TOP_STORY.TXT")) { #@TOP_TEST = &FILE_READ(TOP_TEST, "$datadir/TOP_STORY.TXT"); #@CURRENT_TEST = &FILE_READ(CURRENT_TEST, "$datadir/CURRENT_NEWS.TXT"); #open (CURRENT_NEWS, ">$datadir/CURRENT_NEWS.TXT"); #print CURRENT_NEWS (@TOP_TEST); #print CURRENT_NEWS (@CURRENT_TEST); #close (CURRENT_NEWS); #} $LAST_FILE = "TOP_STORY.TXT"; @TOP_TEST = &FILE_READ(TOP_TEST, "$datadir/TOP_STORY.TXT"); open (UPDATING, ">$datadir/TOP_STORY.TXT"); print UPDATING "\n"; &PRINT_NEWS; print UPDATING (@TOP_TEST); } ### WRITE NEWS TO CURRENT_NEWS.TXT SHUFFLE ALL OTHER NEWS DOWN. else { $LAST_FILE = "CURRENT_NEWS.TXT"; @CURRENT_TEST = &FILE_READ(CURRENT_TEST, "$datadir/CURRENT_NEWS.TXT"); open (UPDATING, ">$datadir/CURRENT_NEWS.TXT"); print UPDATING "\n"; &PRINT_NEWS; print UPDATING (@CURRENT_TEST); } ### IF MAKE HEADLINE IS CHECKED, WRITE HEADLINE TO HEADLINE_FILE.TXT close(UPDATING); } sub PRINT_NEWS { print UPDATING "$INPUT{'subject'} $INPUT{'author'} @ $jam $standard_time
\n"; print UPDATING "$INPUT{'story'}
\n"; if ($INPUT{'source'}) { print UPDATING "Sources : $INPUT{'name_source'}\n"; } print UPDATING "

\n"; print "STORY: Added to $LAST_FILE\n"; print "
Your Post
\n"; print "$INPUT{'subject'} $INPUT{'author'} @ $jam $standard_time
\n"; print "$INPUT{'story'}
\n"; if ($INPUT{'source'}) { print "Sources : $INPUT{'name_source'}\n"; } print "


\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 " "; print " "; print "\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 VersionLatest 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.
\n"; print "\n"; print "
Story Editor

Title : 
Author :  \n"; print "
E-Mail : \n"; print <

Sources : 
Source Name : 
Source URL : 

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 "
\n"; } sub error{ $errors = $_[0] ; &Top; print"

A News error has occured

"; print"
The error is:
$errors

"; &Bottom; exit; } sub Get_Date { $current_time = time(); @days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday); @months = (January,February,March,April,May,June, July,August,September,October,November,December); $time = time; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time+($HourOffset*3600)); $ampm = "am"; if ($hour eq 12) { $ampm = "pm"; } if ($hour eq 0) { $hour = "12"; } if ($hour > 12) { $hour = ($hour - 12); $ampm = "pm"; } if ($min < 10) { $min = "0$min"; } $year = 1900+$year; $hari ="$days[$wday]"; $tanggal = "$months[$mon] $mday, $year"; $jam = "$hour\:$min $ampm"; $special = "$months[$mon]$year"; }