<?php

	/*
	*  Copyright (c) Codiad & daeks (codiad.com), distributed
	*  as-is and without warranty under the MIT License. See
	*  [root]/license.txt for more. This information must remain intact.
	*/
	
	
	require_once('../../common.php');
	require_once('class.update.php');
	
	//////////////////////////////////////////////////////////////////
	// Verify Session or Key
	//////////////////////////////////////////////////////////////////
	
	checkSession();
	
	$update = new Update();
	
	//////////////////////////////////////////////////////////////////
	// check
	//////////////////////////////////////////////////////////////////
	
	if ($_GET['action']=='check_for_update') {
		
		$update->check_for_update();
	}
	
	//////////////////////////////////////////////////////////////////
	// Set Initial Version
	//////////////////////////////////////////////////////////////////
	
	if ($_GET['action']=='init') {
		$update->Init();
	}
	
	//////////////////////////////////////////////////////////////////
	// Clear Version
	//////////////////////////////////////////////////////////////////
	
	if ($_GET['action']=='clear') {
		if (checkAccess()) {
			$update->Clear();
		}
	}
	
	//////////////////////////////////////////////////////////////////
	// OptOut
	//////////////////////////////////////////////////////////////////
	
	if ($_GET['action']=='optout') {
		if (checkAccess()) {
			$update->OptOut();
		}
	}
	
	//////////////////////////////////////////////////////////////////
	// Update Codiad
	//////////////////////////////////////////////////////////////////
	
	if ($_GET['action']=='update') {
		if (checkAccess()) {
			$update->Download();
			echo Common::getConstant('BASE_URL') . "/components/update/update.php";
		} else {
			
			echo "#";
		}
	}