<?php

//////////////////////////////////////////////////////////////////////////////80
// Analytics Controller
//////////////////////////////////////////////////////////////////////////////80
// Copyright (c) Atheos & Liam Siira (Atheos.io), distributed as-is and without
// warranty under the MIT License. See [root]/LICENSE.md for more.
// This information must remain intact.
//////////////////////////////////////////////////////////////////////////////80
// Authors: Atheos Team, @hlsiira
//////////////////////////////////////////////////////////////////////////////80

require_once("class.analytics.php");

$Analytics = new Analytics();

switch ($action) {

	//////////////////////////////////////////////////////////////////////////80
	// Initialize the Update Modules
	//////////////////////////////////////////////////////////////////////////80
	case "init":
		$Analytics->init();
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Load Local Data
	//////////////////////////////////////////////////////////////////////////80
	case "load":
		$Analytics->getLocalData();
		break;

	//////////////////////////////////////////////////////////////////////////80
	// OptOut of Athoes Analytics
	//////////////////////////////////////////////////////////////////////////80
	case "modify":
		if (Common::checkAccess("configure")) {
			$key = POST("key");
			$value = POST("value");
			$Analytics->modify();
		}
		break;

	//////////////////////////////////////////////////////////////////////////80
	// Save Local Data
	//////////////////////////////////////////////////////////////////////////80
	case "save":
		$Analytics->setLocalData();
		break;


	//////////////////////////////////////////////////////////////////////////80
	// Default: Invalid Action
	//////////////////////////////////////////////////////////////////////////80
	default:
		Common::send("error", "Invalid action.");
		break;
}