Source for file mailto.php

Documentation is available at mailto.php

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

Documentation generated on Tue, 19 Nov 2013 15:07:32 +0100 by phpDocumentor 1.4.3