<?php

	define( 'IEM_CRON_JOB', true );
	define( 'IEM_NO_CONTROLLER', true );
	define( 'IEM_CLI_MODE', true );
	require_once( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/index.php' );
	require_once( IEM_PUBLIC_PATH . '/functions/api/settings.php' );
	$settings_api = new Settings_API();

	if ($settings_api->NeedDatabaseUpgrade()) {
		exit();
	}

	unset( $settings_api );

	if (( !SENDSTUDIO_SAFE_MODE && strpos( SENDSTUDIO_DISABLED_FUNCTIONS, 'set_time_limit' ) === false )) {
		set_time_limit( 0 );
	}


	if (( !defined( 'SENDSTUDIO_IS_SETUP' ) || !SENDSTUDIO_IS_SETUP )) {
		exit();
	}

	require_once( SENDSTUDIO_FUNCTION_DIRECTORY . '/sendstudio_functions.php' );
	$path = IEM_ADDONS_PATH . '/geostats/api/geostats.php';

	if (!is_file( $path )) {
		return false;
	}

	require_once( $path );
	$var1 = (( empty( $argv ) && 2 <= count( $argv ) ) ? $argv[1] : 'check');
	$api = new Geostats_API();

	if ($var1 == 'check') {
		$api->status_report();
		return 1;
	}


	if ($var1 == 'update') {
		$api->update();
	}

?>