<?php
// $Id: update_ping.php,v 1.3 2005/10/22 08:15:46 ohwada Exp $

// 2005-09-28 K.OHWADA
// change function to class

//=========================================================
// What's New Module
// send weblog ping, when new article comes
// it assumes being called from wget
// 2004/08/20 K.OHWADA
//=========================================================

// send ping, even when it overlaps with modify article. 
$TIME_OVERLAP = 60;	// 60 sec

include "../../../mainfile.php";
include_once XOOPS_ROOT_PATH."/modules/whatsnew/api/api_ping.php";

// class
$class_block =& Whatsnew_Show_Block::getInstance();
$class_ping  =& Whatsnew_Ping::getInstance();

html_header();

$pass = 'xxx';
if ( isset($_GET['pass']) ) $pass = $_GET['pass'];

$config_data = $class_block->get_config_data();
$ping_pass   = $config_data['ping_pass'];
$ping_time   = $config_data['ping_time'];

if ( $ping_pass && ($pass == $ping_pass) )
{
	$time = $class_block->get_time_latest_after_collect();

	if ( ($time + $TIME_OVERLAP) > $ping_time )
	{
		$class_ping->set_flag_print(1);
		$class_ping->send_ping_cache();

		echo "ping sended <br/>\n";
	}
	else
	{
		echo "no new article <br/>\n";
	}
}
else
{
	echo "password unmatch <br />\n";
}

html_footer();
exit();
// --- main end ---

function html_header()
{

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>What's New Ping</title>
</head>
<body>
<h3>What's New Ping</h3>
Please call me from wget <br />
<?php

}

function html_footer()
{
	echo "</body></html>";
}

?>