<?php

class SController extends Controller
{
	static function actionIndex()
	{
		$key = intval(x62::decode(App::getParam('key')));
		$shortUrl = ShortUrl::model()->getByPK($key);

		if($shortUrl->id) {
			$shortUrl->update(array('views' => intval($shortUrl->views + 1)));
			App::redirect($shortUrl->url);
		} else {
			App::error404();
		}
	}
}
