#!/usr/bin/perl
#
# =========================================================
# LICENCE
# =========================================================
#
# Digital Theater News Headline Grabber (http://www.dtheater.com/dthg.php3)
# dt_news.pl - grabs headlines from http://www.dtheatre.com
# by Joseph Lumbroso. v1.0a 19990824
# This free software is licensed under the terms of the
# GNU public license.
# Copyright (c) 1999 JJL (joe@ego-software,com). All Rights Reserved.
#
# =========================================================
# USAGE
# =========================================================
#
# build a cron script that runs this perl script every 27 minutes
# include print $file into you pages.
#
# =========================================================
# FINAL THOUGHTS
# =========================================================
#
# Please follow the digital theater backend rules for a list of
# these rules go to http://www.dtheater.com/FAQ.php3#T1
#
# Send Bugs/Suggestions/modifications to me at joe@ego-software.com
#
# ENJOY..
#
# =========================================================
# CONFIGURATION
# =========================================================
#
# For swtiches 1 is on 0 is off
# Amount of headlines to print
$hlns = "12";
# Write to file
$wtof = 1;
# Html Formatted (HEADLINE) with out html is
# display is TITLE | LINK
$html = 1;
# Print to screen
$pscr = 1;
# Include Links
$ilnk = 1;
# File Name
$file = "dt.nus";
#
# =========================================================
use IO::Socket;
use IO::Handle;
if ($wtof == 1) { open(NEW, ">$file"); }
my($iaddr, $paddr, $port, $proto, $month, $url, @articles, $runs, $times, @time, %months, $months, $day);
$iaddr = gethostbyname("dtheatre.com");
$port = 80;
$url = "/backend.php3";
$proto = getprotobyname("tcp");
$paddr = sockaddr_in($port, $iaddr);
$times = 0;
socket(DIGIN, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect(DIGIN, $paddr) or die "Connect error: $!";
autoflush DIGIN 1;
print DIGIN "GET $url HTTP/1.0\r\n\r\n";
@intro = ;
$prun = 0;
foreach $intro (@intro) {
if ($header_passed == 1) {
chop($intro);
if ($prun < 3) {
if ($prun == 0) {
$mfied = $intro;
}
if ($prun == 2) {
$mfied .= "\[~\]".$intro;
}
$prun++;
}
if ($prun == 3) {
if ($runs < $hlns) {
($title,$link) = split(/\[~\]/,$mfied);
if ($wtof == 1) {
if ($html == 1) {
print NEW "$title
\n";
} else {
if ($lonk == 1) {
print NEW "$title | $link\n";
} else {
print NEW "$title\n";
}
}
}
$runs++;
if ($pscr == 1) {
if ($html == 1) {
print "$title
\n";
} else {
if ($ilnk == 1) {
print "$title | $link\n";
} else {
print "$title\n";
}
}
}
$prun=0;
}
}
}
if ($header_passed == 0) {
if ($intro =~ /^\s\n$/) {
$header_passed = 1;
}
}
}
if ($wtof == 1) { close NEW; }
close DIGIN;