This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
redir/application/classes/controller/redir.php

42 lines
1.0 KiB
PHP
Raw Normal View History

2011-07-20 12:57:07 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Redirection Engine
*
* @package lnApp
* @subpackage Page/Home
* @category Controllers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
2011-07-20 23:53:38 +00:00
class Controller_Redir extends Controller {
2011-07-20 12:57:07 +00:00
protected $auth_required = FALSE;
public function action_index() {
2011-09-13 06:58:59 +00:00
// Try and find the path
$ro = ORM::factory('redir',array('servername'=>$_SERVER['SERVER_NAME'],'path'=>$this->request->param('id')));
2011-07-20 23:53:38 +00:00
2011-09-13 06:58:59 +00:00
if (! $ro->loaded()) {
$ro = ORM::factory('redir',array('servername'=>$_SERVER['SERVER_NAME'],'path'=>NULL));
if (! $ro->loaded())
$ro = ORM::factory('redir',0);
}
2011-07-20 23:53:38 +00:00
$ro->count++;
$ro->date_last_refer = time();
$ro->save();
if (! is_null($ro->redirect) AND trim($ro->redirect))
$this->request->redirect($ro->redirect);
else
$this->response->body(file_get_contents(Kohana::config('config.defaultfile')));
2011-07-20 12:57:07 +00:00
}
2011-09-13 06:58:59 +00:00
public function action_path() {
return $this->action_index();
}
2011-07-20 12:57:07 +00:00
}
?>