diff --git a/application/classes/HTTP/Exception/404.php b/application/classes/HTTP/Exception/404.php index 88279de..7bdd5fa 100644 --- a/application/classes/HTTP/Exception/404.php +++ b/application/classes/HTTP/Exception/404.php @@ -29,6 +29,18 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 { $ro->date_last_refer = time(); $ro->save(); + // Update our referrer info + $rfo = $ro->referrer->where('referrer','=',$this->request()->referrer())->find(); + + if (! $rfo->loaded()) { + $rfo->redir_id = $ro->id; + $rfo->referrer = $this->request()->referrer(); + } + + $rfo->count++; + $rfo->date_last_refer = $ro->date_last_refer; + $rfo->save(); + // Prepare the response object. $response = Response::factory(); diff --git a/application/classes/Model/Redir.php b/application/classes/Model/Redir.php index 4730724..3cc4a75 100644 --- a/application/classes/Model/Redir.php +++ b/application/classes/Model/Redir.php @@ -4,13 +4,17 @@ * Main redirector model * * @package Redir - * @subpackage Events * @category Models * @author Deon George * @copyright (c) 2010-2013 Deon George * @license http://dev.leenooks.net/license.html */ class Model_Redir extends ORM { + protected $_model_names_plural = FALSE; protected $_table_names_plural = FALSE; + + protected $_has_many = array( + 'referrer'=>array('far_key'=>'id'), + ); } ?> diff --git a/application/classes/Model/Referrer.php b/application/classes/Model/Referrer.php new file mode 100644 index 0000000..2ed2b41 --- /dev/null +++ b/application/classes/Model/Referrer.php @@ -0,0 +1,20 @@ +array(), + ); +} +?> diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..b8178fe Binary files /dev/null and b/favicon.ico differ