<?php
App::uses('AppFrontController', 'Controller');

class AppCronsController extends AppFrontController {

	protected $preventNonCron = true;

	public $Cron = null;

	# ~ Prevent non cron request - - - - - - - - - - - - - - - - - - - - - - - - - #
	function beforeFilter() {
		$this->Auth->allow();
		parent::beforeFilter();

		# Prevent access from browser
		if ($this->preventNonCron && !defined('CRONJOB')) {
			die('Not allowed');
		}
	}

	# ~ Build stats from API log - - - - - - - - - - - - - - - - - - - - - - - - - #
	public function buildStats() {
		ClassRegistry::init('LogApi')->query('CALL `BuildAPIStats`()');
		exit(0);
	}

}
