<?php
/*
PluginAdRotate
Copyright (C) 2005 Matthew Wood
                                                                                
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
*/

include_once(PLOG_CLASS_PATH."class/action/blogaction.class.php");
include_once(PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php");
include_once(PLOG_CLASS_PATH.
  "plugins/adrotate/class/dao/adrotateadsstats.class.php");

class AdRotateRedirectAction extends BlogAction
{
  function AdRotateRedirectAction($actionInfo,$request)
  {
    $this->BlogAction($actionInfo,$request);
  }
  function perform()
  {
    $aras = new AdRotateAdsStats();
    $rdirmd5 = $GLOBALS['HTTP_GET_VARS']['redir'];
    $ad = $aras->getAdByMD5($rdirmd5);
    $aras->incClicks($ad->getId());
    header("Location: ". $ad->getRedirectUrl());
    exit(0);
  }
}
?>
