#!/usr/bin/perl ########################################################################### # # # This script inspired by News ver 1.1b Written by Julian Figueroa # # 1997 - 1998 # # http://www.gamegirlz.com/theory # # # ########################################################################### # 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 : 03/06/99 # # KKKKK RRR RRR Version : 1.03 # # KKKKK RRRRRRR Title : newsupdater.cgi # # KKK KKK RRR RRR # # KKK KKK RRR RRR # # KKK KKK RRR RRR # # # # Mail:webmaster@kingrichard.hypermart.net # # http://www.krdesigns.com # # King Richard Designs Scripts # ########################################################################### # NOTE: You may need to provide full path to each setup files # Some server require this. # $path is the directory path to the location of this file. ########################################################################### $path = "/home/sites/www.scmillenium.com/users/atw/web/cgi-bin/news"; #>>>>>>>>>>>>>>> NO NEED TO EDIT ANYTHING BELOW THIS LINE <<<<<<<< require "$path/setup.pl"; require "$path/kr.pl"; $AUTOLINK_FILE = "$datadir/autolink.txt"; $v1="1"; $v2="0"; $v3="3"; $host = $ENV{'HTTP_REFERER'}; $cgiurl = "/cgi-bin/news/newsupdater.cgi"; 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{'preview'}) { &preview; } 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"); } &start; #} } sub preview { &checkpassword; print <News Updater - King Richard Scripts
News Administrative
This is just a preview. Should you see any error please go back and edit your post. Remember you could also edit it later using the News Manager


top_preview if ($printing_type == 0) { print "
Preview:
\n"; print "$INPUT{'subject'} - $INPUT{'author'} @ 00:00:00 $standard_time
\n"; print "$INPUT{'story'}
\n"; if ($INPUT{'source'}) { print "Sources : $INPUT{'name_source'}\n"; } print "


\n\n"; } elsif ($printing_type == 1) { print "
Preview:
\n"; print "

$INPUT{'author'} @ 00:00:00 $standard_time - $INPUT{'subject'}
\n"; print "$INPUT{'story'}
\n"; if ($INPUT{'source'}) { print "Sources : $INPUT{'name_source'}\n"; } print "



\n\n"; } else { print "
Preview:
\n"; print "$INPUT{'subject'} on 00:00:00 $standard_time
\n"; print "$INPUT{'story'}
\n"; if ($INPUT{'source'}) { print "Sources :
$INPUT{'name_source'}\n"; } print "posted by $INPUT{'author'}


\n\n"; } print <
Go Back and Post your news

bottom_preview &Bottom; exit; } sub start { &checkpassword; if ($INPUT{'news'}) { &checkcomplete; } &grab_new_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); $HEADARCS[$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 = " $tanggal
\n"; if ("$TESTS" eq "$TEST") { &NEXT;} else { &AUTOARCHIVE_NEWS; &NEXT; } } sub AUTOARCHIVE_NEWS { open(CURRENT_TEST, ">$datadir/CURRENT_NEWS.TXT"); if ($headline_on) { open(HEAD_TEST1, ">$datadir/HEADLINE_FILE.TXT"); } open(BACKUP, ">$datadir/$special.TXT"); open(CURRENT_DATE, ">$datadir/CURRENT_DATE.TXT"); print CURRENT_DATE " $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 "$HEADARCS[$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); if ($headline_on) { close (HEAD_TEST1); } 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) { @HEAD_TEST3 = &FILE_READ(HEAD_TEST3, "$datadir/HEADLINE_TOP.TXT"); open (HEADLINE_TOP2, ">$datadir/HEADLINE_TOP.TXT"); print HEADLINE_TOP2 "$jam - $INPUT{'subject'}
\n"; print HEADLINE_TOP2 (@HEAD_TEST3); close (HEADLINE_TOP2); print "TOP HEADLINE: Story Made Into Top Headline
\n"; } else { #CHECK/READ DELAY FILE @HEAD_TEST = &FILE_READ(HEAD_TEST, "$datadir/HEADLINE_FILE.TXT"); open (HEADLINE, ">$datadir/HEADLINE_FILE.TXT"); print HEADLINE "$jam - $INPUT{'subject'}
\n"; print HEADLINE (@HEAD_TEST); 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 { if ($printing_type == 0) { 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"; } elsif ($printing_type == 1) { print UPDATING "

$INPUT{'author'} @ $jam $standard_time - $INPUT{'subject'}
\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{'author'} @ $jam $standard_time - $INPUT{'subject'}
\n"; print "$INPUT{'story'}
\n"; if ($INPUT{'source'}) { print "Sources : $INPUT{'name_source'}\n"; } print "



\n\n"; } else { print UPDATING "

$INPUT{'subject'} on $jam $standard_time
\n"; print UPDATING "$INPUT{'story'}
\n"; if ($INPUT{'source'}) { print UPDATING "Sources :
$INPUT{'name_source'}
\n"; } print UPDATING "
Posted by $INPUT{'author'}

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


\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 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.
\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 : 

Back to your Homepage
EOF &Bottom; exit; } sub scr_top { open (SCR, "$cgidir/scripts.txt"); @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 grab_new_date { $time = time; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime ($time); if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } $year = 1900+$year; @months1 = (January,February,March,April,May,June,July,August,September,October,November,December); $special = "$months1[$mon]$year"; if ($type_date == 0) { @days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday); $hari = $days[$wday]; if ($mday < 10) { $mday = "0$mday"; } $bulan = $mon + 1; if ($bulan < 10) { $bulan = "0$bulan"; } $tanggal = "$hari - $bulan/$mday/$year"; } elsif ($type_date == 1) { &daysup; @days = (Sun,Mon,Tue,Wed,Thu,Fri,Sat); $hari = $days[$wday]; @months = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); $bulan = $months[$mon]; $tanggal = "$hari - $bulan $mday, $year"; } else { &daysup; @days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday); $hari = $days[$wday]; @months = (January,February,March,April,May,June,July,August,September,October,November,December); $bulan = $months[$mon]; $tanggal = "$hari - $bulan $mday, $year"; } if ($type_time) { $ampm = "AM"; if ($hour eq 12) { $ampm = "PM"; } if ($hour eq 0) { $hour = "12"; } if ($hour > 12) { $hour = ($hour - 12); $ampm = "PM"; } if ($hour < 10) { $hour = "0$hour"; } if ($sec_activate) { $jam = "$hour\:$min\:$sec $ampm"; } else { $jam = "$hour\:$min $ampm"; } } else { if ($hour < 10) { $hour = "0$hour"; } if ($sec_activate) { $jam = "$hour\:$min\:$sec"; } else { $jam = "$hour\:$min"; } } } sub daysup { if ($mday == 1) { $mday = "$mdayst"; } elsif ($mday == 2) { $mday = "$mdaynd"; } elsif ($mday == 3) { $mday = "$mdayrd"; } else { $mday = "$mdayth"; } }