[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_mailto/helpers/ -> mailto.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: mailto.php 21078 2011-04-04 20:52:23Z dextercowley $
   4   * @package        Joomla.Site
   5   * @subpackage    com_mailto
   6   * @copyright    Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
   7   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  /**
  11   * @package        Joomla.Site
  12   * @subpackage    com_mailto
  13   */
  14  class MailtoHelper
  15  {
  16      /**
  17       * Adds a URL to the mailto system and returns the hash 
  18       *
  19       * @param string url
  20       * @return URL hash
  21       */
  22  	function addLink($url)
  23      {
  24          $hash = sha1($url);
  25          MailtoHelper::cleanHashes();
  26          $session =& JFactory::getSession();
  27          $mailto_links = $session->get('com_mailto.links', Array());
  28          if(!isset($mailto_links[$hash]))
  29          {
  30              $mailto_links[$hash] = new stdClass();
  31          }
  32          $mailto_links[$hash]->link = $url;
  33          $mailto_links[$hash]->expiry = time();
  34          $session->set('com_mailto.links', $mailto_links);
  35          return $hash;
  36      }
  37  
  38      /**
  39       * Checks if a URL is a Flash file
  40       *
  41       * @param string
  42       * @return URL
  43       */
  44  	function validateHash($hash)
  45      {
  46          $retval = false;
  47          $session =& JFactory::getSession();
  48          MailtoHelper::cleanHashes();
  49          $mailto_links = $session->get('com_mailto.links', Array());
  50          if(isset($mailto_links[$hash]))
  51          {
  52              $retval = $mailto_links[$hash]->link;
  53          }
  54          return $retval;
  55      }
  56  
  57      /**
  58       * Cleans out old hashes
  59       *
  60       * @since 1.5.23
  61       */
  62  	function cleanHashes($lifetime = 1440)
  63      {
  64          // flag for if we've cleaned on this cycle
  65          static $cleaned = false;
  66          if(!$cleaned)
  67          {
  68              $past = time() - $lifetime;
  69              $session =& JFactory::getSession();
  70              $mailto_links = $session->get('com_mailto.links', Array());
  71              foreach($mailto_links as $index=>$link)
  72              {
  73                  if($link->expiry < $past)
  74                  {
  75                      unset($mailto_links[$index]);
  76                  }
  77              }
  78              $cleaned = true;
  79          }
  80          
  81          
  82      }
  83  }
  84  


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1