<?php
/*
* Submit
*
* Web Traffic Genius Pro v3.5.4
* Copyright (c) 2008-2010
* Success on the Internet Pty Ltd
* PO Box 25
* Salisbury SA 5108
* Australia
* Phone: +61 422 512 549
* Fax: +61 8 8425 9657
* Web: http://www.webtrafficgenius.com
* Support: http://www.marketing-assassins.com
*
*/
require_once(dirname(__FILE__) . '/config.php');
require_once(dirname(__FILE__) . '/php5_functions.php');
require_once(dirname(__FILE__) . '/http_functions.php');
require_once(dirname(__FILE__) . '/curl_functions.php');
require_once(dirname(__FILE__) . '/form_parser.php');
require_once(dirname(__FILE__) . '/feed_generator.php');
require_once(dirname(__FILE__) . '/aggregator_model.php');
require_once(dirname(__FILE__) . '/rss_log.php');
require_once(dirname(__FILE__) . '/callback_functions.php');
require_once(dirname(__FILE__) . '/rss_database.php');
require_once(dirname(__FILE__) . '/rss_cron_job.php');

set_time_limit(0);

if ($_GET['id'])
{
	$postID = $_GET['id'];
	$abspath = $_GET['abspath'];
	require_once ($abspath.'wp-load.php');
	require_once ($abspath.'wp-config.php');
	
	$logger = new WTG_Rss_Log();
	$logger->openlog();
	$logger->info("A post was just published(postId=$postID). About to Trigger feed submission session.");
			
	$GLOBALS['wtg']['feedName'] = wtg_dump_feed($postID);
	if (empty($GLOBALS['wtg']['feedName'])) {
		$logger->error("Dump feed FAIL exit");
		return;
	}
	$logger->info("Feed url will be " . wtg_callback_rss_feed_url(array('feed_name' => $GLOBALS['wtg']['feedName'])));
	
	$logger->error("Starting Submit Process");
	wtg_submit_rss();
	
	$logger->closelog();
	/*$result=wtg_get_version(WTG_UPGRADE_VERSION_URL);
	$version_message='';
	if(version_compare($result, WTG_CURRENT_VERSION, '>')) {
		$version_message="###################################\nA new version of Web Traffic Genius is available.\n###################################\n\n";
	}
	
	// send the log
	if (!empty($wtg_option['email']) && !empty($wtg_option['latest'])) {
			wp_mail($wtg_option['email'], 'Latest RSS feed submission log', $version_message.$logger->get_latest_log_text());
	} 
	if (!empty($wtg_option['email']) && !empty($wtg_option['complete'])) {
		   wp_mail($wtg_option['email'], 'Complete RSS feed submission log', $version_message.$logger->get_complete_log_text());
	}*/
}

?>