#!/usr/bin/perl

#use Net::SCP::Expect;
# perl -MCPAN -e 'install "Net::SCP::Expect"'
require "functions.pl";


while(1){

	system("perl /root/zoozle/new-bots-X/EmuleNewsCrawler.pl");
	system("perl /root/zoozle/new-bots-X/TorrentNewsCrawler.pl");	# torrent.newsbot.pl
	

	# newsarchive cachen
	# system("perl /root/zoozle/caching/NewsarchiveCachePage.pl");

	&CACHE();
	
	# sitemaps für heute erstellen
	system("perl /root/zoozle/sitemaps/SitemapToday.pl");

	# sitemaps aus den suchkeywords der user bilden 
	system("perl /root/zoozle/sitemaps/SitemapKeywordsToday.pl");
		
	system("date");	
	sleep 30200;

};


sub CACHE(){

	my $timeout	= "300";
	my $ua		= "Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.6) Gecko/20040206 Firefox/1.0.1";

	my %CACHING = (
		"/home/wwwroot/index.html" => "http://www.zoozle.org/index.php",		# .net: "/srv/server/wwwroot/index.html" => "http://www.zoozle.net/index.php",
	);

	while( my ( $path, $url ) = each(%CACHING) ){
		my $page = &http_get($url, $timeout, $ua, );
		print "Generate Cache for $url\n";
		
		if ( length($page) >= 1000 ) {
		
			unlink $path;
			open(WH,">$path");
				print WH $page;
			close WH;

		}; # if ( length($page) >= 1000 ) {

	}; # while( my ( $path, $url ) = each(%CACHING) ){

	return 1;

}; # sub CACHE(){}

