/**
 * @version   0.0.1
 * @package		Joomla.Site
 * @subpackage	mod_bf_google_adsense
 * @copyright	Copyright (C) 2013 Jonathan Brain. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die('Restricted access');
// no direct access
$user = JFactory::getUser();
if (empty($user->id) || $params->get('showloggedin')) {
    $php_condition = trim($params->get('php_condition'), " ;\t\n\r\v");
    if (!empty($php_condition)) {
        if (!eval('return ' . $php_condition . ';')) {
            return;
        }
    }
    $layout = $params->get('layout', 'default');
    $ip_block_list = trim($params->get('ip_block_list'));
    foreach (preg_split('/[,\\s]+/', $ip_block_list) as $value) {
        if (empty($value)) {
            continue;
        }
        if (preg_match('/^' . $value . '$/', FOFUtilsIp::getIp())) {
            $layout .= '-alternate';
            break;
        }
    }
    $wrapper_options = trim($params->get('wrapper_options'));
    require JModuleHelper::getLayoutPath('mod_bf_google_adsense', $layout);
}
 /**
  * Should I allow the remote client's IP to be overridden by an X-Forwarded-For or Client-Ip HTTP header?
  *
  * @param   bool  $newState  True to allow the override
  *
  * @return  void
  */
 public static function setAllowIpOverrides($newState)
 {
     self::$allowIpOverrides = $newState ? true : false;
 }
 /**
  * Get hashed IP address of remote user
  * 
  * @access private
  * @since 2.0.1
  * @return string
  */
 function getIPHash()
 {
     return strtolower(md5(FOFUtilsIp::getIp()));
 }