<?php

class GoController extends Controller
{

	static function actionAway()
	{
		if (!isset($_GET['url'])) {
			App::error404();
		}

		$url = $_GET['url'];
		$url = filter_var($url, FILTER_VALIDATE_URL);

		if($url && isset($_SERVER['HTTP_REFERER'])) {
			$go = new GoAway(array(
				'date' => date('c'),
				'url' => $url,
				'ref' => $_SERVER['HTTP_REFERER'],
			));
			$go->save();
			App::redirect($url, 302);
		} else {
			App::log('goAwayErrors', $url);
			App::error404();
		}
	}
}
